Skip to content

Commit

Permalink
Merge pull request #7580 from brave/add_rewards_bottom_banner_existin…
Browse files Browse the repository at this point in the history
…g_user_android

Add rewards bottom banner existing user android
  • Loading branch information
deeppandya authored Jan 13, 2021
2 parents 95dfa11 + b8d2cf7 commit 619e551
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 13 deletions.
1 change: 1 addition & 0 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ brave_java_resources = [
"java/res/layout/brave_sync_done.xml",
"java/res/layout/brave_sync_layout.xml",
"java/res/layout/brave_toolbar.xml",
"java/res/layout/bre_bottom_banner.xml",
"java/res/layout/crypto_widget_layout.xml",
"java/res/layout/ddg_offer_layout.xml",
"java/res/layout/fragment_binance_buy.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,6 @@ public void onClick(View view) {
}
if (BraveAdsNativeHelper.nativeIsBraveAdsEnabled(Profile.getLastUsedRegularProfile())) {
showBraveRewardsWelcomeLayout(root);
} else {
showBraveRewardsOptInLayout(root);
}
} else {
braveRewardsViewPager.setCurrentItem(braveRewardsViewPager.getCurrentItem() + 1);
Expand Down Expand Up @@ -844,20 +842,26 @@ public void setContentView(View root) {

public void showLikePopDownMenu() {
this.showLikePopDownMenu(0, 0);
checkForRewardsOnboarding();
BraveRewardsNativeWorker.getInstance().StartProcess();
}

private void checkForRewardsOnboarding() {
if (root != null && ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_REWARDS)
&& BraveRewardsHelper.shouldShowBraveRewardsOnboardingOnce()) {
showBraveRewardsOnboarding(root, false);
BraveRewardsHelper.setShowBraveRewardsOnboardingOnce(false);
}
}

@Override
public void OnStartProcess() {
if (root != null && PackageUtils.isFirstInstall(mActivity)
&& ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_REWARDS)) {
if (BraveRewardsHelper.shouldShowBraveRewardsOnboardingOnce()) {
showBraveRewardsOnboarding(root, false);
BraveRewardsHelper.setShowBraveRewardsOnboardingOnce(false);
} else if (BraveRewardsHelper.getBraveRewardsAppOpenCount() == 0
if (BraveRewardsHelper.getBraveRewardsAppOpenCount() == 0
&& BraveRewardsHelper.shouldShowBraveRewardsOnboardingModal()
&& !BraveAdsNativeHelper.nativeIsBraveAdsEnabled(
Profile.getLastUsedRegularProfile())) {
Profile.getLastUsedRegularProfile())) {
showBraveRewardsOnboardingModal(root);
BraveRewardsHelper.updateBraveRewardsAppOpenCount();
BraveRewardsHelper.setShowBraveRewardsOnboardingModal(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public void onPageSelected(int position) {
public void onPageScrollStateChanged(int state) {}
});
showWidgetBasedOnOrder();
NTPUtil.showBREBottomBanner(this);
}

private void showFallBackNTPLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import org.chromium.chrome.browser.ntp_background_images.model.Wallpaper;
import org.chromium.chrome.browser.ntp_background_images.util.SponsoredImageUtil;
import org.chromium.chrome.browser.preferences.BravePref;
import org.chromium.chrome.browser.preferences.BravePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.settings.BackgroundImagesPreferences;
import org.chromium.chrome.browser.tab.TabLaunchType;
Expand Down Expand Up @@ -133,6 +135,38 @@ public static int checkForNonDisruptiveBanner(NTPImage ntpImage, SponsoredTab sp
return SponsoredImageUtil.BR_INVALID_OPTION;
}

public static void showBREBottomBanner(View view) {
Context context = ContextUtils.getApplicationContext();
if (!PackageUtils.isFirstInstall(context)
&& BraveAdsNativeHelper.nativeIsBraveAdsEnabled(Profile.getLastUsedRegularProfile())
&& ContextUtils.getAppSharedPreferences().getBoolean(
BackgroundImagesPreferences.PREF_SHOW_BRE_BANNER, true)) {
final ViewGroup breBottomBannerLayout = (ViewGroup) view.findViewById(R.id.bre_banner);
breBottomBannerLayout.setVisibility(View.VISIBLE);
BackgroundImagesPreferences.setOnPreferenceValue(
BackgroundImagesPreferences.PREF_SHOW_BRE_BANNER, false);
ImageView bannerClose = breBottomBannerLayout.findViewById(R.id.bre_banner_close);
bannerClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
breBottomBannerLayout.setVisibility(View.GONE);
}
});

Button takeTourButton = breBottomBannerLayout.findViewById(R.id.btn_take_tour);
takeTourButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (BraveActivity.getBraveActivity() != null) {
BraveRewardsHelper.setShowBraveRewardsOnboardingOnce(true);
BraveActivity.getBraveActivity().openRewardsPanel();
}
breBottomBannerLayout.setVisibility(View.GONE);
}
});
}
}

