[fenix] For https://github.com/mozilla-mobile/fenix/issues/23500: creditcards: focus cardNumberInput in createView

Right now, when the user navigates to the "Add Card" screen, the "Card Number"
title will be focused by default. Instead, let's make it so that the first
field for data entry is focused.

Since we're focusing the first field, let's also make sure that the soft
keyboard opens and that the cursor is placed at the end of whatever text has
already been input.
pull/600/head
Geordan Neukum 2 years ago committed by mergify[bot]
parent 7a57194a48
commit d31cdfeb3b

@ -16,10 +16,12 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import mozilla.components.support.ktx.android.view.hideKeyboard
import mozilla.components.support.ktx.android.view.showKeyboard
import org.mozilla.fenix.R
import org.mozilla.fenix.SecureFragment
import org.mozilla.fenix.databinding.FragmentCreditCardEditorBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.placeCursorAtEnd
import org.mozilla.fenix.ext.redirectToReAuth
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.settings.creditcards.controller.DefaultCreditCardEditorController
@ -70,6 +72,12 @@ class CreditCardEditorFragment : SecureFragment(R.layout.fragment_credit_card_ed
}
creditCardEditorView = CreditCardEditorView(binding, interactor)
creditCardEditorView.bind(creditCardEditorState)
binding.cardNumberInput.apply {
requestFocus()
placeCursorAtEnd()
showKeyboard()
}
}
}

Loading…
Cancel
Save