Skip to content

Commit

Permalink
Uplift of #16232 to beta
Browse files Browse the repository at this point in the history
Implement Rewards 2.5 user states
  • Loading branch information
zenparsing committed Dec 6, 2022
1 parent 5b35602 commit f127efc
Show file tree
Hide file tree
Showing 301 changed files with 8,553 additions and 5,621 deletions.
44 changes: 16 additions & 28 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ brave_java_resources = [
"java/res/drawable-hdpi/uphold_green.png",
"java/res/drawable-hdpi/uphold_white.png",
"java/res/drawable-hdpi/verified_creator_large.png",
"java/res/drawable-hdpi/verified_disclosure.png",
"java/res/drawable-hdpi/yandex.png",
"java/res/drawable-mdpi/bat_logo.png",
"java/res/drawable-mdpi/bat_unverified.png",
Expand Down Expand Up @@ -165,7 +164,6 @@ brave_java_resources = [
"java/res/drawable-mdpi/uphold_green.png",
"java/res/drawable-mdpi/uphold_white.png",
"java/res/drawable-mdpi/verified_creator_large.png",
"java/res/drawable-mdpi/verified_disclosure.png",
"java/res/drawable-mdpi/yandex.png",
"java/res/drawable-night-hdpi/ic_cookie_background.png",
"java/res/drawable-night-mdpi/ic_cookie_background.png",
Expand Down Expand Up @@ -257,7 +255,6 @@ brave_java_resources = [
"java/res/drawable-xhdpi/uphold_green.png",
"java/res/drawable-xhdpi/uphold_white.png",
"java/res/drawable-xhdpi/verified_creator_large.png",
"java/res/drawable-xhdpi/verified_disclosure.png",
"java/res/drawable-xhdpi/yandex.png",
"java/res/drawable-xxhdpi/bat_logo.png",
"java/res/drawable-xxhdpi/bat_unverified.png",
Expand Down Expand Up @@ -334,7 +331,6 @@ brave_java_resources = [
"java/res/drawable-xxhdpi/uphold_green.png",
"java/res/drawable-xxhdpi/uphold_white.png",
"java/res/drawable-xxhdpi/verified_creator_large.png",
"java/res/drawable-xxhdpi/verified_disclosure.png",
"java/res/drawable-xxhdpi/yandex.png",
"java/res/drawable-xxxhdpi/bat_logo.png",
"java/res/drawable-xxxhdpi/bat_unverified.png",
Expand Down Expand Up @@ -405,22 +401,15 @@ brave_java_resources = [
"java/res/drawable-xxxhdpi/uphold_green.png",
"java/res/drawable-xxxhdpi/uphold_white.png",
"java/res/drawable-xxxhdpi/verified_creator_large.png",
"java/res/drawable-xxxhdpi/verified_disclosure.png",
"java/res/drawable-xxxhdpi/yandex.png",
"java/res/drawable//ic_circle_down.xml",
"java/res/drawable//ic_warning.xml",
"java/res/drawable/ac_radio_button_normal.xml",
"java/res/drawable/ac_radio_button_selected.xml",
"java/res/drawable/ac_radio_button_selector.xml",
"java/res/drawable/ac_radio_group_bg.xml",
"java/res/drawable/ac_text_selector.xml",
"java/res/drawable/ad_free_card_bg.xml",
"java/res/drawable/ads_custom_notification_border.xml",
"java/res/drawable/ads_custom_notification_border_dark.xml",
"java/res/drawable/bat_ads_logo_button.xml",
"java/res/drawable/bat_funds_selector.xml",
"java/res/drawable/bat_panel_gradient.xml",
"java/res/drawable/bat_rewards_summary_gradient.xml",
"java/res/drawable/bat_value_text_selector.xml",
"java/res/drawable/blue_48_rounded_bg.xml",
"java/res/drawable/blue_rounded_button.xml",
Expand Down Expand Up @@ -449,7 +438,6 @@ brave_java_resources = [
"java/res/drawable/brave_rewards_onboarding_selector.xml",
"java/res/drawable/brave_rewards_rectangle.xml",
"java/res/drawable/brave_rewards_warning_text_background.xml",
"java/res/drawable/brave_rewards_welcome_bg.xml",
"java/res/drawable/brave_shields_tooltip_text_bg.xml",
"java/res/drawable/brave_stats_radio_button_normal.xml",
"java/res/drawable/brave_stats_radio_button_selected.xml",
Expand Down Expand Up @@ -479,12 +467,14 @@ brave_java_resources = [
"java/res/drawable/default_dot.xml",
"java/res/drawable/default_indicator.xml",
"java/res/drawable/edittext_boarder_selector.xml",
"java/res/drawable/ic_ac_onboarding.xml",
"java/res/drawable/ic_accessibility.xml",
"java/res/drawable/ic_add.xml",
"java/res/drawable/ic_addresses.xml",
"java/res/drawable/ic_always_on_info.xml",
"java/res/drawable/ic_appearance.xml",
"java/res/drawable/ic_arrow_back.xml",
"java/res/drawable/ic_arrow_circle_right.xml",
"java/res/drawable/ic_arrow_clock.xml",
"java/res/drawable/ic_arrow_down.xml",
"java/res/drawable/ic_arrow_down_circular_day_night.xml",
Expand All @@ -502,6 +492,7 @@ brave_java_resources = [
"java/res/drawable/ic_baseline_more_vert_24.xml",
"java/res/drawable/ic_basic_check.xml",
"java/res/drawable/ic_bat_logo.xml",
"java/res/drawable/ic_bat_unverified_off.xml",
"java/res/drawable/ic_bell_icon.xml",
"java/res/drawable/ic_bg.xml",
"java/res/drawable/ic_bg_video_playback.xml",
Expand All @@ -521,12 +512,12 @@ brave_java_resources = [
"java/res/drawable/ic_check_white.xml",
"java/res/drawable/ic_checkbox_filled.xml",
"java/res/drawable/ic_checkbox_outline.xml",
"java/res/drawable/ic_chevron_left.xml",
"java/res/drawable/ic_chevron_right.xml",
"java/res/drawable/ic_clock.xml",
"java/res/drawable/ic_close.xml",
"java/res/drawable/ic_close_12.xml",
"java/res/drawable/ic_closing_all_closes_brave.xml",
"java/res/drawable/ic_connect_account.xml",
"java/res/drawable/ic_copy.xml",
"java/res/drawable/ic_cross.xml",
"java/res/drawable/ic_crypto_wallets.xml",
Expand All @@ -536,7 +527,6 @@ brave_java_resources = [
"java/res/drawable/ic_downloads.xml",
"java/res/drawable/ic_edit.xml",
"java/res/drawable/ic_embellishments.xml",
"java/res/drawable/ic_error_notification.xml",
"java/res/drawable/ic_eth.xml",
"java/res/drawable/ic_eth_24.xml",
"java/res/drawable/ic_exchange_button.xml",
Expand All @@ -548,12 +538,10 @@ brave_java_resources = [
"java/res/drawable/ic_globe_connect_icon.xml",
"java/res/drawable/ic_guardian.xml",
"java/res/drawable/ic_hearts.xml",
"java/res/drawable/ic_hearts_rewards.xml",
"java/res/drawable/ic_help.xml",
"java/res/drawable/ic_help_filled.xml",
"java/res/drawable/ic_home_screen_widget.xml",
"java/res/drawable/ic_homepage.xml",
"java/res/drawable/ic_icon_bat_eta.xml",
"java/res/drawable/ic_info.xml",
"java/res/drawable/ic_info_rewards.xml",
"java/res/drawable/ic_key.xml",
Expand All @@ -563,22 +551,22 @@ brave_java_resources = [
"java/res/drawable/ic_logo_bitflyer_colored.xml",
"java/res/drawable/ic_mask.xml",
"java/res/drawable/ic_menu.xml",
"java/res/drawable/ic_money_bag_coins.xml",
"java/res/drawable/ic_more_horiz.xml",
"java/res/drawable/ic_new_tab_page.xml",
"java/res/drawable/ic_news.xml",
"java/res/drawable/ic_news_settings.xml",
"java/res/drawable/ic_notification.xml",
"java/res/drawable/ic_notification_auto_contribute.xml",
"java/res/drawable/ic_notification_claim.xml",
"java/res/drawable/ic_notification_error.xml",
"java/res/drawable/ic_notification_icon.xml",
"java/res/drawable/ic_notification_info_icon.xml",
"java/res/drawable/ic_notification_pending.xml",
"java/res/drawable/ic_onboarding_arrow_down.xml",
"java/res/drawable/ic_onboarding_backup.xml",
"java/res/drawable/ic_onboarding_backup_dark.xml",
"java/res/drawable/ic_onboarding_graphic_android_brave_ads.xml",
"java/res/drawable/ic_onboarding_graphic_auto_contribute.xml",
"java/res/drawable/ic_onboarding_graphic_bat_ecosystem.xml",
"java/res/drawable/ic_onboarding_graphic_bat_schedule.xml",
"java/res/drawable/ic_onboarding_graphic_cashback.xml",
"java/res/drawable/ic_onboarding_graphic_completed.xml",
"java/res/drawable/ic_onboarding_graphic_tipping.xml",
"java/res/drawable/ic_onboarding_intro.xml",
Expand Down Expand Up @@ -636,13 +624,11 @@ brave_java_resources = [
"java/res/drawable/ic_twitter_logo_white.xml",
"java/res/drawable/ic_unverified_state.xml",
"java/res/drawable/ic_up_icon.xml",
"java/res/drawable/ic_uphold.xml",
"java/res/drawable/ic_verify_wallet_arrow.xml",
"java/res/drawable/ic_vimeo.xml",
"java/res/drawable/ic_vpn.xml",
"java/res/drawable/ic_vpn_promo.xml",
"java/res/drawable/ic_vpn_shield.xml",
"java/res/drawable/ic_wallet_arrow.xml",
"java/res/drawable/ic_wallet_lock.xml",
"java/res/drawable/ic_wallet_settings.xml",
"java/res/drawable/ic_warning_circle.xml",
Expand Down Expand Up @@ -671,11 +657,12 @@ brave_java_resources = [
"java/res/drawable/rect_round_corners_12.xml",
"java/res/drawable/rect_up_round_corners_12.xml",
"java/res/drawable/rewards_button_orange.xml",
"java/res/drawable/rewards_panel_notification_date_bg.xml",
"java/res/drawable/rewards_panel_unverified_off_bg.xml",
"java/res/drawable/rewards_settings_gradient_bg.xml",
"java/res/drawable/rewards_tipping_radio_button_normal.xml",
"java/res/drawable/rewards_tipping_radio_button_selected.xml",
"java/res/drawable/rewards_tipping_radio_button_selector.xml",
"java/res/drawable/rewards_tipping_radio_group_bg.xml",
"java/res/drawable/rounded_8_bottom_bg.xml",
"java/res/drawable/rounded_8_top_bg.xml",
"java/res/drawable/rounded_corners.xml",
Expand Down Expand Up @@ -705,7 +692,6 @@ brave_java_resources = [
"java/res/drawable/transparent_bg_bordered.xml",
"java/res/drawable/twitter_button_background.xml",
"java/res/drawable/unverified_48_rounded_bg.xml",
"java/res/drawable/wallet_disconnected_button.xml",
"java/res/drawable/wallet_radio_button_normal.xml",
"java/res/drawable/wallet_radio_button_selected.xml",
"java/res/drawable/wallet_radio_button_selector.xml",
Expand All @@ -715,9 +701,10 @@ brave_java_resources = [
"java/res/drawable/white_48_rounded_bg.xml",
"java/res/drawable/white_rounded_holo_button_thin.xml",
"java/res/drawable/yearly_selector.xml",
"java/res/font/poppins_light.ttf",
"java/res/font/poppins_medium.ttf",
"java/res/font/poppins_regular.ttf",
"java/res/font/poppins_300.ttf",
"java/res/font/poppins_400.ttf",
"java/res/font/poppins_500.ttf",
"java/res/font/poppins_600.ttf",
"java/res/layout-land/brave_shields_stats_row.xml",
"java/res/layout-land/verify_wallet_activity.xml",
"java/res/layout-sw600dp-land/brave_shields_stats_row.xml",
Expand Down Expand Up @@ -777,12 +764,12 @@ brave_java_resources = [
"java/res/layout/brave_rewards_panel_settings_layout.xml",
"java/res/layout/brave_rewards_panel_summary_layout.xml",
"java/res/layout/brave_rewards_panel_tip_layout.xml",
"java/res/layout/brave_rewards_panel_unverified_layout.xml",
"java/res/layout/brave_rewards_reset_tab_content.xml",
"java/res/layout/brave_rewards_site_banner.xml",
"java/res/layout/brave_rewards_tip_confirmation.xml",
"java/res/layout/brave_rewards_tip_failure_fragment.xml",
"java/res/layout/brave_rewards_tipping_panel.xml",
"java/res/layout/brave_rewards_welcome_layout.xml",
"java/res/layout/brave_set_default_browser_dialog.xml",
"java/res/layout/brave_shields_main_layout.xml",
"java/res/layout/brave_shields_option_layout.xml",
Expand Down Expand Up @@ -820,6 +807,7 @@ brave_java_resources = [
"java/res/layout/brave_wallet_toolbar.xml",
"java/res/layout/brave_webrtc_policy_preference.xml",
"java/res/layout/bre_bottom_banner.xml",
"java/res/layout/connect_account_layout.xml",
"java/res/layout/custom_layout_preference.xml",
"java/res/layout/dapps_dialog.xml",
"java/res/layout/dialog_aurora_bridge.xml",
Expand Down
15 changes: 1 addition & 14 deletions android/java/org/chromium/chrome/browser/BraveRewardsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
import java.util.Calendar;
import java.util.Locale;

public class BraveRewardsHelper implements LargeIconBridge.LargeIconCallback{
private static final String PREF_BRAVE_REWARDS_APP_OPEN_COUNT = "brave_rewards_app_open_count";
public class BraveRewardsHelper implements LargeIconBridge.LargeIconCallback {
private static final String PREF_SHOW_BRAVE_REWARDS_ONBOARDING_MODAL =
"show_brave_rewards_onboarding_modal";
private static final String PREF_SHOW_BRAVE_REWARDS_ONBOARDING_ONCE =
Expand Down Expand Up @@ -134,18 +133,6 @@ && shouldShowBraveRewardsOnboardingModal() && braveRewardsNativeWorker != null
return false;
}

public static int getBraveRewardsAppOpenCount() {
return ContextUtils.getAppSharedPreferences().getInt(PREF_BRAVE_REWARDS_APP_OPEN_COUNT, 0);
}

public static void updateBraveRewardsAppOpenCount() {
SharedPreferences.Editor sharedPreferencesEditor = ContextUtils.getAppSharedPreferences().edit();
sharedPreferencesEditor.putInt(PREF_BRAVE_REWARDS_APP_OPEN_COUNT,
SharedPreferencesManager.getInstance().readInt(
BravePreferenceKeys.BRAVE_APP_OPEN_COUNT));
sharedPreferencesEditor.apply();
}

public static boolean shouldShowMiniOnboardingModal() {
return ContextUtils.getAppSharedPreferences().getBoolean(
PREF_SHOW_ONBOARDING_MINI_MODAL, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface PublisherObserver { void onFrontTabPublisherChanged(boolean ver
public static final int REWARDS_NOTIFICATION_TIPS_PROCESSED = 8;
public static final int REWARDS_NOTIFICATION_ADS_ONBOARDING = 9;
public static final int REWARDS_NOTIFICATION_VERIFIED_PUBLISHER = 10;
public static final int REWARDS_NOTIFICATION_PENDING_NOT_ENOUGH_FUNDS = 11;
public static final int REWARDS_NOTIFICATION_GENERAL_LEDGER = 12;

public static final int LEDGER_OK = 0;
public static final int LEDGER_ERROR = 1;
Expand Down Expand Up @@ -193,6 +195,12 @@ public void GetRewardsParameters() {
}
}

public void fetchBalance() {
synchronized (lock) {
BraveRewardsNativeWorkerJni.get().fetchBalance(mNativeBraveRewardsNativeWorker);
}
}

@Nullable
public BraveRewardsBalance GetWalletBalance() {
synchronized(lock) {
Expand All @@ -216,6 +224,13 @@ public String getExternalWalletType() {
}
}

public boolean canConnectAccount() {
synchronized (lock) {
return BraveRewardsNativeWorkerJni.get().canConnectAccount(
mNativeBraveRewardsNativeWorker);
}
}

public double[] GetTipChoices() {
synchronized (lock) {
return BraveRewardsNativeWorkerJni.get().GetTipChoices(mNativeBraveRewardsNativeWorker);
Expand Down Expand Up @@ -462,6 +477,20 @@ public void GetPublisherBanner(String publisher_key) {
}
}

public void getPublishersVisitedCount() {
synchronized (lock) {
BraveRewardsNativeWorkerJni.get().getPublishersVisitedCount(
mNativeBraveRewardsNativeWorker);
}
}

@CalledByNative
public void onGetPublishersVisitedCount(int count) {
for (BraveRewardsObserver observer : mObservers) {
observer.onGetPublishersVisitedCount(count);
}
}

public void DisconnectWallet() {
synchronized (lock) {
BraveRewardsNativeWorkerJni.get().disconnectWallet(mNativeBraveRewardsNativeWorker);
Expand Down Expand Up @@ -518,9 +547,16 @@ public void OnRefreshPublisher(int status, String publisherKey) {
}

@CalledByNative
public void OnRewardsParameters(int errorCode) {
public void OnRewardsParameters() {
for (BraveRewardsObserver observer : mObservers) {
observer.OnRewardsParameters(errorCode);
observer.OnRewardsParameters();
}
}

@CalledByNative
public void onBalance(int errorCode) {
for (BraveRewardsObserver observer : mObservers) {
observer.onBalance(errorCode);
}
}

Expand Down Expand Up @@ -658,9 +694,23 @@ public void OnGetAdsAccountStatement(boolean success, double next_payment_date,
}

@CalledByNative
public void OnDisconnectWallet(int error_code, String external_wallet) {
public void OnExternalWalletConnected() {
for (BraveRewardsObserver observer : mObservers) {
observer.OnExternalWalletConnected();
}
}

@CalledByNative
public void OnExternalWalletLoggedOut() {
for (BraveRewardsObserver observer : mObservers) {
observer.OnExternalWalletLoggedOut();
}
}

@CalledByNative
public void OnExternalWalletReconnected() {
for (BraveRewardsObserver observer : mObservers) {
observer.OnDisconnectWallet(error_code, external_wallet);
observer.OnExternalWalletReconnected();
}
}

Expand Down Expand Up @@ -716,6 +766,8 @@ interface Natives {
String getWalletBalance(long nativeBraveRewardsNativeWorker);
String getExternalWalletType(long nativeBraveRewardsNativeWorker);
void GetPublisherBanner(long nativeBraveRewardsNativeWorker, String publisher_key);
void getPublishersVisitedCount(long nativeBraveRewardsNativeWorker);
boolean canConnectAccount(long nativeBraveRewardsNativeWorker);
double[] GetTipChoices(long nativeBraveRewardsNativeWorker);
double getWalletRate(long nativeBraveRewardsNativeWorker);
void getPublisherInfo(long nativeBraveRewardsNativeWorker, int tabId, String host);
Expand Down Expand Up @@ -759,6 +811,7 @@ boolean isCurrentPublisherInRecurrentDonations(
void refreshPublisher(long nativeBraveRewardsNativeWorker, String publisherKey);
void createRewardsWallet(long nativeBraveRewardsNativeWorker, String countryCode);
void getRewardsParameters(long nativeBraveRewardsNativeWorker);
void fetchBalance(long nativeBraveRewardsNativeWorker);
void setAutoContributeEnabled(
long nativeBraveRewardsNativeWorker, boolean isSetAutoContributeEnabled);
void setAutoContributionAmount(long nativeBraveRewardsNativeWorker, double amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

public interface BraveRewardsObserver {
default public void onCreateRewardsWallet(String result){};
default public void OnRewardsParameters(int errorCode){};
default public void OnRewardsParameters(){};
default public void onBalance(int errorCode){};
default public void OnPublisherInfo(int tabId){};
default public void OnGetCurrentBalanceReport(double[] report){};
default public void OnNotificationAdded(String id, int type, long timestamp, String[] args){};
Expand All @@ -23,7 +24,9 @@ default public void OnGetLatestNotification(
default public void OnGrantFinish(int result){};
default public void OnGetExternalWallet(String external_wallet){};
default public void onGetAvailableCountries(String[] countries){};
default public void OnDisconnectWallet(int error_code, String external_wallet){};
default public void OnExternalWalletConnected(){};
default public void OnExternalWalletLoggedOut(){};
default public void OnExternalWalletReconnected(){};
default public void OnClaimPromotion(int error_code){};
default public void onUnblindedTokensReady() {}
default public void onReconcileComplete(int resultCode, int rewardsType, double amount) {}
Expand All @@ -33,4 +36,5 @@ default public void onReconcileComplete(int resultCode, int rewardsType, double
default public void OnGetAdsAccountStatement(boolean success, double nextPaymentDate,
int adsReceivedThisMonth, double earningsThisMonth, double earningsLastMonth){};
default public void onPublisherBanner(String jsonBannerInfo){};
default public void onGetPublishersVisitedCount(int count){};
}
Loading

0 comments on commit f127efc

Please sign in to comment.