Commit c8ecd260 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Incognito] Refactor incognito interstitial view setup

This CL refactors the incognito interstitial view setup by regrouping
it in the same class as the view binding method so that we can have all
the view related methods in one place.

There is no behavior change with this refactoring.

Bug: 1138824
Change-Id: Iaeceed44202e1973c765ac7c807b122e4be696d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506435Reviewed-by: default avatarRohit Agarwal <roagarwal@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822116}
parent 4aedc0e7
...@@ -4,15 +4,11 @@ ...@@ -4,15 +4,11 @@
package org.chromium.chrome.browser.incognito.interstitial; package org.chromium.chrome.browser.incognito.interstitial;
import android.text.style.StyleSpan;
import android.view.View; import android.view.View;
import android.widget.TextView;
import androidx.annotation.MainThread; import androidx.annotation.MainThread;
import org.chromium.chrome.R;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor; import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.text.SpanApplier;
/** /**
* The coordinator of the incognito interstitial along with IncognitoInterstitialDelegate are the * The coordinator of the incognito interstitial along with IncognitoInterstitialDelegate are the
...@@ -35,25 +31,10 @@ public class IncognitoInterstitialCoordinator { ...@@ -35,25 +31,10 @@ public class IncognitoInterstitialCoordinator {
@MainThread @MainThread
public IncognitoInterstitialCoordinator( public IncognitoInterstitialCoordinator(
View view, IncognitoInterstitialDelegate incognitoInterstitialDelegate) { View view, IncognitoInterstitialDelegate incognitoInterstitialDelegate) {
formatIncognitoInterstitialMessage(view); IncognitoInterstitialViewBinder.setUpView(view);
IncognitoInterstitialMediator mediator = IncognitoInterstitialMediator mediator =
new IncognitoInterstitialMediator(incognitoInterstitialDelegate); new IncognitoInterstitialMediator(incognitoInterstitialDelegate);
PropertyModelChangeProcessor.create( PropertyModelChangeProcessor.create(
mediator.getModel(), view, IncognitoInterstitialViewBinder::bindView); mediator.getModel(), view, IncognitoInterstitialViewBinder::bindView);
} }
private static void formatIncognitoInterstitialMessage(View incognitoInterstitialView) {
TextView incognitoInterstitialMessageView =
incognitoInterstitialView.findViewById(R.id.incognito_interstitial_message);
String incognitoInterstitialMessageText =
incognitoInterstitialMessageView.getText().toString();
incognitoInterstitialMessageView.setText(
SpanApplier.applySpans(incognitoInterstitialMessageText,
new SpanApplier.SpanInfo(
"<b1>", "</b1>", new StyleSpan(android.graphics.Typeface.BOLD)),
new SpanApplier.SpanInfo(
"<b2>", "</b2>", new StyleSpan(android.graphics.Typeface.BOLD))));
}
} }
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
package org.chromium.chrome.browser.incognito.interstitial; package org.chromium.chrome.browser.incognito.interstitial;
import android.text.style.StyleSpan;
import android.view.View; import android.view.View;
import android.widget.TextView;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.text.SpanApplier;
/** /**
* This class regroups the bindView util methods of the * This class regroups the bindView util methods of the
...@@ -30,6 +33,18 @@ class IncognitoInterstitialViewBinder { ...@@ -30,6 +33,18 @@ class IncognitoInterstitialViewBinder {
} }
} }
/**
* Sets up the incognito interstitial view.
*/
static void setUpView(View view) {
TextView message = view.findViewById(R.id.incognito_interstitial_message);
message.setText(SpanApplier.applySpans(message.getText().toString(),
new SpanApplier.SpanInfo(
"<b1>", "</b1>", new StyleSpan(android.graphics.Typeface.BOLD)),
new SpanApplier.SpanInfo(
"<b2>", "</b2>", new StyleSpan(android.graphics.Typeface.BOLD))));
}
// Necessary helper methods to return the subviews present inside the incognito // Necessary helper methods to return the subviews present inside the incognito
// interstitial |view|. // interstitial |view|.
// TODO(crbug.com/1103262): Add these methods to the IncognitoInterstitialView once we implement // TODO(crbug.com/1103262): Add these methods to the IncognitoInterstitialView once we implement
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment