diff --git a/android/java/org/chromium/chrome/browser/BraveRewardsHelper.java b/android/java/org/chromium/chrome/browser/BraveRewardsHelper.java index 9e79030d29e6..2901b05c3f41 100644 --- a/android/java/org/chromium/chrome/browser/BraveRewardsHelper.java +++ b/android/java/org/chromium/chrome/browser/BraveRewardsHelper.java @@ -32,6 +32,7 @@ import org.jni_zero.CalledByNative; +import org.chromium.base.Callback; import org.chromium.base.ContextUtils; import org.chromium.chrome.R; import org.chromium.chrome.browser.app.BraveActivity; @@ -587,8 +588,38 @@ public static SpannableString tosSpannableString(String text, int colorRes) { return textSpannableString; } - public static void setSpan(Context context, String text, SpannableString tosTextSS, - int stringId, ClickableSpan clickableSpan) { + public static SpannableString toSpannableString( + String text, + int colorRes, + int clickableSubstringResId, + Callback onSubstringClicked) { + Context context = ContextUtils.getApplicationContext(); + Spanned textSpanned = spannedFromHtmlString(text); + SpannableString textSpannableString = new SpannableString(textSpanned.toString()); + + NoUnderlineClickableSpan substringClickableSpan = + new NoUnderlineClickableSpan( + context, + colorRes, + (textView) -> { + onSubstringClicked.onResult(context); + }); + + setSpan( + context, + text, + textSpannableString, + clickableSubstringResId, + substringClickableSpan); + return textSpannableString; + } + + public static void setSpan( + Context context, + String text, + SpannableString tosTextSS, + int stringId, + ClickableSpan clickableSpan) { String spanString = context.getResources().getString(stringId); int spanLength = spanString.length(); int index = text.indexOf(spanString); diff --git a/android/java/org/chromium/chrome/browser/app/BraveActivity.java b/android/java/org/chromium/chrome/browser/app/BraveActivity.java index 3dfa0cdc136c..dd80dd222f13 100644 --- a/android/java/org/chromium/chrome/browser/app/BraveActivity.java +++ b/android/java/org/chromium/chrome/browser/app/BraveActivity.java @@ -256,6 +256,8 @@ public abstract class BraveActivity extends ChromeActivity "https://basicattentiontoken.org/user-terms-of-service/"; public static final String BRAVE_PRIVACY_POLICY = "https://brave.com/privacy/browser/#rewards"; public static final String OPEN_URL = "open_url"; + public static final String BRAVE_WEBCOMPAT_INFO_WIKI_URL = + "https://github.com/brave/brave-browser/wiki/Web-compatibility-reports"; private static final int DAYS_1 = 1; private static final int DAYS_4 = 4; diff --git a/android/java/org/chromium/chrome/browser/shields/BraveShieldsHandler.java b/android/java/org/chromium/chrome/browser/shields/BraveShieldsHandler.java index 448db20bf67f..3f94ad03a9fb 100644 --- a/android/java/org/chromium/chrome/browser/shields/BraveShieldsHandler.java +++ b/android/java/org/chromium/chrome/browser/shields/BraveShieldsHandler.java @@ -4,6 +4,7 @@ * You can obtain one at https://mozilla.org/MPL/2.0/. */ package org.chromium.chrome.browser.shields; + import android.animation.AnimatorSet; import android.app.Activity; import android.content.Context; @@ -17,6 +18,7 @@ import android.net.Uri; import android.os.Build; import android.text.SpannableString; +import android.text.method.LinkMovementMethod; import android.text.method.ScrollingMovementMethod; import android.text.style.StyleSpan; import android.view.ContextThemeWrapper; @@ -44,6 +46,7 @@ import org.chromium.chrome.browser.BraveRewardsNativeWorker; import org.chromium.chrome.browser.app.BraveActivity; import org.chromium.chrome.browser.brave_stats.BraveStatsUtil; +import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.night_mode.GlobalNightModeStateProviderHolder; import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge; @@ -114,6 +117,7 @@ public BlockersInfo() { private BraveRewardsNativeWorker mBraveRewardsNativeWorker; private BraveRewardsHelper mIconFetcher; + private TextView mReportBrokenSiteDisclaimerView; private String mUrlSpec; private String mHost; @@ -741,13 +745,32 @@ private void setUpReportBrokenSiteLayout() { mReportSiteUrlText.setText(siteUrl); mReportSiteUrlText.setMovementMethod(new ScrollingMovementMethod()); + mReportBrokenSiteDisclaimerView = + mReportBrokenSiteLayout.findViewById(R.id.report_broken_site_disclaimer_text); + String reportBrokenSiteDisclaimerText = + String.format( + mContext.getResources().getString(R.string.report_broken_site_text_2), + mContext.getResources().getString(R.string.report_broken_site_text_link)); + + mReportBrokenSiteDisclaimerView.setText( + BraveRewardsHelper.toSpannableString( + reportBrokenSiteDisclaimerText, + R.color.brave_link, + R.string.report_broken_site_text_link, + (context) -> { + CustomTabActivity.showInfoPage( + context, BraveActivity.BRAVE_WEBCOMPAT_INFO_WIKI_URL); + })); + mReportBrokenSiteDisclaimerView.setMovementMethod(LinkMovementMethod.getInstance()); + Button mCancelButton = mReportBrokenSiteLayout.findViewById(R.id.btn_cancel); - mCancelButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - hideBraveShieldsMenu(); - } - }); + mCancelButton.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View view) { + hideBraveShieldsMenu(); + } + }); Button mSubmitButton = mReportBrokenSiteLayout.findViewById(R.id.btn_submit); mSubmitButton.setOnClickListener( diff --git a/android/java/res/layout/report_broken_site_layout.xml b/android/java/res/layout/report_broken_site_layout.xml index 2d796727d9b4..689bc9ce4672 100644 --- a/android/java/res/layout/report_broken_site_layout.xml +++ b/android/java/res/layout/report_broken_site_layout.xml @@ -43,11 +43,11 @@ android:layout_marginBottom="14dp"/> + android:textColor="@color/default_icon_color_tint_list"/> - Note: This site address will be submitted with your Brave version number and your IP address(which will not be stored). + Thank you for helping make Brave better for all. This report will only contain information necessary for us to fix this site. %1$s + + + Learn more. This is an error page. It cannot be reported as a broken site. diff --git a/components/resources/brave_components_strings.grd b/components/resources/brave_components_strings.grd index 7dcec136ab2d..b95345040460 100644 --- a/components/resources/brave_components_strings.grd +++ b/components/resources/brave_components_strings.grd @@ -451,7 +451,7 @@ This page cannot be reported because it was not served over HTTP/HTTPS. This page is a local web page and is not eligible for reporting. This is an error page. It cannot be reported as a broken site. - Thank you for helping make Brave better for all. This report will only send information necessary for us to fix this site. + Thank you for helping make Brave better for all. This report will only contain information necessary for us to fix this site. Learn more. Additional details (optional) Contact me at: (optional)