For #23771 - Set correct destructive text color for card editor error messages (#23803)

Co-authored-by: tristan-jea <>
Co-authored-by: Tristan <99796140+tristan-jea@users.noreply.github.com>
upstream-sync
Gabriel Luong 2 years ago committed by GitHub
parent ef077c5fb1
commit f47a428f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@
package org.mozilla.fenix.settings.creditcards.view
import android.content.res.ColorStateList
import android.view.View
import android.widget.ArrayAdapter
import androidx.annotation.VisibleForTesting
@ -59,6 +60,17 @@ class CreditCardEditorView(
binding.cardNumberInput.text = state.cardNumber.toEditable()
binding.nameOnCardInput.text = state.billingName.toEditable()
binding.cardNumberLayout.setErrorTextColor(
ColorStateList.valueOf(
binding.root.context.getColorFromAttr(R.attr.destructive)
)
)
binding.nameOnCardLayout.setErrorTextColor(
ColorStateList.valueOf(
binding.root.context.getColorFromAttr(R.attr.destructive)
)
)
bindExpiryMonthDropDown(state.expiryMonth)
bindExpiryYearDropDown(state.expiryYears)
}

@ -17,11 +17,13 @@ import mozilla.components.concept.storage.NewCreditCardFields
import mozilla.components.concept.storage.UpdatableCreditCardFields
import mozilla.components.service.sync.autofill.AutofillCreditCardsAddressesStorage
import mozilla.components.service.sync.autofill.AutofillCrypto
import mozilla.components.support.ktx.android.content.getColorFromAttr
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.utils.CreditCardNetworkType
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@ -162,6 +164,11 @@ class CreditCardEditorViewTest {
}
assertFalse(creditCardEditorView.validateForm())
assertNotNull(fragmentCreditCardEditorBinding.cardNumberLayout.error)
assertEquals(
fragmentCreditCardEditorBinding.cardNumberLayout.errorCurrentTextColors,
fragmentCreditCardEditorBinding.root.context.getColorFromAttr(R.attr.destructive)
)
verify(exactly = 0) {
interactor.onSaveCreditCard(
@ -182,6 +189,11 @@ class CreditCardEditorViewTest {
fragmentCreditCardEditorBinding.saveButton.performClick()
assertFalse(creditCardEditorView.validateForm())
assertNotNull(fragmentCreditCardEditorBinding.cardNumberLayout.error)
assertEquals(
fragmentCreditCardEditorBinding.cardNumberLayout.errorCurrentTextColors,
fragmentCreditCardEditorBinding.root.context.getColorFromAttr(R.attr.destructive)
)
verify(exactly = 0) {
interactor.onSaveCreditCard(
@ -219,6 +231,11 @@ class CreditCardEditorViewTest {
}
assertFalse(creditCardEditorView.validateForm())
assertNotNull(fragmentCreditCardEditorBinding.nameOnCardLayout.error)
assertEquals(
fragmentCreditCardEditorBinding.nameOnCardLayout.errorCurrentTextColors,
fragmentCreditCardEditorBinding.root.context.getColorFromAttr(R.attr.destructive)
)
verify(exactly = 0) {
interactor.onSaveCreditCard(

Loading…
Cancel
Save