From 69e211ab363545fc0e2db5166c0bd182ccd5175b Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Wed, 23 Oct 2024 15:35:55 -0400 Subject: [PATCH 01/11] Initial API --- .../PaymentSheetPlaygroundActivity.kt | 29 +++ .../android/paymentsheet/PaymentSheet.kt | 220 +++++++++++++++++- .../com/stripe/android/uicore/StripeTheme.kt | 53 +++++ 3 files changed, 301 insertions(+), 1 deletion(-) diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt index f3dae62bfe9..335fba1308b 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt @@ -88,6 +88,35 @@ internal class PaymentSheetPlaygroundActivity : AppCompatActivity(), ExternalPay override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) +val radioAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Radio( + selectedColor = getColor(R.colors.primary), + unselectedColor = getColor(R.colors.secondary) +) + +val flatAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Flat( + separatorThicknessDp = 8.0f, + separatorColor = getColor(R.colors.border), + separatorInsetsDp = 4.0f, + topSeparatorEnabled = true, + bottomSeparatorEnabled = false, + radio = radioAppearance +) + +val floatingAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Floating( + spacingDp = 12.0f +) + +val rowAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Row( + additionalInsetsDp = 0.0f, + flat = flatAppearance, + floating = floatingAppearance +) + +val embeddedAppearance = PaymentSheet.EmbeddedPaymentElementAppearance( + row = rowAppearance, + style = PaymentSheet.EmbeddedPaymentElementAppearance.Style.FlatWithRadio +) + setContent { val paymentSheet = PaymentSheet.Builder(viewModel::onPaymentSheetResult) .externalPaymentMethodConfirmHandler(this) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index 9f29f9544a7..e2e5f8cbb63 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.graphics.toArgb import androidx.fragment.app.Fragment import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi import com.stripe.android.ExperimentalCardBrandFilteringApi +import com.stripe.android.Stripe import com.stripe.android.common.configuration.ConfigurationDefaults import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher import com.stripe.android.link.account.LinkStore @@ -944,6 +945,11 @@ class PaymentSheet internal constructor( * Describes the appearance of the primary button (e.g., the "Pay" button). */ val primaryButton: PrimaryButton = PrimaryButton(), + + /** + * Describes the appearance of the Embedded Payment Element + */ + val embeddedAppearance: EmbeddedPaymentElementAppearance = EmbeddedPaymentElementAppearance.default ) : Parcelable { constructor() : this( colorsLight = Colors.defaultLight, @@ -951,6 +957,7 @@ class PaymentSheet internal constructor( shapes = Shapes.default, typography = Typography.default, primaryButton = PrimaryButton(), + embeddedAppearance = EmbeddedPaymentElementAppearance.default ) fun getColors(isDark: Boolean): Colors { @@ -963,6 +970,8 @@ class PaymentSheet internal constructor( private var shapes = Shapes.default private var typography = Typography.default private var primaryButton: PrimaryButton = PrimaryButton() + private var embeddedAppearance: EmbeddedPaymentElementAppearance = + EmbeddedPaymentElementAppearance.default fun colorsLight(colors: Colors) = apply { this.colorsLight = colors @@ -984,8 +993,12 @@ class PaymentSheet internal constructor( this.primaryButton = primaryButton } + fun embeddedAppearance(embeddedAppearance: EmbeddedPaymentElementAppearance) = apply { + this.embeddedAppearance = embeddedAppearance + } + fun build(): Appearance { - return Appearance(colorsLight, colorsDark, shapes, typography, primaryButton) + return Appearance(colorsLight, colorsDark, shapes, typography, primaryButton, embeddedAppearance) } } } @@ -1163,6 +1176,209 @@ class PaymentSheet internal constructor( } } + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) + @Parcelize + data class EmbeddedPaymentElementAppearance( + val row: Row, + val style: Style + ) : Parcelable { + /** + * The display style options for the Embedded Mobile Payment Element. + */ + enum class Style { + /** + * A flat style with radio buttons. + */ + FlatWithRadio, + + /** + * A floating button style. + */ + FloatingButton + } + + companion object { + val default = EmbeddedPaymentElementAppearance( + row = Row.defaultLight, + style = Style.FlatWithRadio + ) + } + + /** + * Describes the appearance of the row in the Embedded Mobile Payment Element. + */ + @Parcelize + data class Row( + /** + * Additional vertical insets applied to a payment method row. + * - Note: Increasing this value increases the height of each row. + */ + val additionalInsetsDp: Float, + + /** + * Appearance settings for the flat style. + */ + val flat: Flat, + + /** + * Appearance settings for the floating button style + */ + val floating: Floating + ) : Parcelable { + constructor( + context: Context, + additionalInsetsDp: Int, + flat: Flat, + floating: Floating + ) : this( + additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp), + flat = flat, + floating = floating + ) + + companion object { + val defaultLight = Row( + additionalInsetsDp = StripeThemeDefaults.row.additionalInsets, + flat = Flat.defaultLight, + floating = Floating.default + ) + + val defaultDark = Row( + additionalInsetsDp = StripeThemeDefaults.row.additionalInsets, + flat = Flat.defaultDark, + floating = Floating.default + ) + } + } + + @Parcelize + data class Flat( + /** + * The thickness of the separator line between rows. + */ + val separatorThicknessDp: Float, + + /** + * The color of the separator line between rows. + */ + @ColorInt + val separatorColor: Int, + + /** + * The insets of the separator line between rows. + */ + val separatorInsetsDp: Float, + + /** + * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. + */ + val topSeparatorEnabled: Boolean, + + /** + * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. + */ + val bottomSeparatorEnabled: Boolean, + + /** + * Appearance settings for the radio button + */ + val radio: Radio + ) : Parcelable { + constructor( + context: Context, + separatorThicknessDp: Int, + separatorColor: Color, + separatorInsetsDp: Int, + topSeparatorEnabled: Boolean, + bottomSeparatorEnabled: Boolean, + radio: Radio + ) : this( + separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), + separatorColor = separatorColor.toArgb(), + separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), + topSeparatorEnabled = topSeparatorEnabled, + bottomSeparatorEnabled = bottomSeparatorEnabled, + radio = radio + ) + + companion object { + val defaultLight = Flat( + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + radio = Radio.defaultLight + ) + + val defaultDark = Flat( + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + radio = Radio.defaultDark + ) + } + } + + @Parcelize + data class Radio( + /** + * The color of the radio button when selected. + */ + @ColorInt + val selectedColor: Int, + + /** + * The color of the radio button when unselected. + */ + @ColorInt + val unselectedColor: Int + ) : Parcelable { + constructor( + selectedColor: Color, + unselectedColor: Color + ) : this( + selectedColor = selectedColor.toArgb(), + unselectedColor = unselectedColor.toArgb() + ) + + companion object { + val defaultLight = Radio( + selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary, + unselectedColor = StripeThemeDefaults.colorsLight.componentBorder + ) + + val defaultDark = Radio( + selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary, + unselectedColor = StripeThemeDefaults.colorsDark.componentBorder + ) + } + } + + @Parcelize + data class Floating( + /** + * The spacing between payment method rows + */ + val spacingDp: Float + ) : Parcelable { + constructor( + context: Context, + spacingDp: Int + ) : this( + spacingDp = context.getRawValueFromDimenResource(spacingDp) + ) + + companion object { + val default = Floating( + spacingDp = StripeThemeDefaults.floating.spacing + ) + } + } + } + @Parcelize data class PrimaryButton( /** @@ -2143,3 +2359,5 @@ class PaymentSheet internal constructor( } } } + +typealias embeddedTypography = PaymentSheet.Typography diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt index 43382f15ed1..ee2d34cea34 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt @@ -123,6 +123,32 @@ data class PrimaryButtonTypography( val fontSize: TextUnit ) +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class EmbeddedRowStyle( + val additionalInsets: Float, + val flat: EmbeddedFlatStyle +) + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class EmbeddedFlatStyle( + val separatorThickness: Float, + val separatorColor: Color, + val separatorInsets: Float, + val topSeparatorEnabled: Boolean, + val bottomSeparatorEnabled: Boolean +) + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class EmbeddedRadioStyle( + val selectedColor: Color, + val unselectedColor: Color +) + +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class EmbeddedFloatingStyle( + val spacing: Float +) + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) val PRIMARY_BUTTON_SUCCESS_BACKGROUND_COLOR = Color(0xFF24B47E) @@ -209,6 +235,33 @@ object StripeThemeDefaults { fontSize = typography.largeFontSize ) ) + + val flat = EmbeddedFlatStyle( + separatorThickness = 1.0f, + separatorColor = Color(0xFF787880), + separatorInsets = 0.0f, + topSeparatorEnabled = true, + bottomSeparatorEnabled = true + ) + + val row = EmbeddedRowStyle( + additionalInsets = 4.0f, + flat = flat + ) + + val floating = EmbeddedFloatingStyle( + spacing = 12.0f + ) + + val radioLight = EmbeddedRadioStyle( + selectedColor = colorsLight.materialColors.primary, + unselectedColor = colorsLight.componentBorder + ) + + val radioDark = EmbeddedRadioStyle( + selectedColor = colorsDark.materialColors.primary, + unselectedColor = colorsDark.componentBorder + ) } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) From 870bcd280b970cc574e51f1bf85d0a309ca08de2 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Fri, 25 Oct 2024 14:37:00 -0400 Subject: [PATCH 02/11] API v2 --- .../PaymentSheetPlaygroundActivity.kt | 18 +- .../android/paymentsheet/PaymentSheet.kt | 184 ++++++------------ 2 files changed, 66 insertions(+), 136 deletions(-) diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt index 335fba1308b..ce279ef7ad0 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt @@ -88,10 +88,6 @@ internal class PaymentSheetPlaygroundActivity : AppCompatActivity(), ExternalPay override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) -val radioAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Radio( - selectedColor = getColor(R.colors.primary), - unselectedColor = getColor(R.colors.secondary) -) val flatAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Flat( separatorThicknessDp = 8.0f, @@ -99,22 +95,18 @@ val flatAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Flat( separatorInsetsDp = 4.0f, topSeparatorEnabled = true, bottomSeparatorEnabled = false, - radio = radioAppearance ) -val floatingAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Floating( - spacingDp = 12.0f -) -val rowAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Row( - additionalInsetsDp = 0.0f, +val flatWithRadioStyle = PaymentSheet.EmbeddedPaymentElementAppearance.Style.FlatWithRadio( flat = flatAppearance, - floating = floatingAppearance + selectedColor = getColor(R.colors.primary), + unselectedColor = getColor(R.colors.secondary) ) val embeddedAppearance = PaymentSheet.EmbeddedPaymentElementAppearance( - row = rowAppearance, - style = PaymentSheet.EmbeddedPaymentElementAppearance.Style.FlatWithRadio + style = flatWithRadioStyle, + additionalInsetsDp = 0F ) setContent { diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index e2e5f8cbb63..5de0f127a61 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -1178,81 +1178,84 @@ class PaymentSheet internal constructor( @OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Parcelize - data class EmbeddedPaymentElementAppearance( - val row: Row, + class EmbeddedPaymentElementAppearance( + val additionalInsetsDp: Float, val style: Style ) : Parcelable { - /** - * The display style options for the Embedded Mobile Payment Element. - */ - enum class Style { - /** - * A flat style with radio buttons. - */ - FlatWithRadio, - - /** - * A floating button style. - */ - FloatingButton - } companion object { val default = EmbeddedPaymentElementAppearance( - row = Row.defaultLight, - style = Style.FlatWithRadio + additionalInsetsDp = StripeThemeDefaults.row.additionalInsets, + style = Style.FlatWithRadio.defaultLight ) } - /** - * Describes the appearance of the row in the Embedded Mobile Payment Element. - */ @Parcelize - data class Row( - /** - * Additional vertical insets applied to a payment method row. - * - Note: Increasing this value increases the height of each row. - */ - val additionalInsetsDp: Float, + sealed class Style : Parcelable { - /** - * Appearance settings for the flat style. - */ - val flat: Flat, - - /** - * Appearance settings for the floating button style - */ - val floating: Floating - ) : Parcelable { - constructor( - context: Context, - additionalInsetsDp: Int, - flat: Flat, - floating: Floating - ) : this( - additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp), - flat = flat, - floating = floating - ) - - companion object { - val defaultLight = Row( - additionalInsetsDp = StripeThemeDefaults.row.additionalInsets, - flat = Flat.defaultLight, - floating = Floating.default + @Parcelize + class FlatWithRadio( + val flat: Flat, + /** + * The color of the radio button when selected. + */ + @ColorInt + val selectedColor: Int, + + /** + * The color of the radio button when unselected. + */ + @ColorInt + val unselectedColor: Int + ) : Style() { + constructor( + flat: Flat, + selectedColor: Color, + unselectedColor: Color + ) : this( + flat = flat, + selectedColor = selectedColor.toArgb(), + unselectedColor = unselectedColor.toArgb() ) + companion object { + val defaultLight = FlatWithRadio( + flat = Flat.defaultLight, + selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary, + unselectedColor = StripeThemeDefaults.colorsLight.componentBorder, + ) + + val defaultDark = FlatWithRadio( + flat = Flat.defaultDark, + selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary, + unselectedColor = StripeThemeDefaults.colorsDark.componentBorder, + ) + } + } - val defaultDark = Row( - additionalInsetsDp = StripeThemeDefaults.row.additionalInsets, - flat = Flat.defaultDark, - floating = Floating.default + @Parcelize + class FloatingButton( + /** + * The spacing between payment method rows + */ + val spacingDp: Float + ) : Style() { + constructor( + context: Context, + spacingDp: Int + ) : this( + spacingDp = context.getRawValueFromDimenResource(spacingDp) ) + + companion object { + val default = FloatingButton( + spacingDp = StripeThemeDefaults.floating.spacing + ) + } } } @Parcelize - data class Flat( + class Flat( /** * The thickness of the separator line between rows. */ @@ -1278,11 +1281,6 @@ class PaymentSheet internal constructor( * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. */ val bottomSeparatorEnabled: Boolean, - - /** - * Appearance settings for the radio button - */ - val radio: Radio ) : Parcelable { constructor( context: Context, @@ -1291,14 +1289,12 @@ class PaymentSheet internal constructor( separatorInsetsDp: Int, topSeparatorEnabled: Boolean, bottomSeparatorEnabled: Boolean, - radio: Radio ) : this( separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), separatorColor = separatorColor.toArgb(), separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), topSeparatorEnabled = topSeparatorEnabled, bottomSeparatorEnabled = bottomSeparatorEnabled, - radio = radio ) companion object { @@ -1308,7 +1304,6 @@ class PaymentSheet internal constructor( separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, - radio = Radio.defaultLight ) val defaultDark = Flat( @@ -1317,63 +1312,6 @@ class PaymentSheet internal constructor( separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, - radio = Radio.defaultDark - ) - } - } - - @Parcelize - data class Radio( - /** - * The color of the radio button when selected. - */ - @ColorInt - val selectedColor: Int, - - /** - * The color of the radio button when unselected. - */ - @ColorInt - val unselectedColor: Int - ) : Parcelable { - constructor( - selectedColor: Color, - unselectedColor: Color - ) : this( - selectedColor = selectedColor.toArgb(), - unselectedColor = unselectedColor.toArgb() - ) - - companion object { - val defaultLight = Radio( - selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary, - unselectedColor = StripeThemeDefaults.colorsLight.componentBorder - ) - - val defaultDark = Radio( - selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary, - unselectedColor = StripeThemeDefaults.colorsDark.componentBorder - ) - } - } - - @Parcelize - data class Floating( - /** - * The spacing between payment method rows - */ - val spacingDp: Float - ) : Parcelable { - constructor( - context: Context, - spacingDp: Int - ) : this( - spacingDp = context.getRawValueFromDimenResource(spacingDp) - ) - - companion object { - val default = Floating( - spacingDp = StripeThemeDefaults.floating.spacing ) } } From aeecdfb9811bd5471649e93bc007c356dd103181 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Tue, 29 Oct 2024 17:33:02 -0400 Subject: [PATCH 03/11] Test --- .../PaymentSheetPlaygroundActivity.kt | 44 +++-- .../ExperimentalEmbeddedPaymentElementApi.kt | 11 ++ .../android/paymentsheet/PaymentSheet.kt | 171 +++++++++--------- 3 files changed, 120 insertions(+), 106 deletions(-) create mode 100644 paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt index ce279ef7ad0..c0ab9a0defe 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.stripe.android.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.customersheet.CustomerSheet import com.stripe.android.customersheet.CustomerSheetResult import com.stripe.android.customersheet.rememberCustomerSheet @@ -83,31 +84,36 @@ internal class PaymentSheetPlaygroundActivity : AppCompatActivity(), ExternalPay ) } - @OptIn(ExperimentalCustomerSessionApi::class) + //@OptIn(ExperimentalCustomerSessionApi::class, ExperimentalEmbeddedPaymentElementApi::class) + //@OptIn(ExperimentalEmbeddedPaymentElementApi::class) + //@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Suppress("LongMethod") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + val flatWithRadioStyle = PaymentSheet.EmbeddedPaymentElement.RowStyle.FlatWithRadio( + separatorThicknessDp = 8.0f, + separatorColor = getColor(R.colors.border), + separatorInsetsDp = 4.0f, + topSeparatorEnabled = true, + bottomSeparatorEnabled = false, + selectedColor = getColor(R.colors.primary), + unselectedColor = getColor(R.colors.secondary) + ) + val embeddedAppearance = PaymentSheet.EmbeddedPaymentElement( + style = flatWithRadioStyle, + ) + val app = PaymentSheet.Appearance( + colorsLight = PaymentSheet.Colors.defaultLight, + colorsDark = PaymentSheet.Colors.defaultDark, + shapes = PaymentSheet.Shapes(0f, 0f), + typography = PaymentSheet.Typography.default, + primaryButton = PaymentSheet.PrimaryButton(), + ) -val flatAppearance = PaymentSheet.EmbeddedPaymentElementAppearance.Flat( - separatorThicknessDp = 8.0f, - separatorColor = getColor(R.colors.border), - separatorInsetsDp = 4.0f, - topSeparatorEnabled = true, - bottomSeparatorEnabled = false, -) - - -val flatWithRadioStyle = PaymentSheet.EmbeddedPaymentElementAppearance.Style.FlatWithRadio( - flat = flatAppearance, - selectedColor = getColor(R.colors.primary), - unselectedColor = getColor(R.colors.secondary) -) + val app2 = PaymentSheet.Appearance() -val embeddedAppearance = PaymentSheet.EmbeddedPaymentElementAppearance( - style = flatWithRadioStyle, - additionalInsetsDp = 0F -) + val appBuilder = PaymentSheet.Appearance.Builder().typography(PaymentSheet.Typography.default).build() setContent { val paymentSheet = PaymentSheet.Builder(viewModel::onPaymentSheetResult) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt new file mode 100644 index 00000000000..32ffb5bd061 --- /dev/null +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt @@ -0,0 +1,11 @@ +package com.stripe.android.paymentsheet + +import androidx.annotation.RestrictTo + +@RequiresOptIn( + level = RequiresOptIn.Level.ERROR, + message = "This API is under construction. It can be changed or removed at any time (use at your own risk)" +) +@Retention(AnnotationRetention.BINARY) +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +annotation class ExperimentalEmbeddedPaymentElementApi \ No newline at end of file diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index 5de0f127a61..11aff831a0d 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -11,9 +11,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.fragment.app.Fragment +import com.google.android.gms.common.internal.safeparcel.SafeParcelable import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi import com.stripe.android.ExperimentalCardBrandFilteringApi -import com.stripe.android.Stripe +import com.stripe.android.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.common.configuration.ConfigurationDefaults import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher import com.stripe.android.link.account.LinkStore @@ -949,7 +950,8 @@ class PaymentSheet internal constructor( /** * Describes the appearance of the Embedded Payment Element */ - val embeddedAppearance: EmbeddedPaymentElementAppearance = EmbeddedPaymentElementAppearance.default + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) + internal val embeddedAppearance: EmbeddedPaymentElement = EmbeddedPaymentElement.default ) : Parcelable { constructor() : this( colorsLight = Colors.defaultLight, @@ -957,7 +959,22 @@ class PaymentSheet internal constructor( shapes = Shapes.default, typography = Typography.default, primaryButton = PrimaryButton(), - embeddedAppearance = EmbeddedPaymentElementAppearance.default + ) + + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) + constructor( + colorsLight: Colors, + colorsDark: Colors, + shapes: Shapes, + typography: Typography, + primaryButton: PrimaryButton, + ) : this( + colorsLight =colorsLight , + colorsDark = colorsDark, + shapes = shapes, + typography = typography, + primaryButton = primaryButton, + embeddedAppearance = EmbeddedPaymentElement.default ) fun getColors(isDark: Boolean): Colors { @@ -970,8 +987,9 @@ class PaymentSheet internal constructor( private var shapes = Shapes.default private var typography = Typography.default private var primaryButton: PrimaryButton = PrimaryButton() - private var embeddedAppearance: EmbeddedPaymentElementAppearance = - EmbeddedPaymentElementAppearance.default + @ExperimentalEmbeddedPaymentElementApi + private var embeddedAppearance: EmbeddedPaymentElement = + EmbeddedPaymentElement.default fun colorsLight(colors: Colors) = apply { this.colorsLight = colors @@ -993,10 +1011,12 @@ class PaymentSheet internal constructor( this.primaryButton = primaryButton } - fun embeddedAppearance(embeddedAppearance: EmbeddedPaymentElementAppearance) = apply { + @ExperimentalEmbeddedPaymentElementApi + fun embeddedAppearance(embeddedAppearance: EmbeddedPaymentElement) = apply { this.embeddedAppearance = embeddedAppearance } + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) fun build(): Appearance { return Appearance(colorsLight, colorsDark, shapes, typography, primaryButton, embeddedAppearance) } @@ -1176,26 +1196,48 @@ class PaymentSheet internal constructor( } } - @OptIn(ExperimentalEmbeddedPaymentElementApi::class) + @ExperimentalEmbeddedPaymentElementApi @Parcelize - class EmbeddedPaymentElementAppearance( - val additionalInsetsDp: Float, - val style: Style + class EmbeddedPaymentElement( + val style: RowStyle ) : Parcelable { companion object { - val default = EmbeddedPaymentElementAppearance( - additionalInsetsDp = StripeThemeDefaults.row.additionalInsets, - style = Style.FlatWithRadio.defaultLight + val default = EmbeddedPaymentElement( + style = RowStyle.FlatWithRadio.defaultLight ) } @Parcelize - sealed class Style : Parcelable { + sealed class RowStyle : Parcelable { @Parcelize class FlatWithRadio( - val flat: Flat, + /** + * The thickness of the separator line between rows. + */ + val separatorThicknessDp: Float, + + /** + * The color of the separator line between rows. + */ + @ColorInt + val separatorColor: Int, + + /** + * The insets of the separator line between rows. + */ + val separatorInsetsDp: Float, + + /** + * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. + */ + val topSeparatorEnabled: Boolean, + + /** + * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. + */ + val bottomSeparatorEnabled: Boolean, /** * The color of the radio button when selected. */ @@ -1207,27 +1249,44 @@ class PaymentSheet internal constructor( */ @ColorInt val unselectedColor: Int - ) : Style() { + ) : RowStyle() { constructor( - flat: Flat, + context: Context, + separatorThicknessDp: Int, + separatorColor: Color, + separatorInsetsDp: Int, + topSeparatorEnabled: Boolean, + bottomSeparatorEnabled: Boolean, selectedColor: Color, unselectedColor: Color ) : this( - flat = flat, + separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), + separatorColor = separatorColor.toArgb(), + separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), + topSeparatorEnabled = topSeparatorEnabled, + bottomSeparatorEnabled = bottomSeparatorEnabled, selectedColor = selectedColor.toArgb(), unselectedColor = unselectedColor.toArgb() ) companion object { val defaultLight = FlatWithRadio( - flat = Flat.defaultLight, - selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary, - unselectedColor = StripeThemeDefaults.colorsLight.componentBorder, + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), + unselectedColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), ) val defaultDark = FlatWithRadio( - flat = Flat.defaultDark, - selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary, - unselectedColor = StripeThemeDefaults.colorsDark.componentBorder, + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), + unselectedColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), ) } } @@ -1238,7 +1297,7 @@ class PaymentSheet internal constructor( * The spacing between payment method rows */ val spacingDp: Float - ) : Style() { + ) : RowStyle() { constructor( context: Context, spacingDp: Int @@ -1253,68 +1312,6 @@ class PaymentSheet internal constructor( } } } - - @Parcelize - class Flat( - /** - * The thickness of the separator line between rows. - */ - val separatorThicknessDp: Float, - - /** - * The color of the separator line between rows. - */ - @ColorInt - val separatorColor: Int, - - /** - * The insets of the separator line between rows. - */ - val separatorInsetsDp: Float, - - /** - * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. - */ - val topSeparatorEnabled: Boolean, - - /** - * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. - */ - val bottomSeparatorEnabled: Boolean, - ) : Parcelable { - constructor( - context: Context, - separatorThicknessDp: Int, - separatorColor: Color, - separatorInsetsDp: Int, - topSeparatorEnabled: Boolean, - bottomSeparatorEnabled: Boolean, - ) : this( - separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), - separatorColor = separatorColor.toArgb(), - separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), - topSeparatorEnabled = topSeparatorEnabled, - bottomSeparatorEnabled = bottomSeparatorEnabled, - ) - - companion object { - val defaultLight = Flat( - separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, - separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), - separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, - topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, - bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, - ) - - val defaultDark = Flat( - separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, - separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), - separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, - topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, - bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, - ) - } - } } @Parcelize From 07159e2e44ac32f2eb98612374a9a1e5ddba9d00 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Wed, 30 Oct 2024 14:15:33 -0400 Subject: [PATCH 04/11] test two --- .../PaymentSheetPlaygroundActivity.kt | 40 +- .../android/paymentsheet/PaymentSheet.kt | 575 ++++++++++++++---- .../com/stripe/android/uicore/StripeTheme.kt | 28 +- 3 files changed, 476 insertions(+), 167 deletions(-) diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt index c0ab9a0defe..e45e749e774 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt @@ -45,6 +45,7 @@ import com.stripe.android.customersheet.CustomerSheetResult import com.stripe.android.customersheet.rememberCustomerSheet import com.stripe.android.model.PaymentMethod import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi +import com.stripe.android.paymentsheet.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.paymentsheet.ExternalPaymentMethodConfirmHandler import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.addresselement.AddressLauncher @@ -87,33 +88,26 @@ internal class PaymentSheetPlaygroundActivity : AppCompatActivity(), ExternalPay //@OptIn(ExperimentalCustomerSessionApi::class, ExperimentalEmbeddedPaymentElementApi::class) //@OptIn(ExperimentalEmbeddedPaymentElementApi::class) //@OptIn(ExperimentalEmbeddedPaymentElementApi::class) + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Suppress("LongMethod") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val flatWithRadioStyle = PaymentSheet.EmbeddedPaymentElement.RowStyle.FlatWithRadio( - separatorThicknessDp = 8.0f, - separatorColor = getColor(R.colors.border), - separatorInsetsDp = 4.0f, - topSeparatorEnabled = true, - bottomSeparatorEnabled = false, - selectedColor = getColor(R.colors.primary), - unselectedColor = getColor(R.colors.secondary) - ) - val embeddedAppearance = PaymentSheet.EmbeddedPaymentElement( - style = flatWithRadioStyle, - ) - val app = PaymentSheet.Appearance( - colorsLight = PaymentSheet.Colors.defaultLight, - colorsDark = PaymentSheet.Colors.defaultDark, - shapes = PaymentSheet.Shapes(0f, 0f), - typography = PaymentSheet.Typography.default, - primaryButton = PaymentSheet.PrimaryButton(), - ) - - val app2 = PaymentSheet.Appearance() - - val appBuilder = PaymentSheet.Appearance.Builder().typography(PaymentSheet.Typography.default).build() +val flatWithRadioStyle = PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio( + separatorThicknessDp = 8.0f, + separatorColor = getColor(R.colors.border), + separatorInsetsDp = 4.0f, + topSeparatorEnabled = true, + bottomSeparatorEnabled = false, + selectedColor = getColor(R.colors.primary), + unselectedColor = getColor(R.colors.secondary), + additionalInsetsDp = 12f +) +val embeddedAppearance = PaymentSheet.Appearance.Embedded( + style = flatWithRadioStyle, +) + +val appBuilder = PaymentSheet.Appearance.Builder().embeddedAppearance(embeddedAppearance).build() setContent { val paymentSheet = PaymentSheet.Builder(viewModel::onPaymentSheetResult) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index 11aff831a0d..2e53da76d96 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -11,10 +11,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb import androidx.fragment.app.Fragment -import com.google.android.gms.common.internal.safeparcel.SafeParcelable import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi import com.stripe.android.ExperimentalCardBrandFilteringApi -import com.stripe.android.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.common.configuration.ConfigurationDefaults import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher import com.stripe.android.link.account.LinkStore @@ -921,6 +919,7 @@ class PaymentSheet internal constructor( } @Parcelize + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) data class Appearance( /** * Describes the colors used while the system is in light mode. @@ -950,8 +949,7 @@ class PaymentSheet internal constructor( /** * Describes the appearance of the Embedded Payment Element */ - @OptIn(ExperimentalEmbeddedPaymentElementApi::class) - internal val embeddedAppearance: EmbeddedPaymentElement = EmbeddedPaymentElement.default + internal val embeddedAppearance: Embedded = Embedded.default ) : Parcelable { constructor() : this( colorsLight = Colors.defaultLight, @@ -974,13 +972,236 @@ class PaymentSheet internal constructor( shapes = shapes, typography = typography, primaryButton = primaryButton, - embeddedAppearance = EmbeddedPaymentElement.default + embeddedAppearance = Embedded.default ) fun getColors(isDark: Boolean): Colors { return if (isDark) colorsDark else colorsLight } + @ExperimentalEmbeddedPaymentElementApi + @Parcelize + class Embedded( + internal val style: RowStyle + ) : Parcelable { + + internal companion object { + val default = Embedded( + style = RowStyle.FlatWithRadio.defaultLight + ) + } + + @Parcelize + sealed class RowStyle : Parcelable { + + @Parcelize + class FlatWithRadio( + /** + * The thickness of the separator line between rows. + */ + val separatorThicknessDp: Float, + + /** + * The color of the separator line between rows. + */ + @ColorInt + val separatorColor: Int, + + /** + * The insets of the separator line between rows. + */ + val separatorInsetsDp: Float, + + /** + * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. + */ + val topSeparatorEnabled: Boolean, + + /** + * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. + */ + val bottomSeparatorEnabled: Boolean, + /** + * The color of the radio button when selected. + */ + @ColorInt + val selectedColor: Int, + + /** + * The color of the radio button when unselected. + */ + @ColorInt + val unselectedColor: Int, + /** + * Additional vertical insets applied to a payment method row. + * - Note: Increasing this value increases the height of each row. + */ + val additionalInsetsDp: Float, + ) : RowStyle() { + constructor( + context: Context, + separatorThicknessDp: Int, + separatorColor: Color, + separatorInsetsDp: Int, + topSeparatorEnabled: Boolean, + bottomSeparatorEnabled: Boolean, + selectedColor: Color, + unselectedColor: Color, + additionalInsetsDp: Int + ) : this( + separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), + separatorColor = separatorColor.toArgb(), + separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), + topSeparatorEnabled = topSeparatorEnabled, + bottomSeparatorEnabled = bottomSeparatorEnabled, + selectedColor = selectedColor.toArgb(), + unselectedColor = unselectedColor.toArgb(), + additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) + ) + internal companion object { + val defaultLight = FlatWithRadio( + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), + unselectedColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), + additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp + ) + + val defaultDark = FlatWithRadio( + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), + unselectedColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), + additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp + ) + } + } + + @Parcelize + class FlatWithCheckmark( + /** + * The thickness of the separator line between rows. + */ + val separatorThicknessDp: Float, + + /** + * The color of the separator line between rows. + */ + @ColorInt + val separatorColor: Int, + + /** + * The insets of the separator line between rows. + */ + val separatorInsetsDp: Float, + + /** + * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. + */ + val topSeparatorEnabled: Boolean, + + /** + * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. + */ + val bottomSeparatorEnabled: Boolean, + /** + * The color of the checkmark. + */ + @ColorInt + val checkmarkColor: Int, + /** + * Inset of the checkmark from the end of the row + */ + val checkmarkInsetDp: Float, + /** + * Additional vertical insets applied to a payment method row. + * - Note: Increasing this value increases the height of each row. + */ + val additionalInsetsDp: Float, + ) : RowStyle() { + constructor( + context: Context, + separatorThicknessDp: Int, + separatorColor: Color, + separatorInsetsDp: Int, + topSeparatorEnabled: Boolean, + bottomSeparatorEnabled: Boolean, + checkmarkColor: Color, + checkmarkInsetDp: Int, + additionalInsetsDp: Int + ) : this( + separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), + separatorColor = separatorColor.toArgb(), + separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), + topSeparatorEnabled = topSeparatorEnabled, + bottomSeparatorEnabled = bottomSeparatorEnabled, + checkmarkColor = checkmarkColor.toArgb(), + checkmarkInsetDp = context.getRawValueFromDimenResource(checkmarkInsetDp), + additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) + ) + internal companion object { + val defaultLight = FlatWithCheckmark( + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + checkmarkColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), + checkmarkInsetDp = StripeThemeDefaults.embeddedCommon.checkmarkInsetDp, + additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp + ) + + val defaultDark = FlatWithCheckmark( + separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, + separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), + separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, + topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, + bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, + checkmarkColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), + checkmarkInsetDp = StripeThemeDefaults.embeddedCommon.checkmarkInsetDp, + additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp + ) + } + } + + @Parcelize + class FloatingButton( + /** + * The spacing between payment method rows + */ + val spacingDp: Float, + /** + * Additional vertical insets applied to a payment method row. + * - Note: Increasing this value increases the height of each row. + */ + val additionalInsetsDp: Float, + ) : RowStyle() { + constructor( + context: Context, + spacingDp: Int, + additionalInsetsDp: Int + ) : this( + spacingDp = context.getRawValueFromDimenResource(spacingDp), + additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) + ) + + internal companion object { + val default = FloatingButton( + spacingDp = StripeThemeDefaults.floating.spacing, + additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp + ) + } + } + } + } + + class Builder { private var colorsLight = Colors.defaultLight private var colorsDark = Colors.defaultDark @@ -988,8 +1209,8 @@ class PaymentSheet internal constructor( private var typography = Typography.default private var primaryButton: PrimaryButton = PrimaryButton() @ExperimentalEmbeddedPaymentElementApi - private var embeddedAppearance: EmbeddedPaymentElement = - EmbeddedPaymentElement.default + private var embeddedAppearance: Embedded = + Embedded.default fun colorsLight(colors: Colors) = apply { this.colorsLight = colors @@ -1012,7 +1233,7 @@ class PaymentSheet internal constructor( } @ExperimentalEmbeddedPaymentElementApi - fun embeddedAppearance(embeddedAppearance: EmbeddedPaymentElement) = apply { + fun embeddedAppearance(embeddedAppearance: Embedded) = apply { this.embeddedAppearance = embeddedAppearance } @@ -1196,123 +1417,227 @@ class PaymentSheet internal constructor( } } - @ExperimentalEmbeddedPaymentElementApi - @Parcelize - class EmbeddedPaymentElement( - val style: RowStyle - ) : Parcelable { - - companion object { - val default = EmbeddedPaymentElement( - style = RowStyle.FlatWithRadio.defaultLight - ) - } - - @Parcelize - sealed class RowStyle : Parcelable { - - @Parcelize - class FlatWithRadio( - /** - * The thickness of the separator line between rows. - */ - val separatorThicknessDp: Float, - - /** - * The color of the separator line between rows. - */ - @ColorInt - val separatorColor: Int, - - /** - * The insets of the separator line between rows. - */ - val separatorInsetsDp: Float, - - /** - * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. - */ - val topSeparatorEnabled: Boolean, - - /** - * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. - */ - val bottomSeparatorEnabled: Boolean, - /** - * The color of the radio button when selected. - */ - @ColorInt - val selectedColor: Int, - - /** - * The color of the radio button when unselected. - */ - @ColorInt - val unselectedColor: Int - ) : RowStyle() { - constructor( - context: Context, - separatorThicknessDp: Int, - separatorColor: Color, - separatorInsetsDp: Int, - topSeparatorEnabled: Boolean, - bottomSeparatorEnabled: Boolean, - selectedColor: Color, - unselectedColor: Color - ) : this( - separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), - separatorColor = separatorColor.toArgb(), - separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), - topSeparatorEnabled = topSeparatorEnabled, - bottomSeparatorEnabled = bottomSeparatorEnabled, - selectedColor = selectedColor.toArgb(), - unselectedColor = unselectedColor.toArgb() - ) - companion object { - val defaultLight = FlatWithRadio( - separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, - separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), - separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, - topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, - bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, - selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), - unselectedColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), - ) - - val defaultDark = FlatWithRadio( - separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, - separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), - separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, - topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, - bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, - selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), - unselectedColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), - ) - } - } - - @Parcelize - class FloatingButton( - /** - * The spacing between payment method rows - */ - val spacingDp: Float - ) : RowStyle() { - constructor( - context: Context, - spacingDp: Int - ) : this( - spacingDp = context.getRawValueFromDimenResource(spacingDp) - ) - - companion object { - val default = FloatingButton( - spacingDp = StripeThemeDefaults.floating.spacing - ) - } - } - } - } +// @ExperimentalEmbeddedPaymentElementApi +// @Parcelize +// class EmbeddedPaymentElement( +// val style: RowStyle +// ) : Parcelable { +// +// companion object { +// val default = EmbeddedPaymentElement( +// style = RowStyle.FlatWithRadio.defaultLight +// ) +// } +// +// @Parcelize +// sealed class RowStyle : Parcelable { +// +// @Parcelize +// class FlatWithRadio( +// /** +// * The thickness of the separator line between rows. +// */ +// val separatorThicknessDp: Float, +// +// /** +// * The color of the separator line between rows. +// */ +// @ColorInt +// val separatorColor: Int, +// +// /** +// * The insets of the separator line between rows. +// */ +// val separatorInsetsDp: Float, +// +// /** +// * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. +// */ +// val topSeparatorEnabled: Boolean, +// +// /** +// * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. +// */ +// val bottomSeparatorEnabled: Boolean, +// /** +// * The color of the radio button when selected. +// */ +// @ColorInt +// val selectedColor: Int, +// +// /** +// * The color of the radio button when unselected. +// */ +// @ColorInt +// val unselectedColor: Int, +// /** +// * Additional vertical insets applied to a payment method row. +// * - Note: Increasing this value increases the height of each row. +// */ +// val additionalInsetsDp: Float, +// ) : RowStyle() { +// constructor( +// context: Context, +// separatorThicknessDp: Int, +// separatorColor: Color, +// separatorInsetsDp: Int, +// topSeparatorEnabled: Boolean, +// bottomSeparatorEnabled: Boolean, +// selectedColor: Color, +// unselectedColor: Color, +// additionalInsetsDp: Int +// ) : this( +// separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), +// separatorColor = separatorColor.toArgb(), +// separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), +// topSeparatorEnabled = topSeparatorEnabled, +// bottomSeparatorEnabled = bottomSeparatorEnabled, +// selectedColor = selectedColor.toArgb(), +// unselectedColor = unselectedColor.toArgb(), +// additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) +// ) +// companion object { +// val defaultLight = FlatWithRadio( +// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, +// separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), +// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, +// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, +// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, +// selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), +// unselectedColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), +// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp +// ) +// +// val defaultDark = FlatWithRadio( +// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, +// separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), +// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, +// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, +// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, +// selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), +// unselectedColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), +// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp +// ) +// } +// } +// +// @Parcelize +// class FlatWithCheckmark( +// /** +// * The thickness of the separator line between rows. +// */ +// val separatorThicknessDp: Float, +// +// /** +// * The color of the separator line between rows. +// */ +// @ColorInt +// val separatorColor: Int, +// +// /** +// * The insets of the separator line between rows. +// */ +// val separatorInsetsDp: Float, +// +// /** +// * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. +// */ +// val topSeparatorEnabled: Boolean, +// +// /** +// * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. +// */ +// val bottomSeparatorEnabled: Boolean, +// /** +// * The color of the checkmark. +// */ +// @ColorInt +// val checkmarkColor: Int, +// /** +// * Inset of the checkmark from the end of the row +// */ +// val checkmarkInsetDp: Float, +// /** +// * Additional vertical insets applied to a payment method row. +// * - Note: Increasing this value increases the height of each row. +// */ +// val additionalInsetsDp: Float, +// ) : RowStyle() { +// constructor( +// context: Context, +// separatorThicknessDp: Int, +// separatorColor: Color, +// separatorInsetsDp: Int, +// topSeparatorEnabled: Boolean, +// bottomSeparatorEnabled: Boolean, +// checkmarkColor: Color, +// checkmarkInsetDp: Int, +// additionalInsetsDp: Int +// ) : this( +// separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), +// separatorColor = separatorColor.toArgb(), +// separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), +// topSeparatorEnabled = topSeparatorEnabled, +// bottomSeparatorEnabled = bottomSeparatorEnabled, +// checkmarkColor = checkmarkColor.toArgb(), +// checkmarkInsetDp = context.getRawValueFromDimenResource(checkmarkInsetDp), +// additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) +// ) +// companion object { +// val defaultLight = FlatWithCheckmark( +// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, +// separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), +// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, +// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, +// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, +// checkmarkColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), +// checkmarkInsetDp = StripeThemeDefaults.embeddedCommon.checkmarkInsetDp, +// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp +// ) +// +// val defaultDark = FlatWithCheckmark( +// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, +// separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), +// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, +// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, +// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, +// checkmarkColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), +// checkmarkInsetDp = StripeThemeDefaults.embeddedCommon.checkmarkInsetDp, +// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp +// ) +// } +// } +// +// @Parcelize +// class FloatingButton( +// /** +// * The spacing between payment method rows +// */ +// val spacingDp: Float, +// /** +// * Additional vertical insets applied to a payment method row. +// * - Note: Increasing this value increases the height of each row. +// */ +// val additionalInsetsDp: Float, +// ) : RowStyle() { +// constructor( +// context: Context, +// spacingDp: Int, +// additionalInsetsDp: Int +// ) : this( +// spacingDp = context.getRawValueFromDimenResource(spacingDp), +// additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) +// ) +// +// companion object { +// val default = FloatingButton( +// spacingDp = StripeThemeDefaults.floating.spacing, +// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp +// ) +// } +// } +// } +// } @Parcelize data class PrimaryButton( diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt index ee2d34cea34..5682cc59447 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt @@ -123,12 +123,6 @@ data class PrimaryButtonTypography( val fontSize: TextUnit ) -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -data class EmbeddedRowStyle( - val additionalInsets: Float, - val flat: EmbeddedFlatStyle -) - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class EmbeddedFlatStyle( val separatorThickness: Float, @@ -144,6 +138,12 @@ data class EmbeddedRadioStyle( val unselectedColor: Color ) +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +data class EmbeddedInsets( + val checkmarkInsetDp: Float, + val additionalInsetsDp: Float +) + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class EmbeddedFloatingStyle( val spacing: Float @@ -244,24 +244,14 @@ object StripeThemeDefaults { bottomSeparatorEnabled = true ) - val row = EmbeddedRowStyle( - additionalInsets = 4.0f, - flat = flat + val embeddedCommon = EmbeddedInsets( + additionalInsetsDp = 4.0f, + checkmarkInsetDp = 12.0f ) val floating = EmbeddedFloatingStyle( spacing = 12.0f ) - - val radioLight = EmbeddedRadioStyle( - selectedColor = colorsLight.materialColors.primary, - unselectedColor = colorsLight.componentBorder - ) - - val radioDark = EmbeddedRadioStyle( - selectedColor = colorsDark.materialColors.primary, - unselectedColor = colorsDark.componentBorder - ) } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) From be7e7e98138e1cfefdf8c592c6cebacbed5a80a7 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Mon, 25 Nov 2024 14:08:02 -0500 Subject: [PATCH 05/11] Cleanup --- .../PaymentSheetPlaygroundActivity.kt | 23 +- .../ExperimentalEmbeddedPaymentElementApi.kt | 11 - .../android/paymentsheet/PaymentSheet.kt | 235 +----------------- .../com/stripe/android/uicore/StripeTheme.kt | 6 - 4 files changed, 8 insertions(+), 267 deletions(-) delete mode 100644 paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt index 0a5eca88969..ecdec0b463d 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/PaymentSheetPlaygroundActivity.kt @@ -39,13 +39,11 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.stripe.android.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.customersheet.CustomerSheet import com.stripe.android.customersheet.CustomerSheetResult import com.stripe.android.customersheet.rememberCustomerSheet import com.stripe.android.model.PaymentMethod import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi -import com.stripe.android.paymentsheet.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.paymentsheet.ExternalPaymentMethodConfirmHandler import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.addresselement.AddressLauncher @@ -86,30 +84,11 @@ internal class PaymentSheetPlaygroundActivity : AppCompatActivity(), ExternalPay ) } - //@OptIn(ExperimentalCustomerSessionApi::class, ExperimentalEmbeddedPaymentElementApi::class) - //@OptIn(ExperimentalEmbeddedPaymentElementApi::class) - //@OptIn(ExperimentalEmbeddedPaymentElementApi::class) - @OptIn(ExperimentalEmbeddedPaymentElementApi::class) + @OptIn(ExperimentalCustomerSessionApi::class) @Suppress("LongMethod") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) -val flatWithRadioStyle = PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio( - separatorThicknessDp = 8.0f, - separatorColor = getColor(R.colors.border), - separatorInsetsDp = 4.0f, - topSeparatorEnabled = true, - bottomSeparatorEnabled = false, - selectedColor = getColor(R.colors.primary), - unselectedColor = getColor(R.colors.secondary), - additionalInsetsDp = 12f -) -val embeddedAppearance = PaymentSheet.Appearance.Embedded( - style = flatWithRadioStyle, -) - -val appBuilder = PaymentSheet.Appearance.Builder().embeddedAppearance(embeddedAppearance).build() - setContent { val paymentSheet = PaymentSheet.Builder(viewModel::onPaymentSheetResult) .externalPaymentMethodConfirmHandler(this) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt deleted file mode 100644 index 32ffb5bd061..00000000000 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/ExperimentalEmbeddedPaymentElementApi.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.stripe.android.paymentsheet - -import androidx.annotation.RestrictTo - -@RequiresOptIn( - level = RequiresOptIn.Level.ERROR, - message = "This API is under construction. It can be changed or removed at any time (use at your own risk)" -) -@Retention(AnnotationRetention.BINARY) -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -annotation class ExperimentalEmbeddedPaymentElementApi \ No newline at end of file diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index 93283ce9884..0d797cd2785 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -18,6 +18,7 @@ import com.stripe.android.link.account.LinkStore import com.stripe.android.model.CardBrand import com.stripe.android.model.PaymentIntent import com.stripe.android.model.SetupIntent +import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.paymentelement.confirmation.intent.IntentConfirmationInterceptor import com.stripe.android.paymentsheet.addresselement.AddressDetails import com.stripe.android.paymentsheet.flowcontroller.FlowControllerFactory @@ -929,7 +930,7 @@ class PaymentSheet internal constructor( typography: Typography, primaryButton: PrimaryButton, ) : this( - colorsLight =colorsLight , + colorsLight = colorsLight, colorsDark = colorsDark, shapes = shapes, typography = typography, @@ -980,7 +981,8 @@ class PaymentSheet internal constructor( val topSeparatorEnabled: Boolean, /** - * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. + * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment + * Element. */ val bottomSeparatorEnabled: Boolean, /** @@ -1069,7 +1071,8 @@ class PaymentSheet internal constructor( val topSeparatorEnabled: Boolean, /** - * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. + * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment + * Element. */ val bottomSeparatorEnabled: Boolean, /** @@ -1163,13 +1166,13 @@ class PaymentSheet internal constructor( } } - class Builder { private var colorsLight = Colors.defaultLight private var colorsDark = Colors.defaultDark private var shapes = Shapes.default private var typography = Typography.default private var primaryButton: PrimaryButton = PrimaryButton() + @ExperimentalEmbeddedPaymentElementApi private var embeddedAppearance: Embedded = Embedded.default @@ -1379,228 +1382,6 @@ class PaymentSheet internal constructor( } } -// @ExperimentalEmbeddedPaymentElementApi -// @Parcelize -// class EmbeddedPaymentElement( -// val style: RowStyle -// ) : Parcelable { -// -// companion object { -// val default = EmbeddedPaymentElement( -// style = RowStyle.FlatWithRadio.defaultLight -// ) -// } -// -// @Parcelize -// sealed class RowStyle : Parcelable { -// -// @Parcelize -// class FlatWithRadio( -// /** -// * The thickness of the separator line between rows. -// */ -// val separatorThicknessDp: Float, -// -// /** -// * The color of the separator line between rows. -// */ -// @ColorInt -// val separatorColor: Int, -// -// /** -// * The insets of the separator line between rows. -// */ -// val separatorInsetsDp: Float, -// -// /** -// * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. -// */ -// val topSeparatorEnabled: Boolean, -// -// /** -// * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. -// */ -// val bottomSeparatorEnabled: Boolean, -// /** -// * The color of the radio button when selected. -// */ -// @ColorInt -// val selectedColor: Int, -// -// /** -// * The color of the radio button when unselected. -// */ -// @ColorInt -// val unselectedColor: Int, -// /** -// * Additional vertical insets applied to a payment method row. -// * - Note: Increasing this value increases the height of each row. -// */ -// val additionalInsetsDp: Float, -// ) : RowStyle() { -// constructor( -// context: Context, -// separatorThicknessDp: Int, -// separatorColor: Color, -// separatorInsetsDp: Int, -// topSeparatorEnabled: Boolean, -// bottomSeparatorEnabled: Boolean, -// selectedColor: Color, -// unselectedColor: Color, -// additionalInsetsDp: Int -// ) : this( -// separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), -// separatorColor = separatorColor.toArgb(), -// separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), -// topSeparatorEnabled = topSeparatorEnabled, -// bottomSeparatorEnabled = bottomSeparatorEnabled, -// selectedColor = selectedColor.toArgb(), -// unselectedColor = unselectedColor.toArgb(), -// additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) -// ) -// companion object { -// val defaultLight = FlatWithRadio( -// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, -// separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), -// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, -// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, -// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, -// selectedColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), -// unselectedColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), -// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp -// ) -// -// val defaultDark = FlatWithRadio( -// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, -// separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), -// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, -// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, -// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, -// selectedColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), -// unselectedColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), -// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp -// ) -// } -// } -// -// @Parcelize -// class FlatWithCheckmark( -// /** -// * The thickness of the separator line between rows. -// */ -// val separatorThicknessDp: Float, -// -// /** -// * The color of the separator line between rows. -// */ -// @ColorInt -// val separatorColor: Int, -// -// /** -// * The insets of the separator line between rows. -// */ -// val separatorInsetsDp: Float, -// -// /** -// * Determines if the top separator is visible at the top of the Embedded Mobile Payment Element. -// */ -// val topSeparatorEnabled: Boolean, -// -// /** -// * Determines if the bottom separator is visible at the bottom of the Embedded Mobile Payment Element. -// */ -// val bottomSeparatorEnabled: Boolean, -// /** -// * The color of the checkmark. -// */ -// @ColorInt -// val checkmarkColor: Int, -// /** -// * Inset of the checkmark from the end of the row -// */ -// val checkmarkInsetDp: Float, -// /** -// * Additional vertical insets applied to a payment method row. -// * - Note: Increasing this value increases the height of each row. -// */ -// val additionalInsetsDp: Float, -// ) : RowStyle() { -// constructor( -// context: Context, -// separatorThicknessDp: Int, -// separatorColor: Color, -// separatorInsetsDp: Int, -// topSeparatorEnabled: Boolean, -// bottomSeparatorEnabled: Boolean, -// checkmarkColor: Color, -// checkmarkInsetDp: Int, -// additionalInsetsDp: Int -// ) : this( -// separatorThicknessDp = context.getRawValueFromDimenResource(separatorThicknessDp), -// separatorColor = separatorColor.toArgb(), -// separatorInsetsDp = context.getRawValueFromDimenResource(separatorInsetsDp), -// topSeparatorEnabled = topSeparatorEnabled, -// bottomSeparatorEnabled = bottomSeparatorEnabled, -// checkmarkColor = checkmarkColor.toArgb(), -// checkmarkInsetDp = context.getRawValueFromDimenResource(checkmarkInsetDp), -// additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) -// ) -// companion object { -// val defaultLight = FlatWithCheckmark( -// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, -// separatorColor = StripeThemeDefaults.colorsLight.componentBorder.toArgb(), -// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, -// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, -// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, -// checkmarkColor = StripeThemeDefaults.colorsLight.materialColors.primary.toArgb(), -// checkmarkInsetDp = StripeThemeDefaults.embeddedCommon.checkmarkInsetDp, -// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp -// ) -// -// val defaultDark = FlatWithCheckmark( -// separatorThicknessDp = StripeThemeDefaults.flat.separatorThickness, -// separatorColor = StripeThemeDefaults.colorsDark.componentBorder.toArgb(), -// separatorInsetsDp = StripeThemeDefaults.flat.separatorInsets, -// topSeparatorEnabled = StripeThemeDefaults.flat.topSeparatorEnabled, -// bottomSeparatorEnabled = StripeThemeDefaults.flat.bottomSeparatorEnabled, -// checkmarkColor = StripeThemeDefaults.colorsDark.materialColors.primary.toArgb(), -// checkmarkInsetDp = StripeThemeDefaults.embeddedCommon.checkmarkInsetDp, -// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp -// ) -// } -// } -// -// @Parcelize -// class FloatingButton( -// /** -// * The spacing between payment method rows -// */ -// val spacingDp: Float, -// /** -// * Additional vertical insets applied to a payment method row. -// * - Note: Increasing this value increases the height of each row. -// */ -// val additionalInsetsDp: Float, -// ) : RowStyle() { -// constructor( -// context: Context, -// spacingDp: Int, -// additionalInsetsDp: Int -// ) : this( -// spacingDp = context.getRawValueFromDimenResource(spacingDp), -// additionalInsetsDp = context.getRawValueFromDimenResource(additionalInsetsDp) -// ) -// -// companion object { -// val default = FloatingButton( -// spacingDp = StripeThemeDefaults.floating.spacing, -// additionalInsetsDp = StripeThemeDefaults.embeddedCommon.additionalInsetsDp -// ) -// } -// } -// } -// } - @Parcelize data class PrimaryButton( /** @@ -2575,5 +2356,3 @@ class PaymentSheet internal constructor( } } } - -typealias embeddedTypography = PaymentSheet.Typography diff --git a/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt b/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt index 5682cc59447..38b7e34b645 100644 --- a/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt +++ b/stripe-ui-core/src/main/java/com/stripe/android/uicore/StripeTheme.kt @@ -132,12 +132,6 @@ data class EmbeddedFlatStyle( val bottomSeparatorEnabled: Boolean ) -@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -data class EmbeddedRadioStyle( - val selectedColor: Color, - val unselectedColor: Color -) - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class EmbeddedInsets( val checkmarkInsetDp: Float, From 90d98ae961295e1c728e874e9882f360c929b2a2 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Mon, 25 Nov 2024 14:25:28 -0500 Subject: [PATCH 06/11] Add OptIn for AppearacneBottomSheetDialogFragment --- .../activity/AppearanceBottomSheetDialogFragment.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/AppearanceBottomSheetDialogFragment.kt b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/AppearanceBottomSheetDialogFragment.kt index 4e37c710e91..bd7b6e84ef9 100644 --- a/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/AppearanceBottomSheetDialogFragment.kt +++ b/paymentsheet-example/src/main/java/com/stripe/android/paymentsheet/example/playground/activity/AppearanceBottomSheetDialogFragment.kt @@ -64,6 +64,7 @@ import androidx.compose.ui.unit.sp import com.godaddy.android.colorpicker.ClassicColorPicker import com.godaddy.android.colorpicker.HsvColor import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.example.R @@ -182,6 +183,7 @@ private fun CustomizationCard( } } +@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Composable private fun Colors( currentAppearance: PaymentSheet.Appearance, @@ -364,6 +366,7 @@ private fun Colors( ) } +@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Composable private fun Shapes( currentAppearance: PaymentSheet.Appearance, @@ -390,6 +393,7 @@ private fun Shapes( } } +@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Composable private fun Typography( currentAppearance: PaymentSheet.Appearance, @@ -416,6 +420,7 @@ private fun Typography( } } +@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Composable private fun PrimaryButton( currentAppearance: PaymentSheet.Appearance, From e4d478fd2956b18ee57840d845827e3df1da2345 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Mon, 25 Nov 2024 16:06:08 -0500 Subject: [PATCH 07/11] Add RestrictTo annotations --- .../main/java/com/stripe/android/paymentsheet/PaymentSheet.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index 0d797cd2785..c8b73502c5c 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -6,6 +6,7 @@ import android.os.Parcelable import androidx.activity.ComponentActivity import androidx.annotation.ColorInt import androidx.annotation.FontRes +import androidx.annotation.RestrictTo import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb @@ -922,6 +923,7 @@ class PaymentSheet internal constructor( primaryButton = PrimaryButton(), ) + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @OptIn(ExperimentalEmbeddedPaymentElementApi::class) constructor( colorsLight: Colors, @@ -942,6 +944,7 @@ class PaymentSheet internal constructor( return if (isDark) colorsDark else colorsLight } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @ExperimentalEmbeddedPaymentElementApi @Parcelize class Embedded( @@ -1197,6 +1200,7 @@ class PaymentSheet internal constructor( this.primaryButton = primaryButton } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @ExperimentalEmbeddedPaymentElementApi fun embeddedAppearance(embeddedAppearance: Embedded) = apply { this.embeddedAppearance = embeddedAppearance From 32935ff5e4fad01f500bc4049e927cca62cee074 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Mon, 25 Nov 2024 16:07:27 -0500 Subject: [PATCH 08/11] Update paymentsheet-example/detekt-baseline.xml --- paymentsheet-example/detekt-baseline.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paymentsheet-example/detekt-baseline.xml b/paymentsheet-example/detekt-baseline.xml index de63d277b1c..fc1965a9149 100644 --- a/paymentsheet-example/detekt-baseline.xml +++ b/paymentsheet-example/detekt-baseline.xml @@ -5,8 +5,8 @@ EmptyFunctionBlock:DrawablePainter.kt$EmptyPainter${} FunctionNaming:Receipt.kt$@Preview @Composable fun Receipt_Editable() FunctionNaming:Receipt.kt$@Preview @Composable fun Receipt_NotEditable() - LongMethod:AppearanceBottomSheetDialogFragment.kt$@Composable private fun Colors( currentAppearance: PaymentSheet.Appearance, updateAppearance: (PaymentSheet.Appearance) -> Unit, ) - LongMethod:AppearanceBottomSheetDialogFragment.kt$@Composable private fun PrimaryButton( currentAppearance: PaymentSheet.Appearance, updateAppearance: (PaymentSheet.Appearance) -> Unit, ) + LongMethod:AppearanceBottomSheetDialogFragment.kt$@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Composable private fun Colors( currentAppearance: PaymentSheet.Appearance, updateAppearance: (PaymentSheet.Appearance) -> Unit, ) + LongMethod:AppearanceBottomSheetDialogFragment.kt$@OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Composable private fun PrimaryButton( currentAppearance: PaymentSheet.Appearance, updateAppearance: (PaymentSheet.Appearance) -> Unit, ) LongMethod:Receipt.kt$@Composable fun Receipt( isLoading: Boolean, cartState: CartState, isEditable: Boolean = false, onQuantityChanged: (CartProduct.Id, Int) -> Unit = { _, _ -> }, bottomContent: @Composable () -> Unit, ) MagicNumber:AppearanceBottomSheetDialogFragment.kt$16 MagicNumber:CartProduct.kt$100 From 98d8d2ec8c1c3decb6d37be08214b328a5121fa2 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Mon, 25 Nov 2024 16:30:51 -0500 Subject: [PATCH 09/11] API dump --- paymentsheet/api/paymentsheet.api | 89 +++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/paymentsheet/api/paymentsheet.api b/paymentsheet/api/paymentsheet.api index 2a9e4014703..74ec899d6d9 100644 --- a/paymentsheet/api/paymentsheet.api +++ b/paymentsheet/api/paymentsheet.api @@ -610,15 +610,15 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance : and public static final field $stable I public static final field CREATOR Landroid/os/Parcelable$Creator; public fun ()V - public fun (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;)V - public synthetic fun (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;)V + public synthetic fun (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; public final fun component2 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; public final fun component3 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes; public final fun component4 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Typography; public final fun component5 ()Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton; - public final fun copy (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance; - public static synthetic fun copy$default (Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;ILjava/lang/Object;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance; + public final fun copy (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance; + public static synthetic fun copy$default (Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;ILjava/lang/Object;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance; public final fun describeContents ()I public fun equals (Ljava/lang/Object;)Z public final fun getColors (Z)Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; @@ -651,6 +651,87 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Creat public synthetic fun newArray (I)[Ljava/lang/Object; } +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + +public abstract class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle : android/os/Parcelable { + public static final field $stable I +} + +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark : com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle { + public static final field $stable I + public static final field CREATOR Landroid/os/Parcelable$Creator; + public fun (FIFZZIFF)V + public synthetic fun (Landroid/content/Context;IJIZZJIILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun describeContents ()I + public final fun getAdditionalInsetsDp ()F + public final fun getBottomSeparatorEnabled ()Z + public final fun getCheckmarkColor ()I + public final fun getCheckmarkInsetDp ()F + public final fun getSeparatorColor ()I + public final fun getSeparatorInsetsDp ()F + public final fun getSeparatorThicknessDp ()F + public final fun getTopSeparatorEnabled ()Z + public final fun writeToParcel (Landroid/os/Parcel;I)V +} + +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithRadio : com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle { + public static final field $stable I + public static final field CREATOR Landroid/os/Parcelable$Creator; + public fun (FIFZZIIF)V + public synthetic fun (Landroid/content/Context;IJIZZJJILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun describeContents ()I + public final fun getAdditionalInsetsDp ()F + public final fun getBottomSeparatorEnabled ()Z + public final fun getSelectedColor ()I + public final fun getSeparatorColor ()I + public final fun getSeparatorInsetsDp ()F + public final fun getSeparatorThicknessDp ()F + public final fun getTopSeparatorEnabled ()Z + public final fun getUnselectedColor ()I + public final fun writeToParcel (Landroid/os/Parcel;I)V +} + +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithRadio$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithRadio; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithRadio; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton : com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle { + public static final field $stable I + public static final field CREATOR Landroid/os/Parcelable$Creator; + public fun (FF)V + public fun (Landroid/content/Context;II)V + public final fun describeContents ()I + public final fun getAdditionalInsetsDp ()F + public final fun getSpacingDp ()F + public final fun writeToParcel (Landroid/os/Parcel;I)V +} + +public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + public final class com/stripe/android/paymentsheet/PaymentSheet$BillingDetails : android/os/Parcelable { public static final field $stable I public static final field CREATOR Landroid/os/Parcelable$Creator; From c62f2526b72296a8e84ac7c9a2b90ee5072607bc Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Tue, 26 Nov 2024 12:00:20 -0500 Subject: [PATCH 10/11] RestrictTo annotations --- paymentsheet/api/paymentsheet.api | 32 ------------------- .../android/paymentsheet/PaymentSheet.kt | 3 ++ 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/paymentsheet/api/paymentsheet.api b/paymentsheet/api/paymentsheet.api index 74ec899d6d9..8b1709e0a7f 100644 --- a/paymentsheet/api/paymentsheet.api +++ b/paymentsheet/api/paymentsheet.api @@ -659,27 +659,6 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embed public synthetic fun newArray (I)[Ljava/lang/Object; } -public abstract class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle : android/os/Parcelable { - public static final field $stable I -} - -public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark : com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle { - public static final field $stable I - public static final field CREATOR Landroid/os/Parcelable$Creator; - public fun (FIFZZIFF)V - public synthetic fun (Landroid/content/Context;IJIZZJIILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun describeContents ()I - public final fun getAdditionalInsetsDp ()F - public final fun getBottomSeparatorEnabled ()Z - public final fun getCheckmarkColor ()I - public final fun getCheckmarkInsetDp ()F - public final fun getSeparatorColor ()I - public final fun getSeparatorInsetsDp ()F - public final fun getSeparatorThicknessDp ()F - public final fun getTopSeparatorEnabled ()Z - public final fun writeToParcel (Landroid/os/Parcel;I)V -} - public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark$Creator : android/os/Parcelable$Creator { public fun ()V public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FlatWithCheckmark; @@ -713,17 +692,6 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embed public synthetic fun newArray (I)[Ljava/lang/Object; } -public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton : com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle { - public static final field $stable I - public static final field CREATOR Landroid/os/Parcelable$Creator; - public fun (FF)V - public fun (Landroid/content/Context;II)V - public final fun describeContents ()I - public final fun getAdditionalInsetsDp ()F - public final fun getSpacingDp ()F - public final fun writeToParcel (Landroid/os/Parcel;I)V -} - public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton$Creator : android/os/Parcelable$Creator { public fun ()V public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded$RowStyle$FloatingButton; diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index c8b73502c5c..58c07623070 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -957,6 +957,7 @@ class PaymentSheet internal constructor( ) } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Parcelize sealed class RowStyle : Parcelable { @@ -1050,6 +1051,7 @@ class PaymentSheet internal constructor( } } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Parcelize class FlatWithCheckmark( /** @@ -1138,6 +1140,7 @@ class PaymentSheet internal constructor( } } + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Parcelize class FloatingButton( /** From 9e6946eee68f053a47d60bb21db1ab0c972187c5 Mon Sep 17 00:00:00 2001 From: Tyler Clawson Date: Tue, 26 Nov 2024 13:16:04 -0500 Subject: [PATCH 11/11] Fix tests --- paymentsheet/api/paymentsheet.api | 26 ------------------- .../android/paymentsheet/PaymentSheet.kt | 13 +++++----- .../CustomerSheetConfigurationTest.kt | 2 ++ .../bacs/BacsConfirmationDefinitionTest.kt | 2 ++ 4 files changed, 10 insertions(+), 33 deletions(-) diff --git a/paymentsheet/api/paymentsheet.api b/paymentsheet/api/paymentsheet.api index 8b1709e0a7f..cfa40e26289 100644 --- a/paymentsheet/api/paymentsheet.api +++ b/paymentsheet/api/paymentsheet.api @@ -606,32 +606,6 @@ public final class com/stripe/android/paymentsheet/PaymentSheet$Address$Creator public synthetic fun newArray (I)[Ljava/lang/Object; } -public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance : android/os/Parcelable { - public static final field $stable I - public static final field CREATOR Landroid/os/Parcelable$Creator; - public fun ()V - public fun (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;)V - public synthetic fun (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; - public final fun component2 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; - public final fun component3 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes; - public final fun component4 ()Lcom/stripe/android/paymentsheet/PaymentSheet$Typography; - public final fun component5 ()Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton; - public final fun copy (Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance; - public static synthetic fun copy$default (Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Colors;Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes;Lcom/stripe/android/paymentsheet/PaymentSheet$Typography;Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton;Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance$Embedded;ILjava/lang/Object;)Lcom/stripe/android/paymentsheet/PaymentSheet$Appearance; - public final fun describeContents ()I - public fun equals (Ljava/lang/Object;)Z - public final fun getColors (Z)Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; - public final fun getColorsDark ()Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; - public final fun getColorsLight ()Lcom/stripe/android/paymentsheet/PaymentSheet$Colors; - public final fun getPrimaryButton ()Lcom/stripe/android/paymentsheet/PaymentSheet$PrimaryButton; - public final fun getShapes ()Lcom/stripe/android/paymentsheet/PaymentSheet$Shapes; - public final fun getTypography ()Lcom/stripe/android/paymentsheet/PaymentSheet$Typography; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; - public final fun writeToParcel (Landroid/os/Parcel;I)V -} - public final class com/stripe/android/paymentsheet/PaymentSheet$Appearance$Builder { public static final field $stable I public fun ()V diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt index 58c07623070..c40625cdfd8 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt @@ -883,6 +883,7 @@ class PaymentSheet internal constructor( } @Parcelize + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @OptIn(ExperimentalEmbeddedPaymentElementApi::class) data class Appearance( /** @@ -923,14 +924,12 @@ class PaymentSheet internal constructor( primaryButton = PrimaryButton(), ) - @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) - @OptIn(ExperimentalEmbeddedPaymentElementApi::class) constructor( - colorsLight: Colors, - colorsDark: Colors, - shapes: Shapes, - typography: Typography, - primaryButton: PrimaryButton, + colorsLight: Colors = Colors.defaultLight, + colorsDark: Colors = Colors.defaultDark, + shapes: Shapes = Shapes.default, + typography: Typography = Typography.default, + primaryButton: PrimaryButton = PrimaryButton(), ) : this( colorsLight = colorsLight, colorsDark = colorsDark, diff --git a/paymentsheet/src/test/java/com/stripe/android/customersheet/CustomerSheetConfigurationTest.kt b/paymentsheet/src/test/java/com/stripe/android/customersheet/CustomerSheetConfigurationTest.kt index 2f8df55a145..2eb505b6f35 100644 --- a/paymentsheet/src/test/java/com/stripe/android/customersheet/CustomerSheetConfigurationTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/customersheet/CustomerSheetConfigurationTest.kt @@ -2,6 +2,7 @@ package com.stripe.android.customersheet import com.google.common.truth.Truth.assertThat import com.stripe.android.model.CardBrand +import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.paymentsheet.PaymentSheet import junit.framework.TestCase.fail import org.junit.Test @@ -10,6 +11,7 @@ import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) class CustomerSheetConfigurationTest { + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Test fun `Builder returns a configuration`() { val googlePayEnabled = true diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentelement/confirmation/bacs/BacsConfirmationDefinitionTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentelement/confirmation/bacs/BacsConfirmationDefinitionTest.kt index e16f0182115..050517d8e2d 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentelement/confirmation/bacs/BacsConfirmationDefinitionTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentelement/confirmation/bacs/BacsConfirmationDefinitionTest.kt @@ -6,6 +6,7 @@ import com.stripe.android.core.strings.resolvableString import com.stripe.android.isInstanceOf import com.stripe.android.model.PaymentMethod import com.stripe.android.model.PaymentMethodCreateParams +import com.stripe.android.paymentelement.ExperimentalEmbeddedPaymentElementApi import com.stripe.android.paymentelement.confirmation.ConfirmationDefinition import com.stripe.android.paymentelement.confirmation.ConfirmationHandler import com.stripe.android.paymentelement.confirmation.FakeConfirmationOption @@ -227,6 +228,7 @@ class BacsConfirmationDefinitionTest { assertThat(launchAction.receivesResultInProcess).isTrue() } + @OptIn(ExperimentalEmbeddedPaymentElementApi::class) @Test fun `On 'launch', should use launcher to launch`() = runTest { val definition = createBacsConfirmationDefinition()