-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add WinBackPromptEvaluator to re-engage users who were previously default browser #8319
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
Open
catalinradoiu
wants to merge
7
commits into
develop
Choose a base branch
from
feature/cradoiu/show-winback-prompt-after-default-change
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b1d6968
Update AppInstallStore and set wasEverDefaultBrowser flag to true aut…
catalinradoiu 45e8a27
Add the WinBackPromptEvaluator to show browser comparison modal when …
catalinradoiu 87de758
Add missing annotation and update unit test
catalinradoiu 084c08c
Add docs
catalinradoiu 7869025
Make wasEverDefaultBrowser() a suspend function
catalinradoiu 7563c29
Fix test
catalinradoiu f423df4
Check if onboarding is complete
catalinradoiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
94 changes: 94 additions & 0 deletions
94
...s/dax-prompts-impl/src/main/java/com/duckduckgo/daxprompts/impl/WinBackPromptEvaluator.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /* | ||
| * Copyright (c) 2026 DuckDuckGo | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.duckduckgo.daxprompts.impl | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector | ||
| import com.duckduckgo.app.di.AppCoroutineScope | ||
| import com.duckduckgo.app.onboarding.OnboardingFlowChecker | ||
| import com.duckduckgo.browser.api.UserBrowserProperties | ||
| import com.duckduckgo.common.utils.DispatcherProvider | ||
| import com.duckduckgo.daxprompts.api.DaxPromptBrowserComparisonNoParams | ||
| import com.duckduckgo.daxprompts.impl.repository.DaxPromptsRepository | ||
| import com.duckduckgo.di.scopes.AppScope | ||
| import com.duckduckgo.modalcoordinator.api.ModalEvaluator | ||
| import com.duckduckgo.navigation.api.GlobalActivityStarter | ||
| import com.squareup.anvil.annotations.ContributesBinding | ||
| import com.squareup.anvil.annotations.ContributesMultibinding | ||
| import dagger.SingleInstanceIn | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import kotlinx.coroutines.delay | ||
| import kotlinx.coroutines.launch | ||
| import kotlinx.coroutines.withContext | ||
| import javax.inject.Inject | ||
|
|
||
| interface WinBackPromptEvaluator | ||
|
|
||
| @ContributesMultibinding( | ||
| scope = AppScope::class, | ||
| boundType = ModalEvaluator::class, | ||
| ) | ||
| @ContributesBinding( | ||
| scope = AppScope::class, | ||
| boundType = WinBackPromptEvaluator::class, | ||
| ) | ||
| @SingleInstanceIn(scope = AppScope::class) | ||
| class WinBackPromptEvaluatorImpl @Inject constructor( | ||
| @AppCoroutineScope private val appCoroutineScope: CoroutineScope, | ||
| private val applicationContext: Context, | ||
| private val userBrowserProperties: UserBrowserProperties, | ||
| private val defaultBrowserDetector: DefaultBrowserDetector, | ||
| private val daxPromptsRepository: DaxPromptsRepository, | ||
| private val globalActivityStarter: GlobalActivityStarter, | ||
| private val dispatchers: DispatcherProvider, | ||
| private val reactivateUsersToggles: ReactivateUsersToggles, | ||
| private val onboardingFlowChecker: OnboardingFlowChecker, | ||
| ) : ModalEvaluator, WinBackPromptEvaluator { | ||
|
|
||
| override val priority: Int = 1 | ||
|
|
||
| override val evaluatorId: String = "win_back_prompt" | ||
|
|
||
| override suspend fun evaluate(): ModalEvaluator.EvaluationResult = withContext(dispatchers.io()) { | ||
| if (isEnabled() && isEligible()) { | ||
| val intent = globalActivityStarter | ||
| .startIntent(applicationContext, DaxPromptBrowserComparisonNoParams) ?: return@withContext ModalEvaluator.EvaluationResult.Skipped | ||
|
|
||
| delay(MODAL_DISPLAY_DELAY) | ||
| appCoroutineScope.launch(dispatchers.main()) { | ||
| intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP | ||
| applicationContext.startActivity(intent) | ||
| } | ||
|
|
||
| return@withContext ModalEvaluator.EvaluationResult.ModalShown | ||
| } else { | ||
| return@withContext ModalEvaluator.EvaluationResult.Skipped | ||
| } | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| private fun isEnabled() = reactivateUsersToggles.self().isEnabled() && reactivateUsersToggles.defaultBrowserWinBackPrompt().isEnabled() | ||
|
|
||
| private suspend fun isEligible() = onboardingFlowChecker.isOnboardingComplete() && | ||
| userBrowserProperties.wasEverDefaultBrowser() && | ||
| !daxPromptsRepository.getDaxPromptsBrowserComparisonShown() && | ||
| !defaultBrowserDetector.isDefaultBrowser() | ||
|
|
||
| companion object { | ||
| private const val MODAL_DISPLAY_DELAY = 1500L | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.