From 37454d46bf301204b683d61735aac8e0605f7fba Mon Sep 17 00:00:00 2001 From: Sujit Acharya Date: Thu, 24 Nov 2022 14:32:50 +0530 Subject: [PATCH] Android 13 show once notification permission dialog --- .../chrome/browser/app/BraveActivity.java | 5 ++++- .../onboarding/OnboardingPrefManager.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/android/java/org/chromium/chrome/browser/app/BraveActivity.java b/android/java/org/chromium/chrome/browser/app/BraveActivity.java index 42ea80c586c5..047a73ab0aa0 100644 --- a/android/java/org/chromium/chrome/browser/app/BraveActivity.java +++ b/android/java/org/chromium/chrome/browser/app/BraveActivity.java @@ -1245,8 +1245,11 @@ public void onDismiss() { }; private void checkAndshowNotificationWarningDialog() { - if (BraveNotificationWarningDialog.shouldShowNotificationWarningDialog(this)) { + if (BraveNotificationWarningDialog.shouldShowNotificationWarningDialog(this) + && !OnboardingPrefManager.getInstance() + .isNotificationPermissionEnablingDialogShown()) { showNotificationWarningDialog(); + OnboardingPrefManager.getInstance().setNotificationPermissionEnablingDialogShown(true); } else { checkForNotificationData(); } diff --git a/android/java/org/chromium/chrome/browser/onboarding/OnboardingPrefManager.java b/android/java/org/chromium/chrome/browser/onboarding/OnboardingPrefManager.java index 04f2adf8b8e6..5099bd3f20c1 100644 --- a/android/java/org/chromium/chrome/browser/onboarding/OnboardingPrefManager.java +++ b/android/java/org/chromium/chrome/browser/onboarding/OnboardingPrefManager.java @@ -56,6 +56,8 @@ public class OnboardingPrefManager { private static final String PREF_P3A_CRASH_REPORTING_MESSAGE_SHOWN = "p3a_crash_reporting_message_shown"; private static final String PREF_URL_FOCUS_COUNT = "url_focus_count"; + private static final String PREF_NOTIFICATION_PERMISSION_ENABLING_DIALOG = + "notification_permission_enabling_dialog"; private static OnboardingPrefManager sInstance; @@ -341,4 +343,20 @@ private long setTimeInMillis(int timeInMinutes) { Date date = calendar.getTime(); return date.getTime(); } + + /** + * Returns the user preference for whether the Notification Permission Enabling dialog is shown. + */ + public boolean isNotificationPermissionEnablingDialogShown() { + return mSharedPreferences.getBoolean(PREF_NOTIFICATION_PERMISSION_ENABLING_DIALOG, false); + } + + /** + * Sets the user preference for whether the Notification Permission Enabling dialog is shown. + */ + public void setNotificationPermissionEnablingDialogShown(boolean isShown) { + SharedPreferences.Editor sharedPreferencesEditor = mSharedPreferences.edit(); + sharedPreferencesEditor.putBoolean(PREF_NOTIFICATION_PERMISSION_ENABLING_DIALOG, isShown); + sharedPreferencesEditor.apply(); + } }