Commit a6db97ee authored by Bernhard Bauer's avatar Bernhard Bauer Committed by Commit Bot

Update bottom sheet navigation selector during peeking -> half transition according to motion spec.

The navigation selector will now hide immediately when moving the
bottom sheet down from the half state (full state for small screens),
instead of 96dp before the peek position.

Preview: https://drive.google.com/open?id=0B8YGYtFin7saZ2VDNmhnZGZJWTg

Bug: 759130
Change-Id: I326d9baf0f8f837b782a51f6daa84c13fac1074a
Reviewed-on: https://chromium-review.googlesource.com/689999
Commit-Queue: Bernhard Bauer <bauerb@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505344}
parent 0a11888c
...@@ -491,8 +491,6 @@ ...@@ -491,8 +491,6 @@
<!-- Bottom sheet dimensions --> <!-- Bottom sheet dimensions -->
<dimen name="bottom_sheet_help_bubble_inset">10dp</dimen> <dimen name="bottom_sheet_help_bubble_inset">10dp</dimen>
<dimen name="bottom_nav_height">40dp</dimen> <dimen name="bottom_nav_height">40dp</dimen>
<dimen name="bottom_nav_space_from_toolbar">96dp</dimen>
<!-- The following two dimensions override defaults in Android's BottomNavigationView -->
<!-- Chrome Home dimensions --> <!-- Chrome Home dimensions -->
<dimen name="chrome_home_empty_view_top_padding">72dp</dimen> <dimen name="chrome_home_empty_view_top_padding">72dp</dimen>
......
...@@ -397,10 +397,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity ...@@ -397,10 +397,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
mBottomSheetContentController = mBottomSheetContentController =
(BottomSheetContentController) ((ViewStub) findViewById(R.id.bottom_nav_stub)) (BottomSheetContentController) ((ViewStub) findViewById(R.id.bottom_nav_stub))
.inflate(); .inflate();
int controlContainerHeight = mBottomSheetContentController.init(mBottomSheet, mTabModelSelector, this);
((ControlContainer) findViewById(R.id.control_container)).getView().getHeight();
mBottomSheetContentController.init(
mBottomSheet, controlContainerHeight, mTabModelSelector, this);
} }
((BottomContainer) findViewById(R.id.bottom_container)).initialize(mFullscreenManager); ((BottomContainer) findViewById(R.id.bottom_container)).initialize(mFullscreenManager);
} }
......
...@@ -1504,7 +1504,7 @@ public class BottomSheet ...@@ -1504,7 +1504,7 @@ public class BottomSheet
* @param state The state to get the height from. * @param state The state to get the height from.
* @return The height of the sheet at the provided state. * @return The height of the sheet at the provided state.
*/ */
private float getSheetHeightForState(@SheetState int state) { public float getSheetHeightForState(@SheetState int state) {
return mStateRatios[state] * mContainerHeight; return mStateRatios[state] * mContainerHeight;
} }
...@@ -1573,7 +1573,7 @@ public class BottomSheet ...@@ -1573,7 +1573,7 @@ public class BottomSheet
return prevState; return prevState;
} }
private boolean isSmallScreen() { public boolean isSmallScreen() {
// A small screen is defined by there being less than 160dp between half and full states. // A small screen is defined by there being less than 160dp between half and full states.
float fullToHalfDiff = (getFullRatio() - getHalfRatio()) * mContainerHeight; float fullToHalfDiff = (getFullRatio() - getHalfRatio()) * mContainerHeight;
return fullToHalfDiff < mMinHalfFullDistance; return fullToHalfDiff < mMinHalfFullDistance;
......
...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.widget.bottomsheet; ...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.widget.bottomsheet;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.AttributeSet; import android.util.AttributeSet;
...@@ -89,9 +88,10 @@ public class BottomSheetContentController extends BottomNavigationView ...@@ -89,9 +88,10 @@ public class BottomSheetContentController extends BottomNavigationView
public void onSheetOffsetChanged(float heightFraction) { public void onSheetOffsetChanged(float heightFraction) {
// If the omnibox is not focused, allow the navigation bar to set its Y translation. // If the omnibox is not focused, allow the navigation bar to set its Y translation.
if (!mOmniboxHasFocus) { if (!mOmniboxHasFocus) {
float offsetY = float offsetY = mBottomSheet.getSheetHeightForState(mBottomSheet.isSmallScreen()
(mBottomSheet.getMinOffset() - mBottomSheet.getSheetOffsetFromBottom()) ? BottomSheet.SHEET_STATE_FULL
+ mDistanceBelowToolbarPx; : BottomSheet.SHEET_STATE_HALF)
- mBottomSheet.getSheetOffsetFromBottom();
setTranslationY(Math.max(offsetY, 0f)); setTranslationY(Math.max(offsetY, 0f));
if (mBottomSheet.getTargetSheetState() != BottomSheet.SHEET_STATE_PEEK if (mBottomSheet.getTargetSheetState() != BottomSheet.SHEET_STATE_PEEK
...@@ -172,7 +172,6 @@ public class BottomSheetContentController extends BottomNavigationView ...@@ -172,7 +172,6 @@ public class BottomSheetContentController extends BottomNavigationView
private BottomSheet mBottomSheet; private BottomSheet mBottomSheet;
private TabModelSelector mTabModelSelector; private TabModelSelector mTabModelSelector;
private SnackbarManager mSnackbarManager; private SnackbarManager mSnackbarManager;
private float mDistanceBelowToolbarPx;
private int mSelectedItemId; private int mSelectedItemId;
private ChromeActivity mActivity; private ChromeActivity mActivity;
private boolean mShouldOpenSheetOnNextContentChange; private boolean mShouldOpenSheetOnNextContentChange;
...@@ -209,12 +208,11 @@ public class BottomSheetContentController extends BottomNavigationView ...@@ -209,12 +208,11 @@ public class BottomSheetContentController extends BottomNavigationView
/** /**
* Initializes the {@link BottomSheetContentController}. * Initializes the {@link BottomSheetContentController}.
* @param bottomSheet The {@link BottomSheet} associated with this bottom nav. * @param bottomSheet The {@link BottomSheet} associated with this bottom nav.
* @param controlContainerHeight The height of the control container in px.
* @param tabModelSelector The {@link TabModelSelector} for the application. * @param tabModelSelector The {@link TabModelSelector} for the application.
* @param activity The {@link ChromeActivity} that owns the BottomSheet. * @param activity The {@link ChromeActivity} that owns the BottomSheet.
*/ */
public void init(BottomSheet bottomSheet, int controlContainerHeight, public void init(
TabModelSelector tabModelSelector, ChromeActivity activity) { BottomSheet bottomSheet, TabModelSelector tabModelSelector, ChromeActivity activity) {
mBottomSheet = bottomSheet; mBottomSheet = bottomSheet;
mBottomSheet.addObserver(mBottomSheetObserver); mBottomSheet.addObserver(mBottomSheetObserver);
mActivity = activity; mActivity = activity;
...@@ -236,10 +234,6 @@ public class BottomSheetContentController extends BottomNavigationView ...@@ -236,10 +234,6 @@ public class BottomSheetContentController extends BottomNavigationView
}; };
mTabModelSelector.addObserver(mTabModelSelectorObserver); mTabModelSelector.addObserver(mTabModelSelectorObserver);
Resources res = getContext().getResources();
mDistanceBelowToolbarPx = controlContainerHeight
+ res.getDimensionPixelOffset(R.dimen.bottom_nav_space_from_toolbar);
setOnNavigationItemSelectedListener(this); setOnNavigationItemSelectedListener(this);
hideMenuLabels(); hideMenuLabels();
......
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