Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java |
index 0847765c889c88e6fda0ecab4c6e0caea53f64e9..bd8e5435b4987174dac2e39ca929abb175514d4d 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java |
@@ -4,10 +4,6 @@ |
package org.chromium.chrome.browser.toolbar; |
-import android.animation.Animator; |
-import android.animation.AnimatorListenerAdapter; |
-import android.animation.AnimatorSet; |
-import android.animation.ObjectAnimator; |
import android.annotation.SuppressLint; |
import android.content.Context; |
import android.content.res.ColorStateList; |
@@ -52,15 +48,12 @@ import org.chromium.chrome.browser.widget.TintedImageButton; |
import org.chromium.components.dom_distiller.core.DomDistillerService; |
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; |
import org.chromium.ui.base.WindowAndroid; |
-import org.chromium.ui.interpolators.BakedBezierInterpolator; |
/** |
* The Toolbar layout to be used for a custom tab. This is used for both phone and tablet UIs. |
*/ |
public class CustomTabToolbar extends ToolbarLayout implements LocationBar, |
View.OnLongClickListener { |
- private static final int CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS = 200; |
- private static final int CUSTOM_TAB_TOOLBAR_FADE_DURATION_MS = 150; |
private View mLocationBarFrameLayout; |
private View mTitleUrlContainer; |
private UrlBar mUrlBar; |
@@ -71,7 +64,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar, |
private boolean mUseDarkColors; |
private TintedImageButton mCloseButton; |
- private AnimatorSet mSecurityButtonShowAnimator; |
+ private CustomTabToolbarAnimationDelegate mAnimDelegate; |
private boolean mBackgroundColorSet; |
/** |
@@ -99,31 +92,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar, |
mCloseButton = (TintedImageButton) findViewById(R.id.close_button); |
mCloseButton.setOnLongClickListener(this); |
mCustomActionButton.setOnLongClickListener(this); |
- populateToolbarAnimations(); |
- } |
- |
- private void populateToolbarAnimations() { |
- mSecurityButtonShowAnimator = new AnimatorSet(); |
- int securityIconButtonWidth = |
- getResources().getDimensionPixelSize(R.dimen.location_bar_icon_width); |
- Animator titleUrlTranslateAnimator = |
- ObjectAnimator.ofFloat(mTitleUrlContainer, TRANSLATION_X, securityIconButtonWidth); |
- titleUrlTranslateAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE); |
- titleUrlTranslateAnimator.setDuration(CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS); |
- |
- Animator securityButtonAlphaAnimator = ObjectAnimator.ofFloat(mSecurityButton, ALPHA, 1); |
- securityButtonAlphaAnimator.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE); |
- securityButtonAlphaAnimator.setDuration(CUSTOM_TAB_TOOLBAR_FADE_DURATION_MS); |
- securityButtonAlphaAnimator.addListener(new AnimatorListenerAdapter() { |
- @Override |
- public void onAnimationStart(Animator animation) { |
- mSecurityButton.setVisibility(VISIBLE); |
- mTitleUrlContainer.setTranslationX(0); |
- } |
- }); |
- |
- mSecurityButtonShowAnimator.playSequentially( |
- titleUrlTranslateAnimator, securityButtonAlphaAnimator); |
+ mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer); |
} |
@Override |
@@ -362,20 +331,16 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar, |
@Override |
public void updateSecurityIcon(int securityLevel) { |
- // ImageView#setImageResource is no-op if given resource is the current one. |
- mSecurityButton.setImageResource(LocationBarLayout.getSecurityIconResource( |
- securityLevel, !shouldEmphasizeHttpsScheme())); |
- |
if (mSecurityIconType == securityLevel) return; |
mSecurityIconType = securityLevel; |
if (securityLevel == ConnectionSecurityLevel.NONE) { |
- // TODO(yusufo): Add an animator for hiding as well. |
- mSecurityButton.setVisibility(GONE); |
- } else if (mSecurityButton.getVisibility() != View.VISIBLE) { |
- if (mSecurityButtonShowAnimator.isRunning()) mSecurityButtonShowAnimator.cancel(); |
- mSecurityButtonShowAnimator.start(); |
- mUrlBar.deEmphasizeUrl(); |
+ mAnimDelegate.hideSecurityButton(); |
+ } else { |
+ // ImageView#setImageResource is no-op if given resource is the current one. |
+ mSecurityButton.setImageResource(LocationBarLayout.getSecurityIconResource( |
+ securityLevel, !shouldEmphasizeHttpsScheme())); |
+ mAnimDelegate.showSecurityButton(); |
} |
mUrlBar.emphasizeUrl(); |
mUrlBar.invalidate(); |