Skip to content
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

Android 13 show once notification permission dialog #16079

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start using SharedPreference Manager for all pref updates.

sharedPreferencesEditor.putBoolean(PREF_NOTIFICATION_PERMISSION_ENABLING_DIALOG, isShown);
sharedPreferencesEditor.apply();
}
}