Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3348)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java

Issue 893483002: Make infobars hide on scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Observer removal Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReportingView.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
index 933d7707bfa653c8ba4e4ef2fa43cc2ea2c172a6..b636846f12b9821a38ffb33e7bfd07c230c91654 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.infobar;
-import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -14,16 +13,14 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import android.widget.ScrollView;
import org.chromium.base.CalledByNative;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
-import org.chromium.chrome.browser.EmptyTabObserver;
import org.chromium.chrome.browser.Tab;
import org.chromium.chrome.browser.TabObserver;
+import org.chromium.chrome.browser.banners.SwipableOverlayView;
import org.chromium.content_public.browser.WebContents;
-import org.chromium.ui.UiUtils;
import org.chromium.ui.base.DeviceFormFactor;
import java.util.ArrayDeque;
@@ -38,9 +35,8 @@ import java.util.LinkedList;
* When initiated from native code, special code is needed to keep the Java and native infobar in
* sync, see NativeInfoBar.
*/
-public class InfoBarContainer extends ScrollView {
+public class InfoBarContainer extends SwipableOverlayView {
private static final String TAG = "InfoBarContainer";
- private static final long REATTACH_FADE_IN_MS = 250;
private static final int TAB_STRIP_AND_TOOLBAR_HEIGHT_PHONE_DP = 56;
private static final int TAB_STRIP_AND_TOOLBAR_HEIGHT_TABLET_DP = 96;
@@ -111,13 +107,11 @@ public class InfoBarContainer extends ScrollView {
private Paint mTopBorderPaint;
- // Keeps the infobars from becoming visible when they normally would.
- private boolean mDoStayInvisible;
- private TabObserver mTabObserver;
-
- public InfoBarContainer(Context context, int tabId, ViewGroup parentView,
- WebContents webContents) {
- super(context);
+ public InfoBarContainer(
+ Context context, int tabId, ViewGroup parentView, WebContents webContents, Tab tab) {
+ super(context, null);
+ tab.addObserver(getTabObserver());
+ setIsSwipable(false);
// Workaround for http://crbug.com/407149. See explanation in onMeasure() below.
setVerticalScrollBarEnabled(false);
@@ -202,16 +196,8 @@ public class InfoBarContainer extends ScrollView {
return true;
}
- private void addToParentView() {
- if (mParentView != null && mParentView.indexOfChild(this) == -1) {
- mParentView.addView(this);
- }
- }
-
- public void removeFromParentView() {
- if (getParent() != null) {
- ((ViewGroup) getParent()).removeView(this);
- }
+ protected void addToParentView() {
+ super.addToParentView(mParentView);
}
/**
@@ -226,50 +212,17 @@ public class InfoBarContainer extends ScrollView {
addToParentView();
}
- /**
- * Call with {@code true} when a higher priority bottom element is visible to keep the infobars
- * from ever becoming visible. Call with {@code false} to restore normal visibility behavior.
- * @param doStayInvisible Whether the infobars should stay invisible even when they would
- * normally become visible.
- * @param tab The current Tab.
- */
- public void setDoStayInvisible(boolean doStayInvisible, Tab tab) {
- mDoStayInvisible = doStayInvisible;
- if (mTabObserver == null) mTabObserver = createTabObserver();
- if (doStayInvisible) {
- tab.addObserver(mTabObserver);
- } else {
- tab.removeObserver(mTabObserver);
- }
- }
-
- /**
- * Creates a TabObserver for monitoring a Tab, used to reset internal settings when a
- * navigation is done.
- * @return TabObserver that can be used to monitor a Tab.
- */
- private TabObserver createTabObserver() {
- return new EmptyTabObserver() {
+ @Override
+ protected TabObserver createTabObserver() {
+ return new SwipableOverlayViewTabObserver() {
@Override
- public void onDidNavigateMainFrame(Tab tab, String url, String baseUrl,
- boolean isNavigationToDifferentPage, boolean isFragmentNavigation,
- int statusCode) {
- setDoStayInvisible(false, tab);
+ public void onPageLoadStarted(Tab tab) {
+ onPageStarted();
}
};
}
@Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (!mDoStayInvisible) {
- ObjectAnimator.ofFloat(this, "alpha", 0.f, 1.f).setDuration(REATTACH_FADE_IN_MS)
- .start();
- setVisibility(VISIBLE);
- }
- }
-
- @Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
setVisibility(INVISIBLE);
@@ -383,17 +336,6 @@ public class InfoBarContainer extends ScrollView {
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
- // Hide the infobars when the keyboard is showing.
- boolean isShowing = (getVisibility() == View.VISIBLE);
- if (UiUtils.isKeyboardShowing(mContext, this)) {
- if (isShowing) {
- setVisibility(View.INVISIBLE);
- }
- } else {
- if (!isShowing && !mDoStayInvisible) {
- setVisibility(View.VISIBLE);
- }
- }
super.onLayout(changed, l, t, r, b);
// Keep the infobars fixed to the bottom of the screen when infobars are added or removed.
@@ -578,6 +520,21 @@ public class InfoBarContainer extends ScrollView {
return mNativeInfoBarContainer;
}
+ @Override
+ protected void onViewSwipedAway() {
+ assert false;
+ }
+
+ @Override
+ protected void onViewClicked() {
+ assert false;
+ }
+
+ @Override
+ protected void onViewPressed(MotionEvent event) {
+ assert false;
+ }
+
private native long nativeInit(WebContents webContents);
private native void nativeDestroy(long nativeInfoBarContainerAndroid);
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReportingView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698