Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b39eb2b

Browse files
committed
Bug 858687/862755/860308 - Major simplification of browser toolbar layout (r=mfinkle)
1 parent 26467c4 commit b39eb2b

14 files changed

Lines changed: 392 additions & 798 deletions

mobile/android/base/BrowserApp.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public void onCreate(Bundle savedInstanceState) {
342342

343343
super.onCreate(savedInstanceState);
344344

345-
LinearLayout actionBar = (LinearLayout) getActionBarLayout();
345+
RelativeLayout actionBar = (RelativeLayout) getActionBarLayout();
346346
mMainLayout.addView(actionBar, 2);
347347

348348
((GeckoApp.MainLayout) mMainLayout).setTouchEventInterceptor(new HideTabsTouchListener());
@@ -683,16 +683,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
683683
}
684684

685685
public View getActionBarLayout() {
686-
int actionBarRes;
687-
688-
if (!HardwareUtils.hasMenuButton() || HardwareUtils.isTablet())
689-
actionBarRes = R.layout.browser_toolbar_menu;
690-
else
691-
actionBarRes = R.layout.browser_toolbar;
692-
693-
LinearLayout actionBar = (LinearLayout) LayoutInflater.from(this).inflate(actionBarRes, null);
694-
actionBar.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
695-
(int) getResources().getDimension(R.dimen.browser_toolbar_height)));
686+
RelativeLayout actionBar = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.browser_toolbar_menu, null);
687+
actionBar.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
688+
(int) getResources().getDimension(R.dimen.browser_toolbar_height)));
696689
return actionBar;
697690
}
698691

mobile/android/base/BrowserToolbar.java

Lines changed: 73 additions & 183 deletions
Large diffs are not rendered by default.

mobile/android/base/BrowserToolbarBackground.java

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,72 +14,14 @@
1414
import android.graphics.drawable.StateListDrawable;
1515
import android.util.AttributeSet;
1616

17-
public class BrowserToolbarBackground extends GeckoLinearLayout
18-
implements CanvasDelegate.DrawManager {
17+
public class BrowserToolbarBackground extends GeckoLinearLayout {
1918
private GeckoActivity mActivity;
20-
private Path mPath;
21-
private CurveTowards mSide;
22-
private CanvasDelegate mCanvasDelegate;
23-
24-
public enum CurveTowards { NONE, LEFT, RIGHT };
2519

2620
public BrowserToolbarBackground(Context context, AttributeSet attrs) {
2721
super(context, attrs);
28-
29-
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
30-
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x02);
31-
a.recycle();
32-
33-
if (curveTowards == 0x00)
34-
mSide = CurveTowards.NONE;
35-
else if (curveTowards == 0x01)
36-
mSide = CurveTowards.LEFT;
37-
else
38-
mSide = CurveTowards.RIGHT;
39-
40-
// Path is clipped.
41-
mPath = new Path();
42-
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
4322
mActivity = (GeckoActivity) context;
4423
}
4524

46-
@Override
47-
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
48-
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
49-
50-
int width = getMeasuredWidth();
51-
int height = getMeasuredHeight();
52-
int curve = (int) (height * 1.125f);
53-
54-
mPath.reset();
55-
56-
if (mSide == CurveTowards.LEFT) {
57-
mPath.moveTo(0, height);
58-
mPath.cubicTo(curve * 0.75f, height,
59-
curve * 0.25f, 0,
60-
curve, 0);
61-
mPath.lineTo(0, 0);
62-
mPath.lineTo(0, height);
63-
} else if (mSide == CurveTowards.RIGHT) {
64-
mPath.moveTo(width, height);
65-
mPath.cubicTo((width - (curve * 0.75f)), height,
66-
(width - (curve * 0.25f)), 0,
67-
(width - curve), 0);
68-
mPath.lineTo(width, 0);
69-
mPath.lineTo(width, height);
70-
}
71-
}
72-
73-
@Override
74-
public void draw(Canvas canvas) {
75-
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
76-
}
77-
78-
@Override
79-
public void defaultDraw(Canvas canvas) {
80-
super.draw(canvas);
81-
}
82-
8325
@Override
8426
public void onLightweightThemeChanged() {
8527
Drawable drawable = mActivity.getLightweightTheme().getDrawable(this);
@@ -90,35 +32,11 @@ public void onLightweightThemeChanged() {
9032
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(mActivity.getResources().getColor(R.color.background_private)));
9133
stateList.addState(new int[] {}, drawable);
9234

93-
int[] padding = new int[] { getPaddingLeft(),
94-
getPaddingTop(),
95-
getPaddingRight(),
96-
getPaddingBottom()
97-
};
9835
setBackgroundDrawable(stateList);
99-
setPadding(padding[0], padding[1], padding[2], padding[3]);
10036
}
10137

