Commit d4cb9913 authored by dfalcantara's avatar dfalcantara Committed by Commit bot

Stop infobar autohiding when Touch Exploration enabled

Adds a way to stop InfoBars and SwipableOverlayViews from auto-hiding.

BUG=452614

Review URL: https://codereview.chromium.org/968453002

Cr-Commit-Position: refs/heads/master@{#318542}
parent 0fac57d7
...@@ -250,10 +250,17 @@ public abstract class SwipableOverlayView extends ScrollView { ...@@ -250,10 +250,17 @@ public abstract class SwipableOverlayView extends ScrollView {
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
if (!mDoStayInvisible) { if (!mDoStayInvisible) {
ObjectAnimator.ofFloat(this, "alpha", 0.f, 1.f).setDuration(REATTACH_FADE_IN_MS) ObjectAnimator.ofFloat(this, View.ALPHA, 0.f, 1.f).setDuration(REATTACH_FADE_IN_MS)
.start(); .start();
setVisibility(VISIBLE); setVisibility(VISIBLE);
} }
if (!isAllowedToAutoHide()) setTranslationY(0.0f);
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
if (!isAllowedToAutoHide()) setTranslationY(0.0f);
} }
/** /**
...@@ -406,7 +413,7 @@ public abstract class SwipableOverlayView extends ScrollView { ...@@ -406,7 +413,7 @@ public abstract class SwipableOverlayView extends ScrollView {
return new GestureStateListener() { return new GestureStateListener() {
@Override @Override
public void onFlingStartGesture(int vx, int vy, int scrollOffsetY, int scrollExtentY) { public void onFlingStartGesture(int vx, int vy, int scrollOffsetY, int scrollExtentY) {
if (!cancelCurrentAnimation()) return; if (!isAllowedToAutoHide() || !cancelCurrentAnimation()) return;
beginGesture(scrollOffsetY, scrollExtentY); beginGesture(scrollOffsetY, scrollExtentY);
mGestureState = GESTURE_FLINGING; mGestureState = GESTURE_FLINGING;
} }
...@@ -442,7 +449,7 @@ public abstract class SwipableOverlayView extends ScrollView { ...@@ -442,7 +449,7 @@ public abstract class SwipableOverlayView extends ScrollView {
@Override @Override
public void onScrollStarted(int scrollOffsetY, int scrollExtentY) { public void onScrollStarted(int scrollOffsetY, int scrollExtentY) {
if (!cancelCurrentAnimation()) return; if (!isAllowedToAutoHide() || !cancelCurrentAnimation()) return;
beginGesture(scrollOffsetY, scrollExtentY); beginGesture(scrollOffsetY, scrollExtentY);
mGestureState = GESTURE_SCROLLING; mGestureState = GESTURE_SCROLLING;
} }
...@@ -692,6 +699,13 @@ public abstract class SwipableOverlayView extends ScrollView { ...@@ -692,6 +699,13 @@ public abstract class SwipableOverlayView extends ScrollView {
return !mIsBeingDisplayedForFirstTime && !mIsDismissed; return !mIsBeingDisplayedForFirstTime && !mIsDismissed;
} }
/**
* @return Whether the SwipableOverlayView is allowed to hide itself on scroll.
*/
protected boolean isAllowedToAutoHide() {
return true;
}
/** /**
* Override gatherTransparentRegion to make this view's layout a placeholder for its * Override gatherTransparentRegion to make this view's layout a placeholder for its
* animations. This is only called during layout, so it doesn't really make sense to apply * animations. This is only called during layout, so it doesn't really make sense to apply
......
...@@ -40,6 +40,9 @@ public class InfoBarContainer extends SwipableOverlayView { ...@@ -40,6 +40,9 @@ public class InfoBarContainer extends SwipableOverlayView {
private static final int TAB_STRIP_AND_TOOLBAR_HEIGHT_PHONE_DP = 56; private static final int TAB_STRIP_AND_TOOLBAR_HEIGHT_PHONE_DP = 56;
private static final int TAB_STRIP_AND_TOOLBAR_HEIGHT_TABLET_DP = 96; private static final int TAB_STRIP_AND_TOOLBAR_HEIGHT_TABLET_DP = 96;
/** WHether or not the InfoBarContainer is allowed to hide when the user scrolls. */
private static boolean sIsAllowedToAutoHide;
/** /**
* A listener for the InfoBar animation. * A listener for the InfoBar animation.
*/ */
...@@ -520,6 +523,20 @@ public class InfoBarContainer extends SwipableOverlayView { ...@@ -520,6 +523,20 @@ public class InfoBarContainer extends SwipableOverlayView {
return mNativeInfoBarContainer; return mNativeInfoBarContainer;
} }
/**
* Sets whether the InfoBarContainer is allowed to auto-hide when the user scrolls the page.
* Expected to be called when Touch Exploration is enabled.
* @param isAllowed Whether auto-hiding is allowed.
*/
public static void setIsAllowedToAutoHide(boolean isAllowed) {
sIsAllowedToAutoHide = isAllowed;
}
@Override
protected boolean isAllowedToAutoHide() {
return sIsAllowedToAutoHide;
}
@Override @Override
protected void onViewSwipedAway() { protected void onViewSwipedAway() {
assert false; assert false;
......
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