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

[Modularization] Extract InfoBarContainerLayout#Item into separate file in...

[Modularization] Extract InfoBarContainerLayout#Item into separate file in chrome/browser/ui/messages

The interface needs to be accessible to infobar implementation because some
info bars override its methods (e.g. getPriority) to affect
InfoBarContainerLayout behavior.

BUG=1056346
R=mdjones@chromium.org
TBR=juncai@chromium.org,benwells@chromium.org

Change-Id: I6e79f031fad0d48feafb30fb8ae6064702589789
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082874Reviewed-by: default avatarPavel Yatsuk <pavely@chromium.org>
Reviewed-by: default avatarJun Cai <juncai@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747509}
parent 7a58b911
......@@ -830,8 +830,8 @@ chrome_java_sources = [
"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/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/InfoBarView.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/InstantAppsInfoBar.java",
......
......@@ -11,7 +11,7 @@ import android.widget.PopupWindow.OnDismissListener;
import androidx.annotation.StringRes;
import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarContainerObserver;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.components.browser_ui.widget.textbubble.TextBubble;
import org.chromium.components.feature_engagement.FeatureConstants;
......@@ -105,7 +105,7 @@ public class IPHInfoBarSupport implements OnDismissListener,
// warning for a field guaranteed to be non-null being checked for null equality needs to be
// suppressed.
@Override
public void notifyAllAnimationsFinished(Item frontInfoBar) {
public void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar) {
View view = frontInfoBar == null ? null : frontInfoBar.getView();
if (mCurrentState != null) {
......
......@@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.ui.modelutil.PropertyModel;
......@@ -23,7 +24,7 @@ import org.chromium.ui.modelutil.PropertyModel;
* Note that infobars expire by default when a new navigation occurs.
* Make sure to use setExpireOnNavigation(false) if you want an infobar to be sticky.
*/
public abstract class InfoBar implements InfoBarView {
public abstract class InfoBar implements InfoBarInteractionHandler, InfoBarUiItem {
private static final String TAG = "InfoBar";
private final int mIconDrawableId;
......@@ -131,6 +132,12 @@ public abstract class InfoBar implements InfoBarView {
return false;
}
/**
* Prepares the InfoBar for display and adds InfoBar-specific controls to the layout.
* @param layout Layout containing all of the controls.
*/
protected void createContent(InfoBarLayout layout) {}
/**
* Prepares and inserts views into an {@link InfoBarCompactLayout}.
* {@link #usesCompactLayout} must return 'true' for this function to be called.
......@@ -252,6 +259,11 @@ public abstract class InfoBar implements InfoBarView {
mControlsEnabled = state;
}
@Override
public void onClick() {
setControlsEnabled(false);
}
@Override
public void onButtonClicked(boolean isPrimaryButton) {
}
......@@ -278,10 +290,6 @@ public abstract class InfoBar implements InfoBarView {
}
}
@Override
public void createContent(InfoBarLayout layout) {
}
@InfoBarIdentifier
@NativeMethods
......
......@@ -33,7 +33,7 @@ import org.chromium.ui.text.NoUnderlineClickableSpan;
* declares itself to be using a compact layout via {@link InfoBar#usesCompactLayout}.
*/
public class InfoBarCompactLayout extends LinearLayout implements View.OnClickListener {
private final InfoBarView mInfoBarView;
private final InfoBarInteractionHandler mInfoBar;
private final int mCompactInfoBarSize;
private final int mIconWidth;
private final View mCloseButton;
......@@ -41,15 +41,15 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi
/**
* Constructs a compat layout for the specified infobar.
* @param context The context used to render.
* @param infoBarView {@link InfoBarView} that listens to events.
* @param infoBar {@link InfoBarInteractionHandler} that listens to events.
* @param iconResourceId Resource ID of the icon to use for the infobar.
* @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.
*/
InfoBarCompactLayout(Context context, InfoBarView infoBarView, int iconResourceId,
InfoBarCompactLayout(Context context, InfoBarInteractionHandler infoBar, int iconResourceId,
@ColorRes int iconTintId, Bitmap iconBitmap) {
super(context);
mInfoBarView = infoBarView;
mInfoBar = infoBar;
mCompactInfoBarSize =
context.getResources().getDimensionPixelOffset(R.dimen.infobar_compact_size);
mIconWidth = context.getResources().getDimensionPixelOffset(R.dimen.infobar_big_icon_size);
......@@ -64,7 +64,7 @@ public class InfoBarCompactLayout extends LinearLayout implements View.OnClickLi
@Override
public void onClick(View view) {
if (view.getId() == R.id.infobar_close_button) {
mInfoBarView.onCloseButtonClicked();
mInfoBar.onCloseButtonClicked();
} else {
assert false;
}
......
......@@ -16,11 +16,11 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.tab.TabObserver;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController;
......@@ -67,7 +67,7 @@ public class InfoBarContainer implements UserData, KeyboardVisibilityListener {
* Notifies the subscriber when all animations are finished.
* @param frontInfoBar The frontmost infobar or {@code null} if none are showing.
*/
void notifyAllAnimationsFinished(Item frontInfoBar);
void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar);
}
/**
......@@ -164,7 +164,7 @@ public class InfoBarContainer implements UserData, KeyboardVisibilityListener {
}
@Override
public void notifyAllAnimationsFinished(Item frontInfoBar) {
public void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar) {
for (InfoBarAnimationListener listener : mAnimationListeners) {
listener.notifyAllAnimationsFinished(frontInfoBar);
}
......
......@@ -18,14 +18,11 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.IntDef;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.ui.widget.OptimizedFrameLayout;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
/**
......@@ -67,61 +64,6 @@ import java.util.ArrayList;
* TODO(newt): finalize animation timings and interpolators.
*/
public class InfoBarContainerLayout extends OptimizedFrameLayout {
/**
* An interface for items that can be added to an InfoBarContainerLayout.
*/
public interface Item {
// The infobar priority.
@IntDef({InfoBarPriority.CRITICAL, InfoBarPriority.USER_TRIGGERED,
InfoBarPriority.PAGE_TRIGGERED, InfoBarPriority.BACKGROUND})
@Retention(RetentionPolicy.SOURCE)
public @interface InfoBarPriority {
int CRITICAL = 0;
int USER_TRIGGERED = 1;
int PAGE_TRIGGERED = 2;
int BACKGROUND = 3;
}
/**
* Returns the View that represents this infobar. This should have no background or borders;
* a background and shadow will be added by a wrapper view.
*/
View getView();
/**
* Returns whether controls for this View should be clickable. If false, all input events on
* this item will be ignored.
*/
boolean areControlsEnabled();
/**
* Sets whether or not controls for this View should be clickable. This does not affect the
* visual state of the infobar.
* @param state If false, all input events on this Item will be ignored.
*/
void setControlsEnabled(boolean state);
/**
* Returns the accessibility text to announce when this infobar is first shown.
*/
CharSequence getAccessibilityText();
/**
* Returns the priority of an infobar. High priority infobar is shown in front of low
* priority infobar. If infobars have the same priorities, the most recently added one
* is shown behind previous ones.
*
*/
int getPriority();
/**
* Returns the type of infobar, as best as can be determined at this time. See
* components/infobars/core/infobar_delegate.h.
*/
@InfoBarIdentifier
int getInfoBarIdentifier();
}
/**
* Creates an empty InfoBarContainerLayout.
*/
......@@ -139,7 +81,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
* Adds an infobar to the container. The infobar appearing animation will happen after the
* current animation, if any, finishes.
*/
void addInfoBar(Item item) {
void addInfoBar(InfoBarUiItem item) {
mItems.add(findInsertIndex(item), item);
processPendingAnimations();
}
......@@ -148,7 +90,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
* Finds the appropriate index in the infobar stack for inserting this item.
* @param item The infobar to be inserted.
*/
private int findInsertIndex(Item item) {
private int findInsertIndex(InfoBarUiItem item) {
for (int i = 0; i < mItems.size(); ++i) {
if (item.getPriority() < mItems.get(i).getPriority()) {
return i;
......@@ -162,14 +104,14 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
* Removes an infobar from the container. The infobar will be animated off the screen if it's
* currently visible.
*/
void removeInfoBar(Item item) {
void removeInfoBar(InfoBarUiItem item) {
mItems.remove(item);
processPendingAnimations();
}
/**
* Notifies that an infobar's View ({@link Item#getView}) has changed. If the
* infobar is visible in the front of the stack, the infobar will fade out the old contents,
* Notifies that an infobar's View ({@link InfoBarUiItem#getView}) has changed. If
* the infobar is visible in the front of the stack, the infobar will fade out the old contents,
* resize, then fade in the new contents.
*/
void notifyInfoBarViewChanged() {
......@@ -271,11 +213,11 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
* content fades in.
*/
private class FirstInfoBarAppearingAnimation extends InfoBarAnimation {
private Item mFrontItem;
private InfoBarUiItem mFrontItem;
private InfoBarWrapper mFrontWrapper;
private View mFrontContents;
FirstInfoBarAppearingAnimation(Item frontItem) {
FirstInfoBarAppearingAnimation(InfoBarUiItem frontItem) {
mFrontItem = frontItem;
}
......@@ -318,12 +260,12 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
* will be resized simulatenously to the new desired size.
*/
private class FrontInfoBarAppearingAnimation extends InfoBarAnimation {
private Item mFrontItem;
private InfoBarUiItem mFrontItem;
private InfoBarWrapper mFrontWrapper;
private InfoBarWrapper mOldFrontWrapper;
private View mFrontContents;
FrontInfoBarAppearingAnimation(Item frontItem) {
FrontInfoBarAppearingAnimation(InfoBarUiItem frontItem) {
mFrontItem = frontItem;
}
......@@ -415,7 +357,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
private class BackInfoBarAppearingAnimation extends InfoBarAnimation {
private InfoBarWrapper mAppearingWrapper;
BackInfoBarAppearingAnimation(Item appearingItem) {
BackInfoBarAppearingAnimation(InfoBarUiItem appearingItem) {
mAppearingWrapper = new InfoBarWrapper(getContext(), appearingItem);
}
......@@ -714,7 +656,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
* This list is updated immediately when addInfoBar(), removeInfoBar(), and swapInfoBar() are
* called; so during animations, it does *not* match the currently visible views.
*/
private final ArrayList<Item> mItems = new ArrayList<>();
private final ArrayList<InfoBarUiItem> mItems = new ArrayList<>();
/**
* The currently visible InfoBarWrappers, in front to back order.
......@@ -747,7 +689,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
// First, remove any infobars that are no longer in mItems, if any. Check the back infobars
// before the front.
for (int i = mInfoBarWrappers.size() - 1; i >= 0; i--) {
Item visibleItem = mInfoBarWrappers.get(i).getItem();
InfoBarUiItem visibleItem = mInfoBarWrappers.get(i).getItem();
if (!mItems.contains(visibleItem)) {
if (i == 0 && mInfoBarWrappers.size() >= 2) {
// Remove the front infobar and reveal the second-to-front infobar.
......@@ -771,7 +713,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
// Second, run swap animation on front infobar if needed.
if (!mInfoBarWrappers.isEmpty()) {
Item frontItem = mInfoBarWrappers.get(0).getItem();
InfoBarUiItem frontItem = mInfoBarWrappers.get(0).getItem();
View frontContents = mInfoBarWrappers.get(0).getChildAt(0);
if (frontContents != frontItem.getView()) {
runAnimation(new FrontInfoBarSwapContentsAnimation());
......@@ -785,8 +727,8 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
// mInfoBarWrappers.
if (!mInfoBarWrappers.isEmpty()) {
// Find the infobar with the highest index that isn't currently being shown.
Item currentVisibleItem = mInfoBarWrappers.get(0).getItem();
Item itemToInsert = null;
InfoBarUiItem currentVisibleItem = mInfoBarWrappers.get(0).getItem();
InfoBarUiItem itemToInsert = null;
for (int checkIndex = 0; checkIndex < mItems.size(); checkIndex++) {
if (mItems.get(checkIndex) == currentVisibleItem) {
// There are no remaining infobars that can possibly override the
......@@ -807,7 +749,7 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
// Fourth, check if we should add any infobars at the back.
int desiredChildCount = Math.min(mItems.size(), MAX_STACK_DEPTH);
if (mInfoBarWrappers.size() < desiredChildCount) {
Item itemToShow = mItems.get(mInfoBarWrappers.size());
InfoBarUiItem itemToShow = mItems.get(mInfoBarWrappers.size());
runAnimation(mInfoBarWrappers.isEmpty()
? new FirstInfoBarAppearingAnimation(itemToShow)
: new BackInfoBarAppearingAnimation(itemToShow));
......@@ -815,7 +757,8 @@ public class InfoBarContainerLayout extends OptimizedFrameLayout {
}
// Fifth, now that we've stabilized, let listeners know that we have no more animations.
Item frontItem = mInfoBarWrappers.size() > 0 ? mInfoBarWrappers.get(0).getItem() : null;
InfoBarUiItem frontItem =
mInfoBarWrappers.size() > 0 ? mInfoBarWrappers.get(0).getItem() : null;
mAnimationListener.notifyAllAnimationsFinished(frontItem);
}
......
......@@ -17,6 +17,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.chrome.browser.banners.SwipableOverlayView;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.ui.display.DisplayAndroid;
import org.chromium.ui.display.DisplayUtil;
......@@ -92,8 +93,7 @@ public class InfoBarContainerView extends SwipableOverlayView {
}
@Override
public void notifyAllAnimationsFinished(
InfoBarContainerLayout.Item frontInfoBar) {
public void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar) {
mContainerViewObserver.notifyAllAnimationsFinished(frontInfoBar);
}
});
......
......@@ -4,16 +4,14 @@
package org.chromium.chrome.browser.infobar;
/**
* Functions needed to display an InfoBar UI.
*/
public interface InfoBarView extends InfoBarContainerLayout.Item {
public interface InfoBarInteractionHandler {
/**
* Prepares the InfoBar for display and adds InfoBar-specific controls to the layout.
* @param layout Layout containing all of the controls.
* Handles click on the infobar. It is invoked before one of the following functions.
*/
public void createContent(InfoBarLayout layout);
public void onClick();
/**
* Takes some action related to the link being clicked.
......
......@@ -50,9 +50,10 @@ import java.util.List;
* - (optional) One or two buttons with text at the bottom, or a button paired with an ImageView.
*
* When adding custom views, widths and heights defined in the LayoutParams will be ignored.
* Setting a minimum width using {@link View#setMininumWidth()} will be obeyed.
* Setting a minimum width using {@link View#setMinimumWidth()} will be obeyed.
*
* Logic for what happens when things are clicked should be implemented by the InfoBarView.
* Logic for what happens when things are clicked should be implemented by the
* InfoBarInteractionHandler.
*/
public final class InfoBarLayout extends ViewGroup implements View.OnClickListener {
......@@ -87,7 +88,7 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
private final int mPadding;
private final int mMinWidth;
private final InfoBarView mInfoBarView;
private final InfoBarInteractionHandler mInfoBar;
private final ImageButton mCloseButton;
private final InfoBarControlLayout mMessageLayout;
private final List<InfoBarControlLayout> mControlLayouts;
......@@ -106,18 +107,18 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
* message, the buttons, and/or the custom content using setMessage(), setButtons(), and
* setCustomContent().
* @param context The context used to render.
* @param infoBarView InfoBarView that listens to events.
* @param infoBar InfoBarInteractionHandler that listens to events.
* @param iconResourceId ID of the icon to use for the infobar.
* @param iconTintId The {@link ColorRes} used as tint for {@code iconResourceId}.
* @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
* @param message The message to show in the infobar.
*/
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
public InfoBarLayout(Context context, InfoBarInteractionHandler infoBar, int iconResourceId,
@ColorRes int iconTintId, Bitmap iconBitmap, CharSequence message) {
super(context);
mControlLayouts = new ArrayList<InfoBarControlLayout>();
mInfoBarView = infoBarView;
mInfoBar = infoBar;
// Cache resource values.
Resources res = getResources();
......@@ -462,14 +463,14 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
*/
@Override
public void onClick(View view) {
mInfoBarView.setControlsEnabled(false);
mInfoBar.onClick();
if (view.getId() == R.id.infobar_close_button) {
mInfoBarView.onCloseButtonClicked();
mInfoBar.onCloseButtonClicked();
} else if (view.getId() == R.id.button_primary) {
mInfoBarView.onButtonClicked(true);
mInfoBar.onButtonClicked(true);
} else if (view.getId() == R.id.button_secondary) {
mInfoBarView.onButtonClicked(false);
mInfoBar.onButtonClicked(false);
}
}
......@@ -509,7 +510,7 @@ public final class InfoBarLayout extends ViewGroup implements View.OnClickListen
}
private NoUnderlineClickableSpan createClickableSpan() {
return new NoUnderlineClickableSpan(getResources(), (view) -> mInfoBarView.onLinkClicked());
return new NoUnderlineClickableSpan(getResources(), (view) -> mInfoBar.onLinkClicked());
}
/**
......
......@@ -11,18 +11,18 @@ import android.view.View;
import android.widget.FrameLayout;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
/**
* Layout that holds an infobar's contents and provides a background color and a top shadow.
*/
class InfoBarWrapper extends FrameLayout {
private final InfoBarContainerLayout.Item mItem;
private final InfoBarUiItem mItem;
/**
* Constructor for inflating from Java.
*/
InfoBarWrapper(Context context, InfoBarContainerLayout.Item item) {
InfoBarWrapper(Context context, InfoBarUiItem item) {
super(context);
mItem = item;
Resources res = context.getResources();
......@@ -35,7 +35,7 @@ class InfoBarWrapper extends FrameLayout {
setPadding(0, shadowHeight, 0, 0);
}
InfoBarContainerLayout.Item getItem() {
InfoBarUiItem getItem() {
return mItem;
}
......
......@@ -15,7 +15,6 @@ import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.ConfirmInfoBar;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item.InfoBarPriority;
import org.chromium.chrome.browser.infobar.InfoBarLayout;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarControlLayout;
import org.chromium.ui.KeyboardVisibilityDelegate;
......
......@@ -22,7 +22,6 @@ import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeVersionInfo;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.infobar.InfoBarContainer;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.infobar.InfoBarIdentifier;
import org.chromium.chrome.browser.infobar.SurveyInfoBar;
import org.chromium.chrome.browser.infobar.SurveyInfoBarDelegate;
......@@ -36,6 +35,7 @@ import org.chromium.chrome.browser.tab.TabObserver;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.components.variations.VariationsAssociatedData;
import java.lang.annotation.Retention;
......@@ -291,7 +291,7 @@ public class ChromeSurveyController implements InfoBarContainer.InfoBarAnimation
public void notifyAnimationFinished(int animationType) {}
@Override
public void notifyAllAnimationsFinished(Item frontInfoBar) {
public void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar) {
mLoggingHandler.removeCallbacksAndMessages(null);
// If the survey info bar is in front, start the countdown to log that it was displayed.
......
......@@ -48,11 +48,11 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.infobar.InfoBar;
import org.chromium.chrome.browser.infobar.InfoBarContainer;
import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.infobar.InstallableAmbientBadgeInfoBar;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.chrome.browser.webapps.WebappDataStorage;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
......@@ -171,7 +171,7 @@ public class AppBannerManagerTest {
}
@Override
public void notifyAllAnimationsFinished(Item frontInfoBar) {
public void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar) {
mDoneAnimating = true;
}
}
......
......@@ -28,7 +28,7 @@ import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.IPHBubbleDelegate;
import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.PopupState;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import org.chromium.components.browser_ui.widget.textbubble.TextBubble;
/** Tests {@link IPHInfoBarSupport}. */
......@@ -38,7 +38,7 @@ public class IPHInfoBarSupportTest {
@Mock
private IPHBubbleDelegate mDelegate;
@Mock
private Item mItem;
private InfoBarUiItem mItem;
@Mock
private View mView;
......
......@@ -18,6 +18,7 @@ android_library("java") {
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/infobar/InfoBarUiItem.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/SnackbarManager.java",
......@@ -29,6 +30,7 @@ android_library("java") {
"//chrome/browser/util:java",
"//components/browser_ui/styles/android:java_resources",
"//components/browser_ui/widget/android:java",
"//components/infobars/core:infobar_enums_java",
"//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/android_deps:com_android_support_appcompat_v7_java",
"//ui/android:ui_full_java",
......
// 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.
package org.chromium.chrome.browser.ui.messages.infobar;
import android.view.View;
import androidx.annotation.IntDef;
import org.chromium.chrome.browser.infobar.InfoBarIdentifier;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* An interface for items that can be added to an InfoBarContainerLayout.
*/
public interface InfoBarUiItem {
// The infobar priority.
@IntDef({InfoBarPriority.CRITICAL, InfoBarPriority.USER_TRIGGERED,
InfoBarPriority.PAGE_TRIGGERED, InfoBarPriority.BACKGROUND})
@Retention(RetentionPolicy.SOURCE)
public @interface InfoBarPriority {
int CRITICAL = 0;
int USER_TRIGGERED = 1;
int PAGE_TRIGGERED = 2;
int BACKGROUND = 3;
}
/**
* Returns the View that represents this infobar. This should have no background or borders;
* a background and shadow will be added by a wrapper view.
*/
View getView();
/**
* Returns whether controls for this View should be clickable. If false, all input events on
* this item will be ignored.
*/
boolean areControlsEnabled();
/**
* Sets whether or not controls for this View should be clickable. This does not affect the
* visual state of the infobar.
* @param state If false, all input events on this Item will be ignored.
*/
void setControlsEnabled(boolean state);
/**
* Returns the accessibility text to announce when this infobar is first shown.
*/
CharSequence getAccessibilityText();
/**
* Returns the priority of an infobar. High priority infobar is shown in front of low
* priority infobar. If infobars have the same priorities, the most recently added one
* is shown behind previous ones.
*
*/
int getPriority();
/**
* Returns the type of infobar, as best as can be determined at this time. See
* components/infobars/core/infobar_delegate.h.
*/
@InfoBarIdentifier
int getInfoBarIdentifier();
}
......@@ -6,7 +6,7 @@ package org.chromium.chrome.test.util;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener;
import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.ui.messages.infobar.InfoBarUiItem;
import java.util.concurrent.TimeoutException;
......@@ -47,7 +47,7 @@ public class InfoBarTestAnimationListener implements InfoBarAnimationListener {
}
@Override
public void notifyAllAnimationsFinished(Item frontInfoBar) {}
public void notifyAllAnimationsFinished(InfoBarUiItem frontInfoBar) {}
public void addInfoBarAnimationFinished(String msg) throws TimeoutException {
mAddAnimationFinished.waitForCallback(msg, mAddCallCount);
......
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