Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelBase.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelBase.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelBase.java |
index eb333010f4cf1a24567d5f3884f525f2749d5d29..43b71b47b06ebd25695c995c5b495abf13c91a5b 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelBase.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanelBase.java |
@@ -90,20 +90,20 @@ abstract class OverlayPanelBase { |
*/ |
private static final float PROGRESS_BAR_VISIBILITY_THRESHOLD_DP = 10.f; |
+ /** Ratio of dps per pixel. */ |
+ protected final float mPxToDp; |
+ |
/** The height of the Toolbar in dps. */ |
private float mToolbarHeight; |
/** The height of the Bar when the Panel is peeking, in dps. */ |
- private final float mBarHeightPeeking; |
+ private float mBarHeightPeeking; |
/** The height of the Bar when the Panel is expanded, in dps. */ |
- private final float mBarHeightExpanded; |
+ private float mBarHeightExpanded; |
/** The height of the Bar when the Panel is maximized, in dps. */ |
- private final float mBarHeightMaximized; |
- |
- /** Ratio of dps per pixel. */ |
- protected final float mPxToDp; |
+ private float mBarHeightMaximized; |
/** |
* The Y coordinate to apply to the Base Page in order to keep the selection |
@@ -141,12 +141,11 @@ abstract class OverlayPanelBase { |
mContext = context; |
mPxToDp = 1.f / mContext.getResources().getDisplayMetrics().density; |
- mBarHeightPeeking = mContext.getResources().getDimension( |
- R.dimen.overlay_panel_bar_height) * mPxToDp; |
- mBarHeightMaximized = mContext.getResources().getDimension( |
- R.dimen.toolbar_height_no_shadow) * mPxToDp; |
- mBarHeightExpanded = |
- Math.round((mBarHeightPeeking + mBarHeightMaximized) / 2.f); |
+ mBarHeightPeeking = |
+ mContext.getResources().getDimension(R.dimen.overlay_panel_bar_height) * mPxToDp; |
+ mBarHeightMaximized = |
+ mContext.getResources().getDimension(R.dimen.toolbar_height_no_shadow) * mPxToDp; |
+ mBarHeightExpanded = Math.round((mBarHeightPeeking + mBarHeightMaximized) / 2.f); |
mBarMarginSide = BAR_ICON_SIDE_PADDING_DP; |
mProgressBarHeight = PROGRESS_BAR_HEIGHT_DP; |
@@ -1140,6 +1139,54 @@ abstract class OverlayPanelBase { |
} |
// ============================================================================================ |
+ // Bar Handle |
+ // ============================================================================================ |
+ protected int mBarHandleResourceId; |
+ protected float mBarHandleOffsetY; |
+ protected float mBarPaddingBottom; |
+ |
+ /** |
+ * Adds a handle to the bar. |
+ * @param barHeightPx The new bar height in px needed to accommodate the handle. |
+ */ |
+ public void addBarHandle(int barHeightPx) { |
+ mBarHandleResourceId = R.drawable.toolbar_handle_dark; |
+ mBarHeightPeeking = barHeightPx * mPxToDp; |
+ mBarHeightMaximized = mBarHeightPeeking; |
+ mBarHeightExpanded = mBarHeightPeeking; |
+ mHeight = mBarHeightPeeking; |
+ } |
+ |
+ /** |
+ * @return The resource id for the bar handle. |
+ */ |
+ public int getBarHandleResourceId() { |
+ return mBarHandleResourceId; |
+ } |
+ |
+ /** @return The y-offset for the bar handle in px. */ |
+ public float getBarHandleOffsetY() { |
+ if (mBarHandleOffsetY == 0.f && mBarHandleResourceId != 0) { |
+ mBarHandleOffsetY = |
+ mContext.getResources().getDimension(R.dimen.overlay_panel_bar_handle_offset_y); |
+ } |
+ return mBarHandleOffsetY; |
+ } |
+ |
+ /** @return The bottom padding for the bar in px. */ |
+ public float getBarPaddingBottom() { |
+ // When there is no bar handle, the bar contents are vertically centered. When there is a |
+ // bar handle, the contents are displayed below the handle. Bottom padding is needed so that |
+ // the contents don't appear too low in the bar when centered in the space beneath the |
+ // handle. |
+ if (mBarPaddingBottom == 0.f && mBarHandleResourceId != 0) { |
+ mBarPaddingBottom = |
+ mContext.getResources().getDimension(R.dimen.overlay_panel_bar_padding_bottom); |
+ } |
+ return mBarPaddingBottom; |
+ } |
+ |
+ // ============================================================================================ |
// Test Infrastructure |
// ============================================================================================ |