Skip to content

Commit

Permalink
Uplift of #17916 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Apr 5, 2023
1 parent c4f6256 commit cfb6c8a
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.chromium.base.BravePreferenceKeys;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.onboarding.OnboardingPrefManager;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
Expand All @@ -33,6 +34,7 @@
import org.chromium.ui.widget.Toast;

public class BraveSetDefaultBrowserUtils {
private static final String TAG = "BSDBrowserUtils";
public static final String ANDROID_SETUPWIZARD_PACKAGE_NAME = "com.google.android.setupwizard";
public static final String ANDROID_PACKAGE_NAME = "android";
public static final String BRAVE_BLOG_URL = "https://brave.com/privacy-features/";
Expand Down Expand Up @@ -98,19 +100,25 @@ public static void showBraveSetDefaultBrowserDialog(
if (!isBottomSheetVisible) {
isBottomSheetVisible = true;

try {
SetDefaultBrowserBottomSheetFragment bottomSheetDialog =
SetDefaultBrowserBottomSheetFragment.newInstance(isFromMenu);

bottomSheetDialog.show(activity.getSupportFragmentManager(),
"SetDefaultBrowserBottomSheetFragment");
} catch (IllegalStateException e) {
// That exception could be thrown when Activity is not in the foreground.
Log.e(TAG, "showBraveSetDefaultBrowserDialog error: " + e.getMessage());
return;
}

if (!isFromMenu) {
int braveDefaultModalCount = SharedPreferencesManager.getInstance().readInt(
BravePreferenceKeys.BRAVE_SET_DEFAULT_BOTTOM_SHEET_COUNT);
SharedPreferencesManager.getInstance().writeInt(
BravePreferenceKeys.BRAVE_SET_DEFAULT_BOTTOM_SHEET_COUNT,
braveDefaultModalCount + 1);
}

SetDefaultBrowserBottomSheetFragment bottomSheetDialog =
SetDefaultBrowserBottomSheetFragment.newInstance(isFromMenu);

bottomSheetDialog.show(
activity.getSupportFragmentManager(), "SetDefaultBrowserBottomSheetFragment");
}
}

Expand Down

0 comments on commit cfb6c8a

Please sign in to comment.