From ec30a92edc8925d13bfd7cc7854ff465c0c60f8e Mon Sep 17 00:00:00 2001 From: Deep Date: Sat, 21 Nov 2020 13:44:28 -0500 Subject: [PATCH] Fix NLPs for release app --- .../org/chromium/chrome/browser/app/BraveActivity.java | 4 +++- .../brave_stats/BraveStatsBottomSheetDialogFragment.java | 8 ++++---- .../retention/RetentionNotificationPublisher.java | 4 +++- .../chrome/browser/ntp/widget/NTPWidgetStackActivity.java | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/app/BraveActivity.java b/android/java/org/chromium/chrome/browser/app/BraveActivity.java index 22e42e4672b2..352fef58e1dd 100644 --- a/android/java/org/chromium/chrome/browser/app/BraveActivity.java +++ b/android/java/org/chromium/chrome/browser/app/BraveActivity.java @@ -327,7 +327,9 @@ private void checkForNotificationData() { case RetentionNotificationUtil.BRAVE_STATS_ADS_TRACKERS: case RetentionNotificationUtil.BRAVE_STATS_DATA: case RetentionNotificationUtil.BRAVE_STATS_TIME: - if (!NewTabPage.isNTPUrl(getActivityTab().getUrlString())) { + if (getActivityTab() != null + && getActivityTab().getUrlString() != null + && !NewTabPage.isNTPUrl(getActivityTab().getUrlString())) { getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.FROM_CHROME_UI); } break; diff --git a/android/java/org/chromium/chrome/browser/brave_stats/BraveStatsBottomSheetDialogFragment.java b/android/java/org/chromium/chrome/browser/brave_stats/BraveStatsBottomSheetDialogFragment.java index bb57becce090..3a964a3c192c 100644 --- a/android/java/org/chromium/chrome/browser/brave_stats/BraveStatsBottomSheetDialogFragment.java +++ b/android/java/org/chromium/chrome/browser/brave_stats/BraveStatsBottomSheetDialogFragment.java @@ -226,7 +226,7 @@ protected void onPostExecute(Void result) { Pair adsTrackersPair = BraveStatsUtil.getBraveStatsStringFormNumberPair(adsTrackersCount, false); adsTrackersCountText.setText( - String.format(getResources().getString(R.string.ntp_stat_text), + String.format(mContext.getResources().getString(R.string.ntp_stat_text), adsTrackersPair.first, adsTrackersPair.second)); Pair dataSavedPair = @@ -253,7 +253,7 @@ protected void onPostExecute(Void result) { Pair timeSavedPair = BraveStatsUtil.getBraveStatsStringFromTime(timeSavedCount / 1000); timeSavedCountText.setText( - String.format(getResources().getString(R.string.ntp_stat_text), + String.format(mContext.getResources().getString(R.string.ntp_stat_text), timeSavedPair.first, timeSavedPair.second)); timeSavedText.setText(mContext.getResources().getString(R.string.time_saved_text)); @@ -331,10 +331,10 @@ protected void onPostExecute(Void result) { mTrackerCountText.setText(String.valueOf(statPair.second)); mTrackerCountText.setTextColor( - getResources().getColor(R.color.brave_stats_text_color)); + mContext.getResources().getColor(R.color.brave_stats_text_color)); mSiteText.setText(statPair.first); mSiteText.setTextColor( - getResources().getColor(R.color.brave_stats_text_color)); + mContext.getResources().getColor(R.color.brave_stats_text_color)); rootView.addView(layout); } diff --git a/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotificationPublisher.java b/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotificationPublisher.java index 9c5ac53922c2..75a346b29334 100644 --- a/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotificationPublisher.java +++ b/android/java/org/chromium/chrome/browser/notifications/retention/RetentionNotificationPublisher.java @@ -56,7 +56,9 @@ public void onReceive(Context context, Intent intent) { case RetentionNotificationUtil.BRAVE_STATS_ADS_TRACKERS: case RetentionNotificationUtil.BRAVE_STATS_DATA: case RetentionNotificationUtil.BRAVE_STATS_TIME: - if (!NewTabPage.isNTPUrl(braveActivity.getActivityTab().getUrlString())) { + if (braveActivity.getActivityTab() != null + && braveActivity.getActivityTab().getUrlString() != null + && !NewTabPage.isNTPUrl(braveActivity.getActivityTab().getUrlString())) { braveActivity.getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.FROM_CHROME_UI); } break; diff --git a/android/java/org/chromium/chrome/browser/ntp/widget/NTPWidgetStackActivity.java b/android/java/org/chromium/chrome/browser/ntp/widget/NTPWidgetStackActivity.java index d9168d827bc6..89150e09c12b 100644 --- a/android/java/org/chromium/chrome/browser/ntp/widget/NTPWidgetStackActivity.java +++ b/android/java/org/chromium/chrome/browser/ntp/widget/NTPWidgetStackActivity.java @@ -159,7 +159,9 @@ private void returnResult() { } } if (isFromSettings) { - BraveActivity.getBraveActivity().getActivityTab().reloadIgnoringCache(); + if (BraveActivity.getBraveActivity() != null && BraveActivity.getBraveActivity().getActivityTab() != null) { + BraveActivity.getBraveActivity().getActivityTab().reloadIgnoringCache(); + } } else { Intent intent = new Intent(); setResult(BraveNewTabPageLayout.NTP_WIDGET_STACK_CODE, intent);