diff options
author | newt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-17 00:26:50 +0000 |
---|---|---|
committer | newt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-17 00:26:50 +0000 |
commit | 9b9ec682af233181f290e9f4ee075115cc32c9e7 (patch) | |
tree | 7095a53deaf50acd6b77e90714893472ef64eab0 | |
parent | 4f474a5fbb03a1ba35c65f8cb2311a3a96bf7cb3 (diff) | |
download | chromium_src-9b9ec682af233181f290e9f4ee075115cc32c9e7.zip chromium_src-9b9ec682af233181f290e9f4ee075115cc32c9e7.tar.gz chromium_src-9b9ec682af233181f290e9f4ee075115cc32c9e7.tar.bz2 |
[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
4 files changed, 21 insertions, 75 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AnimationHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AnimationHelper.java index cb2e073..3e71ebd 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AnimationHelper.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AnimationHelper.java @@ -124,7 +124,6 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener if (mAnimationStarted) return; mAnimationStarted = true; - boolean infoBarsOnTop = mContainer.areInfoBarsOnTop(); int indexOfWrapperView = mContainer.indexOfChild(mTargetWrapperView); assert indexOfWrapperView != -1; @@ -136,16 +135,14 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener int cumulativeTopStart = 0; int cumulativeTopEnd = 0; int cumulativeEndHeight = 0; - if (!infoBarsOnTop) { - if (heightDifference >= 0) { - // The current container is smaller than the final container, so the current 0 - // coordinate will be >= 0 in the final container. - cumulativeTopStart = heightDifference; - } else { - // The current container is bigger than the final container, so the current 0 - // coordinate will be < 0 in the final container. - cumulativeTopEnd = -heightDifference; - } + if (heightDifference >= 0) { + // The current container is smaller than the final container, so the current 0 + // coordinate will be >= 0 in the final container. + cumulativeTopStart = heightDifference; + } else { + // The current container is bigger than the final container, so the current 0 + // coordinate will be < 0 in the final container. + cumulativeTopEnd = -heightDifference; } for (int i = 0; i < mContainer.getChildCount(); ++i) { @@ -169,13 +166,12 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener } else { // A translation is required to move the View into place. int translation = heightDifference; - if (infoBarsOnTop) translation *= -1; - boolean translateDownward = false; + boolean translateDownward; if (topStart < topEnd) { - translateDownward = infoBarsOnTop; + translateDownward = false; } else if (topStart > topEnd) { - translateDownward = !infoBarsOnTop; + translateDownward = true; } else { translateDownward = bottomEnd > bottomStart; } @@ -204,28 +200,16 @@ public class AnimationHelper implements ViewTreeObserver.OnGlobalLayoutListener // Lock the InfoBarContainer's size at its largest during the animation to avoid // clipping issues. - final int oldContainerTop = mContainer.getTop(); - final int oldContainerBottom = mContainer.getBottom(); - final int 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); + int oldContainerTop = mContainer.getTop(); + int newContainerTop = mContainer.getBottom() - cumulativeEndHeight; + int biggestContainerTop = Math.min(oldContainerTop, newContainerTop); mContainer.setTop(biggestContainerTop); - mContainer.setBottom(biggestContainerBottom); // Set up and run all of the animations. mAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mTargetWrapperView.startTransition(); - mContainer.startTransition(); } @Override diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/ContentWrapperView.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/ContentWrapperView.java index 56cb523..216b35f1 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/ContentWrapperView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/ContentWrapperView.java @@ -35,7 +35,6 @@ public class ContentWrapperView extends FrameLayout { private static final int CONTENT_INDEX = 0; private final int mGravity; - private final boolean mInfoBarsFromTop; private final InfoBar mInfoBar; private View mViewToHide; @@ -45,13 +44,11 @@ public class ContentWrapperView extends FrameLayout { * Constructs a ContentWrapperView object. * @param context The context to create this View with. */ - public ContentWrapperView(Context context, InfoBar infoBar, View panel, - boolean infoBarsFromTop) { + public ContentWrapperView(Context context, InfoBar infoBar, View panel) { // Set up this ViewGroup. super(context); mInfoBar = infoBar; - mGravity = infoBarsFromTop ? Gravity.BOTTOM : Gravity.TOP; - mInfoBarsFromTop = infoBarsFromTop; + mGravity = Gravity.TOP; // Set up this view. Resources resources = context.getResources(); @@ -152,20 +149,6 @@ public class ContentWrapperView extends FrameLayout { // We're transitioning between two views; set the alpha so it doesn't pop in. 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); - } - } } } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java index c202f7f..d0721f7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java @@ -186,8 +186,7 @@ public abstract class InfoBar implements InfoBarView { protected ContentWrapperView getContentWrapper(boolean createIfNotFound) { if (mContentView == null && createIfNotFound) { - mContentView = new ContentWrapperView(getContext(), this, createView(), - getInfoBarContainer().areInfoBarsOnTop()); + mContentView = new ContentWrapperView(getContext(), this, createView()); mContentView.setFocusable(false); } return mContentView; 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 e991272..2b3c5be 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 @@ -16,11 +16,9 @@ import android.widget.LinearLayout; import com.google.common.annotations.VisibleForTesting; -import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.CalledByNative; import org.chromium.content_public.browser.WebContents; import org.chromium.ui.UiUtils; -import org.chromium.ui.base.DeviceFormFactor; import java.util.ArrayDeque; import java.util.ArrayList; @@ -77,9 +75,6 @@ public class InfoBarContainer extends LinearLayout { 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. private final ArrayList<InfoBar> mInfoBars = new ArrayList<InfoBar>(); @@ -114,9 +109,7 @@ public class InfoBarContainer extends LinearLayout { mAnimationSizer = new FrameLayout(activity); mAnimationSizer.setVisibility(INVISIBLE); - // The tablet has the infobars below the location bar. On the phone they are at the bottom. - mInfoBarsOnTop = DeviceFormFactor.isTablet(activity); - setGravity(determineGravity()); + setGravity(Gravity.BOTTOM); // Chromium's InfoBarContainer may add an InfoBar immediately during this initialization // call, so make sure everything in the InfoBarContainer is completely ready beforehand. @@ -132,9 +125,8 @@ public class InfoBarContainer extends LinearLayout { return mAnimationListener; } - public boolean areInfoBarsOnTop() { - return mInfoBarsOnTop; + return false; } @Override @@ -155,13 +147,9 @@ public class InfoBarContainer extends LinearLayout { } } - private int determineGravity() { - return mInfoBarsOnTop ? Gravity.TOP : Gravity.BOTTOM; - } - private FrameLayout.LayoutParams createLayoutParams() { return new FrameLayout.LayoutParams( - LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, determineGravity()); + LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM); } public void removeFromParentView() { @@ -357,7 +345,7 @@ public class InfoBarContainer extends LinearLayout { targetView = info.target.getContentWrapper(true); assert mInfoBars.contains(info.target); toShow = targetView.detachCurrentView(); - addView(targetView, mInfoBarsOnTop ? getChildCount() : 0, + addView(targetView, 0, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); } else { targetView = info.target.getContentWrapper(false); @@ -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. */ |