From b5f9254eae5f2609a80a99fdc6a9d1525e683a61 Mon Sep 17 00:00:00 2001 From: Jay Newstrom Date: Tue, 2 May 2023 11:01:14 -0700 Subject: [PATCH] Use non transitive R classes. (#6635) --- CHANGELOG.md | 3 + .../activity/AddFpxPaymentMethodTest.kt | 5 +- .../AddNetbankingPaymentMethodTest.kt | 5 +- .../activity/CreateCardTokenActivityTest.kt | 7 +- .../activity/CustomerSessionActivity.kt | 3 +- .../detekt-baseline.xml | 5 +- gradle.properties | 3 +- identity-example/detekt-baseline.xml | 2 +- .../identity/example/ui/ComposeExampleUI.kt | 7 +- .../android/identity/ui/AddressSection.kt | 4 +- .../stripe/android/identity/ui/NameSection.kt | 3 +- .../android/identity/ui/UploadScreen.kt | 3 +- .../android/identity/TestApplication.kt | 3 +- .../stripe/android/link/ui/ErrorMessage.kt | 6 +- .../com/stripe/android/link/ui/LinkAppBar.kt | 3 +- .../stripe/android/link/ui/LinkButtonView.kt | 3 +- .../stripe/android/link/ui/LinkLogoutSheet.kt | 3 +- .../stripe/android/link/ui/PrimaryButton.kt | 5 +- .../link/ui/cardedit/CardEditScreen.kt | 3 +- .../paymentmethod/PaymentMethodViewModel.kt | 3 +- .../paymentmethod/SupportedPaymentMethod.kt | 7 +- .../link/ui/wallet/ConfirmRemoveDialog.kt | 6 +- .../android/link/ui/wallet/PaymentDetails.kt | 3 +- .../link/ui/wallet/WalletPaymentMethodMenu.kt | 3 +- .../android/link/ui/wallet/WalletScreen.kt | 3 +- .../link/ui/forms/FormControllerTest.kt | 10 +- .../PaymentMethodViewModelTest.kt | 3 +- payments-core/detekt-baseline.xml | 2 +- .../android/networking/StripeErrorMapping.kt | 5 +- .../view/BecsDebitAccountNumberEditText.kt | 3 +- .../android/view/BecsDebitBsbEditText.kt | 3 +- .../stripe/android/view/CardBrandSpinner.kt | 3 +- .../com/stripe/android/view/CardFormView.kt | 8 +- .../stripe/android/view/CardNumberEditText.kt | 5 +- .../android/view/CardNumberTextInputLayout.kt | 3 +- .../android/view/CountryTextInputLayout.kt | 6 +- .../com/stripe/android/view/CvcEditText.kt | 3 +- .../com/stripe/android/view/EmailEditText.kt | 3 +- .../stripe/android/view/ExpiryDateEditText.kt | 10 +- .../com/stripe/android/view/MaskedCardView.kt | 3 +- .../stripe/android/view/PostalCodeEditText.kt | 8 +- .../stripe/android/view/ShippingInfoWidget.kt | 30 ++--- .../com/stripe/android/view/StripeActivity.kt | 3 +- .../com/stripe/android/view/StripeEditText.kt | 3 +- .../stripe/android/view/CardFormViewTest.kt | 5 +- .../android/view/ExpiryDateEditTextTest.kt | 13 +- .../android/view/ShippingInfoWidgetTest.kt | 30 ++--- .../ui/core/elements/AffirmElementUI.kt | 3 +- .../elements/AuBankAccountNumberConfig.kt | 8 +- .../elements/AuBecsDebitMandateElementUI.kt | 4 +- .../android/ui/core/elements/BsbConfig.kt | 8 +- .../ui/core/elements/CardNumberConfig.kt | 12 +- .../android/ui/core/elements/CvcConfig.kt | 10 +- .../android/ui/core/elements/CvcController.kt | 6 +- .../android/ui/core/elements/IbanConfig.kt | 5 +- .../android/ui/core/elements/TranslationId.kt | 6 +- .../autocomplete/PlacesClientProxy.kt | 6 +- .../ui/core/elements/AddressControllerTest.kt | 3 +- .../ui/core/elements/AddressElementTest.kt | 5 +- .../elements/AdministrativeAreaConfigTest.kt | 5 +- .../elements/CardDetailsControllerTest.kt | 9 +- .../core/elements/CardDetailsElementTest.kt | 4 +- .../ui/core/elements/CardNumberConfigTest.kt | 10 +- .../core/elements/CardNumberControllerTest.kt | 4 +- .../android/ui/core/elements/CvcConfigTest.kt | 6 +- .../ui/core/elements/CvcControllerTest.kt | 4 +- .../ui/core/elements/DateConfigTest.kt | 22 ++-- .../ui/core/elements/LpmSerializerTest.kt | 5 +- .../ui/core/elements/TextFieldStateTest.kt | 4 +- .../core/forms/TransformSpecToElementTest.kt | 6 +- paymentsheet-example/detekt-baseline.xml | 2 +- .../stripe/android/test/core/ui/BuyButton.kt | 4 +- .../stripe/android/test/core/ui/Selectors.kt | 25 ++-- .../PaymentSheetPlaygroundActivity.kt | 3 +- .../addresselement/AddressTextFieldUITest.kt | 4 +- .../android/paymentsheet/PaymentOptionUi.kt | 5 +- .../paymentsheet/PaymentOptionsItem.kt | 3 +- .../paymentsheet/PaymentSheetViewModel.kt | 5 +- .../addresselement/AutocompleteViewModel.kt | 7 +- .../model/PaymentOptionFactory.kt | 5 +- .../ach/TransformToBankIcon.kt | 35 +++--- .../ach/USBankAccountForm.kt | 12 +- .../ach/USBankAccountFormViewModel.kt | 9 +- .../polling/PollingActivity.kt | 4 +- .../polling/PollingScreen.kt | 3 +- .../paymentsheet/ui/AddressOptionsAppBar.kt | 3 +- .../paymentsheet/ui/BillingAddressView.kt | 15 +-- .../paymentsheet/ui/HeaderTextFactory.kt | 3 +- .../ui/PaymentMethodsUiExtension.kt | 9 +- .../paymentsheet/ui/PaymentOptionsUI.kt | 9 +- .../paymentsheet/ui/PaymentSheetTopBar.kt | 6 +- .../ui/PaymentSheetTopBarState.kt | 8 +- .../paymentsheet/ui/PrimaryButtonAnimator.kt | 5 +- .../viewmodels/PrimaryButtonUiStateMapper.kt | 5 +- .../paymentsheet/PaymentSheetActivityTest.kt | 7 +- .../PaymentSelectionUpdaterTest.kt | 10 +- .../forms/BillingDetailsHelpersTest.kt | 6 +- .../forms/FormArgumentsFactoryTest.kt | 6 +- .../paymentsheet/forms/FormViewModelTest.kt | 41 +++--- .../ach/TransformToBankIconTest.kt | 117 +++++++++--------- .../paymentsheet/ui/HeaderTextFactoryTest.kt | 3 +- .../ui/PaymentSheetTopBarScreenshotTest.kt | 18 +-- .../ui/PaymentSheetTopBarStateTest.kt | 5 +- .../paymentsheet/ui/PaymentSheetTopBarTest.kt | 6 +- .../address/TransformAddressToElement.kt | 27 ++-- .../android/uicore/elements/AddressElement.kt | 3 +- .../elements/AdministrativeAreaConfig.kt | 6 +- .../uicore/elements/CheckboxElementUI.kt | 6 +- .../android/uicore/elements/CountryConfig.kt | 4 +- .../android/uicore/elements/NameConfig.kt | 4 +- .../address/TransformAddressToElementTest.kt | 9 +- .../uicore/elements/CountryConfigTest.kt | 4 +- .../elements/SimpleTextFieldControllerTest.kt | 6 +- .../cardscan/CardScanFragment.kt | 3 +- .../stripecardscan/scanui/ScanActivity.kt | 7 +- .../stripecardscan/scanui/ScanFragment.kt | 3 +- .../scanui/SimpleScanActivity.kt | 7 +- .../wechatpay/WeChatPayAuthActivityTest.kt | 3 +- 118 files changed, 511 insertions(+), 407 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74082188cb0..7364d2df4d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## XX.XX.XX - 2023-XX-XX +### All SDKs +* [CHANGED][6635](https://github.com/stripe/stripe-android/pull/6635) Use non transitive R classes. + ## 20.24.1 - 2023-05-01 ### Payments diff --git a/example/src/androidTestDebug/java/com/stripe/example/activity/AddFpxPaymentMethodTest.kt b/example/src/androidTestDebug/java/com/stripe/example/activity/AddFpxPaymentMethodTest.kt index 757b377d8ad..855f0478ec3 100644 --- a/example/src/androidTestDebug/java/com/stripe/example/activity/AddFpxPaymentMethodTest.kt +++ b/example/src/androidTestDebug/java/com/stripe/example/activity/AddFpxPaymentMethodTest.kt @@ -17,6 +17,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import com.stripe.android.R as StripeR @RunWith(AndroidJUnit4::class) @LargeTest @@ -41,7 +42,7 @@ class AddFpxPaymentMethodTest { launchBankSelector() // click on first bank in the list - onView(withId(R.id.bank_list)).perform( + onView(withId(StripeR.id.bank_list)).perform( RecyclerViewActions.actionOnItemAtPosition(0, click()) ) } @@ -51,7 +52,7 @@ class AddFpxPaymentMethodTest { launchBankSelector() // confirm selection without selecting a bank - onView(withId(R.id.action_save)).perform(click()) + onView(withId(StripeR.id.action_save)).perform(click()) // Nothing should happen as no bank was selected } diff --git a/example/src/androidTestDebug/java/com/stripe/example/activity/AddNetbankingPaymentMethodTest.kt b/example/src/androidTestDebug/java/com/stripe/example/activity/AddNetbankingPaymentMethodTest.kt index bd7e7f8a3fd..a01c077599d 100644 --- a/example/src/androidTestDebug/java/com/stripe/example/activity/AddNetbankingPaymentMethodTest.kt +++ b/example/src/androidTestDebug/java/com/stripe/example/activity/AddNetbankingPaymentMethodTest.kt @@ -19,6 +19,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import com.stripe.android.R as StripeR @RunWith(AndroidJUnit4::class) @LargeTest @@ -47,7 +48,7 @@ class AddNetbankingPaymentMethodTest { launchBankSelector() // click on first bank in the list - onView(withId(R.id.bank_list)).perform( + onView(withId(StripeR.id.bank_list)).perform( RecyclerViewActions.actionOnItemAtPosition(0, click()) ) } @@ -57,7 +58,7 @@ class AddNetbankingPaymentMethodTest { launchBankSelector() // confirm selection without selecting a bank - onView(withId(R.id.action_save)).perform(click()) + onView(withId(StripeR.id.action_save)).perform(click()) // Nothing should happen as no bank was selected } diff --git a/example/src/androidTestDebug/java/com/stripe/example/activity/CreateCardTokenActivityTest.kt b/example/src/androidTestDebug/java/com/stripe/example/activity/CreateCardTokenActivityTest.kt index 1c6a87a6f41..0b00622229d 100644 --- a/example/src/androidTestDebug/java/com/stripe/example/activity/CreateCardTokenActivityTest.kt +++ b/example/src/androidTestDebug/java/com/stripe/example/activity/CreateCardTokenActivityTest.kt @@ -17,6 +17,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import com.stripe.android.R as StripeR @RunWith(AndroidJUnit4::class) @LargeTest @@ -46,11 +47,11 @@ class CreateCardTokenActivityTest { ) // fill out card details - onView(withId(R.id.card_number_edit_text)) + onView(withId(StripeR.id.card_number_edit_text)) .perform(replaceText("4242424242424242")) - onView(withId(R.id.expiry_date_edit_text)) + onView(withId(StripeR.id.expiry_date_edit_text)) .perform(replaceText("01/25")) - onView(withId(R.id.cvc_edit_text)) + onView(withId(StripeR.id.cvc_edit_text)) .perform(replaceText("111")) // click create card button diff --git a/example/src/main/java/com/stripe/example/activity/CustomerSessionActivity.kt b/example/src/main/java/com/stripe/example/activity/CustomerSessionActivity.kt index 4282e4deaa5..3bc6548af62 100644 --- a/example/src/main/java/com/stripe/example/activity/CustomerSessionActivity.kt +++ b/example/src/main/java/com/stripe/example/activity/CustomerSessionActivity.kt @@ -16,6 +16,7 @@ import com.stripe.android.model.PaymentMethod import com.stripe.android.view.PaymentMethodsActivityStarter import com.stripe.example.R import com.stripe.example.databinding.CustomerSessionActivityBinding +import com.stripe.android.R as StripeR /** * An example activity that handles working with a [CustomerSession], allowing you to @@ -81,7 +82,7 @@ class CustomerSessionActivity : AppCompatActivity() { } private fun buildCardString(data: PaymentMethod.Card): String { - return getString(R.string.stripe_card_ending_in, data.brand, data.last4) + return getString(StripeR.string.stripe_card_ending_in, data.brand, data.last4) } internal class ActivityViewModel : ViewModel() { diff --git a/financial-connections-example/detekt-baseline.xml b/financial-connections-example/detekt-baseline.xml index 26362403f96..c373eea4339 100644 --- a/financial-connections-example/detekt-baseline.xml +++ b/financial-connections-example/detekt-baseline.xml @@ -1,8 +1,5 @@ - - MaxLineLength:FinancialConnectionsPlaygroundViewModel.kt$FinancialConnectionsPlaygroundViewModel$status = current.status + "Payment Intent created ${it.intentSecret}, opening FinancialConnectionsSheet." - MaximumLineLength:com.stripe.android.financialconnections.example.FinancialConnectionsPlaygroundViewModel.kt:61 - + diff --git a/gradle.properties b/gradle.properties index a2fac685cd3..27069a19176 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,9 +11,10 @@ POM_DEVELOPER_ID=stripe POM_DEVELOPER_NAME=Stripe POM_DEVELOPER_EMAIL=support+android@stripe.com -android.useAndroidX=true android.enableJetifier=false android.enableR8.fullMode=true +android.nonTransitiveRClass=true +android.useAndroidX=true # Update StripeSdkVersion.VERSION_NAME when publishing a new release VERSION_NAME=20.24.1 diff --git a/identity-example/detekt-baseline.xml b/identity-example/detekt-baseline.xml index 063e169c216..23db062d079 100644 --- a/identity-example/detekt-baseline.xml +++ b/identity-example/detekt-baseline.xml @@ -10,7 +10,7 @@ LongMethod:ComposeExampleUI.kt$@Composable private fun SubmitView( submissionState: IdentitySubmissionState, scaffoldState: ScaffoldState, configuration: IdentityVerificationSheet.Configuration, viewModel: IdentityExampleViewModel, ) LongMethod:ComposeExampleUI.kt$@Composable private fun TypeSelectUI( verificationType: VerificationType, integrationType: IntegrationType, onVerificationTypeChanged: (VerificationType) -> Unit ) MaxLineLength:ComposeExampleUI.kt$resultString = "Error generating verificationSessionId and ephemeralKeySecret: ${it.getException().message}" - MaximumLineLength:com.stripe.android.identity.example.ui.ComposeExampleUI.kt:631 + MaximumLineLength:com.stripe.android.identity.example.ui.ComposeExampleUI.kt:632 TooGenericExceptionCaught:IdentityExampleViewModel.kt$IdentityExampleViewModel$t: Throwable diff --git a/identity-example/src/main/java/com/stripe/android/identity/example/ui/ComposeExampleUI.kt b/identity-example/src/main/java/com/stripe/android/identity/example/ui/ComposeExampleUI.kt index faeda076b8c..b66ab126468 100644 --- a/identity-example/src/main/java/com/stripe/android/identity/example/ui/ComposeExampleUI.kt +++ b/identity-example/src/main/java/com/stripe/android/identity/example/ui/ComposeExampleUI.kt @@ -71,6 +71,7 @@ import com.stripe.android.identity.example.ui.IntegrationType.LINK import com.stripe.android.identity.example.ui.IntegrationType.NATIVE import com.stripe.android.identity.example.ui.IntegrationType.WEB import kotlinx.coroutines.launch +import com.stripe.android.identity.R as IdentityR internal enum class VerificationType(val value: String) { DOCUMENT("document"), ID_NUMBER("id_number"), ADDRESS("address"), PHONE("phone") @@ -349,7 +350,7 @@ private fun AllowedDocumentTypes( ) StyledClickableText( - text = AnnotatedString(stringResource(id = R.string.stripe_driver_license)), + text = AnnotatedString(stringResource(id = IdentityR.string.stripe_driver_license)), onClick = { onSubmissionStateChangedListener( identitySubmissionState.copy( @@ -372,7 +373,7 @@ private fun AllowedDocumentTypes( ) }) StyledClickableText( - text = AnnotatedString(stringResource(id = R.string.stripe_passport)), + text = AnnotatedString(stringResource(id = IdentityR.string.stripe_passport)), onClick = { onSubmissionStateChangedListener( identitySubmissionState.copy( @@ -395,7 +396,7 @@ private fun AllowedDocumentTypes( ) }) StyledClickableText( - text = AnnotatedString(stringResource(id = R.string.stripe_id_card)), + text = AnnotatedString(stringResource(id = IdentityR.string.stripe_id_card)), onClick = { onSubmissionStateChangedListener( identitySubmissionState.copy( diff --git a/identity/src/main/java/com/stripe/android/identity/ui/AddressSection.kt b/identity/src/main/java/com/stripe/android/identity/ui/AddressSection.kt index ff39298a5e3..ffc827442c2 100644 --- a/identity/src/main/java/com/stripe/android/identity/ui/AddressSection.kt +++ b/identity/src/main/java/com/stripe/android/identity/ui/AddressSection.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import androidx.navigation.NavController import com.stripe.android.core.model.Country -import com.stripe.android.identity.R import com.stripe.android.identity.navigation.CountryNotListedDestination import com.stripe.android.identity.navigation.navigateTo import com.stripe.android.identity.networking.Resource @@ -32,6 +31,7 @@ import com.stripe.android.uicore.elements.SectionElement import com.stripe.android.uicore.elements.SectionElementUI import com.stripe.android.uicore.elements.SectionFieldElement import com.stripe.android.uicore.forms.FormFieldEntry +import com.stripe.android.uicore.R as UiCoreR /** * Section to collect User's Address. @@ -69,7 +69,7 @@ internal fun AddressSection( } } val sectionElement = remember(selectedCountryCode) { - SectionElement.wrap(sectionList, R.string.stripe_address_label_address) + SectionElement.wrap(sectionList, UiCoreR.string.stripe_address_label_address) } val formFieldValues by sectionElement.getFormFieldValueFlow() .collectAsState(initial = emptyList()) diff --git a/identity/src/main/java/com/stripe/android/identity/ui/NameSection.kt b/identity/src/main/java/com/stripe/android/identity/ui/NameSection.kt index 2a460883220..4aa3535578b 100644 --- a/identity/src/main/java/com/stripe/android/identity/ui/NameSection.kt +++ b/identity/src/main/java/com/stripe/android/identity/ui/NameSection.kt @@ -14,6 +14,7 @@ import com.stripe.android.uicore.elements.SectionElementUI import com.stripe.android.uicore.elements.SimpleTextElement import com.stripe.android.uicore.elements.SimpleTextFieldConfig import com.stripe.android.uicore.elements.SimpleTextFieldController +import com.stripe.android.core.R as CoreR /** * Section to collect User's date of birth. @@ -45,7 +46,7 @@ internal fun NameSection( controller = lastNameController ) ), - label = R.string.stripe_address_label_name + label = CoreR.string.stripe_address_label_name ) } diff --git a/identity/src/main/java/com/stripe/android/identity/ui/UploadScreen.kt b/identity/src/main/java/com/stripe/android/identity/ui/UploadScreen.kt index 76414d5c110..43adc90abc2 100644 --- a/identity/src/main/java/com/stripe/android/identity/ui/UploadScreen.kt +++ b/identity/src/main/java/com/stripe/android/identity/ui/UploadScreen.kt @@ -59,6 +59,7 @@ import com.stripe.android.identity.states.IdentityScanState import com.stripe.android.identity.viewmodel.IdentityViewModel import com.stripe.android.uicore.text.dimensionResourceSp import kotlinx.coroutines.launch +import com.google.android.material.R as MaterialR internal const val FRONT_ROW_TAG = "frontRow" internal const val BACK_ROW_TAG = "backRow" @@ -369,7 +370,7 @@ private fun DialogListItem( .testTag(testTag) .height( dimensionResource( - com.google.android.material.R.dimen.abc_list_item_height_small_material + MaterialR.dimen.abc_list_item_height_small_material ) ) .clickable { onSelected() }, diff --git a/identity/src/test/java/com/stripe/android/identity/TestApplication.kt b/identity/src/test/java/com/stripe/android/identity/TestApplication.kt index c0d4f6ba810..671f1f5af53 100644 --- a/identity/src/test/java/com/stripe/android/identity/TestApplication.kt +++ b/identity/src/test/java/com/stripe/android/identity/TestApplication.kt @@ -1,11 +1,12 @@ package com.stripe.android.identity import android.app.Application +import com.google.android.material.R as MaterialR // A material themed application is needed to inflate MaterialToolbar in IdentityActivity internal class TestApplication : Application() { override fun onCreate() { super.onCreate() - setTheme(R.style.Theme_MaterialComponents_DayNight_NoActionBar) + setTheme(MaterialR.style.Theme_MaterialComponents_DayNight_NoActionBar) } } diff --git a/link/src/main/java/com/stripe/android/link/ui/ErrorMessage.kt b/link/src/main/java/com/stripe/android/link/ui/ErrorMessage.kt index fc3dfff8503..fcbb7e2c7ba 100644 --- a/link/src/main/java/com/stripe/android/link/ui/ErrorMessage.kt +++ b/link/src/main/java/com/stripe/android/link/ui/ErrorMessage.kt @@ -5,15 +5,15 @@ import android.os.Parcelable import androidx.annotation.RestrictTo import androidx.annotation.StringRes import com.stripe.android.core.exception.APIConnectionException -import com.stripe.android.link.R import kotlinx.parcelize.Parcelize +import com.stripe.android.R as StripeR internal fun Throwable.getErrorMessage() = when (this) { is APIConnectionException -> - ErrorMessage.FromResources(R.string.stripe_failure_connection_error) + ErrorMessage.FromResources(StripeR.string.stripe_failure_connection_error) else -> localizedMessage?.let { ErrorMessage.Raw(it) - } ?: ErrorMessage.FromResources(R.string.stripe_internal_error) + } ?: ErrorMessage.FromResources(StripeR.string.stripe_internal_error) } /** diff --git a/link/src/main/java/com/stripe/android/link/ui/LinkAppBar.kt b/link/src/main/java/com/stripe/android/link/ui/LinkAppBar.kt index 03ef08e98d6..bb0c6b183cb 100644 --- a/link/src/main/java/com/stripe/android/link/ui/LinkAppBar.kt +++ b/link/src/main/java/com/stripe/android/link/ui/LinkAppBar.kt @@ -31,6 +31,7 @@ import com.stripe.android.link.model.AccountStatus import com.stripe.android.link.theme.AppBarHeight import com.stripe.android.link.theme.DefaultLinkTheme import com.stripe.android.link.theme.linkColors +import com.stripe.android.ui.core.R as StripeUiCoreR @Composable internal fun LinkAppBar( @@ -52,7 +53,7 @@ internal fun LinkAppBar( ) { Icon( painter = painterResource(state.navigationIcon), - contentDescription = stringResource(id = R.string.stripe_back), + contentDescription = stringResource(id = StripeUiCoreR.string.stripe_back), tint = MaterialTheme.linkColors.closeButton ) } diff --git a/link/src/main/java/com/stripe/android/link/ui/LinkButtonView.kt b/link/src/main/java/com/stripe/android/link/ui/LinkButtonView.kt index 6d22da049b7..60ef96b6744 100644 --- a/link/src/main/java/com/stripe/android/link/ui/LinkButtonView.kt +++ b/link/src/main/java/com/stripe/android/link/ui/LinkButtonView.kt @@ -41,6 +41,7 @@ import com.stripe.android.link.R import com.stripe.android.link.theme.DefaultLinkTheme import com.stripe.android.link.theme.linkColors import com.stripe.android.uicore.StripeTheme +import com.stripe.android.R as StripeR private val LinkButtonVerticalPadding = 6.dp private val LinkButtonHorizontalPadding = 10.dp @@ -99,7 +100,7 @@ fun LinkButton( ) { Icon( painter = painterResource(R.drawable.stripe_link_logo), - contentDescription = stringResource(R.string.stripe_link), + contentDescription = stringResource(StripeR.string.stripe_link), modifier = Modifier .height(22.dp) .padding( diff --git a/link/src/main/java/com/stripe/android/link/ui/LinkLogoutSheet.kt b/link/src/main/java/com/stripe/android/link/ui/LinkLogoutSheet.kt index bd6eb58710f..810fcf22ca2 100644 --- a/link/src/main/java/com/stripe/android/link/ui/LinkLogoutSheet.kt +++ b/link/src/main/java/com/stripe/android/link/ui/LinkLogoutSheet.kt @@ -4,13 +4,14 @@ import androidx.compose.runtime.Composable import com.stripe.android.link.R import com.stripe.android.link.ui.menus.LinkMenu import com.stripe.android.link.ui.menus.LinkMenuItem +import com.stripe.android.R as StripeR internal sealed class LinkLogoutMenuItem( override val textResId: Int, override val isDestructive: Boolean = false ) : LinkMenuItem { object Logout : LinkLogoutMenuItem(textResId = R.string.stripe_log_out, isDestructive = true) - object Cancel : LinkLogoutMenuItem(textResId = R.string.stripe_cancel) + object Cancel : LinkLogoutMenuItem(textResId = StripeR.string.stripe_cancel) } @Composable diff --git a/link/src/main/java/com/stripe/android/link/ui/PrimaryButton.kt b/link/src/main/java/com/stripe/android/link/ui/PrimaryButton.kt index 933993f5499..2a3a1a31564 100644 --- a/link/src/main/java/com/stripe/android/link/ui/PrimaryButton.kt +++ b/link/src/main/java/com/stripe/android/link/ui/PrimaryButton.kt @@ -37,6 +37,7 @@ import com.stripe.android.model.PaymentIntent import com.stripe.android.model.SetupIntent import com.stripe.android.model.StripeIntent import com.stripe.android.ui.core.Amount +import com.stripe.android.ui.core.R as StripeUiCoreR /** * Represent the possible states for the primary button on a Link screen. @@ -69,7 +70,7 @@ internal fun completePaymentButtonLabel( requireNotNull(stripeIntent.amount), requireNotNull(stripeIntent.currency) ).buildPayButtonLabel(resources) - is SetupIntent -> resources.getString(R.string.stripe_setup_button_label) + is SetupIntent -> resources.getString(StripeUiCoreR.string.stripe_setup_button_label) } @Composable @@ -80,7 +81,7 @@ private fun PrimaryButton() { label = "Testing", state = PrimaryButtonState.Enabled, onButtonClick = { }, - iconEnd = R.drawable.stripe_ic_lock + iconEnd = StripeUiCoreR.drawable.stripe_ic_lock ) } } diff --git a/link/src/main/java/com/stripe/android/link/ui/cardedit/CardEditScreen.kt b/link/src/main/java/com/stripe/android/link/ui/cardedit/CardEditScreen.kt index af22ff5f79a..fa321989336 100644 --- a/link/src/main/java/com/stripe/android/link/ui/cardedit/CardEditScreen.kt +++ b/link/src/main/java/com/stripe/android/link/ui/cardedit/CardEditScreen.kt @@ -37,6 +37,7 @@ import com.stripe.android.link.ui.SecondaryButton import com.stripe.android.link.ui.forms.Form import com.stripe.android.link.ui.wallet.PaymentDetailsResult import com.stripe.android.uicore.elements.CheckboxElementUI +import com.stripe.android.R as StripeR internal const val DEFAULT_PAYMENT_METHOD_CHECKBOX_TAG = "DEFAULT_PAYMENT_METHOD_CHECKBOX" @@ -164,7 +165,7 @@ internal fun CardEditBody( ) SecondaryButton( enabled = !isProcessing, - label = stringResource(id = R.string.stripe_cancel), + label = stringResource(id = StripeR.string.stripe_cancel), onClick = onCancelClick ) } diff --git a/link/src/main/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModel.kt b/link/src/main/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModel.kt index c1e28828429..5c5b92ae372 100644 --- a/link/src/main/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModel.kt +++ b/link/src/main/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModel.kt @@ -43,6 +43,7 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import javax.inject.Inject import javax.inject.Provider +import com.stripe.android.R as StripeR /** * ViewModel that controls the PaymentMethod screen, managing what payment method form to show and @@ -73,7 +74,7 @@ internal class PaymentMethodViewModel @Inject constructor( val secondaryButtonLabel = if (isRootScreen) { R.string.stripe_wallet_pay_another_way } else { - R.string.stripe_cancel + StripeR.string.stripe_cancel } val supportedTypes = args.stripeIntent.supportedPaymentMethodTypes(linkAccount) diff --git a/link/src/main/java/com/stripe/android/link/ui/paymentmethod/SupportedPaymentMethod.kt b/link/src/main/java/com/stripe/android/link/ui/paymentmethod/SupportedPaymentMethod.kt index fec876b66ce..d4a3ede267f 100644 --- a/link/src/main/java/com/stripe/android/link/ui/paymentmethod/SupportedPaymentMethod.kt +++ b/link/src/main/java/com/stripe/android/link/ui/paymentmethod/SupportedPaymentMethod.kt @@ -9,6 +9,7 @@ import com.stripe.android.model.ConsumerPaymentDetails import com.stripe.android.model.StripeIntent import com.stripe.android.ui.core.elements.FormItemSpec import com.stripe.android.ui.core.forms.LinkCardForm +import com.stripe.android.ui.core.R as StripeUiCoreR /** * Represents the Payment Methods that are supported by Link. @@ -33,9 +34,9 @@ internal enum class SupportedPaymentMethod( Card( ConsumerPaymentDetails.Card.type, LinkCardForm.items, - R.string.stripe_paymentsheet_payment_method_card, + StripeUiCoreR.string.stripe_paymentsheet_payment_method_card, R.drawable.stripe_link_card, - primaryButtonEndIconResourceId = R.drawable.stripe_ic_lock + primaryButtonEndIconResourceId = StripeUiCoreR.drawable.stripe_ic_lock ) { override fun primaryButtonLabel( stripeIntent: StripeIntent, @@ -45,7 +46,7 @@ internal enum class SupportedPaymentMethod( BankAccount( ConsumerPaymentDetails.BankAccount.type, emptyList(), - R.string.stripe_payment_method_bank, + StripeUiCoreR.string.stripe_payment_method_bank, R.drawable.stripe_link_bank, primaryButtonStartIconResourceId = R.drawable.stripe_link_add ) { diff --git a/link/src/main/java/com/stripe/android/link/ui/wallet/ConfirmRemoveDialog.kt b/link/src/main/java/com/stripe/android/link/ui/wallet/ConfirmRemoveDialog.kt index 805d8b3ae86..ea1ec2b5932 100644 --- a/link/src/main/java/com/stripe/android/link/ui/wallet/ConfirmRemoveDialog.kt +++ b/link/src/main/java/com/stripe/android/link/ui/wallet/ConfirmRemoveDialog.kt @@ -6,10 +6,10 @@ import androidx.compose.material.Text import androidx.compose.material.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource -import com.stripe.android.link.R import com.stripe.android.link.model.removeConfirmation import com.stripe.android.link.theme.linkColors import com.stripe.android.model.ConsumerPaymentDetails +import com.stripe.android.R as StripeR @Composable internal fun ConfirmRemoveDialog( @@ -29,7 +29,7 @@ internal fun ConfirmRemoveDialog( } ) { Text( - text = stringResource(R.string.stripe_remove), + text = stringResource(StripeR.string.stripe_remove), color = MaterialTheme.linkColors.actionLabel ) } @@ -41,7 +41,7 @@ internal fun ConfirmRemoveDialog( } ) { Text( - text = stringResource(R.string.stripe_cancel), + text = stringResource(StripeR.string.stripe_cancel), color = MaterialTheme.linkColors.actionLabel ) } diff --git a/link/src/main/java/com/stripe/android/link/ui/wallet/PaymentDetails.kt b/link/src/main/java/com/stripe/android/link/ui/wallet/PaymentDetails.kt index fafc1d3dbeb..7c776c1ae03 100644 --- a/link/src/main/java/com/stripe/android/link/ui/wallet/PaymentDetails.kt +++ b/link/src/main/java/com/stripe/android/link/ui/wallet/PaymentDetails.kt @@ -43,6 +43,7 @@ import com.stripe.android.link.ui.ErrorText import com.stripe.android.link.ui.ErrorTextStyle import com.stripe.android.model.ConsumerPaymentDetails import com.stripe.android.model.ConsumerPaymentDetails.Card +import com.stripe.android.R as StripeR @Composable internal fun PaymentDetailsListItem( @@ -137,7 +138,7 @@ internal fun PaymentDetailsListItem( ) { Icon( imageVector = Icons.Filled.MoreVert, - contentDescription = stringResource(R.string.stripe_edit), + contentDescription = stringResource(StripeR.string.stripe_edit), tint = MaterialTheme.linkColors.actionLabelLight, modifier = Modifier.size(24.dp) ) diff --git a/link/src/main/java/com/stripe/android/link/ui/wallet/WalletPaymentMethodMenu.kt b/link/src/main/java/com/stripe/android/link/ui/wallet/WalletPaymentMethodMenu.kt index e46a1eccb63..edcd5c07890 100644 --- a/link/src/main/java/com/stripe/android/link/ui/wallet/WalletPaymentMethodMenu.kt +++ b/link/src/main/java/com/stripe/android/link/ui/wallet/WalletPaymentMethodMenu.kt @@ -7,6 +7,7 @@ import com.stripe.android.link.model.removeLabel import com.stripe.android.link.ui.menus.LinkMenu import com.stripe.android.link.ui.menus.LinkMenuItem import com.stripe.android.model.ConsumerPaymentDetails +import com.stripe.android.R as StripeR internal sealed class WalletPaymentMethodMenuItem( override val textResId: Int, @@ -26,7 +27,7 @@ internal sealed class WalletPaymentMethodMenuItem( ) object Cancel : WalletPaymentMethodMenuItem( - textResId = R.string.stripe_cancel + textResId = StripeR.string.stripe_cancel ) } diff --git a/link/src/main/java/com/stripe/android/link/ui/wallet/WalletScreen.kt b/link/src/main/java/com/stripe/android/link/ui/wallet/WalletScreen.kt index 7215c0815b2..faaafc7f39b 100644 --- a/link/src/main/java/com/stripe/android/link/ui/wallet/WalletScreen.kt +++ b/link/src/main/java/com/stripe/android/link/ui/wallet/WalletScreen.kt @@ -76,6 +76,7 @@ import com.stripe.android.uicore.elements.TextFieldController import com.stripe.android.uicore.text.Html import kotlinx.coroutines.flow.flowOf import java.util.UUID +import com.stripe.android.ui.core.R as StripeUiCoreR @Preview @Composable @@ -333,7 +334,7 @@ internal fun WalletBody( label = primaryButtonLabel, state = uiState.primaryButtonState, onButtonClick = onPrimaryButtonClick, - iconEnd = R.drawable.stripe_ic_lock + iconEnd = StripeUiCoreR.drawable.stripe_ic_lock ) SecondaryButton( diff --git a/link/src/test/java/com/stripe/android/link/ui/forms/FormControllerTest.kt b/link/src/test/java/com/stripe/android/link/ui/forms/FormControllerTest.kt index 44d9840a1fd..4c354a68984 100644 --- a/link/src/test/java/com/stripe/android/link/ui/forms/FormControllerTest.kt +++ b/link/src/test/java/com/stripe/android/link/ui/forms/FormControllerTest.kt @@ -6,7 +6,6 @@ import androidx.appcompat.view.ContextThemeWrapper import androidx.test.core.app.ApplicationProvider import com.google.common.truth.Truth.assertThat import com.stripe.android.ui.core.FormController -import com.stripe.android.ui.core.R import com.stripe.android.ui.core.elements.CountrySpec import com.stripe.android.ui.core.elements.EmailSpec import com.stripe.android.ui.core.elements.LayoutSpec @@ -24,12 +23,15 @@ import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR +import com.stripe.android.core.R as CoreR +import com.stripe.android.uicore.R as UiCoreR @RunWith(RobolectricTestRunner::class) class FormControllerTest { private val context = ContextThemeWrapper( ApplicationProvider.getApplicationContext(), - R.style.StripeDefaultTheme + StripeR.style.StripeDefaultTheme ) private val transformSpecToElements = TransformSpecToElements( @@ -56,9 +58,9 @@ class FormControllerTest { ) val nameElement = - getSectionFieldTextControllerWithLabel(formController, R.string.stripe_address_label_full_name) + getSectionFieldTextControllerWithLabel(formController, CoreR.string.stripe_address_label_full_name) val emailElement = - getSectionFieldTextControllerWithLabel(formController, R.string.stripe_email) + getSectionFieldTextControllerWithLabel(formController, UiCoreR.string.stripe_email) nameElement?.onValueChange("joe") assertThat( diff --git a/link/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModelTest.kt b/link/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModelTest.kt index 1dbd95c0e2e..5cbb324a74d 100644 --- a/link/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModelTest.kt +++ b/link/src/test/java/com/stripe/android/link/ui/paymentmethod/PaymentMethodViewModelTest.kt @@ -64,6 +64,7 @@ import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.robolectric.RobolectricTestRunner import javax.inject.Provider +import com.stripe.android.R as StripeR @RunWith(RobolectricTestRunner::class) class PaymentMethodViewModelTest { @@ -413,7 +414,7 @@ class PaymentMethodViewModelTest { fun `when screen is not root then secondaryButtonLabel is correct`() = runTest { whenever(navigator.isOnRootScreen()).thenReturn(false) - assertThat(createViewModel().secondaryButtonLabel).isEqualTo(R.string.stripe_cancel) + assertThat(createViewModel().secondaryButtonLabel).isEqualTo(StripeR.string.stripe_cancel) } @Test diff --git a/payments-core/detekt-baseline.xml b/payments-core/detekt-baseline.xml index 0818d63772d..6d29f90a6bc 100644 --- a/payments-core/detekt-baseline.xml +++ b/payments-core/detekt-baseline.xml @@ -111,6 +111,7 @@ MaxLineLength:DefaultAlipayRepositoryTest.kt$DefaultAlipayRepositoryTest$"https://hooks.stripe.com/adapter/alipay/redirect/complete/src_1HDEFWKlwPmebFhp6tcpln8T/src_client_secret_S6H9mVMKK6qxk9YxsUvbH55K" MaxLineLength:EphemeralKey.kt$EphemeralKey$* MaxLineLength:EphemeralKeyManagerTest.kt$EphemeralKeyManagerTest$"Received an ephemeral key that could not be parsed. See https://stripe.com/docs/mobile/android/basic for more details." + MaxLineLength:ExpiryDateEditTextTest.kt$ExpiryDateEditTextTest$verify(errorMessageListener).displayErrorMessage(context.getString(UiCoreR.string.stripe_incomplete_expiry_date)) MaxLineLength:GooglePayConfig.kt$GooglePayConfig$* MaxLineLength:GooglePayJsonFactory.kt$GooglePayJsonFactory$* MaxLineLength:GooglePayJsonFactory.kt$GooglePayJsonFactory$* [IsReadyToPayRequest](https://developers.google.com/pay/api/android/reference/request-objects#IsReadyToPayRequest) @@ -197,7 +198,6 @@ ReturnCount:DefaultPaymentAuthenticatorRegistry.kt$DefaultPaymentAuthenticatorRegistry$@Suppress("UNCHECKED_CAST") override fun <Authenticatable> getAuthenticator( authenticatable: Authenticatable ): PaymentAuthenticator<Authenticatable> ReturnCount:FraudDetectionDataJsonParser.kt$FraudDetectionDataJsonParser$override fun parse(json: JSONObject): FraudDetectionData? ReturnCount:PaymentAuthWebViewClient.kt$PaymentAuthWebViewClient$private fun isReturnUrl(uri: Uri): Boolean - ReturnCount:PaymentFlowResult.kt$PaymentFlowResult.Unvalidated$internal fun validate(): Result<Validated> ReturnCount:WalletJsonParser.kt$WalletJsonParser$override fun parse(json: JSONObject): Wallet? SwallowedException:ActivityUtils.kt$e: IllegalArgumentException SwallowedException:PaymentUtils.kt$PaymentUtils$e: ClassCastException diff --git a/payments-core/src/main/java/com/stripe/android/networking/StripeErrorMapping.kt b/payments-core/src/main/java/com/stripe/android/networking/StripeErrorMapping.kt index 7b98150ea99..613db88cec0 100644 --- a/payments-core/src/main/java/com/stripe/android/networking/StripeErrorMapping.kt +++ b/payments-core/src/main/java/com/stripe/android/networking/StripeErrorMapping.kt @@ -3,6 +3,7 @@ package com.stripe.android.networking import android.content.Context import com.stripe.android.R import com.stripe.android.core.StripeError +import com.stripe.android.uicore.R as UiCoreR @Suppress("ComplexMethod") internal fun StripeError.withLocalizedMessage(context: Context): StripeError { @@ -14,8 +15,8 @@ internal fun Context.mapErrorCodeToLocalizedMessage(code: String?): String? { val messageResourceId = when (code) { "incorrect_number" -> R.string.stripe_invalid_card_number "invalid_number" -> R.string.stripe_invalid_card_number - "invalid_expiry_month" -> R.string.stripe_invalid_expiry_month - "invalid_expiry_year" -> R.string.stripe_invalid_expiry_year + "invalid_expiry_month" -> UiCoreR.string.stripe_invalid_expiry_month + "invalid_expiry_year" -> UiCoreR.string.stripe_invalid_expiry_year "invalid_cvc" -> R.string.stripe_invalid_cvc "expired_card" -> R.string.stripe_expired_card "incorrect_cvc" -> R.string.stripe_invalid_cvc diff --git a/payments-core/src/main/java/com/stripe/android/view/BecsDebitAccountNumberEditText.kt b/payments-core/src/main/java/com/stripe/android/view/BecsDebitAccountNumberEditText.kt index 942ccd5caeb..772bd7f6571 100644 --- a/payments-core/src/main/java/com/stripe/android/view/BecsDebitAccountNumberEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/BecsDebitAccountNumberEditText.kt @@ -6,11 +6,12 @@ import android.text.InputType import android.util.AttributeSet import androidx.core.widget.doAfterTextChanged import com.stripe.android.R +import androidx.appcompat.R as AppCompatR internal class BecsDebitAccountNumberEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : StripeEditText(context, attrs, defStyleAttr) { val accountNumber: String? diff --git a/payments-core/src/main/java/com/stripe/android/view/BecsDebitBsbEditText.kt b/payments-core/src/main/java/com/stripe/android/view/BecsDebitBsbEditText.kt index ff2a19aee00..f32869349be 100644 --- a/payments-core/src/main/java/com/stripe/android/view/BecsDebitBsbEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/BecsDebitBsbEditText.kt @@ -6,11 +6,12 @@ import android.text.InputFilter import android.text.InputType import android.util.AttributeSet import com.stripe.android.R +import androidx.appcompat.R as AppCompatR internal class BecsDebitBsbEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : StripeEditText(context, attrs, defStyleAttr) { private val banks = BecsDebitBanks(context) diff --git a/payments-core/src/main/java/com/stripe/android/view/CardBrandSpinner.kt b/payments-core/src/main/java/com/stripe/android/view/CardBrandSpinner.kt index 932559d3605..ef12cb8a9ea 100644 --- a/payments-core/src/main/java/com/stripe/android/view/CardBrandSpinner.kt +++ b/payments-core/src/main/java/com/stripe/android/view/CardBrandSpinner.kt @@ -15,11 +15,12 @@ import com.stripe.android.R import com.stripe.android.databinding.StripeCardBrandSpinnerDropdownBinding import com.stripe.android.databinding.StripeCardBrandSpinnerMainBinding import com.stripe.android.model.CardBrand +import androidx.appcompat.R as AppCompatR internal class CardBrandSpinner @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.spinnerStyle + defStyleAttr: Int = AppCompatR.attr.spinnerStyle ) : AppCompatSpinner(context, attrs, defStyleAttr, MODE_DROPDOWN) { private val cardBrandsAdapter = Adapter(context) private var defaultBackground: Drawable? = null diff --git a/payments-core/src/main/java/com/stripe/android/view/CardFormView.kt b/payments-core/src/main/java/com/stripe/android/view/CardFormView.kt index 231dcf397d5..54360a028d3 100644 --- a/payments-core/src/main/java/com/stripe/android/view/CardFormView.kt +++ b/payments-core/src/main/java/com/stripe/android/view/CardFormView.kt @@ -28,6 +28,8 @@ import com.stripe.android.model.CardBrand import com.stripe.android.model.CardParams import com.stripe.android.view.CardFormView.Style import com.stripe.android.view.CardValidCallback.Fields +import com.stripe.android.uicore.R as UiCoreR +import com.stripe.payments.model.R as PaymentsModelR /** * A view to collect credit card information and provide [CardParams] for API invocation. @@ -235,7 +237,7 @@ class CardFormView @JvmOverloads constructor( private fun updatePostalCodeViewLocale(countryCode: CountryCode?) { if (CountryCode.isUS(countryCode)) { postalCodeView.config = PostalCodeEditText.Config.US - postalCodeView.setErrorMessage(resources.getString(R.string.stripe_address_zip_invalid)) + postalCodeView.setErrorMessage(resources.getString(UiCoreR.string.stripe_address_zip_invalid)) } else { postalCodeView.config = PostalCodeEditText.Config.Global postalCodeView.setErrorMessage(resources.getString(R.string.stripe_address_postal_code_invalid)) @@ -283,7 +285,7 @@ class CardFormView @JvmOverloads constructor( cardMultilineWidget.expiryDateEditText.includeSeparatorGaps = true cardMultilineWidget.expirationDatePlaceholderRes = null - cardMultilineWidget.expiryTextInputLayout.hint = context.getString(R.string.stripe_expiration_date_hint) + cardMultilineWidget.expiryTextInputLayout.hint = context.getString(UiCoreR.string.stripe_expiration_date_hint) cardMultilineWidget.cardNumberTextInputLayout.placeholderText = null cardMultilineWidget.setCvcPlaceholderText("") @@ -314,7 +316,7 @@ class CardFormView @JvmOverloads constructor( layout.error = null } - cardMultilineWidget.setCvcIcon(R.drawable.stripe_ic_cvc) + cardMultilineWidget.setCvcIcon(PaymentsModelR.drawable.stripe_ic_cvc) cardMultilineWidget.cardNumberErrorListener = StripeEditText.ErrorMessageListener { errorMessage -> diff --git a/payments-core/src/main/java/com/stripe/android/view/CardNumberEditText.kt b/payments-core/src/main/java/com/stripe/android/view/CardNumberEditText.kt index 48052498f29..4cc8df19855 100644 --- a/payments-core/src/main/java/com/stripe/android/view/CardNumberEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/CardNumberEditText.kt @@ -27,6 +27,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import kotlin.coroutines.CoroutineContext +import androidx.appcompat.R as AppCompatR /** * A [StripeEditText] that handles spacing out the digits of a credit card. @@ -35,7 +36,7 @@ import kotlin.coroutines.CoroutineContext class CardNumberEditText internal constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle, + defStyleAttr: Int = AppCompatR.attr.editTextStyle, // TODO(mshafrir-stripe): make immutable after `CardWidgetViewModel` is integrated in `CardWidget` subclasses @get:VisibleForTesting @@ -51,7 +52,7 @@ class CardNumberEditText internal constructor( constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : this( context, attrs, diff --git a/payments-core/src/main/java/com/stripe/android/view/CardNumberTextInputLayout.kt b/payments-core/src/main/java/com/stripe/android/view/CardNumberTextInputLayout.kt index a940dd6abf1..b37965e5952 100644 --- a/payments-core/src/main/java/com/stripe/android/view/CardNumberTextInputLayout.kt +++ b/payments-core/src/main/java/com/stripe/android/view/CardNumberTextInputLayout.kt @@ -11,6 +11,7 @@ import androidx.core.view.updateLayoutParams import com.google.android.material.textfield.TextInputLayout import com.stripe.android.R import kotlin.properties.Delegates +import com.google.android.material.R as MaterialR /** * An [TextInputLayout] that can show a loading indicator. @@ -19,7 +20,7 @@ import kotlin.properties.Delegates class CardNumberTextInputLayout @JvmOverloads internal constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = R.attr.textInputStyle + defStyleAttr: Int = MaterialR.attr.textInputStyle ) : TextInputLayout(context, attrs, defStyleAttr) { private val progressView = CardWidgetProgressView(context, attrs, defStyleAttr) diff --git a/payments-core/src/main/java/com/stripe/android/view/CountryTextInputLayout.kt b/payments-core/src/main/java/com/stripe/android/view/CountryTextInputLayout.kt index 9b5e49cb929..a0e5453034c 100644 --- a/payments-core/src/main/java/com/stripe/android/view/CountryTextInputLayout.kt +++ b/payments-core/src/main/java/com/stripe/android/view/CountryTextInputLayout.kt @@ -23,6 +23,8 @@ import com.stripe.android.core.model.CountryUtils import kotlinx.parcelize.Parcelize import java.util.Locale import kotlin.properties.Delegates +import androidx.appcompat.R as AppCompatR +import com.google.android.material.R as MaterialR /** * A subclass of [TextInputLayout] that programmatically wraps a styleable [AutoCompleteTextView], @@ -38,7 +40,7 @@ import kotlin.properties.Delegates class CountryTextInputLayout @JvmOverloads internal constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = com.google.android.material.R.attr.textInputStyle + defStyleAttr: Int = MaterialR.attr.textInputStyle ) : TextInputLayout(context, attrs, defStyleAttr) { @StyleRes @@ -209,7 +211,7 @@ class CountryTextInputLayout @JvmOverloads internal constructor( INVALID_COUNTRY_AUTO_COMPLETE_STYLE -> AutoCompleteTextView( context, null, - R.attr.autoCompleteTextViewStyle + AppCompatR.attr.autoCompleteTextViewStyle ) else -> AutoCompleteTextView(context, null, 0, countryAutoCompleteStyleRes) } diff --git a/payments-core/src/main/java/com/stripe/android/view/CvcEditText.kt b/payments-core/src/main/java/com/stripe/android/view/CvcEditText.kt index fc022a22dce..6b55ef5fd69 100644 --- a/payments-core/src/main/java/com/stripe/android/view/CvcEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/CvcEditText.kt @@ -10,6 +10,7 @@ import com.google.android.material.textfield.TextInputLayout import com.stripe.android.R import com.stripe.android.cards.Cvc import com.stripe.android.model.CardBrand +import androidx.appcompat.R as AppCompatR /** * A [StripeEditText] for CVC input. @@ -17,7 +18,7 @@ import com.stripe.android.model.CardBrand class CvcEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : StripeEditText(context, attrs, defStyleAttr) { private val unvalidatedCvc: Cvc.Unvalidated diff --git a/payments-core/src/main/java/com/stripe/android/view/EmailEditText.kt b/payments-core/src/main/java/com/stripe/android/view/EmailEditText.kt index 9d5d4b9c30e..03c38234a06 100644 --- a/payments-core/src/main/java/com/stripe/android/view/EmailEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/EmailEditText.kt @@ -4,11 +4,12 @@ import android.content.Context import android.util.AttributeSet import android.util.Patterns import com.stripe.android.R +import androidx.appcompat.R as AppCompatR internal class EmailEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : StripeEditText(context, attrs, defStyleAttr) { val email: String? diff --git a/payments-core/src/main/java/com/stripe/android/view/ExpiryDateEditText.kt b/payments-core/src/main/java/com/stripe/android/view/ExpiryDateEditText.kt index e7a0fb2d3b9..8ddae92b95c 100644 --- a/payments-core/src/main/java/com/stripe/android/view/ExpiryDateEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/ExpiryDateEditText.kt @@ -13,6 +13,8 @@ import com.stripe.android.R import com.stripe.android.model.ExpirationDate import kotlin.math.min import kotlin.properties.Delegates +import androidx.appcompat.R as AppCompatR +import com.stripe.android.uicore.R as UiCoreR /** * An [EditText] that handles putting numbers around a central divider character. @@ -20,7 +22,7 @@ import kotlin.properties.Delegates class ExpiryDateEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : StripeEditText(context, attrs, defStyleAttr) { // invoked when a valid date has been entered @@ -213,11 +215,11 @@ class ExpiryDateEditText @JvmOverloads constructor( setErrorMessage( resources.getString( if (expirationDate.isPartialEntry) { - R.string.stripe_incomplete_expiry_date + UiCoreR.string.stripe_incomplete_expiry_date } else if (!expirationDate.isMonthValid) { - R.string.stripe_invalid_expiry_month + UiCoreR.string.stripe_invalid_expiry_month } else { - R.string.stripe_invalid_expiry_year + UiCoreR.string.stripe_invalid_expiry_year } ) ) diff --git a/payments-core/src/main/java/com/stripe/android/view/MaskedCardView.kt b/payments-core/src/main/java/com/stripe/android/view/MaskedCardView.kt index 0bbdcc9bd18..5e642e560e4 100644 --- a/payments-core/src/main/java/com/stripe/android/view/MaskedCardView.kt +++ b/payments-core/src/main/java/com/stripe/android/view/MaskedCardView.kt @@ -14,6 +14,7 @@ import com.stripe.android.R import com.stripe.android.databinding.StripeMaskedCardViewBinding import com.stripe.android.model.CardBrand import com.stripe.android.model.PaymentMethod +import com.stripe.payments.model.R as PaymentsModelR /** * View that displays card information without revealing the entire number, usually for @@ -85,7 +86,7 @@ internal class MaskedCardView @JvmOverloads constructor( CardBrand.MasterCard -> R.drawable.stripe_ic_mastercard_template_32 CardBrand.UnionPay -> R.drawable.stripe_ic_unionpay_template_32 CardBrand.CartesBancaires -> R.drawable.stripe_ic_cartebancaire_template_32 - CardBrand.Unknown -> R.drawable.stripe_ic_unknown + CardBrand.Unknown -> PaymentsModelR.drawable.stripe_ic_unknown } ) ) diff --git a/payments-core/src/main/java/com/stripe/android/view/PostalCodeEditText.kt b/payments-core/src/main/java/com/stripe/android/view/PostalCodeEditText.kt index 4e4d33176a3..fd0cce78eae 100644 --- a/payments-core/src/main/java/com/stripe/android/view/PostalCodeEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/PostalCodeEditText.kt @@ -14,11 +14,13 @@ import com.google.android.material.textfield.TextInputLayout import com.stripe.android.R import java.util.regex.Pattern import kotlin.properties.Delegates +import androidx.appcompat.R as AppCompatR +import com.stripe.android.core.R as CoreR class PostalCodeEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : StripeEditText(context, attrs, defStyleAttr) { internal var config: Config by Delegates.observable( @@ -63,7 +65,7 @@ class PostalCodeEditText @JvmOverloads constructor( * Configure the field for United States users */ private fun configureForUs() { - updateHint(R.string.stripe_address_label_zip_code) + updateHint(CoreR.string.stripe_address_label_zip_code) filters = arrayOf(InputFilter.LengthFilter(MAX_LENGTH_US)) keyListener = DigitsKeyListener.getInstance(false, true) setNumberOnlyInputType() @@ -73,7 +75,7 @@ class PostalCodeEditText @JvmOverloads constructor( * Configure the field for global users */ private fun configureForGlobal() { - updateHint(R.string.stripe_address_label_postal_code) + updateHint(CoreR.string.stripe_address_label_postal_code) keyListener = TextKeyListener.getInstance() inputType = InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS filters = arrayOf() diff --git a/payments-core/src/main/java/com/stripe/android/view/ShippingInfoWidget.kt b/payments-core/src/main/java/com/stripe/android/view/ShippingInfoWidget.kt index e3dc8d87688..b29a032ee5a 100644 --- a/payments-core/src/main/java/com/stripe/android/view/ShippingInfoWidget.kt +++ b/payments-core/src/main/java/com/stripe/android/view/ShippingInfoWidget.kt @@ -16,6 +16,8 @@ import com.stripe.android.databinding.StripeAddressWidgetBinding import com.stripe.android.model.Address import com.stripe.android.model.ShippingInformation import java.util.Locale +import com.stripe.android.core.R as CoreR +import com.stripe.android.uicore.R as UiCoreR /** * A widget used to collect address data from a user. @@ -248,18 +250,18 @@ class ShippingInfoWidget @JvmOverloads constructor( } private fun renderLabels() { - nameTextInputLayout.hint = resources.getString(R.string.stripe_address_label_full_name) + nameTextInputLayout.hint = resources.getString(CoreR.string.stripe_address_label_full_name) cityTextInputLayout.hint = if (isFieldOptional(CustomizableShippingField.City)) { resources.getString(R.string.stripe_address_label_city_optional) } else { - resources.getString(R.string.stripe_address_label_city) + resources.getString(CoreR.string.stripe_address_label_city) } phoneNumberTextInputLayout.hint = if (isFieldOptional(CustomizableShippingField.Phone)) { resources.getString(R.string.stripe_address_label_phone_number_optional) } else { - resources.getString(R.string.stripe_address_label_phone_number) + resources.getString(UiCoreR.string.stripe_address_label_phone_number) } hideHiddenFields() } @@ -317,7 +319,7 @@ class ShippingInfoWidget @JvmOverloads constructor( if (isFieldOptional(CustomizableShippingField.Line1)) { resources.getString(R.string.stripe_address_label_address_optional) } else { - resources.getString(R.string.stripe_address_label_address) + resources.getString(UiCoreR.string.stripe_address_label_address) } addressLine2TextInputLayout.hint = resources.getString( R.string.stripe_address_label_apt_optional @@ -326,15 +328,15 @@ class ShippingInfoWidget @JvmOverloads constructor( if (isFieldOptional(CustomizableShippingField.PostalCode)) { resources.getString(R.string.stripe_address_label_zip_code_optional) } else { - resources.getString(R.string.stripe_address_label_zip_code) + resources.getString(CoreR.string.stripe_address_label_zip_code) } stateTextInputLayout.hint = if (isFieldOptional(CustomizableShippingField.State)) { resources.getString(R.string.stripe_address_label_state_optional) } else { - resources.getString(R.string.stripe_address_label_state) + resources.getString(CoreR.string.stripe_address_label_state) } - postalCodeEditText.setErrorMessage(resources.getString(R.string.stripe_address_zip_invalid)) + postalCodeEditText.setErrorMessage(resources.getString(UiCoreR.string.stripe_address_zip_invalid)) stateEditText.setErrorMessage(resources.getString(R.string.stripe_address_state_required)) } @@ -343,7 +345,7 @@ class ShippingInfoWidget @JvmOverloads constructor( if (isFieldOptional(CustomizableShippingField.Line1)) { resources.getString(R.string.stripe_address_label_address_line1_optional) } else { - resources.getString(R.string.stripe_address_label_address_line1) + resources.getString(CoreR.string.stripe_address_label_address_line1) } addressLine2TextInputLayout.hint = resources.getString( R.string.stripe_address_label_address_line2_optional @@ -358,7 +360,7 @@ class ShippingInfoWidget @JvmOverloads constructor( if (isFieldOptional(CustomizableShippingField.State)) { resources.getString(R.string.stripe_address_label_county_optional) } else { - resources.getString(R.string.stripe_address_label_county) + resources.getString(CoreR.string.stripe_address_label_county) } postalCodeEditText.setErrorMessage(resources.getString(R.string.stripe_address_postcode_invalid)) stateEditText.setErrorMessage(resources.getString(R.string.stripe_address_county_required)) @@ -369,20 +371,20 @@ class ShippingInfoWidget @JvmOverloads constructor( if (isFieldOptional(CustomizableShippingField.Line1)) { resources.getString(R.string.stripe_address_label_address_optional) } else { - resources.getString(R.string.stripe_address_label_address) + resources.getString(UiCoreR.string.stripe_address_label_address) } addressLine2TextInputLayout.hint = resources.getString(R.string.stripe_address_label_apt_optional) postalCodeTextInputLayout.hint = if (isFieldOptional(CustomizableShippingField.PostalCode)) { resources.getString(R.string.stripe_address_label_postal_code_optional) } else { - resources.getString(R.string.stripe_address_label_postal_code) + resources.getString(CoreR.string.stripe_address_label_postal_code) } stateTextInputLayout.hint = if (isFieldOptional(CustomizableShippingField.State)) { resources.getString(R.string.stripe_address_label_province_optional) } else { - resources.getString(R.string.stripe_address_label_province) + resources.getString(CoreR.string.stripe_address_label_province) } postalCodeEditText.setErrorMessage( @@ -402,7 +404,7 @@ class ShippingInfoWidget @JvmOverloads constructor( if (isFieldOptional(CustomizableShippingField.Line1)) { resources.getString(R.string.stripe_address_label_address_line1_optional) } else { - resources.getString(R.string.stripe_address_label_address_line1) + resources.getString(CoreR.string.stripe_address_label_address_line1) } addressLine2TextInputLayout.hint = resources.getString(R.string.stripe_address_label_address_line2_optional) @@ -423,7 +425,7 @@ class ShippingInfoWidget @JvmOverloads constructor( postalCodeEditText.setErrorMessage( resources.getString( - R.string.stripe_address_zip_postal_invalid + UiCoreR.string.stripe_address_zip_postal_invalid ) ) stateEditText.setErrorMessage( diff --git a/payments-core/src/main/java/com/stripe/android/view/StripeActivity.kt b/payments-core/src/main/java/com/stripe/android/view/StripeActivity.kt index 8f6fd87411b..7e21f2a89fc 100644 --- a/payments-core/src/main/java/com/stripe/android/view/StripeActivity.kt +++ b/payments-core/src/main/java/com/stripe/android/view/StripeActivity.kt @@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.view.isVisible import com.stripe.android.R import com.stripe.android.databinding.StripeActivityBinding +import androidx.appcompat.R as AppCompatR /** * Provides a toolbar, save button, and loading states for the save button. @@ -76,7 +77,7 @@ abstract class StripeActivity : AppCompatActivity() { val saveItem = menu.findItem(R.id.action_save) val tintedIcon = stripeColorUtils.getTintedIconWithAttribute( theme, - R.attr.titleTextColor, + AppCompatR.attr.titleTextColor, R.drawable.stripe_ic_checkmark ) saveItem.icon = tintedIcon diff --git a/payments-core/src/main/java/com/stripe/android/view/StripeEditText.kt b/payments-core/src/main/java/com/stripe/android/view/StripeEditText.kt index 0113ad5ad15..c7536ec5af2 100644 --- a/payments-core/src/main/java/com/stripe/android/view/StripeEditText.kt +++ b/payments-core/src/main/java/com/stripe/android/view/StripeEditText.kt @@ -20,6 +20,7 @@ import androidx.core.widget.doAfterTextChanged import com.google.android.material.textfield.TextInputEditText import com.stripe.android.R import kotlinx.parcelize.Parcelize +import androidx.appcompat.R as AppCompatR /** * Extension of [TextInputEditText] that listens for users pressing the delete key when @@ -31,7 +32,7 @@ import kotlinx.parcelize.Parcelize open class StripeEditText @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle + defStyleAttr: Int = AppCompatR.attr.editTextStyle ) : TextInputEditText(context, attrs, defStyleAttr) { @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) internal var isLastKeyDelete: Boolean = false diff --git a/payments-core/src/test/java/com/stripe/android/view/CardFormViewTest.kt b/payments-core/src/test/java/com/stripe/android/view/CardFormViewTest.kt index 12313b4d767..cdbced7788d 100644 --- a/payments-core/src/test/java/com/stripe/android/view/CardFormViewTest.kt +++ b/payments-core/src/test/java/com/stripe/android/view/CardFormViewTest.kt @@ -25,6 +25,7 @@ import org.junit.runner.RunWith import org.robolectric.Robolectric import org.robolectric.RobolectricTestRunner import java.util.Locale +import com.stripe.android.uicore.R as UiCoreR @RunWith(RobolectricTestRunner::class) class CardFormViewTest { @@ -135,7 +136,7 @@ class CardFormViewTest { idleLooper() standardBinding!!.let { - assertThat(it.errors.text).isEqualTo(context.getString(R.string.stripe_address_zip_invalid)) + assertThat(it.errors.text).isEqualTo(context.getString(UiCoreR.string.stripe_address_zip_invalid)) assertThat(it.errors.isVisible).isTrue() } } @@ -163,7 +164,7 @@ class CardFormViewTest { idleLooper() standardBinding!!.let { - assertThat(it.errors.text).isEqualTo(context.getString(R.string.stripe_invalid_expiry_year)) + assertThat(it.errors.text).isEqualTo(context.getString(UiCoreR.string.stripe_invalid_expiry_year)) assertThat(it.errors.isVisible).isTrue() } } diff --git a/payments-core/src/test/java/com/stripe/android/view/ExpiryDateEditTextTest.kt b/payments-core/src/test/java/com/stripe/android/view/ExpiryDateEditTextTest.kt index 0a73931d3eb..1ec747f11e4 100644 --- a/payments-core/src/test/java/com/stripe/android/view/ExpiryDateEditTextTest.kt +++ b/payments-core/src/test/java/com/stripe/android/view/ExpiryDateEditTextTest.kt @@ -18,6 +18,7 @@ import org.mockito.kotlin.verifyNoMoreInteractions import org.robolectric.RobolectricTestRunner import java.util.Calendar import kotlin.test.Test +import com.stripe.android.uicore.R as UiCoreR /** * Test class for [ExpiryDateEditText]. @@ -195,7 +196,7 @@ class ExpiryDateEditTextTest { assertThat(expiryDateEditText.shouldShowError) .isTrue() assertThat(expiryDateEditText.errorMessage) - .isEqualTo(context.getString(R.string.stripe_incomplete_expiry_date)) + .isEqualTo(context.getString(UiCoreR.string.stripe_incomplete_expiry_date)) assertThat(expiryDateEditText.text.toString()) .isEqualTo("14") } @@ -207,7 +208,7 @@ class ExpiryDateEditTextTest { assertThat(expiryDateEditText.shouldShowError) .isTrue() assertThat(expiryDateEditText.errorMessage) - .isEqualTo(context.getString(R.string.stripe_incomplete_expiry_date)) + .isEqualTo(context.getString(UiCoreR.string.stripe_incomplete_expiry_date)) assertThat(expiryDateEditText.text.toString()) .isEqualTo("14/3") } @@ -240,7 +241,7 @@ class ExpiryDateEditTextTest { assertThat(expiryDateEditText.shouldShowError) .isTrue() assertThat(expiryDateEditText.errorMessage) - .isEqualTo(context.getString(R.string.stripe_invalid_expiry_year)) + .isEqualTo(context.getString(UiCoreR.string.stripe_invalid_expiry_year)) assertThat(invocations) .isEqualTo(0) } @@ -261,7 +262,7 @@ class ExpiryDateEditTextTest { assertThat(expiryDateEditText.shouldShowError) .isTrue() assertThat(expiryDateEditText.errorMessage) - .isEqualTo(context.getString(R.string.stripe_invalid_expiry_year)) + .isEqualTo(context.getString(UiCoreR.string.stripe_invalid_expiry_year)) ViewTestUtils.sendDeleteKeyEvent(expiryDateEditText) assertThat(expiryDateEditText.text.toString()) @@ -291,7 +292,7 @@ class ExpiryDateEditTextTest { assertThat(expiryDateEditText.shouldShowError) .isTrue() assertThat(expiryDateEditText.errorMessage) - .isEqualTo(context.getString(R.string.stripe_invalid_expiry_month)) + .isEqualTo(context.getString(UiCoreR.string.stripe_invalid_expiry_month)) } @Test @@ -414,7 +415,7 @@ class ExpiryDateEditTextTest { idleLooper() - verify(errorMessageListener).displayErrorMessage(context.getString(R.string.stripe_incomplete_expiry_date)) + verify(errorMessageListener).displayErrorMessage(context.getString(UiCoreR.string.stripe_incomplete_expiry_date)) } @Test diff --git a/payments-core/src/test/java/com/stripe/android/view/ShippingInfoWidgetTest.kt b/payments-core/src/test/java/com/stripe/android/view/ShippingInfoWidgetTest.kt index bf49aaed36c..797d0625bd7 100644 --- a/payments-core/src/test/java/com/stripe/android/view/ShippingInfoWidgetTest.kt +++ b/payments-core/src/test/java/com/stripe/android/view/ShippingInfoWidgetTest.kt @@ -21,6 +21,8 @@ import org.robolectric.RobolectricTestRunner import java.util.Locale import kotlin.test.BeforeTest import kotlin.test.Test +import com.stripe.android.core.R as CoreR +import com.stripe.android.uicore.R as UiCoreR /** * Test class for [ShippingInfoWidget] @@ -93,39 +95,39 @@ class ShippingInfoWidgetTest { fun shippingInfoWidget_whenCountryChanged_fieldsRenderCorrectly() { countryTextInputLayout.updateUiForCountryEntered(Locale.US.getCountryCode()) assertThat(addressLine1TextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_address)) + .isEqualTo(res.getString(UiCoreR.string.stripe_address_label_address)) assertThat(addressLine2TextInputLayout.hint) .isEqualTo(res.getString(R.string.stripe_address_label_apt_optional)) assertThat(postalCodeTextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_zip_code)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_zip_code)) assertThat(stateTextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_state)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_state)) countryTextInputLayout.updateUiForCountryEntered(Locale.CANADA.getCountryCode()) assertThat(addressLine1TextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_address)) + .isEqualTo(res.getString(UiCoreR.string.stripe_address_label_address)) assertThat(addressLine2TextInputLayout.hint) .isEqualTo(res.getString(R.string.stripe_address_label_apt_optional)) assertThat(postalCodeTextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_postal_code)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_postal_code)) assertThat(stateTextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_province)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_province)) countryTextInputLayout.updateUiForCountryEntered(Locale.UK.getCountryCode()) assertThat(addressLine1TextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_address_line1)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_address_line1)) assertThat(addressLine2TextInputLayout.hint) .isEqualTo(res.getString(R.string.stripe_address_label_address_line2_optional)) assertThat(postalCodeTextInputLayout.hint) .isEqualTo(res.getString(R.string.stripe_address_label_postcode)) assertThat(stateTextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_county)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_county)) countryTextInputLayout.updateUiForCountryEntered( Locale("", NO_POSTAL_CODE_COUNTRY_CODE).getCountryCode() ) assertThat(addressLine1TextInputLayout.hint) - .isEqualTo(res.getString(R.string.stripe_address_label_address_line1)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_address_line1)) assertThat(addressLine2TextInputLayout.hint) .isEqualTo(res.getString(R.string.stripe_address_label_address_line2_optional)) assertThat(postalCodeTextInputLayout.visibility) @@ -229,7 +231,7 @@ class ShippingInfoWidgetTest { assertThat(stateTextInputLayout.error) .isEqualTo(res.getString(R.string.stripe_address_state_required)) assertThat(postalCodeTextInputLayout.error) - .isEqualTo(res.getString(R.string.stripe_address_zip_invalid)) + .isEqualTo(res.getString(UiCoreR.string.stripe_address_zip_invalid)) countryTextInputLayout.updateUiForCountryEntered(Locale.UK.getCountryCode()) assertThat(shippingInfoWidget.validateAllFields()) @@ -258,19 +260,19 @@ class ShippingInfoWidgetTest { @Test fun shippingInfoWidget_whenFieldsOptional_markedAsOptional() { assertThat(postalCodeTextInputLayout.hint.toString()) - .isEqualTo(res.getString(R.string.stripe_address_label_zip_code)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_zip_code)) assertThat(nameTextInputLayout.hint.toString()) - .isEqualTo(res.getString(R.string.stripe_address_label_full_name)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_full_name)) shippingInfoWidget.optionalFields = listOf( ShippingInfoWidget.CustomizableShippingField.PostalCode ) assertThat(postalCodeTextInputLayout.hint.toString()) .isEqualTo(res.getString(R.string.stripe_address_label_zip_code_optional)) assertThat(nameTextInputLayout.hint.toString()) - .isEqualTo(res.getString(R.string.stripe_address_label_full_name)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_full_name)) countryTextInputLayout.updateUiForCountryEntered(Locale.CANADA.getCountryCode()) assertThat(stateTextInputLayout.hint.toString()) - .isEqualTo(res.getString(R.string.stripe_address_label_province)) + .isEqualTo(res.getString(CoreR.string.stripe_address_label_province)) shippingInfoWidget.optionalFields = listOf( ShippingInfoWidget.CustomizableShippingField.PostalCode, ShippingInfoWidget.CustomizableShippingField.State diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AffirmElementUI.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AffirmElementUI.kt index dbd58d783b8..d08bad8110c 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AffirmElementUI.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AffirmElementUI.kt @@ -11,12 +11,13 @@ import com.stripe.android.ui.core.R import com.stripe.android.uicore.stripeColors import com.stripe.android.uicore.text.EmbeddableImage import com.stripe.android.uicore.text.Html +import com.stripe.android.R as StripeR @Composable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun AffirmElementUI() { Html( - html = stringResource(id = R.string.stripe_affirm_buy_now_pay_later), + html = stringResource(id = StripeR.string.stripe_affirm_buy_now_pay_later), imageLoader = mapOf( "affirm" to EmbeddableImage.Drawable( R.drawable.stripe_ic_affirm_logo, diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBankAccountNumberConfig.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBankAccountNumberConfig.kt index e5231f159c1..2fe2e66ea64 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBankAccountNumberConfig.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBankAccountNumberConfig.kt @@ -5,13 +5,13 @@ import androidx.annotation.StringRes import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.VisualTransformation -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldConfig import com.stripe.android.uicore.elements.TextFieldIcon import com.stripe.android.uicore.elements.TextFieldState import com.stripe.android.uicore.elements.TextFieldStateConstants import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import com.stripe.android.R as StripeR /** * A text field configuration for an AU bank account number @@ -26,7 +26,7 @@ class AuBankAccountNumberConfig : TextFieldConfig { override val loading: StateFlow = MutableStateFlow(false) @StringRes - override val label = R.string.stripe_becs_widget_account_number + override val label = StripeR.string.stripe_becs_widget_account_number override val keyboard = KeyboardType.Number override fun filter(userTyped: String) = @@ -43,13 +43,13 @@ class AuBankAccountNumberConfig : TextFieldConfig { if (input.length < LENGTH) { return TextFieldStateConstants.Error.Incomplete( - R.string.stripe_becs_widget_account_number_incomplete + StripeR.string.stripe_becs_widget_account_number_incomplete ) } if (input.length > LENGTH) { return TextFieldStateConstants.Error.Invalid( - R.string.stripe_becs_widget_account_number_invalid + StripeR.string.stripe_becs_widget_account_number_invalid ) } diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBecsDebitMandateElementUI.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBecsDebitMandateElementUI.kt index b60592afb65..6dd48b6ad77 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBecsDebitMandateElementUI.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/AuBecsDebitMandateElementUI.kt @@ -7,9 +7,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import com.stripe.android.ui.core.R import com.stripe.android.uicore.stripeColors import com.stripe.android.uicore.text.Html +import com.stripe.android.R as StripeR @Composable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @@ -17,7 +17,7 @@ fun AuBecsDebitMandateElementUI( element: AuBecsDebitMandateTextElement ) { Html( - html = stringResource(id = R.string.stripe_au_becs_mandate, element.merchantName ?: ""), + html = stringResource(id = StripeR.string.stripe_au_becs_mandate, element.merchantName ?: ""), color = MaterialTheme.stripeColors.subtitle, style = MaterialTheme.typography.body2, modifier = Modifier.padding(vertical = 8.dp) diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/BsbConfig.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/BsbConfig.kt index 954de1fc169..5d6fca703ad 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/BsbConfig.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/BsbConfig.kt @@ -8,7 +8,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.OffsetMapping import androidx.compose.ui.text.input.TransformedText import androidx.compose.ui.text.input.VisualTransformation -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldConfig import com.stripe.android.uicore.elements.TextFieldIcon import com.stripe.android.uicore.elements.TextFieldState @@ -16,6 +15,7 @@ import com.stripe.android.uicore.elements.TextFieldStateConstants import com.stripe.android.view.BecsDebitBanks import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import com.stripe.android.R as StripeR /** * A text field configuration for a BSB number, or Bank State Branch Number, @@ -30,7 +30,7 @@ class BsbConfig(private val banks: List) : TextFieldConfig override val loading: StateFlow = MutableStateFlow(false) @StringRes - override val label = R.string.stripe_becs_widget_bsb + override val label = StripeR.string.stripe_becs_widget_bsb override val keyboard = KeyboardType.Number // Displays the BSB number in 2 groups of 3 characters with a dash added between them @@ -77,7 +77,7 @@ class BsbConfig(private val banks: List) : TextFieldConfig if (input.length < LENGTH) { return TextFieldStateConstants.Error.Incomplete( - R.string.stripe_becs_widget_bsb_incomplete + StripeR.string.stripe_becs_widget_bsb_incomplete ) } @@ -87,7 +87,7 @@ class BsbConfig(private val banks: List) : TextFieldConfig if (bank == null || input.length > LENGTH) { return TextFieldStateConstants.Error.Invalid( - R.string.stripe_becs_widget_bsb_invalid + StripeR.string.stripe_becs_widget_bsb_invalid ) } diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardNumberConfig.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardNumberConfig.kt index 23d37c086e1..60eeedb769c 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardNumberConfig.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardNumberConfig.kt @@ -5,14 +5,14 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.VisualTransformation import com.stripe.android.CardUtils import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldState import com.stripe.android.uicore.elements.TextFieldStateConstants +import com.stripe.android.R as StripeR internal class CardNumberConfig : CardDetailsTextFieldConfig { override val capitalization: KeyboardCapitalization = KeyboardCapitalization.None override val debugLabel: String = "Card number" - override val label: Int = R.string.stripe_acc_label_card_number + override val label: Int = StripeR.string.stripe_acc_label_card_number override val keyboard: KeyboardType = KeyboardType.NumberPassword override val visualTransformation: VisualTransformation = CardNumberVisualTransformation(' ') @@ -23,15 +23,15 @@ internal class CardNumberConfig : CardDetailsTextFieldConfig { return if (number.isBlank()) { TextFieldStateConstants.Error.Blank } else if (brand == CardBrand.Unknown) { - TextFieldStateConstants.Error.Invalid(R.string.stripe_invalid_card_number) + TextFieldStateConstants.Error.Invalid(StripeR.string.stripe_invalid_card_number) } else if (isDigitLimit && number.length < numberAllowedDigits) { - TextFieldStateConstants.Error.Incomplete(R.string.stripe_invalid_card_number) + TextFieldStateConstants.Error.Incomplete(StripeR.string.stripe_invalid_card_number) } else if (!luhnValid) { - TextFieldStateConstants.Error.Invalid(R.string.stripe_invalid_card_number) + TextFieldStateConstants.Error.Invalid(StripeR.string.stripe_invalid_card_number) } else if (isDigitLimit && number.length == numberAllowedDigits) { TextFieldStateConstants.Valid.Full } else { - TextFieldStateConstants.Error.Invalid(R.string.stripe_invalid_card_number) + TextFieldStateConstants.Error.Invalid(StripeR.string.stripe_invalid_card_number) } } diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcConfig.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcConfig.kt index 4fca425e527..bfbb8c17187 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcConfig.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcConfig.kt @@ -5,15 +5,15 @@ import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.VisualTransformation import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldState import com.stripe.android.uicore.elements.TextFieldStateConstants +import com.stripe.android.R as StripeR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class CvcConfig : CardDetailsTextFieldConfig { override val capitalization: KeyboardCapitalization = KeyboardCapitalization.None override val debugLabel: String = "cvc" - override val label: Int = R.string.stripe_cvc_number_hint + override val label: Int = StripeR.string.stripe_cvc_number_hint override val keyboard: KeyboardType = KeyboardType.NumberPassword override val visualTransformation: VisualTransformation = VisualTransformation.None @@ -31,13 +31,13 @@ class CvcConfig : CardDetailsTextFieldConfig { else -> TextFieldStateConstants.Valid.Limitless } } else if (isDigitLimit && number.length < numberAllowedDigits) { - TextFieldStateConstants.Error.Incomplete(R.string.stripe_invalid_cvc) + TextFieldStateConstants.Error.Incomplete(StripeR.string.stripe_invalid_cvc) } else if (isDigitLimit && number.length > numberAllowedDigits) { - TextFieldStateConstants.Error.Invalid(R.string.stripe_invalid_cvc) + TextFieldStateConstants.Error.Invalid(StripeR.string.stripe_invalid_cvc) } else if (isDigitLimit && number.length == numberAllowedDigits) { TextFieldStateConstants.Valid.Full } else { - TextFieldStateConstants.Error.Invalid(R.string.stripe_invalid_cvc) + TextFieldStateConstants.Error.Invalid(StripeR.string.stripe_invalid_cvc) } } diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcController.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcController.kt index 366e465c070..e6c608c652a 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcController.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/CvcController.kt @@ -6,7 +6,6 @@ import androidx.compose.ui.autofill.AutofillType import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.FieldError import com.stripe.android.uicore.elements.SectionFieldErrorController import com.stripe.android.uicore.elements.TextFieldController @@ -17,6 +16,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map +import com.stripe.android.R as StripeR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class CvcController constructor( @@ -31,9 +31,9 @@ class CvcController constructor( private val _label = cardBrandFlow.map { cardBrand -> if (cardBrand == CardBrand.AmericanExpress) { - R.string.stripe_cvc_amex_hint + StripeR.string.stripe_cvc_amex_hint } else { - R.string.stripe_cvc_number_hint + StripeR.string.stripe_cvc_number_hint } } override val label: Flow = _label diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/IbanConfig.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/IbanConfig.kt index f7e2fb6fedb..7af8e1c74cd 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/IbanConfig.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/IbanConfig.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import java.math.BigInteger import java.util.Locale +import com.stripe.android.R as StripeR /** * A text field configuration for an IBAN, or International Bank Account Number, as defined in @@ -35,7 +36,7 @@ class IbanConfig : TextFieldConfig { override val trailingIcon: MutableStateFlow = MutableStateFlow( TextFieldIcon.Trailing( - R.drawable.stripe_ic_bank_generic, + StripeR.drawable.stripe_ic_bank_generic, isTintable = true ) ) @@ -105,7 +106,7 @@ class IbanConfig : TextFieldConfig { } } else { TextFieldStateConstants.Error.Incomplete( - R.string.stripe_invalid_bank_account_iban + StripeR.string.stripe_invalid_bank_account_iban ) } } diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/TranslationId.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/TranslationId.kt index 00fe8c390d9..59522f1da2c 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/TranslationId.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/TranslationId.kt @@ -4,6 +4,8 @@ import androidx.annotation.RestrictTo import com.stripe.android.ui.core.R import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import com.stripe.android.R as StripeR +import com.stripe.android.core.R as CoreR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) @Serializable @@ -19,8 +21,8 @@ enum class TranslationId(val resourceId: Int) { EpsBank(R.string.stripe_eps_bank), @SerialName("address.label.name") - AddressName(R.string.stripe_address_label_full_name), + AddressName(CoreR.string.stripe_address_label_full_name), @SerialName("upe.labels.name.onAccount") - AuBecsAccountName(R.string.stripe_au_becs_account_name) + AuBecsAccountName(StripeR.string.stripe_au_becs_account_name) } diff --git a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/autocomplete/PlacesClientProxy.kt b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/autocomplete/PlacesClientProxy.kt index f763116c40f..3e1d517b235 100644 --- a/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/autocomplete/PlacesClientProxy.kt +++ b/payments-ui-core/src/main/java/com/stripe/android/ui/core/elements/autocomplete/PlacesClientProxy.kt @@ -11,7 +11,6 @@ import com.google.android.libraries.places.api.net.FetchPlaceRequest import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest import com.google.android.libraries.places.api.net.PlacesClient import com.stripe.android.BuildConfig -import com.stripe.android.ui.core.R import com.stripe.android.ui.core.elements.autocomplete.model.AddressComponent import com.stripe.android.ui.core.elements.autocomplete.model.AutocompletePrediction import com.stripe.android.ui.core.elements.autocomplete.model.FetchPlaceResponse @@ -20,6 +19,7 @@ import com.stripe.android.ui.core.elements.autocomplete.model.Place import com.stripe.android.uicore.elements.DefaultIsPlacesAvailable import com.stripe.android.uicore.elements.IsPlacesAvailable import kotlinx.coroutines.tasks.await +import com.google.android.libraries.places.R as PlacesR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) interface PlacesClientProxy { @@ -57,9 +57,9 @@ interface PlacesClientProxy { ): Int? { return if (isPlacesAvailable()) { if (isSystemDarkTheme) { - R.drawable.places_powered_by_google_dark + PlacesR.drawable.places_powered_by_google_dark } else { - R.drawable.places_powered_by_google_light + PlacesR.drawable.places_powered_by_google_light } } else { if (BuildConfig.DEBUG) { diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressControllerTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressControllerTest.kt index 3855904458b..705e4820ac8 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressControllerTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressControllerTest.kt @@ -13,6 +13,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.shadows.ShadowLooper +import com.stripe.android.uicore.R as UiCoreR // TODO(ccen) Rewrite the test with generic Element and move it to stripe-ui-core @RunWith(RobolectricTestRunner::class) @@ -52,7 +53,7 @@ class AddressControllerTest { ShadowLooper.runUiThreadTasksIncludingDelayedTasks() assertThat(addressController.error.first()?.errorMessage) - .isEqualTo(R.string.stripe_email_is_invalid) + .isEqualTo(UiCoreR.string.stripe_email_is_invalid) emailController.onValueChange("joe@email.com") diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressElementTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressElementTest.kt index 8ac803d144f..0110284e70b 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressElementTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AddressElementTest.kt @@ -29,6 +29,7 @@ import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.shadows.ShadowLooper import java.util.concurrent.atomic.AtomicInteger +import com.stripe.android.uicore.R as UiCoreR // TODO(ccen) Rewrite the test with generic Element and move it to stripe-ui-core @RunWith(RobolectricTestRunner::class) @@ -88,7 +89,7 @@ class AddressElementTest { assertThat(addressElement.controller.error.first()) .isNotNull() assertThat(addressElement.controller.error.first()?.errorMessage) - .isEqualTo(R.string.stripe_email_is_invalid) + .isEqualTo(UiCoreR.string.stripe_email_is_invalid) countryDropdownFieldController.onValueChange(1) ShadowLooper.runUiThreadTasksIncludingDelayedTasks() @@ -433,7 +434,7 @@ class AddressElementTest { val line1TrailingIcon = addressElement.trailingIconFor(IdentifierSpec.Line1) assertThat(line1TrailingIcon?.contentDescription) - .isEqualTo(R.string.stripe_address_search_content_description) + .isEqualTo(UiCoreR.string.stripe_address_search_content_description) assertThat(addressElement.trailingIconFor(IdentifierSpec.Line2)).isNull() line1TrailingIcon?.onClick?.invoke() diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AdministrativeAreaConfigTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AdministrativeAreaConfigTest.kt index dd266490f45..d60f17aab5a 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AdministrativeAreaConfigTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/AdministrativeAreaConfigTest.kt @@ -3,6 +3,7 @@ package com.stripe.android.ui.core.elements import com.google.common.truth.Truth import com.stripe.android.uicore.elements.AdministrativeAreaConfig import org.junit.Test +import com.stripe.android.core.R as CoreR class AdministrativeAreaConfigTest { @Test @@ -20,7 +21,7 @@ class AdministrativeAreaConfigTest { AdministrativeAreaConfig.Country.US() ) Truth.assertThat(config.label) - .isEqualTo(com.stripe.android.core.R.string.stripe_address_label_state) + .isEqualTo(CoreR.string.stripe_address_label_state) } @Test @@ -29,7 +30,7 @@ class AdministrativeAreaConfigTest { AdministrativeAreaConfig.Country.Canada() ) Truth.assertThat(config.label) - .isEqualTo(com.stripe.android.core.R.string.stripe_address_label_province) + .isEqualTo(CoreR.string.stripe_address_label_province) } @Test diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsControllerTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsControllerTest.kt index 0980ccf30bd..835f083d8b1 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsControllerTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsControllerTest.kt @@ -4,18 +4,19 @@ import androidx.appcompat.view.ContextThemeWrapper import androidx.lifecycle.asLiveData import androidx.test.core.app.ApplicationProvider import com.google.common.truth.Truth.assertThat -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.FieldError import com.stripe.android.utils.TestUtils.idleLooper import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR +import com.stripe.android.uicore.R as UiCoreR @RunWith(RobolectricTestRunner::class) class CardDetailsControllerTest { private val context = - ContextThemeWrapper(ApplicationProvider.getApplicationContext(), R.style.StripeDefaultTheme) + ContextThemeWrapper(ApplicationProvider.getApplicationContext(), StripeR.style.StripeDefaultTheme) @Test fun `Verify the first field in error is returned in error flow`() { @@ -34,14 +35,14 @@ class CardDetailsControllerTest { idleLooper() assertThat(flowValues[flowValues.size - 1]?.errorMessage).isEqualTo( - R.string.stripe_invalid_card_number + StripeR.string.stripe_invalid_card_number ) cardController.numberElement.controller.onValueChange("4242424242424242") idleLooper() assertThat(flowValues[flowValues.size - 1]?.errorMessage).isEqualTo( - R.string.stripe_incomplete_expiry_date + UiCoreR.string.stripe_incomplete_expiry_date ) } diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsElementTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsElementTest.kt index f4778a70742..f861648ad22 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsElementTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardDetailsElementTest.kt @@ -5,19 +5,19 @@ import androidx.test.core.app.ApplicationProvider import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.IdentifierSpec import com.stripe.android.uicore.forms.FormFieldEntry import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR @RunWith(RobolectricTestRunner::class) class CardDetailsElementTest { private val context = - ContextThemeWrapper(ApplicationProvider.getApplicationContext(), R.style.StripeDefaultTheme) + ContextThemeWrapper(ApplicationProvider.getApplicationContext(), StripeR.style.StripeDefaultTheme) @Test fun `test form field values returned and expiration date parsing`() = runTest { diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberConfigTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberConfigTest.kt index a628db2dcd2..ecd381b1220 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberConfigTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberConfigTest.kt @@ -4,9 +4,9 @@ import androidx.compose.ui.text.AnnotatedString import com.google.common.truth.Truth import com.stripe.android.model.CardBrand import com.stripe.android.ui.core.CardNumberFixtures -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldStateConstants import org.junit.Test +import com.stripe.android.R as StripeR class CardNumberConfigTest { private val cardNumberConfig = CardNumberConfig() @@ -54,7 +54,7 @@ class CardNumberConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_card_number) + ).isEqualTo(StripeR.string.stripe_invalid_card_number) } @Test @@ -64,7 +64,7 @@ class CardNumberConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Incomplete::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_card_number) + ).isEqualTo(StripeR.string.stripe_invalid_card_number) } @Test @@ -74,7 +74,7 @@ class CardNumberConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_card_number) + ).isEqualTo(StripeR.string.stripe_invalid_card_number) } @Test @@ -84,7 +84,7 @@ class CardNumberConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_card_number) + ).isEqualTo(StripeR.string.stripe_invalid_card_number) } @Test diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberControllerTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberControllerTest.kt index e871ef4d513..37c5021e398 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberControllerTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CardNumberControllerTest.kt @@ -7,7 +7,6 @@ import com.stripe.android.cards.CardNumber import com.stripe.android.cards.StaticCardAccountRangeSource import com.stripe.android.model.AccountRange import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.FieldError import com.stripe.android.uicore.elements.TextFieldIcon import com.stripe.android.uicore.forms.FormFieldEntry @@ -21,6 +20,7 @@ import org.junit.After import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR @RunWith(RobolectricTestRunner::class) internal class CardNumberControllerTest { @@ -51,7 +51,7 @@ internal class CardNumberControllerTest { idleLooper() assertThat(errorFlowValues[errorFlowValues.size - 1]?.errorMessage) - .isEqualTo(R.string.stripe_invalid_card_number) + .isEqualTo(StripeR.string.stripe_invalid_card_number) } @Test diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcConfigTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcConfigTest.kt index a773f53cf02..16e8b1c3bcb 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcConfigTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcConfigTest.kt @@ -2,9 +2,9 @@ package com.stripe.android.ui.core.elements import com.google.common.truth.Truth import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldStateConstants import org.junit.Test +import com.stripe.android.R as StripeR class CvcConfigTest { private val cvcConfig = CvcConfig() @@ -35,7 +35,7 @@ class CvcConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Incomplete::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_cvc) + ).isEqualTo(StripeR.string.stripe_invalid_cvc) } @Test @@ -45,7 +45,7 @@ class CvcConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_cvc) + ).isEqualTo(StripeR.string.stripe_invalid_cvc) } @Test diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcControllerTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcControllerTest.kt index 133fc959a66..66e4e6762eb 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcControllerTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/CvcControllerTest.kt @@ -3,7 +3,6 @@ package com.stripe.android.ui.core.elements import androidx.lifecycle.asLiveData import com.google.common.truth.Truth.assertThat import com.stripe.android.model.CardBrand -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.FieldError import com.stripe.android.uicore.forms.FormFieldEntry import com.stripe.android.utils.TestUtils.idleLooper @@ -11,6 +10,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR @RunWith(RobolectricTestRunner::class) internal class CvcControllerTest { @@ -33,7 +33,7 @@ internal class CvcControllerTest { idleLooper() assertThat(errorFlowValues[errorFlowValues.size - 1]?.errorMessage) - .isEqualTo(R.string.stripe_invalid_cvc) + .isEqualTo(StripeR.string.stripe_invalid_cvc) } @Test diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/DateConfigTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/DateConfigTest.kt index 722bd697b4a..ad9cc972b1b 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/DateConfigTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/DateConfigTest.kt @@ -1,11 +1,11 @@ package com.stripe.android.ui.core.elements import com.google.common.truth.Truth -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.DateConfig import com.stripe.android.uicore.elements.TextFieldStateConstants import org.junit.Test import java.util.Calendar +import com.stripe.android.uicore.R as UiCoreR class DateConfigTest { private val dateConfig = DateConfig() @@ -29,7 +29,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Incomplete::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_incomplete_expiry_date) + ).isEqualTo(UiCoreR.string.stripe_incomplete_expiry_date) } @Test @@ -39,7 +39,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_incomplete_expiry_date) + ).isEqualTo(UiCoreR.string.stripe_incomplete_expiry_date) } @Test @@ -49,7 +49,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_incomplete_expiry_date) + ).isEqualTo(UiCoreR.string.stripe_incomplete_expiry_date) } @Test @@ -59,7 +59,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_expiry_year) + ).isEqualTo(UiCoreR.string.stripe_invalid_expiry_year) } @Test @@ -69,7 +69,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_expiry_year) + ).isEqualTo(UiCoreR.string.stripe_invalid_expiry_year) } @Test @@ -117,13 +117,13 @@ class DateConfigTest { fun `current month - 1 and year`() { var previousMonth = get1BasedCurrentMonth() - 1 var year = Calendar.getInstance().get(Calendar.YEAR) % 100 - var expectedErrorMessage = R.string.stripe_invalid_expiry_month + var expectedErrorMessage = UiCoreR.string.stripe_invalid_expiry_month // On January, use December of previous year. if (previousMonth == 0) { previousMonth = 12 year -= 1 - expectedErrorMessage = R.string.stripe_invalid_expiry_year + expectedErrorMessage = UiCoreR.string.stripe_invalid_expiry_year } val input = produceInput( @@ -153,7 +153,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_expiry_year) + ).isEqualTo(UiCoreR.string.stripe_invalid_expiry_year) } @Test @@ -169,7 +169,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_invalid_expiry_year) + ).isEqualTo(UiCoreR.string.stripe_invalid_expiry_year) } @Test @@ -201,7 +201,7 @@ class DateConfigTest { .isInstanceOf(TextFieldStateConstants.Error.Invalid::class.java) Truth.assertThat( state.getError()?.errorMessage - ).isEqualTo(R.string.stripe_incomplete_expiry_date) + ).isEqualTo(UiCoreR.string.stripe_incomplete_expiry_date) } @Test diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/LpmSerializerTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/LpmSerializerTest.kt index a4ce4f03cf6..5ac566eb652 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/LpmSerializerTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/LpmSerializerTest.kt @@ -10,6 +10,7 @@ import org.robolectric.RobolectricTestRunner import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit import kotlin.test.fail +import com.stripe.android.uicore.R as UiCoreR @RunWith(RobolectricTestRunner::class) class LpmSerializerTest { @@ -254,7 +255,7 @@ class LpmSerializerTest { "api_path": { "v1": "something_bogus" }, - "stringResId": ${R.string.stripe_email} + "stringResId": ${UiCoreR.string.stripe_email} } ] } @@ -304,7 +305,7 @@ class LpmSerializerTest { "fields": [ { "type": "$key", - "stringResId": ${R.string.stripe_email} + "stringResId": ${UiCoreR.string.stripe_email} } ] } diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/TextFieldStateTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/TextFieldStateTest.kt index b3bbd24bd00..7c57bb2f6a6 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/TextFieldStateTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/elements/TextFieldStateTest.kt @@ -1,17 +1,17 @@ package com.stripe.android.ui.core.elements import com.google.common.truth.Truth.assertThat -import com.stripe.android.ui.core.R import com.stripe.android.uicore.elements.TextFieldStateConstants import com.stripe.android.uicore.elements.canAcceptInput import org.junit.Test +import com.stripe.android.R as StripeR class TextFieldStateTest { @Test fun `Accepts input on a text field that's not full`() { val fieldState = TextFieldStateConstants.Error.Incomplete( - errorMessageResId = R.string.stripe_invalid_cvc + errorMessageResId = StripeR.string.stripe_invalid_cvc ) val didAccept = fieldState.canAcceptInput( diff --git a/payments-ui-core/src/test/java/com/stripe/android/ui/core/forms/TransformSpecToElementTest.kt b/payments-ui-core/src/test/java/com/stripe/android/ui/core/forms/TransformSpecToElementTest.kt index 43e9f9bb6d7..f645b9afebd 100644 --- a/payments-ui-core/src/test/java/com/stripe/android/ui/core/forms/TransformSpecToElementTest.kt +++ b/payments-ui-core/src/test/java/com/stripe/android/ui/core/forms/TransformSpecToElementTest.kt @@ -41,13 +41,15 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR +import com.stripe.android.core.R as CoreR @RunWith(RobolectricTestRunner::class) internal class TransformSpecToElementTest { private val context = ContextThemeWrapper( ApplicationProvider.getApplicationContext(), - R.style.StripeDefaultTheme + StripeR.style.StripeDefaultTheme ) private val nameSection = NameSpec() @@ -150,7 +152,7 @@ internal class TransformSpecToElementTest { as SimpleTextElement // Verify the correct config is setup for the controller - assertThat(nameElement.controller.label.first()).isEqualTo(R.string.stripe_address_label_full_name) + assertThat(nameElement.controller.label.first()).isEqualTo(CoreR.string.stripe_address_label_full_name) assertThat(nameElement.identifier.v1).isEqualTo("simple") assertThat(nameElement.controller.showOptionalLabel).isTrue() } diff --git a/paymentsheet-example/detekt-baseline.xml b/paymentsheet-example/detekt-baseline.xml index e6a6c37c1ac..2423ea5b278 100644 --- a/paymentsheet-example/detekt-baseline.xml +++ b/paymentsheet-example/detekt-baseline.xml @@ -26,7 +26,7 @@ MagicNumber:DrawablePainter.kt$DrawablePainter$255 MagicNumber:Payment.kt$0.5f MaxLineLength:PaymentSheetPlaygroundActivity.kt$PaymentSheetPlaygroundActivity$get() = viewBinding.allowsDelayedPaymentMethodsRadioGroup.checkedRadioButtonId == R.id.allowsDelayedPaymentMethods_on_button - MaximumLineLength:com.stripe.android.paymentsheet.example.playground.activity.PaymentSheetPlaygroundActivity.kt:146 + MaximumLineLength:com.stripe.android.paymentsheet.example.playground.activity.PaymentSheetPlaygroundActivity.kt:147 PackageNaming:CompleteFlowActivity.kt$package com.stripe.android.paymentsheet.example.samples.ui.complete_flow PackageNaming:CompleteFlowViewModel.kt$package com.stripe.android.paymentsheet.example.samples.ui.complete_flow PackageNaming:CompleteFlowViewState.kt$package com.stripe.android.paymentsheet.example.samples.ui.complete_flow diff --git a/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/BuyButton.kt b/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/BuyButton.kt index 4ad0cd20c8c..c4b961c10fc 100644 --- a/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/BuyButton.kt +++ b/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/BuyButton.kt @@ -8,8 +8,8 @@ import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.test.platform.app.InstrumentationRegistry -import com.stripe.android.paymentsheet.example.R import com.stripe.android.paymentsheet.ui.PAYMENT_SHEET_PRIMARY_BUTTON_TEST_TAG +import com.stripe.android.ui.core.R as StripeUiCoreR class BuyButton(private val composeTestRule: ComposeTestRule) { fun click() { @@ -35,7 +35,7 @@ class BuyButton(private val composeTestRule: ComposeTestRule) { fun waitProcessingComplete() { val expectedText = InstrumentationRegistry.getInstrumentation().targetContext.resources.getString( - R.string.stripe_pay_button_amount + StripeUiCoreR.string.stripe_pay_button_amount ).replace("%s", "") composeTestRule.waitUntil(timeoutMillis = 5000L) { runCatching { diff --git a/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/Selectors.kt b/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/Selectors.kt index b2362ea6708..130090e8276 100644 --- a/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/Selectors.kt +++ b/paymentsheet-example/src/androidTest/java/com/stripe/android/test/core/ui/Selectors.kt @@ -32,6 +32,9 @@ import com.stripe.android.test.core.Shipping import com.stripe.android.test.core.TestParameters import com.stripe.android.ui.core.elements.SAVE_FOR_FUTURE_CHECKBOX_TEST_TAG import java.util.Locale +import com.stripe.android.R as StripeR +import com.stripe.android.core.R as CoreR +import com.stripe.android.uicore.R as UiCoreR /** * This contains the Android specific code such as for accessing UI elements, detecting @@ -221,7 +224,7 @@ class Selectors( // Note: Compose will take care of scrolling to the field if not in view. fun getEmail() = composeTestRule.onNodeWithText( - getResourceString(R.string.stripe_email) + getResourceString(UiCoreR.string.stripe_email) ) fun getName(@StringRes resourceId: Int) = composeTestRule.onNodeWithText( @@ -229,34 +232,34 @@ class Selectors( ) fun getLine1() = composeTestRule.onNodeWithText( - getResourceString(R.string.stripe_address_label_address_line1) + getResourceString(CoreR.string.stripe_address_label_address_line1) ) fun getCity() = composeTestRule.onNodeWithText( - getResourceString(R.string.stripe_address_label_city) + getResourceString(CoreR.string.stripe_address_label_city) ) fun getState() = composeTestRule.onNodeWithText( - getResourceString(R.string.stripe_address_label_state) + getResourceString(CoreR.string.stripe_address_label_state) ) fun selectState(value: String) { - composeTestRule.onNodeWithText(getResourceString(R.string.stripe_address_label_state)) + composeTestRule.onNodeWithText(getResourceString(CoreR.string.stripe_address_label_state)) .performClick() composeTestRule.onNodeWithText(value) .performClick() } fun getZip() = composeTestRule.onNodeWithText( - getResourceString(R.string.stripe_address_label_zip_code) + getResourceString(CoreR.string.stripe_address_label_zip_code) ) fun getAuBsb() = composeTestRule.onNodeWithText( - getResourceString(com.stripe.android.ui.core.R.string.stripe_becs_widget_bsb) + getResourceString(StripeR.string.stripe_becs_widget_bsb) ) fun getAuAccountNumber() = composeTestRule.onNodeWithText( - getResourceString(R.string.stripe_becs_widget_account_number) + getResourceString(StripeR.string.stripe_becs_widget_account_number) ) fun getGoogleDividerText() = composeTestRule.onNodeWithText( @@ -267,19 +270,19 @@ class Selectors( fun getCardNumber() = composeTestRule.onNodeWithText( InstrumentationRegistry.getInstrumentation().targetContext.resources.getString( - com.stripe.android.R.string.stripe_acc_label_card_number + StripeR.string.stripe_acc_label_card_number ) ) fun getCardExpiration() = composeTestRule.onNodeWithText( InstrumentationRegistry.getInstrumentation().targetContext.resources.getString( - R.string.stripe_expiration_date_hint + UiCoreR.string.stripe_expiration_date_hint ) ) fun getCardCvc() = composeTestRule.onNodeWithText( InstrumentationRegistry.getInstrumentation().targetContext.resources.getString( - com.stripe.android.ui.core.R.string.stripe_cvc_number_hint + StripeR.string.stripe_cvc_number_hint ) ) diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/PaymentSheetPlaygroundActivity.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/PaymentSheetPlaygroundActivity.kt index 3e49e1eb00e..57f6412c490 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/PaymentSheetPlaygroundActivity.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/PaymentSheetPlaygroundActivity.kt @@ -45,6 +45,7 @@ import com.stripe.android.paymentsheet.example.playground.viewmodel.PaymentSheet import com.stripe.android.paymentsheet.model.PaymentOption import kotlinx.coroutines.launch import java.util.Locale +import com.stripe.android.uicore.R as UiCoreR class PaymentSheetPlaygroundActivity : AppCompatActivity() { @@ -662,7 +663,7 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() { val checkboxLabel = if (viewBinding.shippingAddressCheckboxLabel.text.isNotBlank()) { viewBinding.shippingAddressCheckboxLabel.text.toString() } else { - getString(R.string.stripe_billing_same_as_shipping) + getString(UiCoreR.string.stripe_billing_same_as_shipping) } builder.additionalFields( AddressLauncher.AdditionalFieldsConfiguration( diff --git a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/addresselement/AddressTextFieldUITest.kt b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/addresselement/AddressTextFieldUITest.kt index 7422e355b70..3120a00a47c 100644 --- a/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/addresselement/AddressTextFieldUITest.kt +++ b/paymentsheet/src/androidTest/java/com/stripe/android/paymentsheet/addresselement/AddressTextFieldUITest.kt @@ -6,7 +6,6 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth -import com.stripe.android.R import com.stripe.android.uicore.DefaultStripeTheme import com.stripe.android.uicore.elements.AddressTextFieldController import com.stripe.android.uicore.elements.AddressTextFieldUI @@ -14,6 +13,7 @@ import com.stripe.android.uicore.elements.SimpleTextFieldConfig import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import com.stripe.android.uicore.R as UiCoreR @RunWith(AndroidJUnit4::class) class AddressTextFieldUITest { @@ -39,7 +39,7 @@ class AddressTextFieldUITest { DefaultStripeTheme { AddressTextFieldUI( controller = AddressTextFieldController( - SimpleTextFieldConfig(label = R.string.stripe_address_label_address) + SimpleTextFieldConfig(label = UiCoreR.string.stripe_address_label_address) ), onClick = onClick ) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionUi.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionUi.kt index 8ce8393950d..4852d01e457 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionUi.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionUi.kt @@ -45,6 +45,7 @@ import com.stripe.android.ui.core.elements.SimpleDialogElementUI import com.stripe.android.uicore.StripeTheme import com.stripe.android.uicore.elements.SectionCard import com.stripe.android.uicore.shouldUseDarkDynamicColor +import com.stripe.android.R as StripeR @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) const val PAYMENT_OPTION_CARD_TEST_TAG = "PAYMENT_OPTION_CARD_TEST_TAG" @@ -122,8 +123,8 @@ internal fun PaymentOptionUi( openDialog = openRemoveDialog, titleText = removePmDialogTitle, messageText = description, - confirmText = stringResource(R.string.stripe_remove), - dismissText = stringResource(R.string.stripe_cancel), + confirmText = stringResource(StripeR.string.stripe_remove), + dismissText = stringResource(StripeR.string.stripe_cancel), onConfirmListener = onRemoveListener ) } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionsItem.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionsItem.kt index a81aee796cd..8b293c22992 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionsItem.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentOptionsItem.kt @@ -2,6 +2,7 @@ package com.stripe.android.paymentsheet import android.content.res.Resources import com.stripe.android.model.PaymentMethod +import com.stripe.android.R as StripeR internal sealed class PaymentOptionsItem { @@ -35,7 +36,7 @@ internal sealed class PaymentOptionsItem { fun getDescription(resources: Resources) = when (paymentMethod.type) { PaymentMethod.Type.Card -> resources.getString( - R.string.stripe_card_ending_in, + StripeR.string.stripe_card_ending_in, paymentMethod.card?.brand, paymentMethod.card?.last4 ) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheetViewModel.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheetViewModel.kt index dd97932343c..ebaf365a41a 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheetViewModel.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheetViewModel.kt @@ -76,6 +76,7 @@ import kotlinx.coroutines.withContext import javax.inject.Inject import javax.inject.Provider import kotlin.coroutines.CoroutineContext +import com.stripe.android.R as StripeR @OptIn(ExperimentalPaymentSheetDecouplingApi::class) internal class PaymentSheetViewModel @Inject internal constructor( @@ -578,8 +579,8 @@ internal class PaymentSheetViewModel @Inject internal constructor( onError( when (result.errorCode) { GooglePayPaymentMethodLauncher.NETWORK_ERROR -> - R.string.stripe_failure_connection_error - else -> R.string.stripe_internal_error + StripeR.string.stripe_failure_connection_error + else -> StripeR.string.stripe_internal_error } ) } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AutocompleteViewModel.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AutocompleteViewModel.kt index cd9d0b9d828..48db9ff15f8 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AutocompleteViewModel.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AutocompleteViewModel.kt @@ -9,7 +9,6 @@ import androidx.lifecycle.viewModelScope import com.stripe.android.core.injection.NonFallbackInjectable import com.stripe.android.core.injection.NonFallbackInjector import com.stripe.android.paymentsheet.PaymentSheet -import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.addresselement.analytics.AddressLauncherEventReporter import com.stripe.android.paymentsheet.injection.AutocompleteViewModelSubcomponent import com.stripe.android.ui.core.elements.autocomplete.PlacesClientProxy @@ -32,6 +31,8 @@ import kotlinx.coroutines.launch import java.lang.IllegalStateException import javax.inject.Inject import javax.inject.Provider +import com.stripe.android.R as StripeR +import com.stripe.android.uicore.R as UiCoreR internal class AutocompleteViewModel @Inject constructor( val args: AddressElementActivityContract.Args, @@ -53,7 +54,7 @@ internal class AutocompleteViewModel @Inject constructor( val addressResult = MutableStateFlow?>(null) private val config = SimpleTextFieldConfig( - label = R.string.stripe_address_label_address, + label = UiCoreR.string.stripe_address_label_address, trailingIcon = MutableStateFlow(null) ) @@ -98,7 +99,7 @@ internal class AutocompleteViewModel @Inject constructor( } else { config.trailingIcon.update { TextFieldIcon.Trailing( - idRes = R.drawable.stripe_ic_clear, + idRes = StripeR.drawable.stripe_ic_clear, isTintable = true, onClick = { clearQuery() } ) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentOptionFactory.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentOptionFactory.kt index a50da8ecd28..2452933b8d3 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentOptionFactory.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentOptionFactory.kt @@ -13,6 +13,7 @@ import com.stripe.android.paymentsheet.ui.getLabel import com.stripe.android.paymentsheet.ui.getSavedPaymentMethodIcon import com.stripe.android.uicore.image.StripeImageLoader import javax.inject.Inject +import com.stripe.android.R as StripeR internal class PaymentOptionFactory @Inject constructor( private val resources: Resources, @@ -59,7 +60,7 @@ internal class PaymentOptionFactory @Inject constructor( drawableResourceId = R.drawable.stripe_google_pay_mark, lightThemeIconUrl = null, darkThemeIconUrl = null, - label = resources.getString(R.string.stripe_google_pay), + label = resources.getString(StripeR.string.stripe_google_pay), imageLoader = ::loadPaymentOption, ) } @@ -68,7 +69,7 @@ internal class PaymentOptionFactory @Inject constructor( drawableResourceId = R.drawable.stripe_ic_paymentsheet_link, lightThemeIconUrl = null, darkThemeIconUrl = null, - label = resources.getString(R.string.stripe_link), + label = resources.getString(StripeR.string.stripe_link), imageLoader = ::loadPaymentOption, ) } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIcon.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIcon.kt index 5549c51fc39..013562239c0 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIcon.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIcon.kt @@ -1,45 +1,46 @@ package com.stripe.android.paymentsheet.paymentdatacollection.ach -import com.stripe.android.paymentsheet.R +import com.stripe.android.R as StripeR +import com.stripe.android.financialconnections.R as FinancialConnectionsR internal interface TransformToBankIcon { companion object { operator fun invoke(bankName: String?): Int { - if (bankName == null) return R.drawable.stripe_ic_bank + if (bankName == null) return FinancialConnectionsR.drawable.stripe_ic_bank val bankNameRegexIconMap = mapOf( Regex("Bank of America", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_boa, + StripeR.drawable.stripe_ic_bank_boa, Regex("Capital One", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_capitalone, + StripeR.drawable.stripe_ic_bank_capitalone, Regex("Citibank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_citi, + StripeR.drawable.stripe_ic_bank_citi, Regex("BBVA|COMPASS", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_compass, + StripeR.drawable.stripe_ic_bank_compass, Regex("MORGAN CHASE|JP MORGAN|Chase", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_morganchase, + StripeR.drawable.stripe_ic_bank_morganchase, Regex("NAVY FEDERAL CREDIT UNION", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_nfcu, + StripeR.drawable.stripe_ic_bank_nfcu, Regex("PNC\\s?BANK|PNC Bank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_pnc, + StripeR.drawable.stripe_ic_bank_pnc, Regex("SUNTRUST|SunTrust Bank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_suntrust, + StripeR.drawable.stripe_ic_bank_suntrust, Regex("Silicon Valley Bank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_svb, + StripeR.drawable.stripe_ic_bank_svb, Regex("Stripe|TestInstitution", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_stripe, + StripeR.drawable.stripe_ic_bank_stripe, Regex("TD Bank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_td, + StripeR.drawable.stripe_ic_bank_td, Regex("USAA FEDERAL SAVINGS BANK|USAA Bank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_usaa, + StripeR.drawable.stripe_ic_bank_usaa, Regex("U\\.?S\\. BANK|US Bank", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_usbank, + StripeR.drawable.stripe_ic_bank_usbank, Regex("Wells Fargo", RegexOption.IGNORE_CASE) to - R.drawable.stripe_ic_bank_wellsfargo + StripeR.drawable.stripe_ic_bank_wellsfargo ) return bankNameRegexIconMap .filter { it.key.findAll(bankName).any() } .firstNotNullOfOrNull { it.value } - ?: R.drawable.stripe_ic_bank + ?: FinancialConnectionsR.drawable.stripe_ic_bank } } } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt index 3d67f109503..07d97b3ac68 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountForm.kt @@ -56,6 +56,8 @@ import com.stripe.android.uicore.elements.SectionCard import com.stripe.android.uicore.elements.TextFieldController import com.stripe.android.uicore.elements.TextFieldSection import com.stripe.android.uicore.stripeColors +import com.stripe.android.R as StripeR +import com.stripe.android.ui.core.R as PaymentsUiCoreR @Composable internal fun USBankAccountForm( @@ -439,7 +441,7 @@ private fun AddressSection( contentAlignment = Alignment.CenterEnd ) { Column { - Section(R.string.stripe_billing_details, sectionErrorString) { + Section(PaymentsUiCoreR.string.stripe_billing_details, sectionErrorString) { AddressElementUI( enabled = !processing, controller = addressController, @@ -472,7 +474,7 @@ private fun AccountDetailsForm( .padding(bottom = 8.dp) ) { H6Text( - text = stringResource(R.string.stripe_title_bank_account), + text = stringResource(StripeR.string.stripe_title_bank_account), modifier = Modifier.padding(vertical = 8.dp) ) SectionCard(modifier = Modifier.fillMaxWidth()) { @@ -498,7 +500,7 @@ private fun AccountDetailsForm( ) } Image( - painter = painterResource(R.drawable.stripe_ic_clear), + painter = painterResource(StripeR.drawable.stripe_ic_clear), contentDescription = null, modifier = Modifier .height(20.dp) @@ -531,10 +533,10 @@ private fun AccountDetailsForm( last4 ), confirmText = stringResource( - id = R.string.stripe_remove + id = StripeR.string.stripe_remove ), dismissText = stringResource( - id = R.string.stripe_cancel + id = StripeR.string.stripe_cancel ), onConfirmListener = { openDialog.value = false diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt index fda959a81c9..e8dfd14fba4 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt @@ -64,6 +64,7 @@ import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import javax.inject.Inject import javax.inject.Provider +import com.stripe.android.ui.core.R as StripeUiCoreR internal class USBankAccountFormViewModel @Inject internal constructor( private val args: Args, @@ -214,7 +215,7 @@ internal class USBankAccountFormViewModel @Inject internal constructor( phone = phone.value, address = address.value, primaryButtonText = application.getString( - R.string.stripe_continue_button_label + StripeUiCoreR.string.stripe_continue_button_label ), ) ) @@ -416,7 +417,7 @@ internal class USBankAccountFormViewModel @Inject internal constructor( phone = phone.value, address = address.value, primaryButtonText = application.getString( - R.string.stripe_continue_button_label + StripeUiCoreR.string.stripe_continue_button_label ), ) } @@ -571,12 +572,12 @@ internal class USBankAccountFormViewModel @Inject internal constructor( args.formArgs.amount!!.buildPayButtonLabel(application.resources) } else { application.getString( - R.string.stripe_setup_button_label + StripeUiCoreR.string.stripe_setup_button_label ) } } else -> application.getString( - R.string.stripe_continue_button_label + StripeUiCoreR.string.stripe_continue_button_label ) } } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt index c7cd1ffbd85..8876e8ad4d9 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt @@ -6,7 +6,7 @@ import android.graphics.Color import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.FragmentResultListener -import com.stripe.android.paymentsheet.R +import com.stripe.android.link.R as LinkR internal class PollingActivity : AppCompatActivity() { @@ -47,6 +47,6 @@ internal class PollingActivity : AppCompatActivity() { Intent().putExtras(result) ) finish() - overridePendingTransition(0, R.anim.stripe_slide_down) + overridePendingTransition(0, LinkR.anim.stripe_slide_down) } } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingScreen.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingScreen.kt index dc7366aa025..72d48eaa312 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingScreen.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingScreen.kt @@ -39,6 +39,7 @@ import com.stripe.android.uicore.StripeTheme import com.stripe.android.uicore.stripeColors import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +import com.stripe.android.ui.core.R as StripeUiCoreR private object Spacing { val extended = 12.dp @@ -150,7 +151,7 @@ private fun FailedPolling( IconButton(onClick = onCancel) { Icon( painter = painterResource(R.drawable.stripe_ic_paymentsheet_back), - contentDescription = stringResource(R.string.stripe_back), + contentDescription = stringResource(StripeUiCoreR.string.stripe_back), ) } }, diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/AddressOptionsAppBar.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/AddressOptionsAppBar.kt index b3fb4e14679..26633dfe216 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/AddressOptionsAppBar.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/AddressOptionsAppBar.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.stripe.android.paymentsheet.R import com.stripe.android.uicore.stripeColors +import com.stripe.android.ui.core.R as StripeUiCoreR @Composable internal fun AddressOptionsAppBar( @@ -38,7 +39,7 @@ internal fun AddressOptionsAppBar( if (isRootScreen) { R.string.stripe_paymentsheet_close } else { - R.string.stripe_back + StripeUiCoreR.string.stripe_back } ), tint = MaterialTheme.stripeColors.appBarIcon diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/BillingAddressView.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/BillingAddressView.kt index b327949ba6d..4e80e53913d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/BillingAddressView.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/BillingAddressView.kt @@ -22,11 +22,12 @@ import com.stripe.android.core.model.CountryCode import com.stripe.android.core.model.CountryCode.Companion.isUS import com.stripe.android.core.model.CountryUtils import com.stripe.android.model.Address -import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.databinding.StripeBillingAddressLayoutBinding import com.stripe.android.view.PostalCodeValidator import java.util.Locale import kotlin.properties.Delegates +import com.stripe.android.R as StripeR +import com.stripe.android.core.R as CoreR internal class BillingAddressView @JvmOverloads constructor( context: Context, @@ -279,16 +280,16 @@ internal class BillingAddressView @JvmOverloads constructor( private fun updateStateView(countryCode: CountryCode?) { when { isUS(countryCode) -> { - R.string.stripe_address_label_state + CoreR.string.stripe_address_label_state } CountryCode.isCA(countryCode) -> { - R.string.stripe_address_label_province + CoreR.string.stripe_address_label_province } CountryCode.isGB(countryCode) -> { - R.string.stripe_address_label_county + CoreR.string.stripe_address_label_county } else -> { - R.string.stripe_address_label_region_generic + StripeR.string.stripe_address_label_region_generic } }.let { stateLayout.hint = resources.getString(it) @@ -313,9 +314,9 @@ internal class BillingAddressView @JvmOverloads constructor( viewBinding.postalCodeLayout.hint = resources.getString( if (isUS(countryCode)) { - R.string.stripe_acc_label_zip_short + StripeR.string.stripe_acc_label_zip_short } else { - R.string.stripe_address_label_postal_code + CoreR.string.stripe_address_label_postal_code } ) } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/HeaderTextFactory.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/HeaderTextFactory.kt index 4af3f5d848c..3e165d3ee1d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/HeaderTextFactory.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/HeaderTextFactory.kt @@ -4,6 +4,7 @@ import com.stripe.android.model.PaymentMethod import com.stripe.android.model.PaymentMethodCode import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen +import com.stripe.android.R as StripeR internal class HeaderTextFactory( private val isCompleteFlow: Boolean, @@ -45,7 +46,7 @@ internal class HeaderTextFactory( PaymentSheetScreen.AddFirstPaymentMethod, PaymentSheetScreen.AddAnotherPaymentMethod -> { if (types.singleOrNull() == PaymentMethod.Type.Card.code) { - R.string.stripe_title_add_a_card + StripeR.string.stripe_title_add_a_card } else { R.string.stripe_paymentsheet_choose_payment_method } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentMethodsUiExtension.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentMethodsUiExtension.kt index cdc2a56311d..2179116b8a7 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentMethodsUiExtension.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentMethodsUiExtension.kt @@ -6,12 +6,15 @@ import com.stripe.android.model.CardBrand import com.stripe.android.model.PaymentMethod import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.paymentdatacollection.ach.TransformToBankIcon +import com.stripe.android.financialconnections.R as FinancialConnectionsR +import com.stripe.android.ui.core.R as StripeUiCoreR +import com.stripe.payments.model.R as PaymentsModelR @DrawableRes internal fun PaymentMethod.getSavedPaymentMethodIcon(): Int? = when (type) { PaymentMethod.Type.Card -> card?.brand?.getCardBrandIcon() ?: R.drawable.stripe_ic_paymentsheet_card_unknown - PaymentMethod.Type.SepaDebit -> R.drawable.stripe_ic_paymentsheet_pm_sepa_debit + PaymentMethod.Type.SepaDebit -> StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_sepa_debit PaymentMethod.Type.USBankAccount -> usBankAccount?.bankName?.let { TransformToBankIcon(it) } else -> null } @@ -25,7 +28,7 @@ internal fun CardBrand.getCardBrandIcon(): Int = when (this) { CardBrand.DinersClub -> R.drawable.stripe_ic_paymentsheet_card_dinersclub CardBrand.MasterCard -> R.drawable.stripe_ic_paymentsheet_card_mastercard CardBrand.UnionPay -> R.drawable.stripe_ic_paymentsheet_card_unionpay - CardBrand.CartesBancaires -> R.drawable.stripe_ic_cartebancaire + CardBrand.CartesBancaires -> PaymentsModelR.drawable.stripe_ic_cartebancaire CardBrand.Unknown -> R.drawable.stripe_ic_paymentsheet_card_unknown } @@ -43,7 +46,7 @@ internal fun PaymentMethod.getLabel(resources: Resources): String? = when (type) } internal fun PaymentMethod.getLabelIcon(): Int? = when (type) { - PaymentMethod.Type.USBankAccount -> R.drawable.stripe_ic_bank + PaymentMethod.Type.USBankAccount -> FinancialConnectionsR.drawable.stripe_ic_bank else -> null } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentOptionsUI.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentOptionsUI.kt index 0f0c2756a24..231e4d53f70 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentOptionsUI.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentOptionsUI.kt @@ -32,6 +32,7 @@ import com.stripe.android.paymentsheet.toPaymentSelection import com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel import com.stripe.android.uicore.shouldUseDarkDynamicColor import com.stripe.android.uicore.stripeColors +import com.stripe.android.R as StripeR @Composable internal fun PaymentOptions( @@ -198,8 +199,8 @@ private fun GooglePay( isSelected = isSelected, isEnabled = isEnabled, iconRes = R.drawable.stripe_google_pay_mark, - labelText = stringResource(R.string.stripe_google_pay), - description = stringResource(R.string.stripe_google_pay), + labelText = stringResource(StripeR.string.stripe_google_pay), + description = stringResource(StripeR.string.stripe_google_pay), onItemSelectedListener = { onItemSelected(PaymentSelection.GooglePay) }, modifier = modifier, ) @@ -229,8 +230,8 @@ private fun Link( isEnabled = isEnabled, iconRes = R.drawable.stripe_link_mark, iconTint = linkLogoColor, - labelText = stringResource(R.string.stripe_link), - description = stringResource(R.string.stripe_link), + labelText = stringResource(StripeR.string.stripe_link), + description = stringResource(StripeR.string.stripe_link), onItemSelectedListener = { onItemSelected(PaymentSelection.Link) }, modifier = modifier, ) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBar.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBar.kt index 2f3481811ea..bc62e8f24ba 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBar.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBar.kt @@ -35,6 +35,8 @@ import com.stripe.android.uicore.StripeTheme import com.stripe.android.uicore.StripeThemeDefaults import com.stripe.android.uicore.stripeColors import com.stripe.android.uicore.stripeTypography +import com.stripe.android.R as StripeR +import com.stripe.android.ui.core.R as StripeUiCoreR @Composable internal fun PaymentSheetTopBar( @@ -172,10 +174,10 @@ internal fun PaymentSheetTopBar_Preview() { StripeTheme(colors = StripeThemeDefaults.colorsLight.copy(appBarIcon = Color.Red)) { val state = PaymentSheetTopBarState( icon = R.drawable.stripe_ic_paymentsheet_back, - contentDescription = R.string.stripe_back, + contentDescription = StripeUiCoreR.string.stripe_back, showTestModeLabel = true, showEditMenu = true, - editMenuLabel = R.string.stripe_edit, + editMenuLabel = StripeR.string.stripe_edit, isEnabled = true, ) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarState.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarState.kt index 327df2101e7..3a94ba0e804 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarState.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarState.kt @@ -7,6 +7,8 @@ import androidx.compose.runtime.remember import com.stripe.android.model.PaymentMethod import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen +import com.stripe.android.R as StripeR +import com.stripe.android.ui.core.R as StripeUiCoreR internal data class PaymentSheetTopBarState( @DrawableRes val icon: Int, @@ -33,7 +35,7 @@ internal fun rememberPaymentSheetTopBarState( } val contentDescription = if (screen == PaymentSheetScreen.AddAnotherPaymentMethod) { - R.string.stripe_back + StripeUiCoreR.string.stripe_back } else { R.string.stripe_paymentsheet_close } @@ -41,9 +43,9 @@ internal fun rememberPaymentSheetTopBarState( val showOptionsMenu = screen is PaymentSheetScreen.SelectSavedPaymentMethods val editMenuLabel = if (isEditing) { - R.string.stripe_done + StripeR.string.stripe_done } else { - R.string.stripe_edit + StripeR.string.stripe_edit } PaymentSheetTopBarState( diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PrimaryButtonAnimator.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PrimaryButtonAnimator.kt index dde72c732f8..faeb5bc3187 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PrimaryButtonAnimator.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ui/PrimaryButtonAnimator.kt @@ -9,6 +9,7 @@ import androidx.core.animation.doOnEnd import androidx.core.view.isInvisible import androidx.core.view.isVisible import com.stripe.android.paymentsheet.R +import com.stripe.android.R as StripeR internal class PrimaryButtonAnimator( private val context: Context @@ -25,7 +26,7 @@ internal class PrimaryButtonAnimator( view.startAnimation( AnimationUtils.loadAnimation( context, - R.anim.stripe_paymentsheet_transition_fade_in + StripeR.anim.stripe_paymentsheet_transition_fade_in ).also { animation -> animation.setAnimationListener( object : Animation.AnimationListener { @@ -91,7 +92,7 @@ internal class PrimaryButtonAnimator( view.startAnimation( AnimationUtils.loadAnimation( context, - R.anim.stripe_paymentsheet_transition_fade_out + StripeR.anim.stripe_paymentsheet_transition_fade_out ).also { animation -> animation.setAnimationListener( object : Animation.AnimationListener { diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/viewmodels/PrimaryButtonUiStateMapper.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/viewmodels/PrimaryButtonUiStateMapper.kt index fd3227830dc..55dc9c8477d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/viewmodels/PrimaryButtonUiStateMapper.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/viewmodels/PrimaryButtonUiStateMapper.kt @@ -9,6 +9,7 @@ import com.stripe.android.paymentsheet.ui.PrimaryButton import com.stripe.android.ui.core.Amount import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine +import com.stripe.android.ui.core.R as StripeUiCoreR internal class PrimaryButtonUiStateMapper( private val context: Context, @@ -64,12 +65,12 @@ internal class PrimaryButtonUiStateMapper( val fallback = context.getString(R.string.stripe_paymentsheet_pay_button_label) amount?.buildPayButtonLabel(context.resources) ?: fallback } else { - context.getString(R.string.stripe_setup_button_label) + context.getString(StripeUiCoreR.string.stripe_setup_button_label) } } private fun continueButtonLabel(): String { val customLabel = config?.primaryButtonLabel - return customLabel ?: context.getString(R.string.stripe_continue_button_label) + return customLabel ?: context.getString(StripeUiCoreR.string.stripe_continue_button_label) } } diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/PaymentSheetActivityTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/PaymentSheetActivityTest.kt index 744f62c6e7d..a365b3b1b8f 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/PaymentSheetActivityTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/PaymentSheetActivityTest.kt @@ -102,6 +102,7 @@ import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds +import com.stripe.android.ui.core.R as StripeUiCoreR @RunWith(AndroidJUnit4::class) @Config(sdk = [Build.VERSION_CODES.Q]) @@ -774,7 +775,7 @@ internal class PaymentSheetActivityTest { fun `notes visibility is visible`() { val scenario = activityScenario(viewModel) scenario.launch(intent).onActivity { - val text = context.getString(R.string.stripe_paymentsheet_payment_method_us_bank_account) + val text = context.getString(StripeUiCoreR.string.stripe_paymentsheet_payment_method_us_bank_account) viewModel.updateBelowButtonText(text) composeTestRule @@ -1032,8 +1033,8 @@ internal class PaymentSheetActivityTest { code = PaymentMethod.Type.Card.code, requiresMandate = false, mandateRequirement = MandateRequirement.Never, - displayNameResource = com.stripe.android.ui.core.R.string.stripe_paymentsheet_payment_method_card, - iconResource = com.stripe.android.ui.core.R.drawable.stripe_ic_paymentsheet_pm_card, + displayNameResource = StripeUiCoreR.string.stripe_paymentsheet_payment_method_card, + iconResource = StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_card, lightThemeIconUrl = null, darkThemeIconUrl = null, tintIconOnSelection = true, diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/PaymentSelectionUpdaterTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/PaymentSelectionUpdaterTest.kt index 2acba0a7807..17a5394d9e4 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/PaymentSelectionUpdaterTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/flowcontroller/PaymentSelectionUpdaterTest.kt @@ -10,7 +10,6 @@ import com.stripe.android.model.PaymentMethodFixtures import com.stripe.android.model.SetupIntentFixtures import com.stripe.android.model.StripeIntent import com.stripe.android.paymentsheet.PaymentSheet -import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.model.PaymentSelection import com.stripe.android.paymentsheet.state.PaymentSheetState import com.stripe.android.testing.PaymentMethodFactory @@ -18,6 +17,7 @@ import com.stripe.android.ui.core.forms.resources.LpmRepository import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import kotlin.test.Test +import com.stripe.android.ui.core.R as StripeUiCoreR @RunWith(RobolectricTestRunner::class) class PaymentSelectionUpdaterTest { @@ -38,7 +38,7 @@ class PaymentSelectionUpdaterTest { fun `Can use existing payment selection if it's still supported`() { val existingSelection = PaymentSelection.New.GenericPaymentMethod( labelResource = "Sofort", - iconResource = R.drawable.stripe_ic_paymentsheet_pm_klarna, + iconResource = StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_klarna, lightThemeIconUrl = null, darkThemeIconUrl = null, paymentMethodCreateParams = PaymentMethodCreateParamsFixtures.SOFORT, @@ -142,7 +142,7 @@ class PaymentSelectionUpdaterTest { fun `PaymentSelection is reset when payment method requires mandate after updating intent`() { val existingSelection = PaymentSelection.New.GenericPaymentMethod( labelResource = "paypal", - iconResource = R.drawable.stripe_ic_paymentsheet_pm_paypal, + iconResource = StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_paypal, lightThemeIconUrl = null, darkThemeIconUrl = null, paymentMethodCreateParams = PaymentMethodCreateParamsFixtures.PAYPAL, @@ -175,7 +175,7 @@ class PaymentSelectionUpdaterTest { fun `PaymentSelection is preserved when payment method no longer requires mandate after updating intent`() { val existingSelection = PaymentSelection.New.GenericPaymentMethod( labelResource = "paypal", - iconResource = R.drawable.stripe_ic_paymentsheet_pm_paypal, + iconResource = StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_paypal, lightThemeIconUrl = null, darkThemeIconUrl = null, paymentMethodCreateParams = PaymentMethodCreateParamsFixtures.PAYPAL.copy( @@ -209,7 +209,7 @@ class PaymentSelectionUpdaterTest { fun `PaymentSelection is preserved when payment method still requires mandate after updating intent`() { val existingSelection = PaymentSelection.New.GenericPaymentMethod( labelResource = "paypal", - iconResource = R.drawable.stripe_ic_paymentsheet_pm_paypal, + iconResource = StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_paypal, lightThemeIconUrl = null, darkThemeIconUrl = null, paymentMethodCreateParams = PaymentMethodCreateParamsFixtures.PAYPAL.copy( diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/BillingDetailsHelpersTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/BillingDetailsHelpersTest.kt index f3635be21b8..5dd84258bae 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/BillingDetailsHelpersTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/BillingDetailsHelpersTest.kt @@ -5,7 +5,6 @@ import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.forms.BillingDetailsHelpers.removeCorrespondingPlaceholder import com.stripe.android.paymentsheet.forms.BillingDetailsHelpers.specForPlaceholderField import com.stripe.android.paymentsheet.forms.BillingDetailsHelpers.specsForConfiguration -import com.stripe.android.ui.core.R import com.stripe.android.ui.core.elements.AddressSpec import com.stripe.android.ui.core.elements.EmailSpec import com.stripe.android.ui.core.elements.NameSpec @@ -17,6 +16,7 @@ import com.stripe.android.uicore.elements.IdentifierSpec import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR @RunWith(RobolectricTestRunner::class) class BillingDetailsHelpersTest { @@ -83,7 +83,7 @@ class BillingDetailsHelpersTest { ), SimpleTextSpec( apiPath = IdentifierSpec.Generic("dummy"), - label = R.string.stripe_affirm_buy_now_pay_later, + label = StripeR.string.stripe_affirm_buy_now_pay_later, ), ), ) @@ -94,7 +94,7 @@ class BillingDetailsHelpersTest { EmailSpec(), SimpleTextSpec( apiPath = IdentifierSpec.Generic("dummy"), - label = R.string.stripe_affirm_buy_now_pay_later, + label = StripeR.string.stripe_affirm_buy_now_pay_later, ), PhoneSpec(), AddressSpec(), diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormArgumentsFactoryTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormArgumentsFactoryTest.kt index aa53cfbe010..7a891dd4fa5 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormArgumentsFactoryTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormArgumentsFactoryTest.kt @@ -9,7 +9,6 @@ import com.stripe.android.model.PaymentMethod import com.stripe.android.model.PaymentMethodCreateParams import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.PaymentSheetFixtures -import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.model.PaymentSelection import com.stripe.android.paymentsheet.paymentdatacollection.FormArguments import com.stripe.android.testing.PaymentIntentFactory @@ -20,6 +19,7 @@ import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import org.robolectric.RobolectricTestRunner +import com.stripe.android.ui.core.R as StripeUiCoreR @RunWith(RobolectricTestRunner::class) class FormArgumentsFactoryTest { @@ -66,8 +66,8 @@ class FormArgumentsFactoryTest { merchantName = PaymentSheetFixtures.MERCHANT_DISPLAY_NAME, amount = Amount(50, "USD"), newLpm = PaymentSelection.New.GenericPaymentMethod( - labelResource = resources.getString(R.string.stripe_paymentsheet_payment_method_bancontact), - iconResource = R.drawable.stripe_ic_paymentsheet_pm_bancontact, + labelResource = resources.getString(StripeUiCoreR.string.stripe_paymentsheet_payment_method_bancontact), + iconResource = StripeUiCoreR.drawable.stripe_ic_paymentsheet_pm_bancontact, lightThemeIconUrl = null, darkThemeIconUrl = null, paymentMethodCreateParams = paymentMethodCreateParams, diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormViewModelTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormViewModelTest.kt index 63dec1558e5..2f4d3735a03 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormViewModelTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/forms/FormViewModelTest.kt @@ -49,6 +49,9 @@ import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import org.robolectric.RobolectricTestRunner +import com.stripe.android.R as StripeR +import com.stripe.android.core.R as CoreR +import com.stripe.android.uicore.R as UiCoreR @Suppress("LargeClass") @RunWith(RobolectricTestRunner::class) @@ -56,7 +59,7 @@ internal class FormViewModelTest { private val emailSection = EmailSpec() private val context = ContextThemeWrapper( ApplicationProvider.getApplicationContext(), - R.style.StripeDefaultTheme + StripeR.style.StripeDefaultTheme ) val lpmRepository = LpmRepository(LpmRepository.LpmRepositoryArguments(context.resources)) @@ -105,7 +108,7 @@ internal class FormViewModelTest { // Set all the card fields, billing is set in the args val emailController = - getSectionFieldTextControllerWithLabel(formViewModel, R.string.stripe_email) + getSectionFieldTextControllerWithLabel(formViewModel, UiCoreR.string.stripe_email) emailController?.onValueChange("joe@email.com") @@ -227,7 +230,7 @@ internal class FormViewModelTest { ) val emailController = - getSectionFieldTextControllerWithLabel(formViewModel, R.string.stripe_email) + getSectionFieldTextControllerWithLabel(formViewModel, UiCoreR.string.stripe_email) // Add text to the name to make it valid emailController?.onValueChange("email@valid.com") @@ -265,7 +268,7 @@ internal class FormViewModelTest { ) val emailController = - getSectionFieldTextControllerWithLabel(formViewModel, R.string.stripe_email) + getSectionFieldTextControllerWithLabel(formViewModel, UiCoreR.string.stripe_email) // Add text to the email to make it invalid emailController?.onValueChange("joe") @@ -321,9 +324,9 @@ internal class FormViewModelTest { ) val nameElement = - getSectionFieldTextControllerWithLabel(formViewModel, R.string.stripe_address_label_full_name) + getSectionFieldTextControllerWithLabel(formViewModel, CoreR.string.stripe_address_label_full_name) val emailElement = - getSectionFieldTextControllerWithLabel(formViewModel, R.string.stripe_email) + getSectionFieldTextControllerWithLabel(formViewModel, UiCoreR.string.stripe_email) nameElement?.onValueChange("joe") assertThat( @@ -377,7 +380,7 @@ internal class FormViewModelTest { getSectionFieldTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_full_name + CoreR.string.stripe_address_label_full_name )?.onValueChange("joe") assertThat( formViewModel.completeFormValues.first()?.fieldValuePairs?.get(IdentifierSpec.Name) @@ -386,7 +389,7 @@ internal class FormViewModelTest { getSectionFieldTextControllerWithLabel( formViewModel, - R.string.stripe_email + UiCoreR.string.stripe_email )?.onValueChange("joe@gmail.com") assertThat( formViewModel.completeFormValues.first()?.fieldValuePairs?.get(IdentifierSpec.Email) @@ -461,7 +464,7 @@ internal class FormViewModelTest { getSectionFieldTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_full_name + CoreR.string.stripe_address_label_full_name )?.onValueChange("joe") assertThat( formViewModel.completeFormValues.first()?.fieldValuePairs?.get(emailSection.apiPath) @@ -470,7 +473,7 @@ internal class FormViewModelTest { getSectionFieldTextControllerWithLabel( formViewModel, - R.string.stripe_email + UiCoreR.string.stripe_email )?.onValueChange("joe@gmail.com") assertThat( formViewModel.completeFormValues.first()?.fieldValuePairs?.get(emailSection.apiPath) @@ -489,7 +492,7 @@ internal class FormViewModelTest { // Fill all address values except line2 val addressControllers = AddressControllers.create(formViewModel) val populateAddressControllers = addressControllers.controllers - .filter { it.label.first() != R.string.stripe_address_label_address_line2 } + .filter { it.label.first() != UiCoreR.string.stripe_address_label_address_line2 } populateAddressControllers .forEachIndexed { index, textFieldController -> textFieldController.onValueChange("12345") @@ -659,17 +662,17 @@ internal class FormViewModelTest { val nameSection = formElement[0] as SectionElement val nameElement = nameSection.fields[0] as SimpleTextElement - assertThat(nameElement.controller.label.first()).isEqualTo(R.string.stripe_address_label_full_name) + assertThat(nameElement.controller.label.first()).isEqualTo(CoreR.string.stripe_address_label_full_name) assertThat(nameElement.identifier.v1).isEqualTo("billing_details[name]") val emailSection = formElement[1] as SectionElement val emailElement = emailSection.fields[0] as EmailElement - assertThat(emailElement.controller.label.first()).isEqualTo(R.string.stripe_email) + assertThat(emailElement.controller.label.first()).isEqualTo(UiCoreR.string.stripe_email) assertThat(emailElement.identifier.v1).isEqualTo("billing_details[email]") val phoneSection = formElement[2] as SectionElement val phoneElement = phoneSection.fields[0] as PhoneNumberElement - assertThat(phoneElement.controller.label.first()).isEqualTo(R.string.stripe_address_label_phone_number) + assertThat(phoneElement.controller.label.first()).isEqualTo(UiCoreR.string.stripe_address_label_phone_number) assertThat(phoneElement.identifier.v1).isEqualTo("billing_details[phone]") val addressSection = formElement[3] as SectionElement @@ -847,23 +850,23 @@ internal class FormViewModelTest { listOfNotNull( getAddressSectionTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_address_line1 + CoreR.string.stripe_address_label_address_line1 ), getAddressSectionTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_address_line2 + UiCoreR.string.stripe_address_label_address_line2 ), getAddressSectionTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_city + CoreR.string.stripe_address_label_city ), getAddressSectionTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_state + CoreR.string.stripe_address_label_state ), getAddressSectionTextControllerWithLabel( formViewModel, - R.string.stripe_address_label_zip_code + CoreR.string.stripe_address_label_zip_code ) ) ) diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIconTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIconTest.kt index f00e2e1972b..604508cf8f1 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIconTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/TransformToBankIconTest.kt @@ -1,95 +1,96 @@ package com.stripe.android.paymentsheet.paymentdatacollection.ach -import com.stripe.android.paymentsheet.R import org.junit.Assert import org.junit.Test +import com.stripe.android.R as StripeR +import com.stripe.android.financialconnections.R as FinancialConnectionsR class TransformToBankIconTest { @Test fun `given valid bank name, transform returns the correct bank icon`() { // bank of america - Assert.assertEquals(TransformToBankIcon("Bank of America"), R.drawable.stripe_ic_bank_boa) - Assert.assertEquals(TransformToBankIcon("bank of america"), R.drawable.stripe_ic_bank_boa) - Assert.assertEquals(TransformToBankIcon("BANKof AMERICA"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("Bank of America"), StripeR.drawable.stripe_ic_bank_boa) + Assert.assertEquals(TransformToBankIcon("bank of america"), StripeR.drawable.stripe_ic_bank_boa) + Assert.assertEquals(TransformToBankIcon("BANKof AMERICA"), FinancialConnectionsR.drawable.stripe_ic_bank) // capital one - Assert.assertEquals(TransformToBankIcon("Capital One"), R.drawable.stripe_ic_bank_capitalone) - Assert.assertEquals(TransformToBankIcon("capital one"), R.drawable.stripe_ic_bank_capitalone) - Assert.assertEquals(TransformToBankIcon("Capital One"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("Capital One"), StripeR.drawable.stripe_ic_bank_capitalone) + Assert.assertEquals(TransformToBankIcon("capital one"), StripeR.drawable.stripe_ic_bank_capitalone) + Assert.assertEquals(TransformToBankIcon("Capital One"), FinancialConnectionsR.drawable.stripe_ic_bank) // compass - Assert.assertEquals(TransformToBankIcon("BBVA"), R.drawable.stripe_ic_bank_compass) - Assert.assertEquals(TransformToBankIcon("bbva"), R.drawable.stripe_ic_bank_compass) - Assert.assertEquals(TransformToBankIcon("Compass"), R.drawable.stripe_ic_bank_compass) - Assert.assertEquals(TransformToBankIcon("compass"), R.drawable.stripe_ic_bank_compass) - Assert.assertEquals(TransformToBankIcon("b b v a"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("BBVA"), StripeR.drawable.stripe_ic_bank_compass) + Assert.assertEquals(TransformToBankIcon("bbva"), StripeR.drawable.stripe_ic_bank_compass) + Assert.assertEquals(TransformToBankIcon("Compass"), StripeR.drawable.stripe_ic_bank_compass) + Assert.assertEquals(TransformToBankIcon("compass"), StripeR.drawable.stripe_ic_bank_compass) + Assert.assertEquals(TransformToBankIcon("b b v a"), FinancialConnectionsR.drawable.stripe_ic_bank) // citi - Assert.assertEquals(TransformToBankIcon("Citibank"), R.drawable.stripe_ic_bank_citi) - Assert.assertEquals(TransformToBankIcon("citibank"), R.drawable.stripe_ic_bank_citi) - Assert.assertEquals(TransformToBankIcon("Citi Bank"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("Citibank"), StripeR.drawable.stripe_ic_bank_citi) + Assert.assertEquals(TransformToBankIcon("citibank"), StripeR.drawable.stripe_ic_bank_citi) + Assert.assertEquals(TransformToBankIcon("Citi Bank"), FinancialConnectionsR.drawable.stripe_ic_bank) // morgan chase - Assert.assertEquals(TransformToBankIcon("MORGAN CHASE"), R.drawable.stripe_ic_bank_morganchase) - Assert.assertEquals(TransformToBankIcon("morgan chase"), R.drawable.stripe_ic_bank_morganchase) - Assert.assertEquals(TransformToBankIcon("JP MORGAN"), R.drawable.stripe_ic_bank_morganchase) - Assert.assertEquals(TransformToBankIcon("jp morgan"), R.drawable.stripe_ic_bank_morganchase) - Assert.assertEquals(TransformToBankIcon("Chase"), R.drawable.stripe_ic_bank_morganchase) - Assert.assertEquals(TransformToBankIcon("chase"), R.drawable.stripe_ic_bank_morganchase) + Assert.assertEquals(TransformToBankIcon("MORGAN CHASE"), StripeR.drawable.stripe_ic_bank_morganchase) + Assert.assertEquals(TransformToBankIcon("morgan chase"), StripeR.drawable.stripe_ic_bank_morganchase) + Assert.assertEquals(TransformToBankIcon("JP MORGAN"), StripeR.drawable.stripe_ic_bank_morganchase) + Assert.assertEquals(TransformToBankIcon("jp morgan"), StripeR.drawable.stripe_ic_bank_morganchase) + Assert.assertEquals(TransformToBankIcon("Chase"), StripeR.drawable.stripe_ic_bank_morganchase) + Assert.assertEquals(TransformToBankIcon("chase"), StripeR.drawable.stripe_ic_bank_morganchase) // nfcu - Assert.assertEquals(TransformToBankIcon("NAVY FEDERAL CREDIT UNION"), R.drawable.stripe_ic_bank_nfcu) - Assert.assertEquals(TransformToBankIcon("navy federal credit union"), R.drawable.stripe_ic_bank_nfcu) - Assert.assertEquals(TransformToBankIcon("NFCU"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("NAVY FEDERAL CREDIT UNION"), StripeR.drawable.stripe_ic_bank_nfcu) + Assert.assertEquals(TransformToBankIcon("navy federal credit union"), StripeR.drawable.stripe_ic_bank_nfcu) + Assert.assertEquals(TransformToBankIcon("NFCU"), FinancialConnectionsR.drawable.stripe_ic_bank) // pnc - Assert.assertEquals(TransformToBankIcon("PNC BANK"), R.drawable.stripe_ic_bank_pnc) - Assert.assertEquals(TransformToBankIcon("pnc bank"), R.drawable.stripe_ic_bank_pnc) - Assert.assertEquals(TransformToBankIcon("PNC Bank"), R.drawable.stripe_ic_bank_pnc) - Assert.assertEquals(TransformToBankIcon("PNC BANK"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("PNC BANK"), StripeR.drawable.stripe_ic_bank_pnc) + Assert.assertEquals(TransformToBankIcon("pnc bank"), StripeR.drawable.stripe_ic_bank_pnc) + Assert.assertEquals(TransformToBankIcon("PNC Bank"), StripeR.drawable.stripe_ic_bank_pnc) + Assert.assertEquals(TransformToBankIcon("PNC BANK"), FinancialConnectionsR.drawable.stripe_ic_bank) // suntrust - Assert.assertEquals(TransformToBankIcon("SUNTRUST"), R.drawable.stripe_ic_bank_suntrust) - Assert.assertEquals(TransformToBankIcon("suntrust"), R.drawable.stripe_ic_bank_suntrust) - Assert.assertEquals(TransformToBankIcon("SunTrust Bank"), R.drawable.stripe_ic_bank_suntrust) - Assert.assertEquals(TransformToBankIcon("suntrust bank"), R.drawable.stripe_ic_bank_suntrust) + Assert.assertEquals(TransformToBankIcon("SUNTRUST"), StripeR.drawable.stripe_ic_bank_suntrust) + Assert.assertEquals(TransformToBankIcon("suntrust"), StripeR.drawable.stripe_ic_bank_suntrust) + Assert.assertEquals(TransformToBankIcon("SunTrust Bank"), StripeR.drawable.stripe_ic_bank_suntrust) + Assert.assertEquals(TransformToBankIcon("suntrust bank"), StripeR.drawable.stripe_ic_bank_suntrust) // svb - Assert.assertEquals(TransformToBankIcon("Silicon Valley Bank"), R.drawable.stripe_ic_bank_svb) - Assert.assertEquals(TransformToBankIcon("silicon valley bank"), R.drawable.stripe_ic_bank_svb) - Assert.assertEquals(TransformToBankIcon("svb"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("Silicon Valley Bank"), StripeR.drawable.stripe_ic_bank_svb) + Assert.assertEquals(TransformToBankIcon("silicon valley bank"), StripeR.drawable.stripe_ic_bank_svb) + Assert.assertEquals(TransformToBankIcon("svb"), FinancialConnectionsR.drawable.stripe_ic_bank) // stripe - Assert.assertEquals(TransformToBankIcon("stripe"), R.drawable.stripe_ic_bank_stripe) - Assert.assertEquals(TransformToBankIcon("Stripe"), R.drawable.stripe_ic_bank_stripe) - Assert.assertEquals(TransformToBankIcon("stripe"), R.drawable.stripe_ic_bank_stripe) - Assert.assertEquals(TransformToBankIcon("TestInstitution"), R.drawable.stripe_ic_bank_stripe) - Assert.assertEquals(TransformToBankIcon("testinstitution"), R.drawable.stripe_ic_bank_stripe) + Assert.assertEquals(TransformToBankIcon("stripe"), StripeR.drawable.stripe_ic_bank_stripe) + Assert.assertEquals(TransformToBankIcon("Stripe"), StripeR.drawable.stripe_ic_bank_stripe) + Assert.assertEquals(TransformToBankIcon("stripe"), StripeR.drawable.stripe_ic_bank_stripe) + Assert.assertEquals(TransformToBankIcon("TestInstitution"), StripeR.drawable.stripe_ic_bank_stripe) + Assert.assertEquals(TransformToBankIcon("testinstitution"), StripeR.drawable.stripe_ic_bank_stripe) // td - Assert.assertEquals(TransformToBankIcon("TD Bank"), R.drawable.stripe_ic_bank_td) - Assert.assertEquals(TransformToBankIcon("td bank"), R.drawable.stripe_ic_bank_td) - Assert.assertEquals(TransformToBankIcon("TD"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("TD Bank"), StripeR.drawable.stripe_ic_bank_td) + Assert.assertEquals(TransformToBankIcon("td bank"), StripeR.drawable.stripe_ic_bank_td) + Assert.assertEquals(TransformToBankIcon("TD"), FinancialConnectionsR.drawable.stripe_ic_bank) // usaa - Assert.assertEquals(TransformToBankIcon("USAA FEDERAL SAVINGS BANK"), R.drawable.stripe_ic_bank_usaa) - Assert.assertEquals(TransformToBankIcon("usaa federal savings bank"), R.drawable.stripe_ic_bank_usaa) - Assert.assertEquals(TransformToBankIcon("USAA Bank"), R.drawable.stripe_ic_bank_usaa) - Assert.assertEquals(TransformToBankIcon("usaa bank"), R.drawable.stripe_ic_bank_usaa) - Assert.assertEquals(TransformToBankIcon("USAA Savings Bank"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("USAA FEDERAL SAVINGS BANK"), StripeR.drawable.stripe_ic_bank_usaa) + Assert.assertEquals(TransformToBankIcon("usaa federal savings bank"), StripeR.drawable.stripe_ic_bank_usaa) + Assert.assertEquals(TransformToBankIcon("USAA Bank"), StripeR.drawable.stripe_ic_bank_usaa) + Assert.assertEquals(TransformToBankIcon("usaa bank"), StripeR.drawable.stripe_ic_bank_usaa) + Assert.assertEquals(TransformToBankIcon("USAA Savings Bank"), FinancialConnectionsR.drawable.stripe_ic_bank) // us bank - Assert.assertEquals(TransformToBankIcon("U.S. BANK"), R.drawable.stripe_ic_bank_usbank) - Assert.assertEquals(TransformToBankIcon("u.s. bank"), R.drawable.stripe_ic_bank_usbank) - Assert.assertEquals(TransformToBankIcon("u.s. Bank"), R.drawable.stripe_ic_bank_usbank) - Assert.assertEquals(TransformToBankIcon("US Bank"), R.drawable.stripe_ic_bank_usbank) - Assert.assertEquals(TransformToBankIcon("us bank"), R.drawable.stripe_ic_bank_usbank) - Assert.assertEquals(TransformToBankIcon("usbank"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("U.S. BANK"), StripeR.drawable.stripe_ic_bank_usbank) + Assert.assertEquals(TransformToBankIcon("u.s. bank"), StripeR.drawable.stripe_ic_bank_usbank) + Assert.assertEquals(TransformToBankIcon("u.s. Bank"), StripeR.drawable.stripe_ic_bank_usbank) + Assert.assertEquals(TransformToBankIcon("US Bank"), StripeR.drawable.stripe_ic_bank_usbank) + Assert.assertEquals(TransformToBankIcon("us bank"), StripeR.drawable.stripe_ic_bank_usbank) + Assert.assertEquals(TransformToBankIcon("usbank"), FinancialConnectionsR.drawable.stripe_ic_bank) // wells fargo - Assert.assertEquals(TransformToBankIcon("Wells Fargo"), R.drawable.stripe_ic_bank_wellsfargo) - Assert.assertEquals(TransformToBankIcon("wells fargo"), R.drawable.stripe_ic_bank_wellsfargo) - Assert.assertEquals(TransformToBankIcon("WELLS FARGO"), R.drawable.stripe_ic_bank_wellsfargo) - Assert.assertEquals(TransformToBankIcon("Well's Fargo"), R.drawable.stripe_ic_bank) + Assert.assertEquals(TransformToBankIcon("Wells Fargo"), StripeR.drawable.stripe_ic_bank_wellsfargo) + Assert.assertEquals(TransformToBankIcon("wells fargo"), StripeR.drawable.stripe_ic_bank_wellsfargo) + Assert.assertEquals(TransformToBankIcon("WELLS FARGO"), StripeR.drawable.stripe_ic_bank_wellsfargo) + Assert.assertEquals(TransformToBankIcon("Well's Fargo"), FinancialConnectionsR.drawable.stripe_ic_bank) } } diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/HeaderTextFactoryTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/HeaderTextFactoryTest.kt index f7cf231b348..d144f7e2469 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/HeaderTextFactoryTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/HeaderTextFactoryTest.kt @@ -4,6 +4,7 @@ import com.google.common.truth.Truth.assertThat import com.stripe.android.paymentsheet.R import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen import org.junit.Test +import com.stripe.android.R as StripeR class HeaderTextFactoryTest { @@ -88,7 +89,7 @@ class HeaderTextFactoryTest { types = listOf("card"), ) - assertThat(resource).isEqualTo(R.string.stripe_title_add_a_card) + assertThat(resource).isEqualTo(StripeR.string.stripe_title_add_a_card) } @Test diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarScreenshotTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarScreenshotTest.kt index 376dcf24905..3e9b8ce9c53 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarScreenshotTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarScreenshotTest.kt @@ -11,6 +11,8 @@ import com.stripe.android.utils.screenshots.PaymentSheetAppearance import com.stripe.android.utils.screenshots.SystemAppearance import org.junit.Rule import org.junit.Test +import com.stripe.android.R as StripeR +import com.stripe.android.ui.core.R as StripeUiCoreR class PaymentSheetTopBarScreenshotTest { @@ -26,10 +28,10 @@ class PaymentSheetTopBarScreenshotTest { fun testLoading() { val state = PaymentSheetTopBarState( icon = R.drawable.stripe_ic_paymentsheet_close, - contentDescription = R.string.stripe_close, + contentDescription = StripeR.string.stripe_close, showTestModeLabel = false, showEditMenu = false, - editMenuLabel = R.string.stripe_edit, + editMenuLabel = StripeR.string.stripe_edit, isEnabled = true, ) @@ -47,10 +49,10 @@ class PaymentSheetTopBarScreenshotTest { fun testPaymentMethodsScreen() { val state = PaymentSheetTopBarState( icon = R.drawable.stripe_ic_paymentsheet_close, - contentDescription = R.string.stripe_close, + contentDescription = StripeR.string.stripe_close, showTestModeLabel = true, showEditMenu = true, - editMenuLabel = R.string.stripe_edit, + editMenuLabel = StripeR.string.stripe_edit, isEnabled = true, ) @@ -68,10 +70,10 @@ class PaymentSheetTopBarScreenshotTest { fun testPaymentMethodsScreenEditing() { val state = PaymentSheetTopBarState( icon = R.drawable.stripe_ic_paymentsheet_close, - contentDescription = R.string.stripe_close, + contentDescription = StripeR.string.stripe_close, showTestModeLabel = true, showEditMenu = true, - editMenuLabel = R.string.stripe_done, + editMenuLabel = StripeR.string.stripe_done, isEnabled = true, ) @@ -89,10 +91,10 @@ class PaymentSheetTopBarScreenshotTest { fun testAddPaymentMethodScreen() { val state = PaymentSheetTopBarState( icon = R.drawable.stripe_ic_paymentsheet_back, - contentDescription = R.string.stripe_back, + contentDescription = StripeUiCoreR.string.stripe_back, showTestModeLabel = true, showEditMenu = false, - editMenuLabel = R.string.stripe_edit, + editMenuLabel = StripeR.string.stripe_edit, isEnabled = true, ) diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarStateTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarStateTest.kt index 2863d200a80..34a5fb93663 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarStateTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarStateTest.kt @@ -10,6 +10,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock +import com.stripe.android.R as StripeR @RunWith(AndroidJUnit4::class) class PaymentSheetTopBarStateTest { @@ -131,7 +132,7 @@ class PaymentSheetTopBarStateTest { isEditing = false, ) - assertThat(state.editMenuLabel).isEqualTo(R.string.stripe_edit) + assertThat(state.editMenuLabel).isEqualTo(StripeR.string.stripe_edit) } @Test @@ -144,7 +145,7 @@ class PaymentSheetTopBarStateTest { isEditing = true, ) - assertThat(state.editMenuLabel).isEqualTo(R.string.stripe_done) + assertThat(state.editMenuLabel).isEqualTo(StripeR.string.stripe_done) } @Test diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarTest.kt index f659e808357..2bc6061c276 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/ui/PaymentSheetTopBarTest.kt @@ -20,6 +20,8 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.never import org.mockito.kotlin.verify import org.robolectric.annotation.Config +import com.stripe.android.R as StripeR +import com.stripe.android.ui.core.R as StripeUiCoreR @RunWith(AndroidJUnit4::class) @Config(sdk = [Build.VERSION_CODES.Q]) @@ -108,10 +110,10 @@ class PaymentSheetTopBarTest { ): PaymentSheetTopBarState { return PaymentSheetTopBarState( icon = R.drawable.stripe_ic_paymentsheet_back, - contentDescription = R.string.stripe_back, + contentDescription = StripeUiCoreR.string.stripe_back, showTestModeLabel = false, showEditMenu = showEditMenu, - editMenuLabel = R.string.stripe_edit, + editMenuLabel = StripeR.string.stripe_edit, isEnabled = isEnabled, ) } diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/address/TransformAddressToElement.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/address/TransformAddressToElement.kt index fa19385ca14..a4568628203 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/address/TransformAddressToElement.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/address/TransformAddressToElement.kt @@ -24,6 +24,7 @@ import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.Json import java.io.InputStream import java.util.UUID +import com.stripe.android.core.R as CoreR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Serializable @@ -36,7 +37,7 @@ enum class FieldType( AddressLine1( "addressLine1", IdentifierSpec.Line1, - R.string.stripe_address_label_address_line1 + CoreR.string.stripe_address_label_address_line1 ), @SerialName("addressLine2") @@ -50,21 +51,21 @@ enum class FieldType( Locality( "locality", IdentifierSpec.City, - R.string.stripe_address_label_city + CoreR.string.stripe_address_label_city ), @SerialName("dependentLocality") DependentLocality( "dependentLocality", IdentifierSpec.DependentLocality, - R.string.stripe_address_label_city + CoreR.string.stripe_address_label_city ), @SerialName("postalCode") PostalCode( "postalCode", IdentifierSpec.PostalCode, - R.string.stripe_address_label_postal_code + CoreR.string.stripe_address_label_postal_code ) { override fun capitalization() = KeyboardCapitalization.None }, @@ -73,7 +74,7 @@ enum class FieldType( SortingCode( "sortingCode", IdentifierSpec.SortingCode, - R.string.stripe_address_label_postal_code + CoreR.string.stripe_address_label_postal_code ) { override fun capitalization() = KeyboardCapitalization.None }, @@ -89,7 +90,7 @@ enum class FieldType( Name( "name", IdentifierSpec.Name, - R.string.stripe_address_label_full_name + CoreR.string.stripe_address_label_full_name ); open fun capitalization() = KeyboardCapitalization.Words @@ -112,13 +113,13 @@ enum class NameType(@StringRes val stringResId: Int) { Cedex(R.string.stripe_address_label_cedex), @SerialName("city") - City(R.string.stripe_address_label_city), + City(CoreR.string.stripe_address_label_city), @SerialName("country") - Country(R.string.stripe_address_label_country_or_region), + Country(CoreR.string.stripe_address_label_country_or_region), @SerialName("county") - County(R.string.stripe_address_label_county), + County(CoreR.string.stripe_address_label_county), @SerialName("department") Department(R.string.stripe_address_label_department), @@ -154,16 +155,16 @@ enum class NameType(@StringRes val stringResId: Int) { PostTown(R.string.stripe_address_label_post_town), @SerialName("postal") - Postal(R.string.stripe_address_label_postal_code), + Postal(CoreR.string.stripe_address_label_postal_code), @SerialName("prefecture") Perfecture(R.string.stripe_address_label_jp_prefecture), @SerialName("province") - Province(R.string.stripe_address_label_province), + Province(CoreR.string.stripe_address_label_province), @SerialName("state") - State(R.string.stripe_address_label_state), + State(CoreR.string.stripe_address_label_state), @SerialName("suburb") Suburb(R.string.stripe_address_label_suburb), @@ -178,7 +179,7 @@ enum class NameType(@StringRes val stringResId: Int) { VillageTownship(R.string.stripe_address_label_village_township), @SerialName("zip") - Zip(R.string.stripe_address_label_zip_code) + Zip(CoreR.string.stripe_address_label_zip_code) } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AddressElement.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AddressElement.kt index 1a1c3c466dc..a29a2b54d05 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AddressElement.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AddressElement.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flattenConcat import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map +import com.stripe.android.core.R as CoreR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) open class AddressElement constructor( @@ -39,7 +40,7 @@ open class AddressElement constructor( IdentifierSpec.Name, SimpleTextFieldController( textFieldConfig = SimpleTextFieldConfig( - label = R.string.stripe_address_label_full_name + label = CoreR.string.stripe_address_label_full_name ), initialValue = rawValuesMap[IdentifierSpec.Name] ) diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AdministrativeAreaConfig.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AdministrativeAreaConfig.kt index 742749e7024..86549a006af 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AdministrativeAreaConfig.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/AdministrativeAreaConfig.kt @@ -2,7 +2,7 @@ package com.stripe.android.uicore.elements import androidx.annotation.RestrictTo import androidx.annotation.StringRes -import com.stripe.android.uicore.R +import com.stripe.android.core.R as CoreR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class AdministrativeAreaConfig( @@ -38,7 +38,7 @@ class AdministrativeAreaConfig( ) { @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class Canada( - override val label: Int = R.string.stripe_address_label_province, + override val label: Int = CoreR.string.stripe_address_label_province, override val administrativeAreas: List> = listOf( Pair("AB", "Alberta"), Pair("BC", "British Columbia"), @@ -58,7 +58,7 @@ class AdministrativeAreaConfig( @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class US( - override val label: Int = R.string.stripe_address_label_state, + override val label: Int = CoreR.string.stripe_address_label_state, override val administrativeAreas: List> = listOf( Pair("AL", "Alabama"), Pair("AK", "Alaska"), diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CheckboxElementUI.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CheckboxElementUI.kt index f322ec6f75b..ca4c891ae5c 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CheckboxElementUI.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CheckboxElementUI.kt @@ -14,8 +14,8 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.semantics.testTag import androidx.compose.ui.unit.dp -import com.stripe.android.uicore.R import com.stripe.android.uicore.elements.menu.Checkbox +import androidx.compose.ui.R as ComposeUiR @Composable @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @@ -29,9 +29,9 @@ fun CheckboxElementUI( ) { val accessibilityDescription = stringResource( if (isChecked) { - R.string.selected + ComposeUiR.string.selected } else { - R.string.not_selected + ComposeUiR.string.not_selected } ) diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CountryConfig.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CountryConfig.kt index c1f78dee303..e32fc5ba406 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CountryConfig.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/CountryConfig.kt @@ -5,8 +5,8 @@ import androidx.annotation.StringRes import com.stripe.android.core.model.Country import com.stripe.android.core.model.CountryCode import com.stripe.android.core.model.CountryUtils -import com.stripe.android.uicore.R import java.util.Locale +import com.stripe.android.core.R as CoreR /** * This is the configuration for a country dropdown. @@ -33,7 +33,7 @@ class CountryConfig( override val debugLabel = "country" @StringRes - override val label = R.string.stripe_address_label_country_or_region + override val label = CoreR.string.stripe_address_label_country_or_region internal val countries = CountryUtils.getOrderedCountries(locale) .filter { diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/NameConfig.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/NameConfig.kt index 4f55c5cb499..42d81b9da19 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/NameConfig.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/NameConfig.kt @@ -5,16 +5,16 @@ import androidx.annotation.StringRes import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.VisualTransformation -import com.stripe.android.uicore.R import com.stripe.android.uicore.elements.TextFieldStateConstants.Error import com.stripe.android.uicore.elements.TextFieldStateConstants.Valid import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import com.stripe.android.core.R as CoreR @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) class NameConfig : TextFieldConfig { @StringRes - override val label = R.string.stripe_address_label_full_name + override val label = CoreR.string.stripe_address_label_full_name override val capitalization: KeyboardCapitalization = KeyboardCapitalization.Words override val debugLabel = "name" override val keyboard = KeyboardType.Text diff --git a/stripe-ui-core/src/test/java/com/stripe/android/uicore/address/TransformAddressToElementTest.kt b/stripe-ui-core/src/test/java/com/stripe/android/uicore/address/TransformAddressToElementTest.kt index 0570c46f974..37625f95d99 100644 --- a/stripe-ui-core/src/test/java/com/stripe/android/uicore/address/TransformAddressToElementTest.kt +++ b/stripe-ui-core/src/test/java/com/stripe/android/uicore/address/TransformAddressToElementTest.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.runBlocking import org.junit.Test import java.io.File import java.security.InvalidParameterException +import com.stripe.android.core.R as CoreR class TransformAddressToElementTest { private data class TestTextSpec( @@ -33,7 +34,7 @@ class TransformAddressToElementTest { val addressLine1 = TestTextSpec( IdentifierSpec.Line1, - R.string.stripe_address_label_address_line1, + CoreR.string.stripe_address_label_address_line1, KeyboardCapitalization.Words, KeyboardType.Text, showOptionalLabel = false @@ -49,7 +50,7 @@ class TransformAddressToElementTest { val city = TestTextSpec( IdentifierSpec.City, - R.string.stripe_address_label_city, + CoreR.string.stripe_address_label_city, KeyboardCapitalization.Words, KeyboardType.Text, showOptionalLabel = false @@ -57,7 +58,7 @@ class TransformAddressToElementTest { val zip = TestTextSpec( IdentifierSpec.PostalCode, - R.string.stripe_address_label_zip_code, + CoreR.string.stripe_address_label_zip_code, KeyboardCapitalization.None, KeyboardType.NumberPassword, showOptionalLabel = false @@ -89,7 +90,7 @@ class TransformAddressToElementTest { AdministrativeAreaConfig.Country.US().administrativeAreas.map { it.second } ) assertThat(stateDropdownController.label.first()).isEqualTo( - R.string.stripe_address_label_state + CoreR.string.stripe_address_label_state ) } diff --git a/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/CountryConfigTest.kt b/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/CountryConfigTest.kt index ced00882064..d126ba3cfa4 100644 --- a/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/CountryConfigTest.kt +++ b/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/CountryConfigTest.kt @@ -2,9 +2,9 @@ package com.stripe.android.uicore.elements import com.google.common.truth.Truth.assertThat import com.stripe.android.core.model.CountryUtils -import com.stripe.android.uicore.R import org.junit.Test import java.util.Locale +import com.stripe.android.core.R as CoreR class CountryConfigTest { @@ -17,7 +17,7 @@ class CountryConfigTest { @Test fun `Verify the label`() { assertThat(CountryConfig(locale = Locale.US).label) - .isEqualTo(R.string.stripe_address_label_country_or_region) + .isEqualTo(CoreR.string.stripe_address_label_country_or_region) } @Test diff --git a/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/SimpleTextFieldControllerTest.kt b/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/SimpleTextFieldControllerTest.kt index 87730e52a23..37aaf995d31 100644 --- a/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/SimpleTextFieldControllerTest.kt +++ b/stripe-ui-core/src/test/java/com/stripe/android/uicore/elements/SimpleTextFieldControllerTest.kt @@ -5,7 +5,6 @@ import android.os.Looper.getMainLooper import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.lifecycle.asLiveData import com.google.common.truth.Truth.assertThat -import com.stripe.android.uicore.R import com.stripe.android.uicore.elements.TextFieldStateConstants.Error.Blank import com.stripe.android.uicore.elements.TextFieldStateConstants.Error.Invalid import com.stripe.android.uicore.elements.TextFieldStateConstants.Valid.Full @@ -19,6 +18,7 @@ import org.mockito.kotlin.mock import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows.shadowOf import org.robolectric.annotation.Config +import com.stripe.android.core.R as CoreR @RunWith(RobolectricTestRunner::class) @Config(sdk = [Build.VERSION_CODES.P]) @@ -230,7 +230,7 @@ internal class SimpleTextFieldControllerTest { @Test fun `Verify non-null label`() { val controller = createControllerWithState(nullLabel = false) - assertThat(controller.label.value).isEqualTo(R.string.stripe_address_label_full_name) + assertThat(controller.label.value).isEqualTo(CoreR.string.stripe_address_label_full_name) } @Test @@ -273,7 +273,7 @@ internal class SimpleTextFieldControllerTest { if (nullLabel) { on { label } doReturn null } else { - on { label } doReturn R.string.stripe_address_label_full_name + on { label } doReturn CoreR.string.stripe_address_label_full_name } if (!nullPlaceHolder) { diff --git a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/cardscan/CardScanFragment.kt b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/cardscan/CardScanFragment.kt index d8fb87efaa5..6346c43b289 100644 --- a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/cardscan/CardScanFragment.kt +++ b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/cardscan/CardScanFragment.kt @@ -44,6 +44,7 @@ import kotlinx.coroutines.launch import java.util.concurrent.atomic.AtomicBoolean import kotlin.math.min import kotlin.math.roundToInt +import com.stripe.android.camera.R as CameraR private val MINIMUM_RESOLUTION = Size(1067, 600) // minimum size of OCR const val CARD_SCAN_FRAGMENT_REQUEST_KEY = "CardScanRequestKey" @@ -232,7 +233,7 @@ class CardScanFragment : ScanFragment(), SimpleScanStateful { val viewFinderMargin = ( min(screenSize.width, screenSize.height) * - (context?.getFloatResource(R.dimen.stripeViewFinderMargin) ?: 0F) + (context?.getFloatResource(CameraR.dimen.stripeViewFinderMargin) ?: 0F) ).roundToInt() listOf(viewFinderWindow, viewFinderBorder).forEach { view -> diff --git a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanActivity.kt b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanActivity.kt index 06a34052b1d..2a801e4d0df 100644 --- a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanActivity.kt +++ b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanActivity.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.parcelize.Parcelize import kotlin.coroutines.CoroutineContext +import com.stripe.android.camera.R as CameraR sealed interface CancellationReason : Parcelable { @@ -147,9 +148,9 @@ internal abstract class ScanActivity : CameraPermissionCheckingActivity(), Corou */ protected open fun showCameraNotSupportedDialog() { AlertDialog.Builder(this) - .setTitle(R.string.stripe_error_camera_title) - .setMessage(R.string.stripe_error_camera_unsupported) - .setPositiveButton(R.string.stripe_error_camera_acknowledge_button) { _, _ -> + .setTitle(CameraR.string.stripe_error_camera_title) + .setMessage(CameraR.string.stripe_error_camera_unsupported) + .setPositiveButton(CameraR.string.stripe_error_camera_acknowledge_button) { _, _ -> scanFailure() } .show() diff --git a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanFragment.kt b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanFragment.kt index b748e17c6d0..f5201187eed 100644 --- a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanFragment.kt +++ b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/ScanFragment.kt @@ -30,6 +30,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlin.coroutines.CoroutineContext +import com.stripe.android.camera.R as CameraR private const val PERMISSION_RATIONALE_SHOWN = "permission_rationale_shown" @@ -136,7 +137,7 @@ abstract class ScanFragment : Fragment(), CoroutineScope { */ protected open fun showCameraNotSupported() { instructionsText.visibility = View.VISIBLE - instructionsText.setText(R.string.stripe_error_camera_unsupported) + instructionsText.setText(CameraR.string.stripe_error_camera_unsupported) scanFailure() } diff --git a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/SimpleScanActivity.kt b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/SimpleScanActivity.kt index 3a044398766..64a2c918169 100644 --- a/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/SimpleScanActivity.kt +++ b/stripecardscan/src/main/java/com/stripe/android/stripecardscan/scanui/SimpleScanActivity.kt @@ -31,6 +31,7 @@ import kotlinx.coroutines.Deferred import kotlinx.coroutines.flow.Flow import kotlin.math.min import kotlin.math.roundToInt +import com.stripe.android.camera.R as CameraR internal abstract class SimpleScanActivity : ScanActivity() { @@ -437,7 +438,7 @@ internal abstract class SimpleScanActivity : ScanActivity() } val viewFinderMargin = ( min(screenSize.width, screenSize.height) * - getFloatResource(R.dimen.stripeViewFinderMargin) + getFloatResource(CameraR.dimen.stripeViewFinderMargin) ).roundToInt() listOf(viewFinderWindowView, viewFinderBorderView).forEach { view -> @@ -450,8 +451,8 @@ internal abstract class SimpleScanActivity : ScanActivity() view.constrainToParent() view.addConstraints { - setVerticalBias(it.id, getFloatResource(R.dimen.stripeViewFinderVerticalBias)) - setHorizontalBias(it.id, getFloatResource(R.dimen.stripeViewFinderHorizontalBias)) + setVerticalBias(it.id, getFloatResource(CameraR.dimen.stripeViewFinderVerticalBias)) + setHorizontalBias(it.id, getFloatResource(CameraR.dimen.stripeViewFinderHorizontalBias)) setDimensionRatio(it.id, viewFinderAspectRatio) } diff --git a/wechatpay/src/test/java/com/stripe/android/payments/wechatpay/WeChatPayAuthActivityTest.kt b/wechatpay/src/test/java/com/stripe/android/payments/wechatpay/WeChatPayAuthActivityTest.kt index d6e9e4733bb..1f01767d5c9 100644 --- a/wechatpay/src/test/java/com/stripe/android/payments/wechatpay/WeChatPayAuthActivityTest.kt +++ b/wechatpay/src/test/java/com/stripe/android/payments/wechatpay/WeChatPayAuthActivityTest.kt @@ -25,13 +25,14 @@ import org.robolectric.RobolectricTestRunner import java.lang.reflect.Method import kotlin.test.assertEquals import kotlin.test.assertNull +import androidx.appcompat.R as AppCompatR @RunWith(RobolectricTestRunner::class) class WeChatPayAuthActivityTest { private val mockWeChatApi = mock() private val mockReflectionHelper: WeChatPayReflectionHelper = mock() private val context = ApplicationProvider.getApplicationContext().also { - it.setTheme(R.style.Theme_AppCompat) + it.setTheme(AppCompatR.style.Theme_AppCompat) } private val mockOnRespMethod = mock() private val responseArg = Object()