Commit 9b9ec682 authored by newt@chromium.org's avatar newt@chromium.org

[Android] Always show infobars at the bottom of the screen.

Previously, infobars were shown at the bottom of the screen on phones,
but at the top of the screen on tablets.

BUG=375379
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283593 0039d316-1c4b-4281-b951-d872f2087c98
parent 4f474a5f
...@@ -124,7 +124,6 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener ...@@ -124,7 +124,6 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener
if (mAnimationStarted) return; if (mAnimationStarted) return;
mAnimationStarted = true; mAnimationStarted = true;
boolean infoBarsOnTop = mContainer.areInfoBarsOnTop();
int indexOfWrapperView = mContainer.indexOfChild(mTargetWrapperView); int indexOfWrapperView = mContainer.indexOfChild(mTargetWrapperView);
assert indexOfWrapperView != -1; assert indexOfWrapperView != -1;
...@@ -136,16 +135,14 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener ...@@ -136,16 +135,14 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener
int cumulativeTopStart = 0; int cumulativeTopStart = 0;
int cumulativeTopEnd = 0; int cumulativeTopEnd = 0;
int cumulativeEndHeight = 0; int cumulativeEndHeight = 0;
if (!infoBarsOnTop) { if (heightDifference >= 0) {
if (heightDifference >= 0) { // The current container is smaller than the final container, so the current 0
// The current container is smaller than the final container, so the current 0 // coordinate will be >= 0 in the final container.
// coordinate will be >= 0 in the final container. cumulativeTopStart = heightDifference;
cumulativeTopStart = heightDifference; } else {
} else { // The current container is bigger than the final container, so the current 0
// The current container is bigger than the final container, so the current 0 // coordinate will be < 0 in the final container.
// coordinate will be < 0 in the final container. cumulativeTopEnd = -heightDifference;
cumulativeTopEnd = -heightDifference;
}
} }
for (int i = 0; i < mContainer.getChildCount(); ++i) { for (int i = 0; i < mContainer.getChildCount(); ++i) {
...@@ -169,13 +166,12 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener ...@@ -169,13 +166,12 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener
} else { } else {
// A translation is required to move the View into place. // A translation is required to move the View into place.
int translation = heightDifference; int translation = heightDifference;
if (infoBarsOnTop) translation *= -1;
boolean translateDownward = false; boolean translateDownward;
if (topStart < topEnd) { if (topStart < topEnd) {
translateDownward = infoBarsOnTop; translateDownward = false;
} else if (topStart > topEnd) { } else if (topStart > topEnd) {
translateDownward = !infoBarsOnTop; translateDownward = true;
} else { } else {
translateDownward = bottomEnd > bottomStart; translateDownward = bottomEnd > bottomStart;
} }
...@@ -204,28 +200,16 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener ...@@ -204,28 +200,16 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener
// Lock the InfoBarContainer's size at its largest during the animation to avoid // Lock the InfoBarContainer's size at its largest during the animation to avoid
// clipping issues. // clipping issues.
final int oldContainerTop = mContainer.getTop(); int oldContainerTop = mContainer.getTop();
final int oldContainerBottom = mContainer.getBottom(); int newContainerTop = mContainer.getBottom() - cumulativeEndHeight;
final int newContainerTop; int biggestContainerTop = Math.min(oldContainerTop, newContainerTop);
final int newContainerBottom;
if (infoBarsOnTop) {
newContainerTop = oldContainerTop;
newContainerBottom = newContainerTop + cumulativeEndHeight;
} else {
newContainerBottom = oldContainerBottom;
newContainerTop = newContainerBottom - cumulativeEndHeight;
}
final int biggestContainerTop = Math.min(oldContainerTop, newContainerTop);
final int biggestContainerBottom = Math.max(oldContainerBottom, newContainerBottom);
mContainer.setTop(biggestContainerTop); mContainer.setTop(biggestContainerTop);
mContainer.setBottom(biggestContainerBottom);
// Set up and run all of the animations. // Set up and run all of the animations.
mAnimatorSet.addListener(new AnimatorListenerAdapter() { mAnimatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
mTargetWrapperView.startTransition(); mTargetWrapperView.startTransition();
mContainer.startTransition();
} }
@Override @Override
......
...@@ -35,7 +35,6 @@ public class ContentWrapperView extends FrameLayout { ...@@ -35,7 +35,6 @@ public class ContentWrapperView extends FrameLayout {
private static final int CONTENT_INDEX = 0; private static final int CONTENT_INDEX = 0;
private final int mGravity; private final int mGravity;
private final boolean mInfoBarsFromTop;
private final InfoBar mInfoBar; private final InfoBar mInfoBar;
private View mViewToHide; private View mViewToHide;
...@@ -45,13 +44,11 @@ public class ContentWrapperView extends FrameLayout { ...@@ -45,13 +44,11 @@ public class ContentWrapperView extends FrameLayout {
* Constructs a ContentWrapperView object. * Constructs a ContentWrapperView object.
* @param context The context to create this View with. * @param context The context to create this View with.
*/ */
public ContentWrapperView(Context context, InfoBar infoBar, View panel, public ContentWrapperView(Context context, InfoBar infoBar, View panel) {
boolean infoBarsFromTop) {
// Set up this ViewGroup. // Set up this ViewGroup.
super(context); super(context);
mInfoBar = infoBar; mInfoBar = infoBar;
mGravity = infoBarsFromTop ? Gravity.BOTTOM : Gravity.TOP; mGravity = Gravity.TOP;
mInfoBarsFromTop = infoBarsFromTop;
// Set up this view. // Set up this view.
Resources resources = context.getResources(); Resources resources = context.getResources();
...@@ -152,20 +149,6 @@ public class ContentWrapperView extends FrameLayout { ...@@ -152,20 +149,6 @@ public class ContentWrapperView extends FrameLayout {
// We're transitioning between two views; set the alpha so it doesn't pop in. // We're transitioning between two views; set the alpha so it doesn't pop in.
if (mViewToHide != null) mViewToShow.setAlpha(0.0f); if (mViewToHide != null) mViewToShow.setAlpha(0.0f);
// Because of layout scheduling, we need to move the child Views downward before it
// occurs. Failure to do so results in the Views being located incorrectly during the
// first few frames of the animation.
if (mInfoBarsFromTop && getViewToShowHeight() > getViewToHideHeight()) {
getLayoutParams().height = getViewToShowHeight();
int translation = getTransitionHeightDifference();
for (int i = 0; i < getChildCount(); ++i) {
View v = getChildAt(i);
v.setTop(v.getTop() + translation);
v.setBottom(v.getBottom() + translation);
}
}
} }
} }
......
...@@ -186,8 +186,7 @@ public abstract class InfoBar implements InfoBarView { ...@@ -186,8 +186,7 @@ public abstract class InfoBar implements InfoBarView {
protected ContentWrapperView getContentWrapper(boolean createIfNotFound) { protected ContentWrapperView getContentWrapper(boolean createIfNotFound) {
if (mContentView == null && createIfNotFound) { if (mContentView == null && createIfNotFound) {
mContentView = new ContentWrapperView(getContext(), this, createView(), mContentView = new ContentWrapperView(getContext(), this, createView());
getInfoBarContainer().areInfoBarsOnTop());
mContentView.setFocusable(false); mContentView.setFocusable(false);
} }
return mContentView; return mContentView;
......
...@@ -16,11 +16,9 @@ import android.widget.LinearLayout; ...@@ -16,11 +16,9 @@ import android.widget.LinearLayout;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import org.chromium.ui.base.DeviceFormFactor;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -77,9 +75,6 @@ public class InfoBarContainer extends LinearLayout { ...@@ -77,9 +75,6 @@ public class InfoBarContainer extends LinearLayout {
private final AutoLoginDelegate mAutoLoginDelegate; private final AutoLoginDelegate mAutoLoginDelegate;
// Whether the infobar are shown on top (below the location bar) or at the bottom of the screen.
private final boolean mInfoBarsOnTop;
// The list of all infobars in this container, regardless of whether they've been shown yet. // The list of all infobars in this container, regardless of whether they've been shown yet.
private final ArrayList<InfoBar> mInfoBars = new ArrayList<InfoBar>(); private final ArrayList<InfoBar> mInfoBars = new ArrayList<InfoBar>();
...@@ -114,9 +109,7 @@ public class InfoBarContainer extends LinearLayout { ...@@ -114,9 +109,7 @@ public class InfoBarContainer extends LinearLayout {
mAnimationSizer = new FrameLayout(activity); mAnimationSizer = new FrameLayout(activity);
mAnimationSizer.setVisibility(INVISIBLE); mAnimationSizer.setVisibility(INVISIBLE);
// The tablet has the infobars below the location bar. On the phone they are at the bottom. setGravity(Gravity.BOTTOM);
mInfoBarsOnTop = DeviceFormFactor.isTablet(activity);
setGravity(determineGravity());
// Chromium's InfoBarContainer may add an InfoBar immediately during this initialization // Chromium's InfoBarContainer may add an InfoBar immediately during this initialization
// call, so make sure everything in the InfoBarContainer is completely ready beforehand. // call, so make sure everything in the InfoBarContainer is completely ready beforehand.
...@@ -132,9 +125,8 @@ public class InfoBarContainer extends LinearLayout { ...@@ -132,9 +125,8 @@ public class InfoBarContainer extends LinearLayout {
return mAnimationListener; return mAnimationListener;
} }
public boolean areInfoBarsOnTop() { public boolean areInfoBarsOnTop() {
return mInfoBarsOnTop; return false;
} }
@Override @Override
...@@ -155,13 +147,9 @@ public class InfoBarContainer extends LinearLayout { ...@@ -155,13 +147,9 @@ public class InfoBarContainer extends LinearLayout {
} }
} }
private int determineGravity() {
return mInfoBarsOnTop ? Gravity.TOP : Gravity.BOTTOM;
}
private FrameLayout.LayoutParams createLayoutParams() { private FrameLayout.LayoutParams createLayoutParams() {
return new FrameLayout.LayoutParams( return new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, determineGravity()); LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
} }
public void removeFromParentView() { public void removeFromParentView() {
...@@ -357,7 +345,7 @@ public class InfoBarContainer extends LinearLayout { ...@@ -357,7 +345,7 @@ public class InfoBarContainer extends LinearLayout {
targetView = info.target.getContentWrapper(true); targetView = info.target.getContentWrapper(true);
assert mInfoBars.contains(info.target); assert mInfoBars.contains(info.target);
toShow = targetView.detachCurrentView(); toShow = targetView.detachCurrentView();
addView(targetView, mInfoBarsOnTop ? getChildCount() : 0, addView(targetView, 0,
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
} else { } else {
targetView = info.target.getContentWrapper(false); targetView = info.target.getContentWrapper(false);
...@@ -445,14 +433,6 @@ public class InfoBarContainer extends LinearLayout { ...@@ -445,14 +433,6 @@ public class InfoBarContainer extends LinearLayout {
} }
} }
public void startTransition() {
if (mInfoBarsOnTop) {
// We need to clip this view to its bounds while it is animated because the layout's
// z-ordering puts it on top of other infobars as it's being animated.
ApiCompatibilityUtils.postInvalidateOnAnimation(this);
}
}
/** /**
* Finishes off whatever animation is running. * Finishes off whatever animation is running.
*/ */
......
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