Skip to content

Commit

Permalink
Migrate to non-transitive R classes
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarSpruit committed May 3, 2024
1 parent d571501 commit 7374f46
Show file tree
Hide file tree
Showing 36 changed files with 77 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.adyen.checkout.ui.core.internal.util.showError
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class ACHDirectDebitView @JvmOverloads constructor(
Expand All @@ -49,7 +50,7 @@ internal class ACHDirectDebitView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

internal class AwaitView @JvmOverloads constructor(
context: Context,
Expand All @@ -48,7 +49,7 @@ internal class AwaitView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_double_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_double_margin).toInt()
setPadding(padding, padding, padding, padding)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
import com.adyen.checkout.ui.core.internal.ui.ComponentView
import com.adyen.checkout.ui.core.internal.util.setLocalizedHintFromStyle
import kotlinx.coroutines.CoroutineScope
import com.adyen.checkout.ui.core.R as UICoreR

internal class BacsDirectDebitConfirmationView @JvmOverloads constructor(
context: Context,
Expand All @@ -42,7 +43,7 @@ internal class BacsDirectDebitConfirmationView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.adyen.checkout.ui.core.internal.util.showError
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class BacsDirectDebitInputView @JvmOverloads constructor(
Expand All @@ -58,7 +59,7 @@ internal class BacsDirectDebitInputView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.adyen.checkout.ui.core.internal.util.setLocalizedHintFromStyle
import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import com.adyen.checkout.ui.core.internal.util.showError
import kotlinx.coroutines.CoroutineScope
import com.adyen.checkout.ui.core.R as UICoreR

internal class BlikView @JvmOverloads constructor(
context: Context,
Expand All @@ -47,7 +48,7 @@ internal class BlikView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import com.adyen.checkout.ui.core.internal.util.showError
import com.adyen.checkout.ui.core.internal.util.showKeyboard
import kotlinx.coroutines.CoroutineScope
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class BoletoView @JvmOverloads constructor(
Expand All @@ -47,7 +48,7 @@ internal class BoletoView @JvmOverloads constructor(
init {
orientation = VERTICAL

val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import com.adyen.checkout.ui.core.internal.util.showError
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

/**
* CardView for [CardComponent].
Expand Down Expand Up @@ -82,7 +83,7 @@ class CardView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down Expand Up @@ -145,7 +146,7 @@ class CardView @JvmOverloads constructor(
localizedContext,
)
binding.textInputLayoutPostalCode.setLocalizedHintFromStyle(
R.style.AdyenCheckout_PostalCodeInput,
UICoreR.style.AdyenCheckout_PostalCodeInput,
localizedContext,
)
binding.textInputLayoutAddressLookup.setLocalizedHintFromStyle(
Expand Down Expand Up @@ -279,7 +280,7 @@ class CardView @JvmOverloads constructor(
}
if (binding.textInputLayoutAddressLookup.isVisible && !it.addressState.isValid) {
binding.textInputLayoutAddressLookup.showError(
localizedContext.getString(R.string.checkout_address_lookup_validation_empty)
localizedContext.getString(UICoreR.string.checkout_address_lookup_validation_empty),
)
}
}
Expand Down Expand Up @@ -727,9 +728,9 @@ class CardView @JvmOverloads constructor(
AddressFormUIState.FULL_ADDRESS -> binding.addressFormInput.updateAddressHint(isOptional)
AddressFormUIState.POSTAL_CODE -> {
val postalCodeStyleResId = if (isOptional) {
R.style.AdyenCheckout_PostalCodeInput_Optional
UICoreR.style.AdyenCheckout_PostalCodeInput_Optional
} else {
R.style.AdyenCheckout_PostalCodeInput
UICoreR.style.AdyenCheckout_PostalCodeInput
}
binding.textInputLayoutPostalCode.setLocalizedHintFromStyle(postalCodeStyleResId, localizedContext)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.adyen.checkout.ui.core.internal.util.showError
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

/**
* StoredCardView for [CardComponent].
Expand All @@ -61,7 +62,7 @@ internal class StoredCardView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
import com.adyen.checkout.ui.core.internal.ui.ComponentView
import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import kotlinx.coroutines.CoroutineScope
import com.adyen.checkout.ui.core.R as UICoreR

internal class CashAppPayView @JvmOverloads constructor(
context: Context,
Expand All @@ -36,7 +37,7 @@ internal class CashAppPayView @JvmOverloads constructor(
init {
orientation = VERTICAL

val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.adyen.checkout.components.core.internal.ui.ComponentDelegate
import com.adyen.checkout.ui.core.internal.ui.ComponentView
import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import kotlinx.coroutines.CoroutineScope
import com.adyen.checkout.ui.core.R as UICoreR

internal class CashAppPayWaitingView @JvmOverloads constructor(
context: Context,
Expand All @@ -25,7 +26,7 @@ internal class CashAppPayWaitingView @JvmOverloads constructor(
orientation = HORIZONTAL
gravity = Gravity.CENTER

val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, padding)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.adyen.checkout.dropin.internal.util.arguments
import com.google.android.material.bottomsheet.BottomSheetBehavior
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

@SuppressWarnings("TooManyFunctions")
internal class ActionComponentDialogFragment :
Expand Down Expand Up @@ -83,7 +84,7 @@ internal class ActionComponentDialogFragment :
}

override fun onCreateDialog(savedInstanceState: Bundle?) = super.onCreateDialog(savedInstanceState).apply {
window?.setWindowAnimations(R.style.AdyenCheckout_BottomSheet_NoWindowEnterDialogAnimation)
window?.setWindowAnimations(UICoreR.style.AdyenCheckout_BottomSheet_NoWindowEnterDialogAnimation)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -134,7 +135,7 @@ internal class ActionComponentDialogFragment :
adyenLog(AdyenLogLevel.DEBUG) { "Permission $requiredPermission requested" }
requestPermissionLauncher.launch(arrayOf(requiredPermission))
}
.setPositiveButton(R.string.error_dialog_button) { dialog, _ -> dialog.dismiss() }
.setPositiveButton(UICoreR.string.error_dialog_button) { dialog, _ -> dialog.dismiss() }
.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.adyen.checkout.core.internal.util.adyenLog
import com.adyen.checkout.dropin.databinding.FragmentBacsDirectDebitComponentBinding
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.R as MaterialR

internal class BacsDirectDebitDialogFragment : BaseComponentDialogFragment() {

Expand Down Expand Up @@ -68,7 +69,7 @@ internal class BacsDirectDebitDialogFragment : BaseComponentDialogFragment() {
dialog.setOnShowListener {
val bottomSheetDialog = dialog as BottomSheetDialog
val bottomSheet =
bottomSheetDialog.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
bottomSheetDialog.findViewById<FrameLayout>(MaterialR.id.design_bottom_sheet)
val layoutParams = bottomSheet?.layoutParams
val behavior = bottomSheet?.let { BottomSheetBehavior.from(it) }
behavior?.isDraggable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.adyen.checkout.components.core.paymentmethod.PaymentMethodDetails
import com.adyen.checkout.core.AdyenLogLevel
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.internal.util.adyenLog
import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.internal.provider.getComponentFor
import com.adyen.checkout.ui.core.R as UICoreR

private const val STORED_PAYMENT_METHOD = "STORED_PAYMENT_METHOD"
private const val NAVIGATED_FROM_PRESELECTED = "NAVIGATED_FROM_PRESELECTED"
Expand Down Expand Up @@ -163,6 +163,6 @@ internal abstract class BaseComponentDialogFragment :

fun handleError(componentError: ComponentError) {
adyenLog(AdyenLogLevel.ERROR) { componentError.errorMessage }
protocol.showError(null, getString(R.string.component_error), componentError.errorMessage, true)
protocol.showError(null, getString(UICoreR.string.component_error), componentError.errorMessage, true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import com.adyen.checkout.sessions.core.CheckoutSession
import com.adyen.checkout.sessions.core.SessionPaymentResult
import com.adyen.checkout.wechatpay.WeChatPayUtils
import kotlinx.coroutines.launch
import com.adyen.checkout.ui.core.R as UICoreR

/**
* Activity that presents the available PaymentMethods to the Shopper.
Expand Down Expand Up @@ -273,7 +274,7 @@ internal class DropInActivity :

override fun showError(dialogTitle: String?, errorMessage: String, reason: String, terminate: Boolean) {
adyenLog(AdyenLogLevel.DEBUG) { "showError - message: $errorMessage" }
val title = dialogTitle ?: getString(R.string.error_dialog_title)
val title = dialogTitle ?: getString(UICoreR.string.error_dialog_title)
showDialog(title, errorMessage) {
errorDialogDismissed(reason, terminate)
}
Expand Down Expand Up @@ -721,7 +722,7 @@ internal class DropInActivity :
.setTitle(title)
.setMessage(message)
.setOnDismissListener { onDismiss() }
.setPositiveButton(R.string.error_dialog_button) { dialog, _ -> dialog.dismiss() }
.setPositiveButton(UICoreR.string.error_dialog_button) { dialog, _ -> dialog.dismiss() }
.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.adyen.checkout.giftcard.GiftCardComponentState
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.R as MaterialR

internal abstract class DropInBottomSheetDialogFragment : BottomSheetDialogFragment() {

Expand Down Expand Up @@ -60,7 +61,7 @@ internal abstract class DropInBottomSheetDialogFragment : BottomSheetDialogFragm

dialog.setOnShowListener {
val bottomSheet = (dialog as BottomSheetDialog).findViewById<FrameLayout>(
com.google.android.material.R.id.design_bottom_sheet,
MaterialR.id.design_bottom_sheet,
)

if (bottomSheet != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import com.adyen.checkout.components.core.internal.PaymentComponent
import com.adyen.checkout.core.AdyenLogLevel
import com.adyen.checkout.core.exception.CheckoutException
import com.adyen.checkout.core.internal.util.adyenLog
import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.databinding.FragmentGiftcardComponentBinding
import com.adyen.checkout.dropin.internal.provider.getComponentFor
import com.adyen.checkout.giftcard.GiftCardComponent
import com.adyen.checkout.giftcard.GiftCardComponentCallback
import com.adyen.checkout.giftcard.GiftCardComponentState
import com.adyen.checkout.ui.core.internal.ui.ViewableComponent
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class GiftCardComponentDialogFragment : DropInBottomSheetDialogFragment(), GiftCardComponentCallback {
Expand Down Expand Up @@ -125,7 +125,7 @@ internal class GiftCardComponentDialogFragment : DropInBottomSheetDialogFragment

private fun handleError(componentError: ComponentError) {
adyenLog(AdyenLogLevel.ERROR) { componentError.errorMessage }
protocol.showError(null, getString(R.string.component_error), componentError.errorMessage, true)
protocol.showError(null, getString(UICoreR.string.component_error), componentError.errorMessage, true)
}

override fun onBackPressed(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.adyen.checkout.dropin.R
import com.adyen.checkout.dropin.databinding.FragmentGiftCardPaymentConfirmationBinding
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentConfirmationData
import com.adyen.checkout.dropin.internal.ui.model.GiftCardPaymentMethodModel
import com.adyen.checkout.ui.core.R as UICoreR

internal class GiftCardPaymentConfirmationDialogFragment : DropInBottomSheetDialogFragment() {

Expand Down Expand Up @@ -52,7 +53,7 @@ internal class GiftCardPaymentConfirmationDialogFragment : DropInBottomSheetDial
giftCardPaymentConfirmationData.amountPaid,
giftCardPaymentConfirmationData.shopperLocale,
)
binding.payButton.text = String.format(resources.getString(R.string.pay_button_with_value), amountToPay)
binding.payButton.text = String.format(resources.getString(UICoreR.string.pay_button_with_value), amountToPay)

val remainingBalance = CurrencyUtils.formatAmount(
giftCardPaymentConfirmationData.remainingBalance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.adyen.checkout.ui.core.internal.ui.view.AdyenSwipeToRevealLayout
import com.adyen.checkout.ui.core.internal.util.PayButtonFormatter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class PaymentMethodListDialogFragment :
Expand Down Expand Up @@ -122,7 +123,7 @@ internal class PaymentMethodListDialogFragment :
adyenLog(AdyenLogLevel.ERROR) { event.componentError.errorMessage }
protocol.showError(
dialogTitle = null,
errorMessage = getString(R.string.component_error),
errorMessage = getString(UICoreR.string.component_error),
reason = event.componentError.errorMessage,
terminate = true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.adyen.checkout.ui.core.internal.ui.loadLogo
import com.adyen.checkout.ui.core.internal.util.PayButtonFormatter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogFragment() {
Expand Down Expand Up @@ -203,7 +204,7 @@ internal class PreselectedStoredPaymentMethodFragment : DropInBottomSheetDialogF

private fun handleError(componentError: ComponentError) {
adyenLog(AdyenLogLevel.ERROR) { componentError.errorMessage }
protocol.showError(null, getString(R.string.component_error), componentError.errorMessage, true)
protocol.showError(null, getString(UICoreR.string.component_error), componentError.errorMessage, true)
}

private fun showRemoveStoredPaymentDialog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.adyen.checkout.ui.core.internal.ui.view.AdyenTextInputEditText
import com.adyen.checkout.ui.core.internal.util.setLocalizedHintFromStyle
import kotlinx.coroutines.CoroutineScope
import java.util.Locale
import com.adyen.checkout.ui.core.R as UICoreR

@Suppress("TooManyFunctions")
internal class EContextView @JvmOverloads constructor(
Expand All @@ -46,7 +47,7 @@ internal class EContextView @JvmOverloads constructor(

init {
orientation = VERTICAL
val padding = resources.getDimension(R.dimen.standard_margin).toInt()
val padding = resources.getDimension(UICoreR.dimen.standard_margin).toInt()
setPadding(padding, padding, padding, 0)
}

Expand Down
Loading

0 comments on commit 7374f46

Please sign in to comment.