Skip to content

Commit

Permalink
Remove BAP deprecation modal
Browse files Browse the repository at this point in the history
  • Loading branch information
deeppandya committed May 10, 2021
1 parent ab419e3 commit 8db0058
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 457 deletions.
5 changes: 0 additions & 5 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,6 @@ brave_java_resources = [
"java/res/drawable/ic_toggle_up.xml",
"java/res/drawable/ic_wallet_add.xml",
"java/res/drawable/ic_warning_circle.xml",
"java/res/drawable/ic_warning_triangle.xml",
"java/res/drawable/ic_warning_triangle_2.xml",
"java/res/drawable/image_credit_rounded_shape.xml",
"java/res/drawable/modern_toolbar_background_grey_end_segment.xml",
"java/res/drawable/ntp_widget_indicator_bg.xml",
Expand All @@ -634,8 +632,6 @@ brave_java_resources = [
"java/res/drawable/rewards_button_purple_border.xml",
"java/res/drawable/rewards_button_summary.xml",
"java/res/drawable/rewards_image_button.xml",
"java/res/drawable/rewards_modal_background.xml",
"java/res/drawable/rewards_tooltip_background.xml",
"java/res/drawable/rounded_corners.xml",
"java/res/drawable/rounded_filled.xml",
"java/res/drawable/rounded_filled_binance.xml",
Expand Down Expand Up @@ -721,7 +717,6 @@ brave_java_resources = [
"java/res/layout/fragment_brave_rewards_onboarding.xml",
"java/res/layout/fragment_cross_promotional_modal_dialog.xml",
"java/res/layout/fragment_crypto_widget_bottom_sheet_dialog.xml",
"java/res/layout/fragment_deprecate_bap_modal_dialog.xml",
"java/res/layout/fragment_onboarding_v2.xml",
"java/res/layout/fragment_qr_code_share.xml",
"java/res/layout/fragment_rate_dialog.xml",
Expand Down
1 change: 0 additions & 1 deletion android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/BraveSyncReflectionUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/BraveUphold.java",
"../../brave/android/java/org/chromium/chrome/browser/CrossPromotionalModalDialogFragment.java",
"../../brave/android/java/org/chromium/chrome/browser/DeprecateBAPModalDialogFragment.java",
"../../brave/android/java/org/chromium/chrome/browser/InternetConnection.java",
"../../brave/android/java/org/chromium/chrome/browser/QRCodeShareDialogFragment.java",
"../../brave/android/java/org/chromium/chrome/browser/SetDefaultBrowserActivity.java",
Expand Down
12 changes: 0 additions & 12 deletions android/java/org/chromium/chrome/browser/BraveRewardsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class BraveRewardsHelper implements LargeIconBridge.LargeIconCallback{
private static final String PREF_SHOW_ONBOARDING_MINI_MODAL = "show_onboarding_mini_modal";
private static final String PREF_NEXT_REWARDS_ONBOARDING_MODAL_DATE =
"next_rewards_onboarding_modal_date";
private static final String PREF_NEXT_BAP_MODAL_DATE = "next_bap_modal_date";
private static final String PREF_REWARDS_ENV_CHANGE = "rewards_env_change";
private static final String PREF_REWARDS_ONBOARDING_MODAL = "rewards_onboarding_modal";
private static final int FAVICON_CIRCLE_MEASUREMENTS = 70; // dp
Expand Down Expand Up @@ -103,17 +102,6 @@ public static void setNextRewardsOnboardingModalDate(long nextDate) {
sharedPreferencesEditor.apply();
}

public static long getNextBAPModalDate() {
return ContextUtils.getAppSharedPreferences().getLong(PREF_NEXT_BAP_MODAL_DATE, 0);
}

public static void setNextBAPModalDate(long nextDate) {
SharedPreferences.Editor sharedPreferencesEditor =
ContextUtils.getAppSharedPreferences().edit();
sharedPreferencesEditor.putLong(PREF_NEXT_BAP_MODAL_DATE, nextDate);
sharedPreferencesEditor.apply();
}

public static void setRewardsOnboardingModalShown(boolean isShown) {
SharedPreferences.Editor sharedPreferencesEditor =
ContextUtils.getAppSharedPreferences().edit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,7 @@ public void updateDrawState(@NonNull TextPaint ds) {
loginPopupWindow.setContentView(loginPopupView);

view.post(new Runnable() {
@Override
public void run() {
if (SysUtils.isLowEndDevice()) {
loginPopupWindow.setAnimationStyle(0);
Expand Down

This file was deleted.

121 changes: 1 addition & 120 deletions android/java/org/chromium/chrome/browser/app/BraveActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,19 @@
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ApplicationLifetime;
import org.chromium.chrome.browser.BraveConfig;
import org.chromium.chrome.browser.BraveFeatureList;
import org.chromium.chrome.browser.BraveHelper;
import org.chromium.chrome.browser.BraveRelaunchUtils;
import org.chromium.chrome.browser.BraveRewardsHelper;
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
import org.chromium.chrome.browser.BraveRewardsObserver;
import org.chromium.chrome.browser.BraveSyncReflectionUtils;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.CrossPromotionalModalDialogFragment;
import org.chromium.chrome.browser.DeprecateBAPModalDialogFragment;
import org.chromium.chrome.browser.LaunchIntentDispatcher;
import org.chromium.chrome.browser.SetDefaultBrowserActivity;
import org.chromium.chrome.browser.bookmarks.BookmarkBridge;
import org.chromium.chrome.browser.bookmarks.BookmarkModel;
import org.chromium.chrome.browser.brave_stats.BraveStatsUtil;
import org.chromium.chrome.browser.dependency_injection.ChromeActivityComponent;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.informers.BraveAndroidSyncDisabledInformer;
import org.chromium.chrome.browser.notifications.BraveSetDefaultBrowserNotificationService;
Expand Down Expand Up @@ -111,8 +107,7 @@
* Brave's extension for ChromeActivity
*/
@JNINamespace("chrome::android")
public abstract class BraveActivity<C extends ChromeActivityComponent>
extends ChromeActivity implements BraveRewardsObserver {
public abstract class BraveActivity<C extends ChromeActivityComponent> extends ChromeActivity {
public static final int SITE_BANNER_REQUEST_CODE = 33;
public static final int VERIFY_WALLET_ACTIVITY_REQUEST_CODE = 34;
public static final int USER_WALLET_ACTIVITY_REQUEST_CODE = 35;
Expand Down Expand Up @@ -145,12 +140,9 @@ public abstract class BraveActivity<C extends ChromeActivityComponent>
public static final String ANDROID_PACKAGE_NAME = "android";
public static final String BRAVE_BLOG_URL = "http://www.brave.com/blog";

private static final String JAPAN_COUNTRY_CODE = "JP";

// Explicitly declare this variable to avoid build errors.
// It will be removed in asm and parent variable will be used instead.
protected ObservableSupplier<Profile> mTabModelProfileSupplier;
private BraveRewardsNativeWorker mBraveRewardsNativeWorker;

private static final List<String> yandexRegions =
Arrays.asList("AM", "AZ", "BY", "KG", "KZ", "MD", "RU", "TJ", "TM", "UZ");
Expand All @@ -164,20 +156,6 @@ public BraveActivity() {
public void onResumeWithNative() {
super.onResumeWithNative();
BraveActivityJni.get().restartStatsUpdater();
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_REWARDS)
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()) {
if (mBraveRewardsNativeWorker == null)
mBraveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance();
mBraveRewardsNativeWorker.AddObserver(this);
}
}

@Override
public void onPauseWithNative() {
super.onPauseWithNative();
if (mBraveRewardsNativeWorker != null) {
mBraveRewardsNativeWorker.RemoveObserver(this);
}
}

@Override
Expand Down Expand Up @@ -410,69 +388,6 @@ public void finishNativeInitialization() {
calender.getTimeInMillis());
}
checkSetDefaultBrowserModal();
if (mBraveRewardsNativeWorker != null && mBraveRewardsNativeWorker.isRewardsEnabled()
&& ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_REWARDS)
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()) {
mBraveRewardsNativeWorker.StartProcess();
}
}

@Override
public void OnRewardsParameters(int errorCode) {
if (errorCode == BraveRewardsNativeWorker.LEDGER_OK && mBraveRewardsNativeWorker != null
&& mBraveRewardsNativeWorker.GetWalletBalance() != null
&& mBraveRewardsNativeWorker.GetWalletBalance().getTotal() > 0) {
checkForDeprecateBAPDialog();
}
}

@Override
public void OnStartProcess() {
mBraveRewardsNativeWorker.GetRewardsParameters();
}

private void checkForDeprecateBAPDialog() {
String countryCode = Locale.getDefault().getCountry();
if (countryCode.equals(JAPAN_COUNTRY_CODE) && !isRewardsPanelOpened()
&& System.currentTimeMillis() > BraveRewardsHelper.getNextBAPModalDate()) {
Calendar toDayCalendar = Calendar.getInstance();
Date todayDate = toDayCalendar.getTime();

Calendar march6Calendar = Calendar.getInstance();
march6Calendar.set(Calendar.DAY_OF_MONTH, 6);
march6Calendar.set(Calendar.YEAR, 2021);
march6Calendar.set(Calendar.MONTH, 2);
march6Calendar.set(Calendar.HOUR_OF_DAY, 0);
march6Calendar.set(Calendar.MINUTE, 0);
march6Calendar.set(Calendar.SECOND, 0);
march6Calendar.set(Calendar.MILLISECOND, 0);
Date march6Date = march6Calendar.getTime();

Calendar march13Calendar = Calendar.getInstance();
march13Calendar.set(Calendar.DAY_OF_MONTH, 13);
march13Calendar.set(Calendar.YEAR, 2021);
march13Calendar.set(Calendar.MONTH, 2);
march13Calendar.set(Calendar.HOUR_OF_DAY, 0);
march13Calendar.set(Calendar.MINUTE, 0);
march13Calendar.set(Calendar.SECOND, 0);
march13Calendar.set(Calendar.MILLISECOND, 0);
Date march13Date = march13Calendar.getTime();

boolean shouldSetNextDate = false;
if (todayDate.compareTo(march6Date) < 0) {
showRewardsTooltip();
shouldSetNextDate = true;
} else if (todayDate.compareTo(march6Date) > 0
&& todayDate.compareTo(march13Date) < 0) {
showDeprecateBAPDialog();
shouldSetNextDate = true;
}
if (shouldSetNextDate) {
Calendar calender = toDayCalendar;
calender.add(Calendar.DATE, DAYS_1);
BraveRewardsHelper.setNextBAPModalDate(calender.getTimeInMillis());
}
}
}

private void checkSetDefaultBrowserModal() {
Expand Down Expand Up @@ -587,14 +502,6 @@ public void hideRewardsOnboardingIcon() {
}
}

public void showRewardsTooltip() {
BraveToolbarLayout layout = (BraveToolbarLayout) findViewById(R.id.toolbar);
assert layout != null;
if (layout != null) {
layout.showRewardsTooltip();
}
}

private void createNotificationChannel() {
Context context = ContextUtils.getApplicationContext();
// Create the NotificationChannel, but only on API 26+ because
Expand Down Expand Up @@ -715,24 +622,6 @@ public void openRewardsPanel() {
}
}

public boolean isRewardsPanelOpened() {
BraveToolbarLayout layout = (BraveToolbarLayout) findViewById(R.id.toolbar);
assert layout != null;
if (layout != null) {
return layout.isRewardsPanelOpened();
}
return false;
}

public boolean isShieldsTooltipShown() {
BraveToolbarLayout layout = (BraveToolbarLayout) findViewById(R.id.toolbar);
assert layout != null;
if (layout != null) {
return layout.isShieldsTooltipShown();
}
return false;
}

public Tab selectExistingTab(String url) {
Tab tab = getActivityTab();
if (tab != null && tab.getUrlString().equals(url)) {
Expand Down Expand Up @@ -777,14 +666,6 @@ private void showCrossPromotionalDialog() {
mCrossPromotionalModalDialogFragment.show(getSupportFragmentManager(), "CrossPromotionalModalDialogFragment");
}

public void showDeprecateBAPDialog() {
DeprecateBAPModalDialogFragment mDeprecateBAPModalDialogFragment =
new DeprecateBAPModalDialogFragment();
mDeprecateBAPModalDialogFragment.setCancelable(false);
mDeprecateBAPModalDialogFragment.show(
getSupportFragmentManager(), "DeprecateBAPModalDialogFragment");
}

static public ChromeTabbedActivity getChromeTabbedActivity() {
for (Activity ref : ApplicationStatus.getRunningActivities()) {
if (!(ref instanceof ChromeTabbedActivity)) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public enum ShieldsTooltipEnum {
HTTPS_UPGRADE_TOOLTIP(ShieldsTooltipEnumConstants.HTTPS_UPGRADE_TOOLTIP,
R.string.tooltip_title_4, R.string.tooltip_text_4,
R.color.shields_tooltip_arrow_color_2, R.drawable.shields_tooltip_background_2),
BAP_DEPRECATION_TOOLTIP(ShieldsTooltipEnumConstants.BAP_DEPRECATION_TOOLTIP,
R.string.rewards_tooltip_title, R.string.rewards_tooltip_text,
R.color.rewards_tooltip_arrow_color, R.drawable.rewards_tooltip_background),
BRAVE_SHARE_STATS_TIER1_TOOLTIP(ShieldsTooltipEnumConstants.BRAVE_SHARE_STATS_TIER1_TOOLTIP,
R.string.brave_stats_share_tooltip_tier1_title,
R.string.brave_stats_share_tooltip_special_text, R.color.shields_tooltip_arrow_color_2,
Expand Down Expand Up @@ -102,7 +99,6 @@ interface ShieldsTooltipEnumConstants {
static final int VIDEO_ADS_BLOCKED_TOOLTIP = 1;
static final int ADS_TRACKER_BLOCKED_TOOLTIP = 2;
static final int HTTPS_UPGRADE_TOOLTIP = 3;
static final int BAP_DEPRECATION_TOOLTIP = 4;
static final int BRAVE_SHARE_STATS_TIER1_TOOLTIP = 5;
static final int BRAVE_SHARE_STATS_TIER2_TOOLTIP = 6;
static final int BRAVE_SHARE_STATS_TIER3_TOOLTIP = 7;
Expand Down
Loading

0 comments on commit 8db0058

Please sign in to comment.