Register enum converter for CheckoutVariant in sample#194
Merged
Conversation
The sample observes an enum-typed flag (CheckoutVariant) via DataStoreConfigValueProvider, but never registered a TypeConverter for the enum. DataStore preferences only support primitive keys, so observation crashed with IllegalArgumentException on launch. Register enumConverter<CheckoutVariant>() on the provider before building ConfigValues. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Register every flag in SampleFeatureFlags with FlagRegistry on Application start so the Debug UI renders the list instead of the empty state. Apply statusBarsPadding() to the home-screen top row so the "Debug flags" button is reachable under enableEdgeToEdge. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
8f9458d to
e01b332
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Pull request overview
This PR fixes the Android sample crash when observing the enum-backed checkoutVariant flag through the DataStore provider by registering the enum converter before creating ConfigValues.
Changes:
- Registers sample flags for debug UI discovery.
- Registers
CheckoutVariantDataStore converter inMainActivity. - Adds the DataStore provider dependency and applies status bar padding to the sample screen.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
sample/shared/src/commonMain/kotlin/dev/androidbroadcast/featured/SampleApp.kt |
Adds registerSampleFlags() to populate FlagRegistry. |
sample/shared/src/commonMain/kotlin/dev/androidbroadcast/featured/FeaturedSample.kt |
Adds status bar padding to the sample screen layout. |
sample/android-app/src/main/kotlin/dev/androidbroadcast/featured/sample/MainActivity.kt |
Registers sample flags and the CheckoutVariant DataStore enum converter before creating ConfigValues. |
sample/android-app/build.gradle.kts |
Adds a direct dependency on :providers:datastore. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What crashed
SampleFeatureFlags.checkoutVariantis an enum-typedConfigParam<CheckoutVariant>observed viaDataStoreConfigValueProvider. DataStore's preferences API only supports six primitive types (String, Int, Long, Float, Double, Boolean). Whenobserve()was called for the enum param, it fell through tocreatePreferencesKey, hit theelsebranch, and threwIllegalArgumentException: Unsupported type: class dev.androidbroadcast.featured.CheckoutVariant, crashing the process on launch.Fix
Register
enumConverter<CheckoutVariant>()on theDataStoreConfigValueProviderinstance before constructingConfigValuesinMainActivity. SincedefaultLocalProvider(context)returnsLocalConfigValueProvider(the interface), a safe cast toDataStoreConfigValueProvideris used to callregisterConverter.Also adds
implementation(project(":providers:datastore"))tosample/android-app/build.gradle.kts— the:providers:datastoremodule is animplementation(notapi) dependency of:featured-platform, so its symbols are not transitively visible to the app module.Scope
Sample-only patch. No library code is changed.
Library-level error handling (catching
IllegalArgumentExceptioninobserve()so a missing converter fails gracefully rather than crashing) is tracked in the sibling PRfix/configvalues-observe-catch.