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

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

Issue 1226183002: Add RTL support to custom tabs toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@toolbar_ui_fix
Patch Set: nits Created 5 years, 5 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
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 3c6faf3308bf2353524a69d5e7c0a14fdab1b80f..dab11b1bc30d9d6b51ad986120d42a96d04161d4 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
@@ -23,6 +23,7 @@ import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
+import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@@ -59,9 +60,43 @@ import org.chromium.ui.interpolators.BakedBezierInterpolator;
*/
public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
View.OnLongClickListener {
+
+ /**
+ * A custom FrameLayout specifically designed to hold page info security icon, a title bar and a
+ * url bar. Unlike other layouts in chrome, this layout does not respect RTL, which means it
+ * will always layout the security icon to the left of the url bar.
+ */
+ public static class UrlInfoLayout extends FrameLayout {
Yusuf 2015/07/09 00:22:19 I think we can make do without the customized layo
Ian Wen 2015/07/09 01:19:32 Oh yeah. Removed.
+ private View mSecurityButton;
+ private View mTitleUrlContainer;
+
+ /**
+ * Constructor for xml inflation.
+ */
+ public UrlInfoLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mSecurityButton = findViewById(R.id.security_button);
+ mTitleUrlContainer = findViewById(R.id.title_url_container);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Yusuf 2015/07/09 00:22:19 why not have the same in onMeasure for toolbar lay
Ian Wen 2015/07/09 01:19:32 Done.
+ LayoutParams lp = (LayoutParams) mTitleUrlContainer.getLayoutParams();
+ lp.leftMargin = mSecurityButton.getMeasuredWidth();
+ mTitleUrlContainer.setLayoutParams(lp);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
private static final int CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS = 200;
private static final int CUSTOM_TAB_TOOLBAR_FADE_DURATION_MS = 150;
private View mUrlInfoContainer;
Yusuf 2015/07/09 00:22:19 let's use a new name for this since these became r
Ian Wen 2015/07/09 01:19:32 Done.
+ private View mTitleUrlContainer;
private UrlBar mUrlBar;
private TextView mTitleBar;
private ImageView mSecurityButton;
@@ -91,6 +126,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
mUrlBar.setAllowFocus(false);
mTitleBar = (TextView) findViewById(R.id.title_bar);
mUrlInfoContainer = findViewById(R.id.url_info_container);
+ mTitleUrlContainer = findViewById(R.id.title_url_container);
mSecurityButton = (ImageButton) findViewById(R.id.security_button);
mSecurityIconType = ConnectionSecurityLevel.NONE;
mCustomActionButton = (ImageButton) findViewById(R.id.action_button);
@@ -105,7 +141,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
int securityIconButtonWidth =
getResources().getDimensionPixelSize(R.dimen.location_bar_icon_width);
Animator urlInfoContainerTranslateAnimator =
- ObjectAnimator.ofFloat(mUrlInfoContainer, TRANSLATION_X, securityIconButtonWidth);
+ ObjectAnimator.ofFloat(mTitleUrlContainer, TRANSLATION_X, securityIconButtonWidth);
urlInfoContainerTranslateAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
urlInfoContainerTranslateAnimator.setDuration(CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS);
@@ -116,7 +152,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
@Override
public void onAnimationStart(Animator animation) {
mSecurityButton.setVisibility(VISIBLE);
- mUrlInfoContainer.setTranslationX(0);
+ mTitleUrlContainer.setTranslationX(0);
}
});

Powered by Google App Engine
This is Rietveld 408576698