| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
| 6 | 6 |
| 7 import android.animation.Animator; | 7 import android.animation.Animator; |
| 8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
| 9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
| 10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 private static final int URL_CLEAR_FOCUS_MENU_DELAY_MS = 250; | 88 private static final int URL_CLEAR_FOCUS_MENU_DELAY_MS = 250; |
| 89 | 89 |
| 90 private static final int TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS = 200
; | 90 private static final int TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS = 200
; |
| 91 private static final int TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS
= 200; | 91 private static final int TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS
= 200; |
| 92 private static final int TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS =
100; | 92 private static final int TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS =
100; |
| 93 private static final int TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION_MS =
100; | 93 private static final int TAB_SWITCHER_MODE_POST_EXIT_ANIMATION_DURATION_MS =
100; |
| 94 | 94 |
| 95 private static final float UNINITIALIZED_PERCENT = -1f; | 95 private static final float UNINITIALIZED_PERCENT = -1f; |
| 96 | 96 |
| 97 /** States that the toolbar can be in regarding the tab switcher. */ | 97 /** States that the toolbar can be in regarding the tab switcher. */ |
| 98 private static final int STATIC_TAB = 0; | 98 protected static final int STATIC_TAB = 0; |
| 99 private static final int TAB_SWITCHER = 1; | 99 protected static final int TAB_SWITCHER = 1; |
| 100 private static final int ENTERING_TAB_SWITCHER = 2; | 100 protected static final int ENTERING_TAB_SWITCHER = 2; |
| 101 private static final int EXITING_TAB_SWITCHER = 3; | 101 protected static final int EXITING_TAB_SWITCHER = 3; |
| 102 | 102 |
| 103 @ViewDebug.ExportedProperty(category = "chrome", mapping = { | 103 @ViewDebug.ExportedProperty(category = "chrome", mapping = { |
| 104 @ViewDebug.IntToString(from = STATIC_TAB, to = "STATIC_TAB"), | 104 @ViewDebug.IntToString(from = STATIC_TAB, to = "STATIC_TAB"), |
| 105 @ViewDebug.IntToString(from = TAB_SWITCHER, to = "TAB_SWITCHER"), | 105 @ViewDebug.IntToString(from = TAB_SWITCHER, to = "TAB_SWITCHER"), |
| 106 @ViewDebug.IntToString(from = ENTERING_TAB_SWITCHER, to = "ENTERING_
TAB_SWITCHER"), | 106 @ViewDebug.IntToString(from = ENTERING_TAB_SWITCHER, to = "ENTERING_
TAB_SWITCHER"), |
| 107 @ViewDebug.IntToString(from = EXITING_TAB_SWITCHER, to = "EXITING_TA
B_SWITCHER") | 107 @ViewDebug.IntToString(from = EXITING_TAB_SWITCHER, to = "EXITING_TA
B_SWITCHER") |
| 108 }) | 108 }) |
| 109 | 109 |
| 110 static final int LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA = 51; | 110 static final int LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA = 51; |
| 111 | 111 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 private ImageView mToolbarShadow; | 123 private ImageView mToolbarShadow; |
| 124 | 124 |
| 125 private final int mProgressBackBackgroundColorWhite; | 125 private final int mProgressBackBackgroundColorWhite; |
| 126 | 126 |
| 127 private ObjectAnimator mTabSwitcherModeAnimation; | 127 private ObjectAnimator mTabSwitcherModeAnimation; |
| 128 private ObjectAnimator mDelayedTabSwitcherModeAnimation; | 128 private ObjectAnimator mDelayedTabSwitcherModeAnimation; |
| 129 | 129 |
| 130 private final List<View> mTabSwitcherModeViews = new ArrayList<>(); | 130 private final List<View> mTabSwitcherModeViews = new ArrayList<>(); |
| 131 private final Set<View> mBrowsingModeViews = new HashSet<>(); | 131 private final Set<View> mBrowsingModeViews = new HashSet<>(); |
| 132 @ViewDebug.ExportedProperty(category = "chrome") | 132 @ViewDebug.ExportedProperty(category = "chrome") |
| 133 private int mTabSwitcherState; | 133 protected int mTabSwitcherState; |
| 134 | 134 |
| 135 // This determines whether or not the toolbar draws as expected (false) or w
hether it always | 135 // This determines whether or not the toolbar draws as expected (false) or w
hether it always |
| 136 // draws as if it's showing the non-tabswitcher, non-animating toolbar. This
is used in grabbing | 136 // draws as if it's showing the non-tabswitcher, non-animating toolbar. This
is used in grabbing |
| 137 // a bitmap to use as a texture representation of this view. | 137 // a bitmap to use as a texture representation of this view. |
| 138 @ViewDebug.ExportedProperty(category = "chrome") | 138 @ViewDebug.ExportedProperty(category = "chrome") |
| 139 private boolean mTextureCaptureMode; | 139 private boolean mTextureCaptureMode; |
| 140 private boolean mForceTextureCapture; | 140 private boolean mForceTextureCapture; |
| 141 private boolean mUseLightDrawablesForTextureCapture; | 141 private boolean mUseLightDrawablesForTextureCapture; |
| 142 private boolean mLightDrawablesUsedForLastTextureCapture; | 142 private boolean mLightDrawablesUsedForLastTextureCapture; |
| 143 | 143 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 172 @ViewDebug.ExportedProperty(category = "chrome") | 172 @ViewDebug.ExportedProperty(category = "chrome") |
| 173 private float mUrlFocusChangePercent; | 173 private float mUrlFocusChangePercent; |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * The degree to which the omnibox has expanded to full width, either becaus
e it is getting | 176 * The degree to which the omnibox has expanded to full width, either becaus
e it is getting |
| 177 * focused or the NTP search box is being scrolled up. Note that in the latt
er case, the actual | 177 * focused or the NTP search box is being scrolled up. Note that in the latt
er case, the actual |
| 178 * width of the omnibox is not interpolated linearly from this value. The va
lue will be the | 178 * width of the omnibox is not interpolated linearly from this value. The va
lue will be the |
| 179 * maximum of {@link #mUrlFocusChangePercent} and {@link #mNtpSearchBoxScrol
lPercent}. | 179 * maximum of {@link #mUrlFocusChangePercent} and {@link #mNtpSearchBoxScrol
lPercent}. |
| 180 */ | 180 */ |
| 181 @ViewDebug.ExportedProperty(category = "chrome") | 181 @ViewDebug.ExportedProperty(category = "chrome") |
| 182 private float mUrlExpansionPercent; | 182 protected float mUrlExpansionPercent; |
| 183 private AnimatorSet mUrlFocusLayoutAnimator; | 183 private AnimatorSet mUrlFocusLayoutAnimator; |
| 184 private boolean mDisableLocationBarRelayout; | 184 private boolean mDisableLocationBarRelayout; |
| 185 private boolean mLayoutLocationBarInFocusedMode; | 185 private boolean mLayoutLocationBarInFocusedMode; |
| 186 private int mUnfocusedLocationBarLayoutWidth; | 186 private int mUnfocusedLocationBarLayoutWidth; |
| 187 private int mUnfocusedLocationBarLayoutLeft; | 187 private int mUnfocusedLocationBarLayoutLeft; |
| 188 private boolean mUnfocusedLocationBarUsesTransparentBg; | 188 private boolean mUnfocusedLocationBarUsesTransparentBg; |
| 189 | 189 |
| 190 private int mLocationBarBackgroundAlpha = 255; | 190 private int mLocationBarBackgroundAlpha = 255; |
| 191 private float mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; | 191 private float mNtpSearchBoxScrollPercent = UNINITIALIZED_PERCENT; |
| 192 private ColorDrawable mToolbarBackground; | 192 private ColorDrawable mToolbarBackground; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 /** Manages when the Toolbar hides and unhides. */ | 242 /** Manages when the Toolbar hides and unhides. */ |
| 243 private BrowserStateBrowserControlsVisibilityDelegate mControlsVisibilityDel
egate; | 243 private BrowserStateBrowserControlsVisibilityDelegate mControlsVisibilityDel
egate; |
| 244 | 244 |
| 245 /** Token held when the TabSwitcherCallout is displayed to prevent the Toolb
ar from hiding. */ | 245 /** Token held when the TabSwitcherCallout is displayed to prevent the Toolb
ar from hiding. */ |
| 246 private int mFullscreenCalloutToken = FullscreenManager.INVALID_TOKEN; | 246 private int mFullscreenCalloutToken = FullscreenManager.INVALID_TOKEN; |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * Used to specify the visual state of the toolbar. | 249 * Used to specify the visual state of the toolbar. |
| 250 */ | 250 */ |
| 251 private enum VisualState { | 251 protected enum VisualState { |
| 252 TAB_SWITCHER_INCOGNITO, | 252 TAB_SWITCHER_INCOGNITO, |
| 253 TAB_SWITCHER_NORMAL, | 253 TAB_SWITCHER_NORMAL, |
| 254 NORMAL, | 254 NORMAL, |
| 255 INCOGNITO, | 255 INCOGNITO, |
| 256 BRAND_COLOR, | 256 BRAND_COLOR, |
| 257 NEW_TAB_NORMAL | 257 NEW_TAB_NORMAL |
| 258 } | 258 } |
| 259 | 259 |
| 260 private VisualState mVisualState = VisualState.NORMAL; | 260 private VisualState mVisualState = VisualState.NORMAL; |
| 261 private VisualState mOverlayDrawablesVisualState; | 261 private VisualState mOverlayDrawablesVisualState; |
| 262 private boolean mUseLightToolbarDrawables; | 262 protected boolean mUseLightToolbarDrawables; |
| 263 | 263 |
| 264 private NewTabPage mVisibleNewTabPage; | 264 private NewTabPage mVisibleNewTabPage; |
| 265 private float mPreTextureCaptureAlpha = 1f; | 265 private float mPreTextureCaptureAlpha = 1f; |
| 266 private boolean mIsOverlayTabStackDrawableLight; | 266 private boolean mIsOverlayTabStackDrawableLight; |
| 267 | 267 |
| 268 // The following are some properties used during animation. We use explicit
property classes | 268 // The following are some properties used during animation. We use explicit
property classes |
| 269 // to avoid the cost of reflection for each animation setup. | 269 // to avoid the cost of reflection for each animation setup. |
| 270 | 270 |
| 271 private final Property<ToolbarPhone, Float> mUrlFocusChangePercentProperty = | 271 private final Property<ToolbarPhone, Float> mUrlFocusChangePercentProperty = |
| 272 new Property<ToolbarPhone, Float>(Float.class, "") { | 272 new Property<ToolbarPhone, Float>(Float.class, "") { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 @Override | 731 @Override |
| 732 public void onNtpScrollChanged(float scrollPercentage) { | 732 public void onNtpScrollChanged(float scrollPercentage) { |
| 733 mNtpSearchBoxScrollPercent = scrollPercentage; | 733 mNtpSearchBoxScrollPercent = scrollPercentage; |
| 734 updateUrlExpansionPercent(); | 734 updateUrlExpansionPercent(); |
| 735 updateUrlExpansionAnimation(); | 735 updateUrlExpansionAnimation(); |
| 736 } | 736 } |
| 737 | 737 |
| 738 /** | 738 /** |
| 739 * Calculate the bounds for the location bar background and set them to {@co
de out}. | 739 * Calculate the bounds for the location bar background and set them to {@co
de out}. |
| 740 */ | 740 */ |
| 741 private void updateLocationBarBackgroundBounds(Rect out, VisualState visualS
tate) { | 741 protected void updateLocationBarBackgroundBounds(Rect out, VisualState visua
lState) { |
| 742 // Calculate the visible boundaries of the left and right most child vie
ws of the | 742 // Calculate the visible boundaries of the left and right most child vie
ws of the |
| 743 // location bar. | 743 // location bar. |
| 744 float expansion = visualState == VisualState.NEW_TAB_NORMAL ? 1 : mUrlEx
pansionPercent; | 744 float expansion = visualState == VisualState.NEW_TAB_NORMAL ? 1 : mUrlEx
pansionPercent; |
| 745 int leftViewPosition = (int) MathUtils.interpolate( | 745 int leftViewPosition = (int) MathUtils.interpolate( |
| 746 getViewBoundsLeftOfLocationBar(visualState), | 746 getViewBoundsLeftOfLocationBar(visualState), |
| 747 -mLocationBarBackgroundCornerRadius, | 747 -mLocationBarBackgroundCornerRadius, |
| 748 expansion); | 748 expansion); |
| 749 int rightViewPosition = (int) MathUtils.interpolate( | 749 int rightViewPosition = (int) MathUtils.interpolate( |
| 750 getViewBoundsRightOfLocationBar(visualState), | 750 getViewBoundsRightOfLocationBar(visualState), |
| 751 getWidth() + mLocationBarBackgroundCornerRadius, | 751 getWidth() + mLocationBarBackgroundCornerRadius, |
| (...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 | 2015 |
| 2016 private VisualState computeVisualState(boolean isInTabSwitcherMode) { | 2016 private VisualState computeVisualState(boolean isInTabSwitcherMode) { |
| 2017 if (isInTabSwitcherMode && isIncognito()) return VisualState.TAB_SWITCHE
R_INCOGNITO; | 2017 if (isInTabSwitcherMode && isIncognito()) return VisualState.TAB_SWITCHE
R_INCOGNITO; |
| 2018 if (isInTabSwitcherMode && !isIncognito()) return VisualState.TAB_SWITCH
ER_NORMAL; | 2018 if (isInTabSwitcherMode && !isIncognito()) return VisualState.TAB_SWITCH
ER_NORMAL; |
| 2019 if (isLocationBarShownInNTP()) return VisualState.NEW_TAB_NORMAL; | 2019 if (isLocationBarShownInNTP()) return VisualState.NEW_TAB_NORMAL; |
| 2020 if (isIncognito()) return VisualState.INCOGNITO; | 2020 if (isIncognito()) return VisualState.INCOGNITO; |
| 2021 if (getToolbarDataProvider().isUsingBrandColor()) return VisualState.BRA
ND_COLOR; | 2021 if (getToolbarDataProvider().isUsingBrandColor()) return VisualState.BRA
ND_COLOR; |
| 2022 return VisualState.NORMAL; | 2022 return VisualState.NORMAL; |
| 2023 } | 2023 } |
| 2024 | 2024 |
| 2025 private void updateVisualsForToolbarState() { | 2025 protected void updateVisualsForToolbarState() { |
| 2026 final boolean isIncognito = isIncognito(); | 2026 final boolean isIncognito = isIncognito(); |
| 2027 | 2027 |
| 2028 // These are important for setting visual state while the entering or le
aving the tab | 2028 // These are important for setting visual state while the entering or le
aving the tab |
| 2029 // switcher. | 2029 // switcher. |
| 2030 boolean inOrEnteringStaticTab = mTabSwitcherState == STATIC_TAB | 2030 boolean inOrEnteringStaticTab = mTabSwitcherState == STATIC_TAB |
| 2031 || mTabSwitcherState == EXITING_TAB_SWITCHER; | 2031 || mTabSwitcherState == EXITING_TAB_SWITCHER; |
| 2032 boolean inOrEnteringTabSwitcher = !inOrEnteringStaticTab; | 2032 boolean inOrEnteringTabSwitcher = !inOrEnteringStaticTab; |
| 2033 | 2033 |
| 2034 VisualState newVisualState = computeVisualState(inOrEnteringTabSwitcher)
; | 2034 VisualState newVisualState = computeVisualState(inOrEnteringTabSwitcher)
; |
| 2035 | 2035 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 }); | 2260 }); |
| 2261 | 2261 |
| 2262 if (mControlsVisibilityDelegate != null) { | 2262 if (mControlsVisibilityDelegate != null) { |
| 2263 mFullscreenCalloutToken = | 2263 mFullscreenCalloutToken = |
| 2264 mControlsVisibilityDelegate.showControlsPersistentAndClearOl
dToken( | 2264 mControlsVisibilityDelegate.showControlsPersistentAndClearOl
dToken( |
| 2265 mFullscreenCalloutToken); | 2265 mFullscreenCalloutToken); |
| 2266 } | 2266 } |
| 2267 } | 2267 } |
| 2268 } | 2268 } |
| 2269 | 2269 |
| OLD | NEW |