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

[Modularization] Move InfoBarLayout to chrome/browser/ui/messages

This CL moves InfoBarInteractionHandler, InfoBarLayout,
InfoBarCompactLayout and related resources to chrome/browser/ui/messages


BUG=1056346
R=mdjones@chromium.org

Change-Id: Id1000a4d5cfbb7c4e04c3f70284470f728bc0283
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088183
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749381}
parent 7a6558db
...@@ -424,11 +424,12 @@ Still reading? ...@@ -424,11 +424,12 @@ Still reading?
<ignore regexp="android_webview/test/shell/res/raw/resource_file.html"/> <ignore regexp="android_webview/test/shell/res/raw/resource_file.html"/>
<ignore regexp="android_webview/test/shell/res/raw/resource_icon.png"/> <ignore regexp="android_webview/test/shell/res/raw/resource_icon.png"/>
<ignore regexp="android_webview/tools/automated_ui_tests/java/res/layout/"/> <ignore regexp="android_webview/tools/automated_ui_tests/java/res/layout/"/>
<!-- TODO(crbug.com/1017190): Remove the following 6 suppressions once we lint entire app rather <!-- TODO(crbug.com/1017190): Remove the following 7 suppressions once we lint entire app rather
than each individual target --> than each individual target -->
<ignore regexp="components/browser_ui/strings/android/browser_ui_strings_grd"/> <ignore regexp="components/browser_ui/strings/android/browser_ui_strings_grd"/>
<ignore regexp="chrome/browser/ui/android/strings/ui_strings_grd"/> <ignore regexp="chrome/browser/ui/android/strings/ui_strings_grd"/>
<ignore regexp="The resource `R.drawable.*_expand_.*` appears to be unused"/> <ignore regexp="The resource `R.drawable.*_expand_.*` appears to be unused"/>
<ignore regexp="The resource `R.drawable.btn_close` appears to be unused"/>
<ignore regexp="The resource `R.drawable.ic_more_vert_24dp_on_dark_bg` appears to be unused"/> <ignore regexp="The resource `R.drawable.ic_more_vert_24dp_on_dark_bg` appears to be unused"/>
<ignore regexp="The resource `R.layout.permission_dialog` appears to be unused"/> <ignore regexp="The resource `R.layout.permission_dialog` appears to be unused"/>
<ignore regexp="components/permissions/android/res/drawable"/> <ignore regexp="components/permissions/android/res/drawable"/>
......
...@@ -829,12 +829,9 @@ chrome_java_sources = [ ...@@ -829,12 +829,9 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/infobar/IPHBubbleDelegateImpl.java", "java/src/org/chromium/chrome/browser/infobar/IPHBubbleDelegateImpl.java",
"java/src/org/chromium/chrome/browser/infobar/IPHInfoBarSupport.java", "java/src/org/chromium/chrome/browser/infobar/IPHInfoBarSupport.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBar.java", "java/src/org/chromium/chrome/browser/infobar/InfoBar.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarCompactLayout.java",
"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/InfoBarInteractionHandler.java",
"java/src/org/chromium/chrome/browser/infobar/InfoBarLayout.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",
"java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBar.java", "java/src/org/chromium/chrome/browser/infobar/InstantAppsInfoBar.java",
......
...@@ -59,16 +59,8 @@ ...@@ -59,16 +59,8 @@
<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 when a big icon is shown. -->
<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. -->
<dimen name="infobar_descriptive_text_size">14sp</dimen> <dimen name="infobar_descriptive_text_size">14sp</dimen>
<!-- Padding surrounding the infobar. -->
<dimen name="infobar_padding">16dp</dimen>
<!-- Margin between stacked buttons in an infobar. -->
<dimen name="infobar_margin_between_stacked_buttons">24dp</dimen>
<!-- Minimum width of an infobar. -->
<dimen name="infobar_min_width">220dp</dimen>
<!-- Maximum width of an infobar. --> <!-- Maximum width of an infobar. -->
<dimen name="infobar_max_width">600dp</dimen> <dimen name="infobar_max_width">600dp</dimen>
<!-- Width of side shadows on floating infobars. --> <!-- Width of side shadows on floating infobars. -->
...@@ -78,22 +70,9 @@ ...@@ -78,22 +70,9 @@
<!-- Distance that a back infobar peeks out above the front infobar. --> <!-- Distance that a back infobar peeks out above the front infobar. -->
<dimen name="infobar_peeking_height">10dp</dimen> <dimen name="infobar_peeking_height">10dp</dimen>
<!-- Vertical margin applied between groups of controls. -->
<dimen name="infobar_margin_above_control_groups">24dp</dimen>
<dimen name="infobar_margin_above_button_row">32dp</dimen>
<!-- Dimensions applied to InfoBars with differently sized icons. -->
<dimen name="infobar_small_icon_size">24dp</dimen>
<dimen name="infobar_small_icon_margin">8dp</dimen>
<dimen name="infobar_big_icon_size">48dp</dimen>
<dimen name="infobar_big_icon_margin">16dp</dimen>
<!-- Dimension applied to SyncErrorInfoBar icon. --> <!-- Dimension applied to SyncErrorInfoBar icon. -->
<dimen name="sync_error_infobar_icon_size">48dp</dimen> <dimen name="sync_error_infobar_icon_size">48dp</dimen>
<!-- Dimensions for compact infobars are a little shorter. -->
<dimen name="infobar_compact_size">56dp</dimen>
<!-- Dimensions for compact translate infobar. --> <!-- Dimensions for compact translate infobar. -->
<dimen name="infobar_translate_fade_edge_length">18dp</dimen> <dimen name="infobar_translate_fade_edge_length">18dp</dimen>
<dimen name="infobar_translate_menu_width">260dp</dimen> <dimen name="infobar_translate_menu_width">260dp</dimen>
...@@ -594,9 +573,6 @@ ...@@ -594,9 +573,6 @@
<dimen name="revamped_context_menu_header_circle_bg_vertical_margin">22dp</dimen> <dimen name="revamped_context_menu_header_circle_bg_vertical_margin">22dp</dimen>
<dimen name="revamped_context_menu_header_monogram_text_size">16dp</dimen> <dimen name="revamped_context_menu_header_monogram_text_size">16dp</dimen>
<dimen name="revamped_context_menu_header_monogram_size">26dp</dimen> <dimen name="revamped_context_menu_header_monogram_size">26dp</dimen>
<!-- Reader Mode dimensions -->
<!-- Padding surrounding the message. -->
<dimen name="reader_mode_infobar_text_padding">8dp</dimen>
<!-- Defaults for TabbedModeFirstRunActivity values. --> <!-- Defaults for TabbedModeFirstRunActivity values. -->
<item type="dimen" name="dialog_fixed_width_major">100%</item> <item type="dimen" name="dialog_fixed_width_major">100%</item>
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
<item type="id" name="share_tab_group" /> <item type="id" name="share_tab_group" />
<!-- InfoBar constants --> <!-- InfoBar constants -->
<item type="id" name="infobar_icon" />
<item type="id" name="infobar_close_button" />
<item type="id" name="infobar_extra_check" /> <item type="id" name="infobar_extra_check" />
<item type="id" name="infobar_message" /> <item type="id" name="infobar_message" />
<item type="id" name="permission_infobar_persist_toggle" /> <item type="id" name="permission_infobar_persist_toggle" />
......
...@@ -15,6 +15,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener; ...@@ -15,6 +15,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.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
import org.chromium.ui.widget.ButtonCompat; import org.chromium.ui.widget.ButtonCompat;
......
...@@ -9,6 +9,7 @@ import android.graphics.Bitmap; ...@@ -9,6 +9,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 org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -15,6 +15,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -15,6 +15,7 @@ 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.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import java.util.ArrayList; import java.util.ArrayList;
......
...@@ -9,6 +9,7 @@ import android.graphics.Bitmap; ...@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
import androidx.annotation.ColorRes; import androidx.annotation.ColorRes;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
/** /**
* An infobar that presents the user with several buttons. * An infobar that presents the user with several buttons.
......
...@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.about_settings.AboutSettingsBridge; ...@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.about_settings.AboutSettingsBridge;
import org.chromium.chrome.browser.datareduction.DataReductionPromoUtils; 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.ui.messages.infobar.InfoBarControlLayout; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.net.GURLUtils; import org.chromium.net.GURLUtils;
......
...@@ -20,6 +20,7 @@ import org.chromium.base.task.PostTask; ...@@ -20,6 +20,7 @@ import org.chromium.base.task.PostTask;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadInfoBarController; import org.chromium.chrome.browser.download.DownloadInfoBarController;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.components.offline_items_collection.ContentId; import org.chromium.components.offline_items_collection.ContentId;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
......
...@@ -23,6 +23,7 @@ import org.chromium.chrome.R; ...@@ -23,6 +23,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadManagerService; import org.chromium.chrome.browser.download.DownloadManagerService;
import org.chromium.chrome.browser.download.DownloadOpenSource; import org.chromium.chrome.browser.download.DownloadOpenSource;
import org.chromium.chrome.browser.download.DownloadUtils; import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.components.download.DownloadCollectionBridge; import org.chromium.components.download.DownloadCollectionBridge;
import java.io.File; import java.io.File;
......
...@@ -14,7 +14,9 @@ import androidx.annotation.VisibleForTesting; ...@@ -14,7 +14,9 @@ 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.InfoBarCompactLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.components.url_formatter.UrlFormatter;
/** /**
......
...@@ -9,6 +9,7 @@ import android.text.Spanned; ...@@ -9,6 +9,7 @@ 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.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
/** /**
......
...@@ -15,6 +15,9 @@ import androidx.annotation.Nullable; ...@@ -15,6 +15,9 @@ import androidx.annotation.Nullable;
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.InfoBarCompactLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarInteractionHandler;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
......
...@@ -110,9 +110,9 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout { ...@@ -110,9 +110,9 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
} }
/** /**
* Notifies that an infobar's View ({@link InfoBarUiItem#getView}) has changed. If * Notifies that an infobar's View ({@link InfoBarUiItem#getView}) has changed. If the infobar
* the infobar is visible in the front of the stack, the infobar will fade out the old contents, * is visible in the front of the stack, the infobar will fade out the old contents, resize,
* resize, then fade in the new contents. * then fade in the new contents.
*/ */
void notifyInfoBarViewChanged() { void notifyInfoBarViewChanged() {
processPendingAnimations(); processPendingAnimations();
......
...@@ -18,6 +18,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -18,6 +18,7 @@ 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.ShortcutHelper; import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
import org.chromium.components.browser_ui.widget.text.AccessibleTextView; import org.chromium.components.browser_ui.widget.text.AccessibleTextView;
/** /**
...@@ -66,7 +67,7 @@ public class InstallableAmbientBadgeInfoBar extends InfoBar implements View.OnCl ...@@ -66,7 +67,7 @@ public class InstallableAmbientBadgeInfoBar extends InfoBar implements View.OnCl
iconView.setOnClickListener(this); iconView.setOnClickListener(this);
iconView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); iconView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
final int messagePadding = final int messagePadding =
res.getDimensionPixelOffset(R.dimen.reader_mode_infobar_text_padding); res.getDimensionPixelOffset(R.dimen.infobar_compact_message_vertical_padding);
prompt.setPadding(0, messagePadding, 0, messagePadding); prompt.setPadding(0, messagePadding, 0, messagePadding);
layout.addContent(prompt, 1f); layout.addContent(prompt, 1f);
} }
......
...@@ -10,6 +10,7 @@ import android.widget.ImageView; ...@@ -10,6 +10,7 @@ import android.widget.ImageView;
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.instantapps.InstantAppsBannerData; import org.chromium.chrome.browser.instantapps.InstantAppsBannerData;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.components.browser_ui.widget.DualControlLayout; import org.chromium.components.browser_ui.widget.DualControlLayout;
import org.chromium.components.url_formatter.SchemeDisplay; import org.chromium.components.url_formatter.SchemeDisplay;
import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.components.url_formatter.UrlFormatter;
......
...@@ -9,6 +9,7 @@ import android.graphics.Bitmap; ...@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
import androidx.annotation.ColorRes; import androidx.annotation.ColorRes;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
/** /**
* An infobar to disclose known monitoring to the user. This is a thin veneer over * An infobar to disclose known monitoring to the user. This is a thin veneer over
......
...@@ -8,6 +8,7 @@ import androidx.annotation.VisibleForTesting; ...@@ -8,6 +8,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.InfoBarCompactLayout;
/** /**
* This InfoBar is shown to let the user know when the browser took action to stop a page from using * This InfoBar is shown to let the user know when the browser took action to stop a page from using
......
...@@ -8,6 +8,7 @@ import androidx.annotation.VisibleForTesting; ...@@ -8,6 +8,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.InfoBarCompactLayout;
/** /**
* This InfoBar is shown to let the user know when the browser took action to * This InfoBar is shown to let the user know when the browser took action to
......
...@@ -12,6 +12,8 @@ import org.chromium.chrome.browser.permissions.ChromePermissionsClient; ...@@ -12,6 +12,8 @@ import org.chromium.chrome.browser.permissions.ChromePermissionsClient;
import org.chromium.chrome.browser.settings.SettingsLauncher; import org.chromium.chrome.browser.settings.SettingsLauncher;
import org.chromium.chrome.browser.site_settings.SingleCategorySettings; import org.chromium.chrome.browser.site_settings.SingleCategorySettings;
import org.chromium.chrome.browser.site_settings.SiteSettingsCategory; import org.chromium.chrome.browser.site_settings.SiteSettingsCategory;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.components.permissions.AndroidPermissionRequester; import org.chromium.components.permissions.AndroidPermissionRequester;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
......
...@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.infobar; ...@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.infobar;
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.InfoBarLayout;
/** /**
* An InfoBar that lets the user know that a Preview page has been loaded, and gives the user * An InfoBar that lets the user know that a Preview page has been loaded, and gives the user
......
...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange ...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange
import org.chromium.chrome.browser.dom_distiller.ReaderModeManager; import org.chromium.chrome.browser.dom_distiller.ReaderModeManager;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
import org.chromium.components.browser_ui.widget.text.AccessibleTextView; import org.chromium.components.browser_ui.widget.text.AccessibleTextView;
/** /**
...@@ -74,7 +75,7 @@ public class ReaderModeInfoBar extends InfoBar { ...@@ -74,7 +75,7 @@ public class ReaderModeInfoBar extends InfoBar {
iconView.setOnClickListener(mNavigateListener); iconView.setOnClickListener(mNavigateListener);
iconView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); iconView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
final int messagePadding = getContext().getResources().getDimensionPixelOffset( final int messagePadding = getContext().getResources().getDimensionPixelOffset(
R.dimen.reader_mode_infobar_text_padding); R.dimen.infobar_compact_message_vertical_padding);
prompt.setPadding(0, messagePadding, 0, messagePadding); prompt.setPadding(0, messagePadding, 0, messagePadding);
layout.addContent(prompt, 1f); layout.addContent(prompt, 1f);
} }
......
...@@ -9,6 +9,7 @@ import android.graphics.Bitmap; ...@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
import androidx.annotation.ColorRes; import androidx.annotation.ColorRes;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
/** /**
* An infobar to present a Safety Tip. This is a thin vineer over standard ConfirmInfoBar to provide * An infobar to present a Safety Tip. This is a thin vineer over standard ConfirmInfoBar to provide
......
...@@ -9,6 +9,7 @@ import android.text.TextUtils; ...@@ -9,6 +9,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; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
/** /**
* 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.
......
...@@ -11,6 +11,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -11,6 +11,7 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.settings.SettingsLauncher; import org.chromium.chrome.browser.settings.SettingsLauncher;
import org.chromium.chrome.browser.site_settings.SingleWebsiteSettings; import org.chromium.chrome.browser.site_settings.SingleWebsiteSettings;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
/** /**
* An infobar to disclose to the user that the default search engine has geolocation access by * An infobar to disclose to the user that the default search engine has geolocation access by
......
...@@ -19,6 +19,7 @@ import org.chromium.chrome.browser.tab.EmptyTabObserver; ...@@ -19,6 +19,7 @@ import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabHidingType; import org.chromium.chrome.browser.tab.TabHidingType;
import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
import org.chromium.chrome.browser.util.AccessibilityUtil; import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
......
...@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.sync.ProfileSyncService; ...@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings; import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings;
import org.chromium.chrome.browser.sync.settings.SyncSettingsUtils; import org.chromium.chrome.browser.sync.settings.SyncSettingsUtils;
import org.chromium.chrome.browser.sync.settings.SyncSettingsUtils.SyncError; import org.chromium.chrome.browser.sync.settings.SyncSettingsUtils.SyncError;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
......
...@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.infobar.translate.TranslateMenuHelper; ...@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.infobar.translate.TranslateMenuHelper;
import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout; import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar; import org.chromium.chrome.browser.ui.messages.snackbar.Snackbar;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager.SnackbarController; import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager.SnackbarController;
......
...@@ -11,6 +11,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -11,6 +11,7 @@ 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.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout.InfoBarArrayAdapter; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout.InfoBarArrayAdapter;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
/** /**
* 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.
......
...@@ -7,7 +7,7 @@ package org.chromium.chrome.browser.send_tab_to_self; ...@@ -7,7 +7,7 @@ package org.chromium.chrome.browser.send_tab_to_self;
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.InfoBar; import org.chromium.chrome.browser.infobar.InfoBar;
import org.chromium.chrome.browser.infobar.InfoBarCompactLayout; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
/** /**
* This infobar is shown to let users know they have a shared tab from another * This infobar is shown to let users know they have a shared tab from another
......
...@@ -15,8 +15,8 @@ import org.chromium.base.Log; ...@@ -15,8 +15,8 @@ import org.chromium.base.Log;
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.ConfirmInfoBar; import org.chromium.chrome.browser.infobar.ConfirmInfoBar;
import org.chromium.chrome.browser.infobar.InfoBarLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout; import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.ui.KeyboardVisibilityDelegate; import org.chromium.ui.KeyboardVisibilityDelegate;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
......
...@@ -22,8 +22,8 @@ import org.chromium.chrome.browser.ChromeActivity; ...@@ -22,8 +22,8 @@ import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.infobar.AutofillSaveCardInfoBar; import org.chromium.chrome.browser.infobar.AutofillSaveCardInfoBar;
import org.chromium.chrome.browser.infobar.InfoBar; import org.chromium.chrome.browser.infobar.InfoBar;
import org.chromium.chrome.browser.infobar.InfoBarLayout;
import org.chromium.chrome.browser.sync.SyncTestRule; import org.chromium.chrome.browser.sync.SyncTestRule;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarLayout;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
......
...@@ -16,7 +16,10 @@ android_resources("java_resources") { ...@@ -16,7 +16,10 @@ android_resources("java_resources") {
android_library("java") { android_library("java") {
sources = [ sources = [
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarCompactLayout.java",
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarControlLayout.java", "java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarControlLayout.java",
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarInteractionHandler.java",
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarLayout.java",
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarMessageView.java", "java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarMessageView.java",
"java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarUiItem.java", "java/src/org/chromium/chrome/browser/ui/messages/infobar/InfoBarUiItem.java",
"java/src/org/chromium/chrome/browser/ui/messages/snackbar/Snackbar.java", "java/src/org/chromium/chrome/browser/ui/messages/snackbar/Snackbar.java",
...@@ -34,6 +37,7 @@ android_library("java") { ...@@ -34,6 +37,7 @@ android_library("java") {
"//third_party/android_deps:androidx_annotation_annotation_java", "//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/android_deps:com_android_support_appcompat_v7_java", "//third_party/android_deps:com_android_support_appcompat_v7_java",
"//ui/android:ui_full_java", "//ui/android:ui_full_java",
"//ui/android:ui_utils_java",
] ]
} }
......
...@@ -10,6 +10,28 @@ ...@@ -10,6 +10,28 @@
<dimen name="infobar_control_margin_between_columns">32dp</dimen> <dimen name="infobar_control_margin_between_columns">32dp</dimen>
<!-- Text size of the infobar message and other controls. --> <!-- Text size of the infobar message and other controls. -->
<dimen name="infobar_text_size">16sp</dimen> <dimen name="infobar_text_size">16sp</dimen>
<!-- Text size of the infobar message when a big icon is shown. -->
<dimen name="infobar_big_icon_message_size">20sp</dimen>
<!-- Margin between stacked buttons in an infobar. -->
<dimen name="infobar_margin_between_stacked_buttons">24dp</dimen>
<!-- Padding surrounding the infobar. -->
<dimen name="infobar_padding">16dp</dimen>
<!-- Minimum width of an infobar. -->
<dimen name="infobar_min_width">220dp</dimen>
<!-- Dimensions for compact infobars are a little shorter. -->
<dimen name="infobar_compact_size">56dp</dimen>
<dimen name="infobar_compact_message_vertical_padding">8dp</dimen>
<!-- Dimensions applied to InfoBars with differently sized icons. -->
<dimen name="infobar_small_icon_size">24dp</dimen>
<dimen name="infobar_small_icon_margin">8dp</dimen>
<dimen name="infobar_big_icon_size">48dp</dimen>
<dimen name="infobar_big_icon_margin">16dp</dimen>
<!-- Vertical margin applied between groups of controls. -->
<dimen name="infobar_margin_above_control_groups">24dp</dimen>
<dimen name="infobar_margin_above_button_row">32dp</dimen>
<!-- Snackbars --> <!-- Snackbars -->
<dimen name="snackbar_min_height">48dp</dimen> <dimen name="snackbar_min_height">48dp</dimen>
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<resources>
<!-- InfoBar constants -->
<item type="id" name="infobar_icon" />
<item type="id" name="infobar_close_button" />
</resources>
...@@ -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;
...@@ -23,8 +23,7 @@ import androidx.annotation.StringRes; ...@@ -23,8 +23,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.ui.messages.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarMessageView;
import org.chromium.ui.text.NoUnderlineClickableSpan; import org.chromium.ui.text.NoUnderlineClickableSpan;
/** /**
...@@ -46,8 +45,10 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi ...@@ -46,8 +45,10 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi
* @param iconTintId The {@link ColorRes} used as tint for {@code iconResourceId}. * @param iconTintId The {@link ColorRes} used as tint for {@code iconResourceId}.
* @param iconBitmap Bitmap for the icon to use, if {@code iconResourceId} is not set. * @param iconBitmap Bitmap for the icon to use, if {@code iconResourceId} is not set.
*/ */
InfoBarCompactLayout(Context context, InfoBarInteractionHandler infoBar, int iconResourceId, // TODO(crbug/1056346): ctor is made public to allow access from InfoBar. Once
@ColorRes int iconTintId, Bitmap iconBitmap) { // InfoBar is modularized, restore access to package private.
public InfoBarCompactLayout(Context context, InfoBarInteractionHandler infoBar,
int iconResourceId, @ColorRes int iconTintId, Bitmap iconBitmap) {
super(context); super(context);
mInfoBar = infoBar; mInfoBar = infoBar;
mCompactInfoBarSize = mCompactInfoBarSize =
...@@ -75,7 +76,9 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi ...@@ -75,7 +76,9 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi
* @param view View to insert. * @param view View to insert.
* @param weight Weight to assign to it. * @param weight Weight to assign to it.
*/ */
protected void addContent(View view, float weight) { // TODO(crbug/1056346): addContent is made public to allow access from InfoBar. Once
// InfoBar is modularized, restore access to protected.
public void addContent(View view, float weight) {
LinearLayout.LayoutParams params; LinearLayout.LayoutParams params;
if (weight <= 0.0f) { if (weight <= 0.0f) {
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, mCompactInfoBarSize); params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, mCompactInfoBarSize);
...@@ -181,7 +184,7 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi ...@@ -181,7 +184,7 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi
assert mMessage != null; assert mMessage != null;
final int messagePadding = mLayout.getResources().getDimensionPixelOffset( final int messagePadding = mLayout.getResources().getDimensionPixelOffset(
R.dimen.reader_mode_infobar_text_padding); R.dimen.infobar_compact_message_vertical_padding);
SpannableStringBuilder builder = new SpannableStringBuilder(); SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(mMessage); builder.append(mMessage);
......
...@@ -480,9 +480,7 @@ public final class InfoBarControlLayout extends ViewGroup { ...@@ -480,9 +480,7 @@ 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.
*/ */
// TODO(crbug/1056346): addMainMessage is made public to allow access from InfoBarLayout. Once TextView addMainMessage(CharSequence mainMessage) {
// 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;
......
...@@ -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;
/** /**
* Functions needed to display an InfoBar UI. * Functions needed to display an InfoBar UI.
......
...@@ -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.ColorStateList; import android.content.res.ColorStateList;
...@@ -27,8 +27,7 @@ import androidx.annotation.ColorRes; ...@@ -27,8 +27,7 @@ import androidx.annotation.ColorRes;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
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.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;
...@@ -56,7 +55,6 @@ import java.util.List; ...@@ -56,7 +55,6 @@ import java.util.List;
* InfoBarInteractionHandler. * InfoBarInteractionHandler.
*/ */
public final class InfoBarLayout extends ViewGroup implements View.OnClickListener { public final class InfoBarLayout extends ViewGroup implements View.OnClickListener {
/** /**
* Parameters used for laying out children. * Parameters used for laying out children.
*/ */
...@@ -155,16 +153,20 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -155,16 +153,20 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
/** /**
* Returns the {@link TextView} corresponding to the main infobar message. * Returns the {@link TextView} corresponding to the main infobar message.
* The returned view is a part of internal layout strucutre and shouldn't be accessed by InfoBar
* implementations.
*/ */
TextView getMessageTextView() { public TextView getMessageTextView() {
return mMessageTextView; return mMessageTextView;
} }
/** /**
* Returns the {@link InfoBarControlLayout} containing the TextView showing the main infobar * Returns the {@link InfoBarControlLayout} containing the TextView showing the main infobar
* message and associated controls, which is sandwiched between its icon and close button. * message and associated controls, which is sandwiched between its icon and close button.
* The returned view is a part of internal layout strucutre and shouldn't be accessed by InfoBar
* implementations.
*/ */
InfoBarControlLayout getMessageLayout() { public InfoBarControlLayout getMessageLayout() {
return mMessageLayout; return mMessageLayout;
} }
...@@ -192,7 +194,7 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -192,7 +194,7 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
* @param rangeStart Where the link starts. * @param rangeStart Where the link starts.
* @param rangeEnd Where the link ends. * @param rangeEnd Where the link ends.
*/ */
void setInlineMessageLink(int rangeStart, int rangeEnd) { public void setInlineMessageLink(int rangeStart, int rangeEnd) {
mMessageInlineLinkRangeStart = rangeStart; mMessageInlineLinkRangeStart = rangeStart;
mMessageInlineLinkRangeEnd = rangeEnd; mMessageInlineLinkRangeEnd = rangeEnd;
mMessageTextView.setText(prepareMainMessageString()); mMessageTextView.setText(prepareMainMessageString());
...@@ -243,8 +245,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -243,8 +245,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
*/ */
public void setBottomViews(String primaryText, View secondaryView, int alignment) { public void setBottomViews(String primaryText, View secondaryView, int alignment) {
assert !TextUtils.isEmpty(primaryText); assert !TextUtils.isEmpty(primaryText);
Button primaryButton = DualControlLayout.createButtonForLayout( Button primaryButton =
getContext(), true, primaryText, this); DualControlLayout.createButtonForLayout(getContext(), true, primaryText, this);
assert mButtonRowLayout == null; assert mButtonRowLayout == null;
mButtonRowLayout = new DualControlLayout(getContext(), null); mButtonRowLayout = new DualControlLayout(getContext(), null);
...@@ -279,7 +281,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -279,7 +281,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
* Returns the primary button, or null if it doesn't exist. * Returns the primary button, or null if it doesn't exist.
*/ */
public ButtonCompat getPrimaryButton() { public ButtonCompat getPrimaryButton() {
return mButtonRowLayout == null ? null return mButtonRowLayout == null
? null
: (ButtonCompat) mButtonRowLayout.findViewById(R.id.button_primary); : (ButtonCompat) mButtonRowLayout.findViewById(R.id.button_primary);
} }
...@@ -294,7 +297,9 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -294,7 +297,9 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
* Must be called after the message, buttons, and custom content have been set, and before the * Must be called after the message, buttons, and custom content have been set, and before the
* first call to onMeasure(). * first call to onMeasure().
*/ */
void onContentCreated() { // TODO(crbug/1056346): onContentCreated is made public to allow access from InfoBar. Once
// InfoBar is modularized, restore access to package private.
public void onContentCreated() {
// Add the child views in the desired focus order. // Add the child views in the desired focus order.
if (mIconView != null) addView(mIconView); if (mIconView != null) addView(mIconView);
addView(mMessageLayout); addView(mMessageLayout);
...@@ -355,8 +360,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -355,8 +360,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
*/ */
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
assert getLayoutParams().height == LayoutParams.WRAP_CONTENT assert getLayoutParams().height
: "InfoBar heights cannot be constrained."; == LayoutParams.WRAP_CONTENT : "InfoBar heights cannot be constrained.";
// Apply the padding that surrounds all the infobar controls. // Apply the padding that surrounds all the infobar controls.
final int layoutWidth = Math.max(MeasureSpec.getSize(widthMeasureSpec), mMinWidth); final int layoutWidth = Math.max(MeasureSpec.getSize(widthMeasureSpec), mMinWidth);
...@@ -395,8 +400,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen ...@@ -395,8 +400,8 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
// Control layouts are placed below the message layout and the close button. The icon is // Control layouts are placed below the message layout and the close button. The icon is
// ignored for this particular calculation because the icon enforces a left margin on all of // ignored for this particular calculation because the icon enforces a left margin on all of
// the control layouts and won't be overlapped. // the control layouts and won't be overlapped.
layoutBottom += Math.max(getChildHeightWithMargins(mMessageLayout), layoutBottom += Math.max(
getChildHeightWithMargins(mCloseButton)); getChildHeightWithMargins(mMessageLayout), getChildHeightWithMargins(mCloseButton));
// The other control layouts are constrained only by the icon's width. // The other control layouts are constrained only by the icon's width.
final int controlPaddedStart = paddedStart + iconWidth; final int controlPaddedStart = paddedStart + iconWidth;
......
...@@ -210,6 +210,7 @@ android_library("chrome_java_test_support") { ...@@ -210,6 +210,7 @@ android_library("chrome_java_test_support") {
"//chrome/browser/preferences:java", "//chrome/browser/preferences:java",
"//chrome/browser/ui/android/appmenu:java", "//chrome/browser/ui/android/appmenu:java",
"//chrome/browser/ui/android/appmenu:test_support_java", "//chrome/browser/ui/android/appmenu:test_support_java",
"//chrome/browser/ui/messages/android:java",
"//chrome/browser/util:java", "//chrome/browser/util:java",
"//components/bookmarks/common/android:bookmarks_java", "//components/bookmarks/common/android:bookmarks_java",
"//components/browser_ui/widget/android:java", "//components/browser_ui/widget/android:java",
......
...@@ -11,10 +11,10 @@ import org.junit.Assert; ...@@ -11,10 +11,10 @@ import org.junit.Assert;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBar; import org.chromium.chrome.browser.infobar.InfoBar;
import org.chromium.chrome.browser.infobar.InfoBarCompactLayout;
import org.chromium.chrome.browser.infobar.TranslateCompactInfoBar; import org.chromium.chrome.browser.infobar.TranslateCompactInfoBar;
import org.chromium.chrome.browser.infobar.translate.TranslateMenu; import org.chromium.chrome.browser.infobar.translate.TranslateMenu;
import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout; import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarCompactLayout;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
......
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