Skip to content

Commit

Permalink
Merge pull request #7225 from brave/fix_release_version_issues_android
Browse files Browse the repository at this point in the history
Fix release version issues android
  • Loading branch information
deeppandya authored Nov 21, 2020
2 parents 1b0a406 + ec30a92 commit d5badd2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ protected void onPostExecute(Void result) {
Pair<String, String> 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<String, String> dataSavedPair =
Expand All @@ -253,7 +253,7 @@ protected void onPostExecute(Void result) {
Pair<String, String> 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));

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public long insertSavedBandwidth(SavedBandwidthTable savedBandwidthTable) {
}

public long getTotalSavedBandwidthWithDate(String thresholdTime, String currentTime) {
int sum = 0;
long sum = 0;
String selectQuery = "SELECT SUM(" + SavedBandwidthTable.COLUMN_SAVED_BANDWIDTH + ") as total FROM "
+ SavedBandwidthTable.TABLE_NAME
+ " WHERE " + BraveStatsTable.COLUMN_TIMESTAMP
Expand All @@ -307,22 +307,22 @@ public long getTotalSavedBandwidthWithDate(String thresholdTime, String currentT
Cursor cursor = db.rawQuery(selectQuery, null);

if (cursor.moveToFirst())
sum = cursor.getInt(cursor.getColumnIndex("total"));
sum = cursor.getLong(cursor.getColumnIndex("total"));

cursor.close();
return sum;
}

public long getTotalSavedBandwidth() {
int sum = 0;
long sum = 0;
String selectQuery = "SELECT SUM(" + SavedBandwidthTable.COLUMN_SAVED_BANDWIDTH + ") as total FROM "
+ SavedBandwidthTable.TABLE_NAME;

SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);

if (cursor.moveToFirst())
sum = cursor.getInt(cursor.getColumnIndex("total"));
sum = cursor.getLong(cursor.getColumnIndex("total"));

cursor.close();
return sum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d5badd2

Please sign in to comment.