public static void showNonDisruptiveBanner(ChromeActivity chromeActivity, View view, int ntpType, SponsoredTab sponsoredTab, NewTabPageListener newTabPageListener) {
final ViewGroup nonDisruptiveBannerLayout = (ViewGroup) view.findViewById(R.id.non_disruptive_banner);
nonDisruptiveBannerLayout.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class BackgroundImagesPreferences
public static final String PREF_SHOW_BACKGROUND_IMAGES = "show_background_images";
public static final String PREF_SHOW_SPONSORED_IMAGES = "show_sponsored_images";
public static final String PREF_SHOW_NON_DISRUPTIVE_BANNER = "show_non_disruptive_banner";
public static final String PREF_SHOW_BRE_BANNER = "show_bre_banner";
public static final String PREF_WIDGET_STACK = "widget_stack";

private ChromeSwitchPreference showBackgroundImagesPref;
Expand Down
1 change: 1 addition & 0 deletions android/java/res/layout/brave_rewards_onboarding_modal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:lineSpacingMultiplier="1.5"
android:text="@string/brave_rewards_tos_text"
android:textSize="12sp"
android:textStyle="bold"
Expand Down
74 changes: 74 additions & 0 deletions android/java/res/layout/bre_bottom_banner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 The Brave Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bre_banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@color/ntp_non_disruptive_banner_bg_color"
android:layout_gravity="center_horizontal|bottom"
android:orientation="vertical"
android:visibility="gone">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:orientation="horizontal">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="16sp"
android:drawableStart="@drawable/bat_logo"
android:drawablePadding="16dp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:text="@string/brave_ui_brave_rewards"/>

<ImageView
android:id="@+id/bre_banner_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/btn_close_white"/>

</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_marginBottom="4dp"
android:text="@string/bre_banner_title_text"
android:textColor="@android:color/white"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginBottom="20dp"
android:text="@string/bre_banner_text"
android:textColor="@android:color/white"/>

<Button
android:id="@+id/btn_take_tour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical"
android:background="@drawable/blue_rounded_button"
android:text="@string/take_quick_tour"
android:textAllCaps="false"
android:textSize="16sp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_marginBottom="20dp"
android:textColor="@android:color/white"
style="?android:attr/borderlessButtonStyle"/>

</LinearLayout>
1 change: 1 addition & 0 deletions android/java/res/layout/new_tab_page_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
</LinearLayout>

<include layout="@layout/ntp_non_disruptive_banner"/>
<include layout="@layout/bre_bottom_banner"/>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/super_referral_logo"
Expand Down
18 changes: 12 additions & 6 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1472,19 +1472,19 @@ until they verify, or until 90 days have passed.
Welcome to Brave Rewards!
</message>
<message name="IDS_WELCOME_TO_BRAVE_REWARDS_TEXT" desc="Brave rewards onboarding title">
Brave private ads rewards you with tokens to support content creators unlike traditional ads, all while keeping your personal information private.
Brave Private Ads reward you with tokens to support content creators unlike traditional ads, all while keeping your personal information private.
</message>
<message name="IDS_WHERE_DO_ADS_SHOW_UP" desc="Brave rewards onboarding title">
Where do ads show up?
</message>
<message name="IDS_WHERE_DO_ADS_SHOW_UP_TEXT" desc="Brave rewards onboarding title">
Brave private ads will appear as a normal notification. You control how often you see these ads in settings.
Brave Private Ads will appear as a normal notification. You control how often you see these ads in settings.
</message>
<message name="IDS_WHEN_DO_YOU_RECEIVE_REWARDS" desc="Brave rewards onboarding title">
When do you receive rewards
</message>
<message name="IDS_WHEN_DO_YOU_RECEIVE_REWARDS_TEXT" desc="Brave rewards onboarding title">
Your earned tokens from Brave ads throughout the current month will arrive on the 5th of the next month.
Your earned tokens from Brave Private Ads throughout the current month will arrive on the 5th of the next month.
</message>
<message name="IDS_GIVING_BACK_MADE_EFFORTLESS" desc="Brave rewards onboarding title">
Giving back made effortless
Expand All @@ -1496,13 +1496,13 @@ until they verify, or until 90 days have passed.
Say thank you with tips
</message>
<message name="IDS_SAY_THANK_YOU_WITH_TIPS_TEXT" desc="Brave rewards onboarding title">
Tipping is a way to personally encourage and support content or creators that you love. Get tippin!
Tipping is a way to personally encourage and support content or creators that you absolutely love. Get tippin!
</message>
<message name="IDS_WHAT_CAN_YOU_DO_WITH_TOKENS" desc="Brave rewards onboarding title">
What can you do with tokens?
</message>
<message name="IDS_WHAT_CAN_YOU_DO_WITH_TOKENS_TEXT" desc="Brave rewards onboarding title">
Tokens can be used beyond supporting creators. You can buy digital goods and giftcards with a cashback bonus.
Tokens can be used beyond supporting creators. You can buy digital content and other goods as merchants come onboard.
</message>
<message name="IDS_BASIC_SETTINGS" desc="Brave rewards onboarding title">
Lastly, let’s get you set up on the basic settings
Expand All @@ -1517,7 +1517,7 @@ until they verify, or until 90 days have passed.
How much support do you want to give to your favorite creators?\n(from your ads earnings)
</message>
<message name="IDS_YOU_ARE_DONE" desc="Brave rewards onboarding title">
WOOOOHOOOOO!\nYou’re done.
Woohoo, you’re all set!
</message>
<message name="IDS_YOU_ARE_DONE_TEXT" desc="Brave rewards onboarding title">
By using Brave Rewards, you are protecting your privacy and helping make the web a better place for everyone. And that’s awesome!
Expand Down Expand Up @@ -1600,6 +1600,12 @@ until they verify, or until 90 days have passed.
<message name="IDS_PRIVATE_PRODUCT_ANALYSIS_TEXT" desc="private product analysis text">
private product analytics.
</message>
<message name="IDS_BRE_BANNER_TITLE_TEXT" desc="BRE banner title text">
Need a refresher on Rewards?
</message>
<message name="IDS_BRE_BANNER_TEXT" desc="BRE banner text">
Take a quick tour to brush up on how it works to go down in history as a Rewards rockstar!
</message>
</messages>
</release>
</grit>

0 comments on commit 619e551

Please sign in to comment.