Skip to content

[Android] Add advanced present builder callbacks and migrate sample flow#112

Open
tiagocandido wants to merge 1 commit into
graphite-base/112from
05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow
Open

[Android] Add advanced present builder callbacks and migrate sample flow#112
tiagocandido wants to merge 1 commit into
graphite-base/112from
05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow

Conversation

@tiagocandido
Copy link
Copy Markdown
Contributor

@tiagocandido tiagocandido commented May 14, 2026

What changes are you making?

This PR adds a Kotlin-first per-presentation builder for ShopifyCheckoutKit.present(checkoutUrl, activity) { ... } and migrates the Android sample to that path.

  • Introduces CheckoutPresentation, which exposes builder hooks for onComplete, onFail, onCancel, connect, onShowFileChooser, onGeolocationPermissionsShowPrompt, onGeolocationPermissionsHidePrompt, and onPermissionRequest.
  • Adds a new Kotlin-facing ShopifyCheckoutKit.present(checkoutUrl, context, configure) overload that builds a DefaultCheckoutEventProcessor internally, while keeping the existing DefaultCheckoutEventProcessor overload for Java and reusable-object integrations.
  • Adds dedicated CheckoutPresentationTest coverage for lifecycle callbacks, optional browser/system callbacks, and forwarding a connected CheckoutCommunicationClient, and regenerates lib/api/lib.api for the new API surface.
  • Migrates samples/MobileBuyIntegration off MobileBuyEventProcessor: checkout completion/failure/cancel handling now lives in CartViewModel, browser/system callbacks route through MainActivity, and typed CheckoutProtocol.Client notifications are connected inline from the builder.
  • Updates the Android README and sample README to center the builder-based presentation API and remove outdated or duplicated callback guidance.

How to test

From platforms/android/:

./gradlew :lib:testDebugUnitTest :lib:detekt :lib:lintDebug

From platforms/android/samples/MobileBuyIntegration/:

./gradlew :app:assembleDebug :app:lintDebug

Manual sanity in the sample app:

  • Add an item to cart and open checkout from the cart screen.
  • Complete checkout and confirm the cart clears and navigation returns to product browsing.
  • Close checkout and verify cancel logging still flows through CartViewModel.
  • Exercise a file upload / camera flow and a geolocation prompt from checkout to confirm the host callbacks are routed through MainActivity.
  • Confirm typed CheckoutProtocol.Client notifications still log from the sample flow.

Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated platforms/swift/CHANGELOG.md
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Android version?
  • I have bumped the versionName in platforms/android/lib/build.gradle
  • I have updated platforms/android/CHANGELOG.md
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

Copy link
Copy Markdown
Contributor Author

tiagocandido commented May 14, 2026

@tiagocandido tiagocandido force-pushed the 05-14-_android_add_window.open_ucp_delegation branch from 7ce2cfb to 5a6241f Compare May 14, 2026 12:48
@tiagocandido tiagocandido force-pushed the 05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow branch from 91bd2ce to 26edc28 Compare May 14, 2026 12:48
@tiagocandido tiagocandido force-pushed the 05-14-_android_add_window.open_ucp_delegation branch from 5a6241f to 9e15892 Compare May 14, 2026 13:19
@tiagocandido tiagocandido force-pushed the 05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow branch from 26edc28 to 1ae88e5 Compare May 14, 2026 13:19
@tiagocandido tiagocandido added the #gsd:50662 Rebase Checkout Kit on UCP label May 14, 2026 — with Graphite App
@tiagocandido tiagocandido force-pushed the 05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow branch 3 times, most recently from e305aff to e641ae5 Compare May 14, 2026 13:53
@tiagocandido tiagocandido marked this pull request as ready for review May 14, 2026 14:13
@tiagocandido tiagocandido requested a review from a team as a code owner May 14, 2026 14:13

internal fun buildEventProcessor(): DefaultCheckoutEventProcessor =
object : DefaultCheckoutEventProcessor() {
override fun onCheckoutCompleted(checkoutCompletedEvent: CheckoutCompletedEvent) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

complete should exist in the protocol instead now right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed. complete now lives on the protocol path, same as Swift. I removed builder-level onComplete; the builder just handles fail/cancel and host callbacks now.

@tiagocandido tiagocandido force-pushed the 05-14-_android_add_window.open_ucp_delegation branch from 9e15892 to 08f6c9d Compare May 14, 2026 16:19
@tiagocandido tiagocandido force-pushed the 05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow branch from e641ae5 to 6aa4b97 Compare May 14, 2026 16:19
@tiagocandido tiagocandido force-pushed the 05-14-_android_add_advanced_present_builder_callbacks_and_migrate_sample_flow branch from 6aa4b97 to 166157a Compare May 15, 2026 04:19
@tiagocandido tiagocandido changed the base branch from 05-14-_android_add_window.open_ucp_delegation to graphite-base/112 May 15, 2026 10:51
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 15, 2026

Merge activity

  • May 15, 10:51 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • May 15, 10:51 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..


internal fun buildEventProcessor(): DefaultCheckoutEventProcessor =
object : DefaultCheckoutEventProcessor() {
override fun onCheckoutCompleted(checkoutCompletedEvent: CheckoutCompletedEvent) = Unit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This callback can be dropped here now right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants