Skip to content

Conversation

@ycheng-kickstarter
Copy link
Contributor

@ycheng-kickstarter ycheng-kickstarter commented Sep 18, 2025

📲 What

Removing the ANDROID_CONSENT_MANAGEMENT flag led to unexpected behavior - the consent management dialog on the Discovery screen would pop up a second time, even after the user saw it during onboarding.

This PR includes fixes to ensure these behaviors:

  1. Don't show dialog again if the user has seen it during onboarding
  2. DO show dialog if the user has skipped it during onboarding
  3. Ensure the first 2 requirements are met even if the user goes through login/signup flow as part of onboarding before returning to Discovery screen.

🤔 Why

🛠 How

Have the DiscoveryActivity listen for changes to the CONSENT_MANAGEMENT_PREFERENCE shared pref. When the shared pref value changes, emit hasSeenConsentManagement(true).

In addition to hasSeenOnboarding, have the ViewModel also track a hasExitedOnboarding state.

Only emit showConsentManagementDialog.onNext(Unit) if hasExitedOnboarding is true and hasSeenConsentManagement state is false.

👀 See

📋 QA

Test the following cases with a fresh install each time:

  1. Go through the onboarding flow and click allow on the consent management dialog during the flow. Verify the dialog does not pop up again on return to Discovery screen.
  2. Go through the onboarding flow and either close the flow before reaching the consent management screen or tap the 'Not right now' button on that screen. Verify the dialog DOES pop up on return to Discovery screen.
  3. Repeat cases 1 & 2 and go through the login flow. Verify expected behavior even if you go through the login/signup flow before returning to the Discovery screen.

Story 📖

https://kickstarter.atlassian.net/browse/MBL-2812

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.63%. Comparing base (711bf50) to head (de20747).

Files with missing lines Patch % Lines
...a/com/kickstarter/viewmodels/DiscoveryViewModel.kt 85.71% 0 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2423   +/-   ##
=========================================
  Coverage     64.62%   64.63%           
- Complexity     2389     2390    +1     
=========================================
  Files           376      376           
  Lines         28431    28436    +5     
  Branches       4122     4122           
=========================================
+ Hits          18373    18379    +6     
  Misses         7802     7802           
+ Partials       2256     2255    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ycheng-kickstarter ycheng-kickstarter marked this pull request as ready for review September 18, 2025 19:02
import java.util.concurrent.TimeUnit

class DiscoveryActivity : AppCompatActivity() {
class DiscoveryActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order for the DiscoveryActivity to listen for changes to the CONSENT_MANAGEMENT_PREFERENCE shared preference, we implement the SharedPreferences.OnSharedPreferenceChangeListener and override the function onSharedPreferenceChanged. We register the activity as a listener on initialization, and unregister on destroy.


val onboardingResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
viewModel.inputs.hasExitedOnboarding()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we launch the OnboardingFlowActivity, we register for a result on return. Once the OnboardingFlowActivity returns, we inform the ViewModel and call hasExitedOnboarding()


fun returnToDiscovery() {
val returnIntent = Intent(this, DiscoveryActivity::class.java)
setResult(RESULT_OK, returnIntent)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to set result on return to DiscoveryActivity

private val settingsClick = PublishSubject.create<Unit>()
private val pledgedProjectsClick = PublishSubject.create<Unit>()
private val sortClicked = PublishSubject.create<Int>()
private val hasSeenConsentManagement = BehaviorSubject.createDefault<Boolean>(false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note we are using a BehaviorSubject rather than a PublishSubject, in order to initialize with a default value of false.


Observable.just(sharedPreferences.contains(CONSENT_MANAGEMENT_PREFERENCE))
hasExitedOnboarding
.switchMap { hasSeenConsentManagement }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only showConsentManagementDialog if hasExitedOnboarding is emitted and hasSeenConsentManagement is false.

Copy link
Contributor

@Arkariang Arkariang left a comment

Choose a reason for hiding this comment

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

Tested locally! lgtm 👍

Copy link
Contributor

@tonyteate tonyteate left a comment

Choose a reason for hiding this comment

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

Nice solution @ycheng-kickstarter! Works great 👌

@ycheng-kickstarter ycheng-kickstarter merged commit 4154d91 into master Sep 22, 2025
3 checks passed
@ycheng-kickstarter ycheng-kickstarter deleted the MBL-2812-onboarding-consent-management branch September 22, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants