Skip to content

Commit

Permalink
Brave notification permission issue fix (uplift to 1.48.x) (#16782)
Browse files Browse the repository at this point in the history
Brave notification permission issue fix
  • Loading branch information
sujitacharya2005 authored Feb 2, 2023
1 parent 4e6989b commit ce26a10
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ public void onRequestPermissionsResult(
@Override
public void onResume() {
super.onResume();
if (BravePermissionUtils.hasPermission(
getContext(), PermissionConstants.NOTIFICATION_PERMISSION)) {
statsNotificationView.setVisibility(View.GONE);
} else {
if (!BravePermissionUtils.hasPermission(
getContext(), PermissionConstants.NOTIFICATION_PERMISSION)
|| BravePermissionUtils.isGeneralNotificationPermissionBlocked(getActivity())) {
statsNotificationView.setVisibility(View.VISIBLE);
} else {
statsNotificationView.setVisibility(View.GONE);
}
}

Expand All @@ -224,8 +225,9 @@ private void updateNotificationView(View view) {
btnDismiss.setOnClickListener(v -> { statsNotificationView.setVisibility(View.GONE); });
View notificationOnButton = view.findViewById(R.id.notification_on_button);
notificationOnButton.setOnClickListener(v -> {
if (getActivity().shouldShowRequestPermissionRationale(
PermissionConstants.NOTIFICATION_PERMISSION)
if (BravePermissionUtils.isGeneralNotificationPermissionBlocked(getActivity())
|| getActivity().shouldShowRequestPermissionRationale(
PermissionConstants.NOTIFICATION_PERMISSION)
|| (!BuildInfo.isAtLeastT() || !BuildInfo.targetsAtLeastT())) {
// other than android 13 redirect to
// setting page and for android 13 Last time don't allow selected in permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,9 @@ public void OnGetCurrentBalanceReport(double[] report) {
}

private void requestNotificationPermission() {
if (mActivity.shouldShowRequestPermissionRationale(
PermissionConstants.NOTIFICATION_PERMISSION)
if (BravePermissionUtils.isBraveAdsNotificationPermissionBlocked(mAnchorView.getContext())
|| mActivity.shouldShowRequestPermissionRationale(
PermissionConstants.NOTIFICATION_PERMISSION)
|| (!BuildInfo.isAtLeastT() || !BuildInfo.targetsAtLeastT())) {
// other than android 13 redirect to
// setting page and for android 13 Last time don't allow selected in permission
Expand Down Expand Up @@ -1587,16 +1588,16 @@ public void onNothingSelected(AdapterView<?> arg0) {}
btnContinue.setOnClickListener((new View.OnClickListener() {
@Override
public void onClick(View v) {
if (BravePermissionUtils.hasPermission(mAnchorView.getContext(),
PermissionConstants.NOTIFICATION_PERMISSION)) {
if (countrySpinner != null) {
mBraveRewardsNativeWorker.CreateRewardsWallet(sortedCountryMap.get(
countrySpinner.getSelectedItem().toString()));
}
} else {
// else request notification permission
if (!BravePermissionUtils.hasPermission(mAnchorView.getContext(),
PermissionConstants.NOTIFICATION_PERMISSION)
|| BravePermissionUtils.isBraveAdsNotificationPermissionBlocked(
mAnchorView.getContext())) {
requestNotificationPermission();
}
if (countrySpinner != null) {
mBraveRewardsNativeWorker.CreateRewardsWallet(
sortedCountryMap.get(countrySpinner.getSelectedItem().toString()));
}
}
}));
}
Expand Down
2 changes: 1 addition & 1 deletion browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ This file contains all "about" strings. It is set to NOT be translated, in tran
Turn notifications back on if you'd like to keep earning BAT and receiving weekly privacy reports.
</message>
<message name="IDS_NOTIFICATION_BRAVE_DIALOG_DESCRIPTION_ONLY_REWARDS" desc="Text description for When ONLY Brave Rewards is TURNED ON.">
Turn notifications back on if you'd like to keep earning BAT
Turn notifications back on if you'd like to keep earning BAT.
</message>
<message name="IDS_NOTIFICATION_BRAVE_DIALOG_DESCRIPTION_ONLY_PRIVACY" desc="Text description for When ONLY Privacy Report is TURNED ON.">
Turn notifications back on if you'd like to keep receiving weekly privacy reports.
Expand Down

0 comments on commit ce26a10

Please sign in to comment.