Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
| index f28b82e0f5b6dc0319c9a920b58d0a2f2a557dac..594f2ff96959b5883382cd1b862cc2abf1f03302 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
| @@ -6,6 +6,7 @@ package org.chromium.chrome.browser.compositor.bottombar.contextualsearch; |
| import android.content.Context; |
| import android.os.Handler; |
| +import android.support.v4.view.ViewCompat; |
| import android.view.LayoutInflater; |
| import android.view.View; |
| import android.view.ViewGroup; |
| @@ -18,6 +19,7 @@ import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context |
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial; |
| import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
| import org.chromium.chrome.browser.preferences.privacy.ContextualSearchPreferenceFragment; |
| +import org.chromium.chrome.browser.util.FeatureUtilities; |
| import org.chromium.chrome.browser.util.MathUtils; |
| import org.chromium.ui.resources.dynamics.DynamicResourceLoader; |
| @@ -124,6 +126,26 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| private static final float ARROW_ICON_ROTATION_EXPANDED = -270.f; |
| /** |
| + * The opacity of the close icon when the Panel is peeking. |
| + */ |
| + private static final float CLOSE_ICON_OPACITY_PEEKED = 0.f; |
| + |
| + /** |
| + * The opacity of the close icon when the Panel is expanded. |
| + */ |
| + private static final float CLOSE_ICON_OPACITY_EXPANDED = 0.f; |
| + |
| + /** |
| + * The opacity of the close icon when the Panel is maximized. |
| + */ |
| + private static final float CLOSE_ICON_OPACITY_MAXIMIZED = 1.f; |
| + |
| + /** |
| + * The id of the close icon drawable. |
| + */ |
| + public static final int CLOSE_ICON_DRAWABLE_ID = R.drawable.btn_close; |
| + |
| + /** |
| * The height of the Progress Bar in dps. |
| */ |
| private static final float PROGRESS_BAR_HEIGHT_DP = 2.f; |
| @@ -435,6 +457,9 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| private float mArrowIconOpacity; |
| private float mArrowIconRotation; |
| + private float mCloseIconOpacity; |
| + private float mCloseIconWidth; |
| + |
| /** |
| * @return The top margin of the Contextual Search Bar. |
| */ |
| @@ -457,6 +482,13 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| } |
| /** |
| + * @return The height of the Contextual Search Bar. |
| + */ |
| + public float getSearchBarWidth() { |
|
pedro (no code reviews)
2015/07/08 00:43:47
We don't need this new method. Instead, we can sim
Theresa
2015/07/08 16:03:58
Done.
|
| + return mLayoutWidth; |
| + } |
| + |
| + /** |
| * @return The opacity of the Contextual Search Bar text. |
| */ |
| public float getSearchBarTextOpacity() { |
| @@ -533,6 +565,52 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| return mArrowIconRotation; |
| } |
| + /** |
| + * @return Whether the close icon is visible. |
| + */ |
| + public boolean isCloseIconVisible() { |
| + // TODO(twellington): replace this call with call to new feature helper |
| + // (isCloseButtonAvailable). |
| + return FeatureUtilities.getCustomTabVisible(); |
|
pedro (no code reviews)
2015/07/08 00:43:47
Yes!
Theresa
2015/07/08 21:04:59
Done.
|
| + } |
| + |
| + /** |
| + * @return The opacity of the close icon. |
| + */ |
| + public float getCloseIconOpacity() { |
| + return mCloseIconOpacity; |
| + } |
| + |
| + /** |
| + * @return The width of the close icon. |
| + */ |
| + @SuppressWarnings("deprecation") |
|
pedro (no code reviews)
2015/07/08 00:43:47
Why is there a @SuppressWarnings here?
Theresa
2015/07/08 16:03:58
getDrawable(int id) was deprecated in API level 22
|
| + public float getCloseIconWidth() { |
|
pedro (no code reviews)
2015/07/08 00:43:47
This should probably called getCloseIconDimension(
Theresa
2015/07/08 16:03:58
Done.
|
| + if (mCloseIconWidth == 0) { |
| + mCloseIconWidth = mContext.getResources().getDrawable( |
| + CLOSE_ICON_DRAWABLE_ID).getIntrinsicWidth() * mPxToDp; |
| + } |
| + return mCloseIconWidth; |
| + } |
| + |
| + /** |
| + * @return The Y coordinate of the close icon. |
| + */ |
| + public float getCloseIconY() { |
| + return (getSearchBarHeight() - getCloseIconWidth()) / 2; |
| + } |
| + |
| + /** |
| + * @return The X coordinate of the close icon. |
| + */ |
| + public float getCloseIconX() { |
| + if (ViewCompat.getLayoutDirection(mContainerView) == View.LAYOUT_DIRECTION_RTL) { |
|
pedro (no code reviews)
2015/07/08 00:43:47
Newton or Aurimas might know better, but I think w
Theresa
2015/07/08 16:03:58
Done.
|
| + return getSearchBarMarginSide(); |
| + } else { |
| + return getSearchBarWidth() - getSearchBarMarginSide() - getCloseIconWidth(); |
| + } |
| + } |
| + |
| // -------------------------------------------------------------------------------------------- |
| // Base Page states |
| // -------------------------------------------------------------------------------------------- |
| @@ -912,6 +990,9 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| mArrowIconOpacity = ARROW_ICON_OPACITY_PEEKED; |
| mArrowIconRotation = ARROW_ICON_ROTATION_PEEKED; |
| + // Close icon opacity. |
| + mCloseIconOpacity = CLOSE_ICON_OPACITY_PEEKED; |
| + |
| // Progress Bar. |
| mProgressBarOpacity = 0.f; |
| @@ -970,6 +1051,9 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| ARROW_ICON_ROTATION_EXPANDED, |
| percentage)); |
| + // Close icon opacity. |
| + mCloseIconOpacity = CLOSE_ICON_OPACITY_EXPANDED; |
| + |
| // Progress Bar. |
| float peekedHeight = getPanelHeightFromState(PanelState.PEEKED); |
| float threshold = PROGRESS_BAR_VISIBILITY_THRESHOLD_DP / mPxToDp; |
| @@ -1039,6 +1123,15 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl |
| percentage); |
|
Theresa
2015/07/07 23:18:55
Need to make the arrow fade out all the way before
Theresa
2015/07/08 16:03:58
Done.
|
| mArrowIconRotation = ARROW_ICON_ROTATION_EXPANDED; |
| + // Close icon opacity. |
| + if (isCloseIconVisible()) { |
|
Theresa
2015/07/07 23:18:55
Change opacity regardless of visibility (since cc
Theresa
2015/07/08 00:29:16
Done.
pedro (no code reviews)
2015/07/08 00:43:47
Good point. You can remove the check here and let
|
| + float closeIconOpacity = MathUtils.interpolate( |
| + CLOSE_ICON_OPACITY_EXPANDED, |
| + CLOSE_ICON_OPACITY_MAXIMIZED, |
| + percentage); |
| + mCloseIconOpacity = closeIconOpacity; |
| + } |
| + |
| // Progress Bar. |
| mProgressBarOpacity = 1.f; |
| mProgressBarY = searchBarHeight - PROGRESS_BAR_HEIGHT_DP + 1; |