For #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.
upstream-sync
Geordan Neukum 3 years ago committed by mergify[bot]
parent 6b78fa3295
commit 7271f33eff

@ -16,10 +16,12 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import mozilla.components.support.ktx.android.view.hideKeyboard 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.R
import org.mozilla.fenix.SecureFragment import org.mozilla.fenix.SecureFragment
import org.mozilla.fenix.databinding.FragmentCreditCardEditorBinding import org.mozilla.fenix.databinding.FragmentCreditCardEditorBinding
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.placeCursorAtEnd
import org.mozilla.fenix.ext.redirectToReAuth import org.mozilla.fenix.ext.redirectToReAuth
import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.settings.creditcards.controller.DefaultCreditCardEditorController 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 = CreditCardEditorView(binding, interactor)
creditCardEditorView.bind(creditCardEditorState) creditCardEditorView.bind(creditCardEditorState)
binding.cardNumberInput.apply {
requestFocus()
placeCursorAtEnd()
showKeyboard()
}
} }
} }

Loading…
Cancel
Save