10238
@Override
10339
public void onLightweightThemeReset() {
104-
int[] padding = new int[] { getPaddingLeft(),
105-
getPaddingTop(),
106-
getPaddingRight(),
107-
getPaddingBottom()
108-
};
10940
setBackgroundResource(R.drawable.address_bar_bg);
110-
setPadding(padding[0], padding[1], padding[2], padding[3]);
111-
}
112-
113-
public CurveTowards getCurveTowards() {
114-
return mSide;
115-
}
116-
117-
public void setCurveTowards(CurveTowards side) {
118-
if (side == mSide)
119-
return;
120-
121-
mSide = side;
122-
requestLayout();
12341
}
12442
}

mobile/android/base/BrowserToolbarLayout.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import android.content.Context;
99
import android.util.AttributeSet;
1010
import android.view.MotionEvent;
11-
import android.widget.LinearLayout;
11+
import android.widget.RelativeLayout;
1212

13-
public class BrowserToolbarLayout extends LinearLayout {
13+
public class BrowserToolbarLayout extends GeckoRelativeLayout {
1414
private static final String LOGTAG = "GeckoToolbarLayout";
1515

1616
public BrowserToolbarLayout(Context context, AttributeSet attrs) {

mobile/android/base/GeckoViewsFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ private GeckoViewsFactory() {
5656
mFactoryMap.put("AwesomeBarTabs$BackgroundLayout", AwesomeBarTabs.BackgroundLayout.class.getConstructor(arg1Class, arg2Class));
5757
mFactoryMap.put("BackButton", BackButton.class.getConstructor(arg1Class, arg2Class));
5858
mFactoryMap.put("BrowserToolbarBackground", BrowserToolbarBackground.class.getConstructor(arg1Class, arg2Class));
59-
mFactoryMap.put("BrowserToolbar$RightEdge", BrowserToolbar.RightEdge.class.getConstructor(arg1Class, arg2Class));
6059
mFactoryMap.put("CheckableLinearLayout", CheckableLinearLayout.class.getConstructor(arg1Class, arg2Class));
6160
mFactoryMap.put("FormAssistPopup", FormAssistPopup.class.getConstructor(arg1Class, arg2Class));
6261
mFactoryMap.put("ForwardButton", ForwardButton.class.getConstructor(arg1Class, arg2Class));

mobile/android/base/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ RES_LAYOUT = \
401401
res/layout/awesomebar_tab_indicator.xml \
402402
res/layout/awesomebar_tabs.xml \
403403
res/layout/bookmark_edit.xml \
404-
res/layout/browser_toolbar.xml \
405404
res/layout/browser_toolbar_menu.xml \
406405
res/layout/datetime_picker.xml \
407406
res/layout/doorhangerpopup.xml \
@@ -1000,6 +999,7 @@ MOZ_ANDROID_DRAWABLES += \
1000999
mobile/android/base/resources/drawable/address_bar_bg.xml \
10011000
mobile/android/base/resources/drawable/address_bar_bg_shadow_repeat.xml \
10021001
mobile/android/base/resources/drawable/address_bar_nav_button.xml \
1002+
mobile/android/base/resources/drawable/address_bar_right_edge.xml \
10031003
mobile/android/base/resources/drawable/address_bar_url.xml \
10041004
mobile/android/base/resources/drawable/awesomebar_header_row.xml \
10051005
mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml \
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- This Source Code Form is subject to the terms of the Mozilla Public
3+
- License, v. 2.0. If a copy of the MPL was not distributed with this
4+
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
5+
6+
<clip xmlns:android="http://schemas.android.com/apk/res/android"
7+
android:drawable="@drawable/address_bar_url"
8+
android:clipOrientation="horizontal"
9+
android:gravity="right"/>

0 commit comments

Comments
 (0)