-
Notifications
You must be signed in to change notification settings - Fork 999
MBL-2812 Only show consent management dialog if skipped during onboarding #2423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MBL-2812 Only show consent management dialog if skipped during onboarding #2423
Conversation
…if already displayed during onboarding
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
| import java.util.concurrent.TimeUnit | ||
|
|
||
| class DiscoveryActivity : AppCompatActivity() { | ||
| class DiscoveryActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceChangeListener { |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally! lgtm 👍
There was a problem hiding this 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 👌
📲 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:
🤔 Why
🛠 How
Have the DiscoveryActivity listen for changes to the
CONSENT_MANAGEMENT_PREFERENCEshared pref. When the shared pref value changes, emithasSeenConsentManagement(true).In addition to
hasSeenOnboarding, have the ViewModel also track ahasExitedOnboardingstate.Only emit
showConsentManagementDialog.onNext(Unit)ifhasExitedOnboardingis true andhasSeenConsentManagementstate is false.👀 See
📋 QA
Test the following cases with a fresh install each time:
Story 📖
https://kickstarter.atlassian.net/browse/MBL-2812