Skip to content

Commit

Permalink
Fix forced default browser prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
mherrmann committed Sep 24, 2024
1 parent ae00e6d commit 813481f
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ private void onClickViews() {
if (mBtnPositive != null) {
mBtnPositive.setOnClickListener(
view -> {
if (mCurrentStep != 1 || setDefaultBrowser()) {
if (mCurrentStep == 1 && !isDefaultBrowser()) {
setDefaultBrowser();
} else {
nextOnboardingStep();
}
});
Expand All @@ -231,18 +233,16 @@ private void onClickViews() {
}

private boolean shouldForceDefaultBrowserPrompt() {
return ChromeFeatureList.isEnabled(BraveFeatureList.ANDROID_FORCE_DEFAULT_BROWSER_PROMPT);
return !isDefaultBrowser()
&& ChromeFeatureList.isEnabled(
BraveFeatureList.ANDROID_FORCE_DEFAULT_BROWSER_PROMPT);
}

private boolean setDefaultBrowser() {
if (!isDefaultBrowser()) {
BraveSetDefaultBrowserUtils.setDefaultBrowser(this);
if (!BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
nextOnboardingStep();
return false;
}
private void setDefaultBrowser() {
BraveSetDefaultBrowserUtils.setDefaultBrowser(this);
if (!BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
nextOnboardingStep();
}
return true;
}

private boolean isDefaultBrowser() {
Expand Down Expand Up @@ -289,16 +289,14 @@ public void run() {
200);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
&& (!shouldForceDefaultBrowserPrompt() || isDefaultBrowser())) {
&& !shouldForceDefaultBrowserPrompt()) {
mRequestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
} else {
startTimer(3000);
}
} else if (mCurrentStep == 1) {
if (shouldForceDefaultBrowserPrompt()) {
if (setDefaultBrowser()) {
nextOnboardingStep();
}
setDefaultBrowser();
} else {
int margin = mIsTablet ? 200 : 30;
setLeafAnimation(mVLeafAlignTop, mIvLeafTop, 1.3f, margin, true);
Expand Down

0 comments on commit 813481f

Please sign in to comment.