Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1633)

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java

Issue 1155053003: Do not trigger primary color changes on non-supported toolbar states. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Offline comments and further clean up Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
index f42e830aa23b2ca731f1f51327024163d642adc1..55a0124ee5d588e9d4d28652b321a9518ba11e29 100644
--- a/chrome/android/java_staging/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java
@@ -1614,13 +1614,20 @@ public class ToolbarPhone extends ToolbarLayout
updateVisualsForToolbarState(mInTabSwitcherMode);
}
+ private static boolean isVisualStateValidForBrandColorTransition(VisualState state) {
+ return state == VisualState.NORMAL || state == VisualState.BRAND_COLOR;
+ }
+
@Override
protected void onPrimaryColorChanged() {
super.onPrimaryColorChanged();
if (mBrandColorTransitionActive) mBrandColorTransitionAnimation.cancel();
+ if (!isVisualStateValidForBrandColorTransition(mVisualState)) {
+ return;
+ }
final int initialColor = mToolbarBackground.getColor();
final int finalColor = getToolbarDataProvider().getPrimaryColor();
- if (mInTabSwitcherMode || initialColor == finalColor) return;
+ if (initialColor == finalColor) return;
boolean shouldUseOpaque = BrandColorUtils.shouldUseOpaqueTextboxBackground(finalColor);
final int initialAlpha = mUrlBackgroundAlpha;
final int finalAlpha =
@@ -1737,11 +1744,25 @@ public class ToolbarPhone extends ToolbarLayout
}
private void updateVisualsForToolbarState(boolean isInTabSwitcherMode) {
- if (mBrandColorTransitionActive) return;
final boolean isIncognito = isIncognito();
- VisualState visualState = computeVisualState(isInTabSwitcherMode);
- boolean visualStateChanged = mVisualState != visualState;
+ VisualState newVisualState = computeVisualState(isInTabSwitcherMode);
+
+ // If we are navigating to or from a brand color, allow the transition animation
+ // to run to completion as it will handle the triggering this path again and committing
+ // the proper visual state when it finishes. Brand color transitions are only valid
+ // between normal non-incognito pages and brand color pages, so if the visual states
+ // do not match then cancel the animation below.
+ if (mBrandColorTransitionActive
+ && isVisualStateValidForBrandColorTransition(mVisualState)
+ && isVisualStateValidForBrandColorTransition(newVisualState)) {
+ return;
+ } else if (mBrandColorTransitionAnimation != null
+ && mBrandColorTransitionAnimation.isRunning()) {
+ mBrandColorTransitionAnimation.cancel();
+ }
+
+ boolean visualStateChanged = mVisualState != newVisualState;
int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
if (mVisualState == VisualState.BRAND_COLOR && !visualStateChanged) {
@@ -1758,7 +1779,7 @@ public class ToolbarPhone extends ToolbarLayout
}
}
- mVisualState = visualState;
+ mVisualState = newVisualState;
updateOverlayDrawables();
updateShadowVisibility(isInTabSwitcherMode);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698