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

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

Issue 1329793002: [Custom Tabs]Introduce the url scaling animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 3 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 | chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbarAnimationDelegate.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cbf639e3c542072cd6bdd422e4932b9e7e6770aa..17505bbf3926cda814e7c42a57b5c2842df4d182 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
@@ -15,7 +15,6 @@ import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Pair;
-import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
@@ -60,6 +59,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
private ImageView mSecurityButton;
private ImageButton mCustomActionButton;
private int mSecurityIconType;
+ private boolean mShouldShowTitle;
private boolean mUseDarkColors;
private ImageButton mCloseButton;
@@ -88,9 +88,9 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
mSecurityButton = (ImageButton) findViewById(R.id.security_button);
mSecurityIconType = ConnectionSecurityLevel.NONE;
mCustomActionButton = (ImageButton) findViewById(R.id.action_button);
+ mCustomActionButton.setOnLongClickListener(this);
mCloseButton = (ImageButton) findViewById(R.id.close_button);
mCloseButton.setOnLongClickListener(this);
- mCustomActionButton.setOnLongClickListener(this);
mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer);
}
@@ -186,11 +186,8 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
@Override
public void setShowTitle(boolean showTitle) {
- int titleVisibility = showTitle ? VISIBLE : GONE;
- int urlTextSizeId = showTitle
- ? R.dimen.custom_tabs_url_text_size : R.dimen.location_bar_url_text_size;
- mTitleBar.setVisibility(titleVisibility);
- mUrlBar.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(urlTextSizeId));
+ mShouldShowTitle = showTitle;
+ if (mShouldShowTitle) mAnimDelegate.prepareTitleAnim(mUrlBar, mTitleBar);
}
@Override
@@ -200,6 +197,13 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
mTitleBar.setText("");
return;
}
+
+ // It takes some time to parse the title of the webcontent, and before that Tab#getTitle
+ // always return the url. We postpone the title animation until the title is authentic.
+ if (mShouldShowTitle && !TextUtils.equals(currentTab.getTitle(), currentTab.getUrl())) {
+ mAnimDelegate.startTitleAnimation(getContext());
+ }
+
mTitleBar.setText(currentTab.getTitle());
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbarAnimationDelegate.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698