Skip to content

Commit

Permalink
Android 13 show once notification permission dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
sujitacharya2005 committed Nov 24, 2022
1 parent 7bee6e2 commit 37454d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}

0 comments on commit 37454d4

Please sign in to comment.