[Android] Render checkout in bottom sheet#381
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
33688c9 to
3e920bb
Compare
| ## Troubleshooting | ||
|
|
||
| - Use `LogLevel.DEBUG` while integrating. | ||
| - For production release builds, use Android app shrinking and optimization |
There was a problem hiding this comment.
mainly adding this note for unused protocol classes
There was a problem hiding this comment.
Should we give them the example exclude paths here?
There was a problem hiding this comment.
Add a couple of gradle settings worth toggling
| public static final fun present (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lcom/shopify/checkoutkit/DefaultCheckoutListener;Lcom/shopify/checkoutkit/CheckoutProtocol$Client;)Lcom/shopify/checkoutkit/CheckoutKitDialog; | ||
| public static final synthetic fun present (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lkotlin/jvm/functions/Function1;)Lcom/shopify/checkoutkit/CheckoutKitDialog; | ||
| public static synthetic fun present$default (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lcom/shopify/checkoutkit/DefaultCheckoutListener;Lcom/shopify/checkoutkit/CheckoutProtocol$Client;ILjava/lang/Object;)Lcom/shopify/checkoutkit/CheckoutKitDialog; | ||
| public static final fun present (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lcom/shopify/checkoutkit/DefaultCheckoutListener;)Lcom/shopify/checkoutkit/CheckoutHandle; |
There was a problem hiding this comment.
looking to decouple a little from a type of presentation (Dialog), to a more general CheckoutHandle
| dismissing = false | ||
| dismissFinalized = false | ||
|
|
||
| requestWindowFeature(Window.FEATURE_NO_TITLE) |
There was a problem hiding this comment.
we can probably drop this line, we have R.style.CheckoutKitBottomSheetDialog, which has
<item name="android:windowNoTitle">true</item>
568a78a to
fe0e2e8
Compare
fe0e2e8 to
5a4e62e
Compare
| private val checkoutListener: CheckoutListener, | ||
| private val activity: ComponentActivity, | ||
| private val protocolClient: CheckoutProtocol.Client? = null, | ||
| ) : ComponentDialog(activity, R.style.CheckoutKitBottomSheetDialog) { |
There was a problem hiding this comment.
extending Dialog to pick up a lot of behaviour from that
There was a problem hiding this comment.
Out of curiosity, what kind of behaviour is inherited?
There was a problem hiding this comment.
We get lifecycle awareness.. So dealing with window attach/detach, show/dismiss, cacnel, outside touch, activity teardown and things like that.. And things like back handling, and some accessibility semantics
Hopefully a kind of stable base to build on top of
| android:configChanges="orientation|keyboardHidden" | ||
| android:exported="true" | ||
| android:screenOrientation="portrait" | ||
| android:windowSoftInputMode="adjustResize" |
There was a problem hiding this comment.
removing to ensure it wasn't masking issues with our webview softInputmode
There was a problem hiding this comment.
And do we want to keep this disabled, does this not affect the keyboard handling behaviour?
There was a problem hiding this comment.
This is the manifest for the sample. So it does affect it keyboard handling in the sample.
I was thinking to keep it for ongoing validation/testing.. We could undo if preferred though
5a4e62e to
33b1303
Compare
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <dimen name="checkout_sheet_top_gap">24dp</dimen> | ||
| <dimen name="checkout_sheet_corner_radius">32dp</dimen> |
There was a problem hiding this comment.
made customizable up-stack
Package Size
Android file breakdown
Measured from the PR base SHA and PR head SHA. The file breakdown shows uncompressed sizes within each package artifact, so individual files do not sum to the compressed artifact total. This comment reports package artifact sizes only; it is not a final app binary-size report. |
| .gradle/ | ||
| .kotlin/ | ||
| build/ | ||
| *.apk |
There was a problem hiding this comment.
a little unrleated, but ignore build artifacts
| } | ||
|
|
||
| private const val LOG_TAG = "CheckoutBottomSheet" | ||
| private const val WINDOW_DIM_AMOUNT = 0.32f |
There was a problem hiding this comment.
customization added upstack
| context: Context, | ||
| @ColorInt color: Int, | ||
| ): GradientDrawable { | ||
| val cornerRadius = context.resources.getDimension(R.dimen.checkout_sheet_corner_radius) |
There was a problem hiding this comment.
moved out to the Configuration class upstack
| android:layout_height="match_parent" | ||
| android:background="@android:color/transparent"> | ||
|
|
||
| <View |
There was a problem hiding this comment.
transparent View to catch taps outside the sheet for cancellation
f6c2458 to
aba1a8c
Compare
aba1a8c to
b02925f
Compare
kieran-osgood-shopify
left a comment
There was a problem hiding this comment.
My comments are small but adding request changes for the swipe to dismiss sheet behaviour (noted in slack)
| ## Troubleshooting | ||
|
|
||
| - Use `LogLevel.DEBUG` while integrating. | ||
| - For production release builds, use Android app shrinking and optimization |
There was a problem hiding this comment.
Should we give them the example exclude paths here?
| private val checkoutListener: CheckoutListener, | ||
| private val activity: ComponentActivity, | ||
| private val protocolClient: CheckoutProtocol.Client? = null, | ||
| ) : ComponentDialog(activity, R.style.CheckoutKitBottomSheetDialog) { |
There was a problem hiding this comment.
Out of curiosity, what kind of behaviour is inherited?
| android:configChanges="orientation|keyboardHidden" | ||
| android:exported="true" | ||
| android:screenOrientation="portrait" | ||
| android:windowSoftInputMode="adjustResize" |
There was a problem hiding this comment.
And do we want to keep this disabled, does this not affect the keyboard handling behaviour?
b02925f to
c746257
Compare
Assisted-By: devx/6db0ff39-6d19-4074-ab7f-a027dc8b067f
c746257 to
3e70d57
Compare

Replace dialog-based checkout presentation with a native bottom sheet on Android
The Android checkout presentation has been migrated from a
Dialogto a custom native bottom sheet.CheckoutDialogis removed and replaced byCheckoutBottomSheet, aComponentDialogsubclass that hosts the checkout WebView inside a full-screen edge-to-edge window with a slide-up sheet panel.The bottom sheet includes:
CheckoutBottomSheetLayout(RelativeLayoutsubclass) that owns open/close/settle animations usingPathInterpolatorcurves and drag-to-dismiss gesture handlingCheckoutBottomSheetScrollHandofftouch listener that coordinates exclusive gesture ownership between the WebView scroll and sheet drag, so a gesture that starts as a WebView scroll stays with the WebView even after reaching scroll-topCheckoutSheetHeaderBackgroundDrawableSOFT_INPUT_ADJUST_RESIZEfor keyboard handling, and inset listeners for bottom padding and top marginCheckoutKitDialogis renamed toCheckoutHandleto reflect that it is a generic handle to a presented checkout rather than a reference to a dialog.present()returnsCheckoutHandle?anddismiss()on the handle triggers the sheet's animated dismissal. Activity lifecycle teardown callsdismiss(animate = false)to skip the animation and immediately release the WebView.The
CheckoutWebViewListeneris updated to accept ahideLoadingBackgroundcallback alongside the existing progress bar callbacks, so the loading cover view is hidden once checkout content is ready.Before you merge
Important
platforms/swift/README.mdand/orplatforms/android/README.md)Releasing a new Swift version?
ShopifyCheckoutKit.podspecplatforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swiftplatforms/swift/README.md(major version only)Releasing a new Embedded Checkout Protocol version?
embeddedCheckoutProtocolAndroidinplatforms/android/gradle/libs.versions.tomlprotocol/languages/kotlin/embedded-checkout-protocol/api/embedded-checkout-protocol.apiif the public API changedReleasing a new Android version?
checkoutKitAndroidinplatforms/android/gradle/libs.versions.tomlplatforms/android/README.mdTip
See the Contributing documentation for the full release process per platform.