From dcc5aea986e7e2504377d64eaa16c2413fedfd3a Mon Sep 17 00:00:00 2001 From: deeppandya Date: Thu, 16 Jan 2025 15:26:37 -0500 Subject: [PATCH] Add changes for handling creators Encode Url for creators --- .../browser/rewards/RewardsPageActivity.java | 25 +++++++++++-------- .../toolbar/top/BraveToolbarLayoutImpl.java | 9 +++++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/android/java/org/chromium/chrome/browser/rewards/RewardsPageActivity.java b/android/java/org/chromium/chrome/browser/rewards/RewardsPageActivity.java index 7105879fb451..2054a22fbc68 100644 --- a/android/java/org/chromium/chrome/browser/rewards/RewardsPageActivity.java +++ b/android/java/org/chromium/chrome/browser/rewards/RewardsPageActivity.java @@ -13,6 +13,7 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.Browser; import android.view.Gravity; @@ -22,6 +23,7 @@ import android.widget.ImageView; import androidx.browser.customtabs.CustomTabsIntent; +import androidx.core.content.res.ResourcesCompat; import org.chromium.base.IntentUtils; import org.chromium.chrome.R; @@ -32,7 +34,8 @@ /** New Rewards 3.0 custom tab activity */ public class RewardsPageActivity extends CustomTabActivity { - private static final int CLOSE_BUTTON_MARGIN = 32; + private static final int CLOSE_BUTTON_MARGIN = 16; + private static final int CLOSE_BUTTON_PADDING = 16; @Override public boolean supportsAppMenu() { @@ -57,22 +60,22 @@ public void performPostInflationStartup() { ViewGroup parentView = findViewById(android.R.id.content); ImageView closeImg = new ImageView(RewardsPageActivity.this); + closeImg.setPadding( + CLOSE_BUTTON_PADDING, + CLOSE_BUTTON_PADDING, + CLOSE_BUTTON_PADDING, + CLOSE_BUTTON_PADDING); + + Drawable drawable = + ResourcesCompat.getDrawable( + getResources(), R.drawable.blue_rounded_notification_bg, null); + closeImg.setBackground(drawable); closeImg.setImageResource(R.drawable.ic_baseline_close_24); closeImg.setOnClickListener( button -> { finish(); }); parentView.addView(closeImg, layoutParams); - - // OnBackPressedCallback callback = - // new OnBackPressedCallback(true /* enabled by default */) { - // @Override - // public void handleOnBackPressed() { - // // Handle the back button event - // } - // }; - - // getOnBackPressedDispatcher().addCallback(RewardsPageActivity.this, callback); } public static void showPage(Context context, String url) { diff --git a/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java b/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java index 61c9d2bee3aa..e7d55b430fd2 100644 --- a/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java +++ b/android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java @@ -117,6 +117,7 @@ import org.chromium.chrome.browser.util.BraveTouchUtils; import org.chromium.chrome.browser.util.ConfigurationUtils; import org.chromium.chrome.browser.util.PackageUtils; +import org.chromium.chrome.browser.util.TabUtils; import org.chromium.components.embedder_support.util.UrlUtilities; import org.chromium.components.feature_engagement.Tracker; import org.chromium.content_public.browser.NavigationHandle; @@ -134,6 +135,7 @@ import org.chromium.url.mojom.Url; import java.net.URL; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -516,6 +518,7 @@ public void onPageLoadStarted(Tab tab, GURL url) { mBraveShieldsHandler.clearBraveShieldsCount(tab.getId()); dismissShieldsTooltip(); hidePlaylistButton(); + mPublisherId = ""; } @Override @@ -1214,9 +1217,11 @@ public void onClickImpl(View v) { public void showRewardsPage() { String rewardsUrl = BraveActivity.BRAVE_REWARDS_SETTINGS_URL; if (mPublisherId != null && !mPublisherId.isEmpty()) { - rewardsUrl += "?creator=" + mPublisherId; + rewardsUrl += "?creator=" + URLEncoder.encode(mPublisherId); } - RewardsPageActivity.showPage(getContext(), rewardsUrl); + Log.e(TAG, "rewardsUrl: " + rewardsUrl); + TabUtils.openUrlInNewTab(false, rewardsUrl); + // RewardsPageActivity.showPage(getContext(), rewardsUrl); } private void maybeShowWalletPanel() {