Commit e132c1bd authored by Pavel Yatsuk's avatar Pavel Yatsuk Committed by Commit Bot

[Modularization] Move InfoBarControlLayout and InfoBarMessageView to chrome/browser/ui/messages

This CL moves InfoBarControlLayout, InfoBarMessageView, tests and
related resources to chrome/browser/ui/messages

BUG=1056346
R=mdjones@chromium.org

Change-Id: I2d24ae99bcbe2186486154c883288eb6ddecb50a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076398
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Reviewed-by: default avatarJun Cai <juncai@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745693}
parent 99556884
...@@ -818,9 +818,7 @@ chrome_java_sources = [ ...@@ -818,9 +818,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java", "java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java", "java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarContainerView.java", "java/src/org/chromium/chrome/browser/infobar/InfoBarContainerView.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarLayout.java", "java/src/org/chromium/chrome/browser/infobar/InfoBarLayout.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarMessageView.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarView.java", "java/src/org/chromium/chrome/browser/infobar/InfoBarView.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java", "java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java",
"java/src/org/chromium/chrome/browser/infobar/InstallableAmbientBadgeInfoBar.java", "java/src/org/chromium/chrome/browser/infobar/InstallableAmbientBadgeInfoBar.java",
......
...@@ -202,7 +202,6 @@ chrome_test_java_sources = [ ...@@ -202,7 +202,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/incognito/IncognitoTabLauncherTest.java", "javatests/src/org/chromium/chrome/browser/incognito/IncognitoTabLauncherTest.java",
"javatests/src/org/chromium/chrome/browser/infobar/InfoBarAppearanceTest.java", "javatests/src/org/chromium/chrome/browser/infobar/InfoBarAppearanceTest.java",
"javatests/src/org/chromium/chrome/browser/infobar/InfoBarContainerTest.java", "javatests/src/org/chromium/chrome/browser/infobar/InfoBarContainerTest.java",
"javatests/src/org/chromium/chrome/browser/infobar/InfoBarControlLayoutTest.java",
"javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java", "javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java",
"javatests/src/org/chromium/chrome/browser/infobar/PermissionUpdateInfobarTest.java", "javatests/src/org/chromium/chrome/browser/infobar/PermissionUpdateInfobarTest.java",
"javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java", "javatests/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBarTest.java",
......
...@@ -59,8 +59,6 @@ ...@@ -59,8 +59,6 @@
<dimen name="menu_badge_translation_y">6dp</dimen> <dimen name="menu_badge_translation_y">6dp</dimen>
<!-- Infobar dimensions --> <!-- Infobar dimensions -->
<!-- Text size of the infobar message and other controls. -->
<dimen name="infobar_text_size">16sp</dimen>
<!-- Text size of the infobar message when a big icon is shown. --> <!-- Text size of the infobar message when a big icon is shown. -->
<dimen name="infobar_big_icon_message_size">20sp</dimen> <dimen name="infobar_big_icon_message_size">20sp</dimen>
<!-- Text size of descriptive controls on an infobar. --> <!-- Text size of descriptive controls on an infobar. -->
...@@ -84,10 +82,6 @@ ...@@ -84,10 +82,6 @@
<dimen name="infobar_margin_above_control_groups">24dp</dimen> <dimen name="infobar_margin_above_control_groups">24dp</dimen>
<dimen name="infobar_margin_above_button_row">32dp</dimen> <dimen name="infobar_margin_above_button_row">32dp</dimen>
<!-- Margin between items in the same control group. -->
<dimen name="infobar_control_margin_between_rows">8dp</dimen>
<dimen name="infobar_control_margin_between_columns">32dp</dimen>
<!-- Dimensions applied to InfoBars with differently sized icons. --> <!-- Dimensions applied to InfoBars with differently sized icons. -->
<dimen name="infobar_small_icon_size">24dp</dimen> <dimen name="infobar_small_icon_size">24dp</dimen>
<dimen name="infobar_small_icon_margin">8dp</dimen> <dimen name="infobar_small_icon_margin">8dp</dimen>
......
...@@ -14,6 +14,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener; ...@@ -14,6 +14,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
import org.chromium.ui.widget.ButtonCompat; import org.chromium.ui.widget.ButtonCompat;
......
...@@ -8,6 +8,7 @@ import android.graphics.Bitmap; ...@@ -8,6 +8,7 @@ import android.graphics.Bitmap;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -14,6 +14,7 @@ import android.view.View; ...@@ -14,6 +14,7 @@ import android.view.View;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import java.util.ArrayList; import java.util.ArrayList;
......
...@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.datareduction.DataReductionPromoUtils; ...@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.datareduction.DataReductionPromoUtils;
import org.chromium.chrome.browser.omaha.VersionNumberGetter; import org.chromium.chrome.browser.omaha.VersionNumberGetter;
import org.chromium.chrome.browser.settings.about.AboutSettingsBridge; import org.chromium.chrome.browser.settings.about.AboutSettingsBridge;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.net.GURLUtils; import org.chromium.net.GURLUtils;
......
...@@ -14,6 +14,7 @@ import androidx.annotation.VisibleForTesting; ...@@ -14,6 +14,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.components.url_formatter.UrlFormatter;
/** /**
......
...@@ -8,6 +8,7 @@ import android.text.SpannableString; ...@@ -8,6 +8,7 @@ import android.text.SpannableString;
import android.text.Spanned; import android.text.Spanned;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
/** /**
......
...@@ -24,6 +24,7 @@ import androidx.annotation.StringRes; ...@@ -24,6 +24,7 @@ import androidx.annotation.StringRes;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarMessageView;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
/** /**
......
...@@ -28,6 +28,7 @@ import androidx.annotation.Nullable; ...@@ -28,6 +28,7 @@ import androidx.annotation.Nullable;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.components.browser_ui.widget.DualControlLayout; import org.chromium.components.browser_ui.widget.DualControlLayout;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
......
...@@ -8,6 +8,7 @@ import android.text.TextUtils; ...@@ -8,6 +8,7 @@ import android.text.TextUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
/** /**
* The Save Password infobar asks the user whether they want to save the password for the site. * The Save Password infobar asks the user whether they want to save the password for the site.
......
...@@ -9,7 +9,8 @@ import android.widget.Spinner; ...@@ -9,7 +9,8 @@ import android.widget.Spinner;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBarControlLayout.InfoBarArrayAdapter; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout.InfoBarArrayAdapter;
/** /**
* The Update Password infobar offers the user the ability to update a password for the site. * The Update Password infobar offers the user the ability to update a password for the site.
......
...@@ -16,8 +16,8 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -16,8 +16,8 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.ConfirmInfoBar; import org.chromium.chrome.browser.infobar.ConfirmInfoBar;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item.InfoBarPriority; import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item.InfoBarPriority;
import org.chromium.chrome.browser.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.infobar.InfoBarLayout; import org.chromium.chrome.browser.infobar.InfoBarLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.ui.KeyboardVisibilityDelegate; import org.chromium.ui.KeyboardVisibilityDelegate;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
......
...@@ -9,12 +9,15 @@ android_resources("java_resources") { ...@@ -9,12 +9,15 @@ android_resources("java_resources") {
deps = [ deps = [
"//chrome/browser/ui/android/strings:ui_strings_grd", "//chrome/browser/ui/android/strings:ui_strings_grd",
"//components/browser_ui/strings/android:browser_ui_strings_grd", "//components/browser_ui/strings/android:browser_ui_strings_grd",
"//components/browser_ui/widget/android:java_resources",
"//ui/android:ui_java_resources", "//ui/android:ui_java_resources",
] ]
} }
android_library("java") { android_library("java") {
sources = [ sources = [
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarControlLayout.java",
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarMessageView.java",
"java/src/org/chromium/chrome/browser/ui/messages/snackbar/Snackbar.java", "java/src/org/chromium/chrome/browser/ui/messages/snackbar/Snackbar.java",
"java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarCollection.java", "java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarCollection.java",
"java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarManager.java", "java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarManager.java",
...@@ -26,7 +29,8 @@ android_library("java") { ...@@ -26,7 +29,8 @@ android_library("java") {
"//chrome/browser/util:java", "//chrome/browser/util:java",
"//components/browser_ui/styles/android:java_resources", "//components/browser_ui/styles/android:java_resources",
"//components/browser_ui/widget/android:java", "//components/browser_ui/widget/android:java",
"//third_party/android_deps:com_android_support_support_compat_java", "//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/android_deps:com_android_support_appcompat_v7_java",
"//ui/android:ui_full_java", "//ui/android:ui_full_java",
] ]
} }
...@@ -46,7 +50,10 @@ java_library("junit") { ...@@ -46,7 +50,10 @@ java_library("junit") {
android_library("javatests") { android_library("javatests") {
testonly = true testonly = true
sources = [ "java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarTest.java" ] sources = [
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarControlLayoutTest.java",
"java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarTest.java",
]
deps = [ deps = [
":java", ":java",
"//base:base_java", "//base:base_java",
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<org.chromium.chrome.browser.infobar.InfoBarMessageView <org.chromium.chrome.browser.ui.messages.infobar.InfoBarMessageView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/infobar_message" android:id="@+id/infobar_message"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
found in the LICENSE file. --> found in the LICENSE file. -->
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Infobar dimensions -->
<!-- Margin between items in the same control group. -->
<dimen name="infobar_control_margin_between_rows">8dp</dimen>
<dimen name="infobar_control_margin_between_columns">32dp</dimen>
<!-- Text size of the infobar message and other controls. -->
<dimen name="infobar_text_size">16sp</dimen>
<!-- Snackbars --> <!-- Snackbars -->
<dimen name="snackbar_min_height">48dp</dimen> <dimen name="snackbar_min_height">48dp</dimen>
<dimen name="snackbar_width_tablet">450dp</dimen> <dimen name="snackbar_width_tablet">450dp</dimen>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.ui.messages.infobar;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
...@@ -24,7 +24,7 @@ import androidx.annotation.Nullable; ...@@ -24,7 +24,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R; import org.chromium.chrome.ui.messages.R;
import org.chromium.components.browser_ui.widget.DualControlLayout; import org.chromium.components.browser_ui.widget.DualControlLayout;
import org.chromium.components.browser_ui.widget.RadioButtonLayout; import org.chromium.components.browser_ui.widget.RadioButtonLayout;
...@@ -74,7 +74,7 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -74,7 +74,7 @@ public final class InfoBarControlLayout extends ViewGroup {
view = (TextView) convertView; view = (TextView) convertView;
} else { } else {
view = (TextView) LayoutInflater.from(getContext()) view = (TextView) LayoutInflater.from(getContext())
.inflate(R.layout.infobar_control_spinner_drop_down, parent, false); .inflate(R.layout.infobar_control_spinner_drop_down, parent, false);
} }
view.setText(getItem(position).toString()); view.setText(getItem(position).toString());
...@@ -88,7 +88,7 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -88,7 +88,7 @@ public final class InfoBarControlLayout extends ViewGroup {
view = (DualControlLayout) convertView; view = (DualControlLayout) convertView;
} else { } else {
view = (DualControlLayout) LayoutInflater.from(getContext()) view = (DualControlLayout) LayoutInflater.from(getContext())
.inflate(R.layout.infobar_control_spinner_view, parent, false); .inflate(R.layout.infobar_control_spinner_view, parent, false);
} }
// Set up the spinner label. The text it displays won't change. // Set up the spinner label. The text it displays won't change.
...@@ -176,7 +176,8 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -176,7 +176,8 @@ public final class InfoBarControlLayout extends ViewGroup {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int fullWidth = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED int fullWidth = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED
? Integer.MAX_VALUE : MeasureSpec.getSize(widthMeasureSpec); ? Integer.MAX_VALUE
: MeasureSpec.getSize(widthMeasureSpec);
int columnWidth = Math.max(0, (fullWidth - mMarginBetweenColumns) / 2); int columnWidth = Math.max(0, (fullWidth - mMarginBetweenColumns) / 2);
int atMostFullWidthSpec = MeasureSpec.makeMeasureSpec(fullWidth, MeasureSpec.AT_MOST); int atMostFullWidthSpec = MeasureSpec.makeMeasureSpec(fullWidth, MeasureSpec.AT_MOST);
...@@ -355,8 +356,9 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -355,8 +356,9 @@ public final class InfoBarControlLayout extends ViewGroup {
*/ */
public View addIcon(int iconResourceId, int iconColorId, CharSequence primaryMessage, public View addIcon(int iconResourceId, int iconColorId, CharSequence primaryMessage,
CharSequence secondaryMessage, int resourceId) { CharSequence secondaryMessage, int resourceId) {
LinearLayout layout = (LinearLayout) LayoutInflater.from(getContext()).inflate( LinearLayout layout =
R.layout.infobar_control_icon_with_description, this, false); (LinearLayout) LayoutInflater.from(getContext())
.inflate(R.layout.infobar_control_icon_with_description, this, false);
addView(layout, new ControlLayoutParams()); addView(layout, new ControlLayoutParams());
ImageView iconView = (ImageView) layout.findViewById(R.id.control_icon); ImageView iconView = (ImageView) layout.findViewById(R.id.control_icon);
...@@ -372,8 +374,7 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -372,8 +374,7 @@ public final class InfoBarControlLayout extends ViewGroup {
TypedValue.COMPLEX_UNIT_PX, getContext().getResources().getDimension(resourceId)); TypedValue.COMPLEX_UNIT_PX, getContext().getResources().getDimension(resourceId));
// The secondary message text is optional. // The secondary message text is optional.
TextView secondaryView = TextView secondaryView = (TextView) layout.findViewById(R.id.control_secondary_message);
(TextView) layout.findViewById(R.id.control_secondary_message);
if (secondaryMessage == null) { if (secondaryMessage == null) {
layout.removeView(secondaryView); layout.removeView(secondaryView);
} else { } else {
...@@ -401,8 +402,8 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -401,8 +402,8 @@ public final class InfoBarControlLayout extends ViewGroup {
*/ */
public View addSwitch(int iconResourceId, int iconColorId, CharSequence toggleMessage, public View addSwitch(int iconResourceId, int iconColorId, CharSequence toggleMessage,
int toggleId, boolean isChecked) { int toggleId, boolean isChecked) {
LinearLayout switchLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate( LinearLayout switchLayout = (LinearLayout) LayoutInflater.from(getContext())
R.layout.infobar_control_toggle, this, false); .inflate(R.layout.infobar_control_toggle, this, false);
addView(switchLayout, new ControlLayoutParams()); addView(switchLayout, new ControlLayoutParams());
ImageView iconView = (ImageView) switchLayout.findViewById(R.id.control_icon); ImageView iconView = (ImageView) switchLayout.findViewById(R.id.control_icon);
...@@ -448,8 +449,8 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -448,8 +449,8 @@ public final class InfoBarControlLayout extends ViewGroup {
* Creates a standard spinner and adds it to the layout. * Creates a standard spinner and adds it to the layout.
*/ */
public <T> Spinner addSpinner(int spinnerId, ArrayAdapter<T> arrayAdapter) { public <T> Spinner addSpinner(int spinnerId, ArrayAdapter<T> arrayAdapter) {
Spinner spinner = (Spinner) LayoutInflater.from(getContext()).inflate( Spinner spinner = (Spinner) LayoutInflater.from(getContext())
R.layout.infobar_control_spinner, this, false); .inflate(R.layout.infobar_control_spinner, this, false);
spinner.setAdapter(arrayAdapter); spinner.setAdapter(arrayAdapter);
addView(spinner, new ControlLayoutParams()); addView(spinner, new ControlLayoutParams());
spinner.setId(spinnerId); spinner.setId(spinnerId);
...@@ -479,12 +480,14 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -479,12 +480,14 @@ public final class InfoBarControlLayout extends ViewGroup {
* Adds a full-width control showing the main InfoBar message. For other text, you should call * Adds a full-width control showing the main InfoBar message. For other text, you should call
* {@link InfoBarControlLayout#addDescription(CharSequence)} instead. * {@link InfoBarControlLayout#addDescription(CharSequence)} instead.
*/ */
TextView addMainMessage(CharSequence mainMessage) { // TODO(crbug/1056346): addMainMessage is made public to allow access from InfoBarLayout. Once
// InfoBarLayout is modularized, restore access to package private.
public TextView addMainMessage(CharSequence mainMessage) {
ControlLayoutParams params = new ControlLayoutParams(); ControlLayoutParams params = new ControlLayoutParams();
params.mMustBeFullWidth = true; params.mMustBeFullWidth = true;
TextView messageView = (TextView) LayoutInflater.from(getContext()).inflate( TextView messageView = (TextView) LayoutInflater.from(getContext())
R.layout.infobar_control_message, this, false); .inflate(R.layout.infobar_control_message, this, false);
addView(messageView, params); addView(messageView, params);
messageView.setText(mainMessage); messageView.setText(mainMessage);
...@@ -499,5 +502,4 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -499,5 +502,4 @@ public final class InfoBarControlLayout extends ViewGroup {
static ControlLayoutParams getControlLayoutParams(View child) { static ControlLayoutParams getControlLayoutParams(View child) {
return (ControlLayoutParams) child.getLayoutParams(); return (ControlLayoutParams) child.getLayoutParams();
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.ui.messages.infobar;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
...@@ -20,7 +20,7 @@ import org.junit.Test; ...@@ -20,7 +20,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBarControlLayout.ControlLayoutParams; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout.ControlLayoutParams;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
/** /**
...@@ -60,8 +60,7 @@ public class InfoBarControlLayoutTest { ...@@ -60,8 +60,7 @@ public class InfoBarControlLayoutTest {
View smallSwitch = layout.addSwitch(0, 0, "A", SWITCH_ID_1, false); View smallSwitch = layout.addSwitch(0, 0, "A", SWITCH_ID_1, false);
// Trigger the measurement algorithm. // Trigger the measurement algorithm.
int parentWidthSpec = int parentWidthSpec = MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST);
MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST);
int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
layout.measure(parentWidthSpec, parentHeightSpec); layout.measure(parentWidthSpec, parentHeightSpec);
...@@ -107,8 +106,7 @@ public class InfoBarControlLayoutTest { ...@@ -107,8 +106,7 @@ public class InfoBarControlLayoutTest {
switch2.setMinimumWidth(INFOBAR_WIDTH); switch2.setMinimumWidth(INFOBAR_WIDTH);
// Trigger the measurement algorithm. // Trigger the measurement algorithm.
int parentWidthSpec = int parentWidthSpec = MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST);
MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST);
int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
layout.measure(parentWidthSpec, parentHeightSpec); layout.measure(parentWidthSpec, parentHeightSpec);
...@@ -167,8 +165,7 @@ public class InfoBarControlLayoutTest { ...@@ -167,8 +165,7 @@ public class InfoBarControlLayoutTest {
View view2 = layout.addSwitch(0, 0, "B", SWITCH_ID_2, false); View view2 = layout.addSwitch(0, 0, "B", SWITCH_ID_2, false);
// Trigger the measurement algorithm. // Trigger the measurement algorithm.
int parentWidthSpec = int parentWidthSpec = MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST);
MeasureSpec.makeMeasureSpec(INFOBAR_WIDTH, MeasureSpec.AT_MOST);
int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); int parentHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
layout.measure(parentWidthSpec, parentHeightSpec); layout.measure(parentWidthSpec, parentHeightSpec);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.ui.messages.infobar;
import android.content.Context; import android.content.Context;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
......
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