Bug 785246: Replace curves in menu button. [r=mfinkle]
--HG-- rename : mobile/android/base/resources/layout-land-v14/browser_toolbar.xml => mobile/android/base/resources/layout-land-v14/browser_toolbar.xml.in rename : mobile/android/base/resources/layout-land-v14/browser_toolbar_menu.xml => mobile/android/base/resources/layout-land-v14/browser_toolbar_menu.xml.in rename : mobile/android/base/resources/layout-large-v11/browser_toolbar_menu.xml => mobile/android/base/resources/layout-large-v11/browser_toolbar_menu.xml.in rename : mobile/android/base/resources/layout-xlarge-v11/browser_toolbar_menu.xml => mobile/android/base/resources/layout-xlarge-v11/browser_toolbar_menu.xml.in rename : mobile/android/base/resources/layout/browser_toolbar.xml => mobile/android/base/resources/layout/browser_toolbar.xml.in rename : mobile/android/base/resources/layout/browser_toolbar_menu.xml => mobile/android/base/resources/layout/browser_toolbar_menu.xml.in extra : rebase_source : 9dc69355643a7b0f5f4ecadb7e2d5d4ce554ea7e
@ -52,6 +52,8 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
||||
return new LinkTextView(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "FindInPageBar"))
|
||||
return new FindInPageBar(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "MenuButton"))
|
||||
return new MenuButton(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TabsButton"))
|
||||
return new TabsButton(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TabsPanel"))
|
||||
|
@ -89,6 +89,7 @@ FENNEC_JAVA_FILES = \
|
||||
InputMethods.java \
|
||||
LinkPreference.java \
|
||||
LinkTextView.java \
|
||||
MenuButton.java \
|
||||
MenuItemActionBar.java \
|
||||
MenuItemDefault.java \
|
||||
MultiChoicePreference.java \
|
||||
@ -641,8 +642,6 @@ RES_DRAWABLE_MDPI_V11 = \
|
||||
res/drawable-mdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-mdpi-v11/ic_menu_share.png \
|
||||
res/drawable-mdpi-v11/menu.png \
|
||||
res/drawable-mdpi-v11/menu_normal.png \
|
||||
res/drawable-mdpi-v11/menu_pressed.png \
|
||||
res/drawable-mdpi-v11/menu_panel_bg.9.png \
|
||||
res/drawable-mdpi-v11/menu_popup_bg.9.png \
|
||||
res/drawable-mdpi-v11/menu_popup_arrow.png \
|
||||
@ -669,8 +668,6 @@ RES_DRAWABLE_HDPI_V11 = \
|
||||
res/drawable-hdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-hdpi-v11/ic_menu_share.png \
|
||||
res/drawable-hdpi-v11/menu.png \
|
||||
res/drawable-hdpi-v11/menu_normal.png \
|
||||
res/drawable-hdpi-v11/menu_pressed.png \
|
||||
res/drawable-hdpi-v11/menu_panel_bg.9.png \
|
||||
res/drawable-hdpi-v11/menu_popup_bg.9.png \
|
||||
res/drawable-hdpi-v11/menu_popup_arrow.png \
|
||||
@ -697,8 +694,6 @@ RES_DRAWABLE_XHDPI_V11 = \
|
||||
res/drawable-xhdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_share.png \
|
||||
res/drawable-xhdpi-v11/menu.png \
|
||||
res/drawable-xhdpi-v11/menu_normal.png \
|
||||
res/drawable-xhdpi-v11/menu_pressed.png \
|
||||
res/drawable-xhdpi-v11/menu_panel_bg.9.png \
|
||||
res/drawable-xhdpi-v11/menu_popup_bg.9.png \
|
||||
res/drawable-xhdpi-v11/menu_popup_arrow.png \
|
||||
@ -727,8 +722,6 @@ RES_DRAWABLE_LAND_MDPI_V14 = \
|
||||
res/drawable-land-mdpi-v14/tabs_carat.png \
|
||||
res/drawable-land-mdpi-v14/urlbar_stop.png \
|
||||
res/drawable-land-mdpi-v14/menu.png \
|
||||
res/drawable-land-mdpi-v14/menu_normal.png \
|
||||
res/drawable-land-mdpi-v14/menu_pressed.png \
|
||||
res/drawable-land-mdpi-v14/reader.png \
|
||||
res/drawable-land-mdpi-v14/site_security_identified.png \
|
||||
res/drawable-land-mdpi-v14/site_security_verified.png \
|
||||
@ -748,8 +741,6 @@ RES_DRAWABLE_LAND_HDPI_V14 = \
|
||||
res/drawable-land-hdpi-v14/tabs_carat.png \
|
||||
res/drawable-land-hdpi-v14/urlbar_stop.png \
|
||||
res/drawable-land-hdpi-v14/menu.png \
|
||||
res/drawable-land-hdpi-v14/menu_normal.png \
|
||||
res/drawable-land-hdpi-v14/menu_pressed.png \
|
||||
res/drawable-land-hdpi-v14/reader.png \
|
||||
res/drawable-land-hdpi-v14/site_security_identified.png \
|
||||
res/drawable-land-hdpi-v14/site_security_verified.png \
|
||||
@ -769,8 +760,6 @@ RES_DRAWABLE_LAND_XHDPI_V14 = \
|
||||
res/drawable-land-xhdpi-v14/tabs_carat.png \
|
||||
res/drawable-land-xhdpi-v14/urlbar_stop.png \
|
||||
res/drawable-land-xhdpi-v14/menu.png \
|
||||
res/drawable-land-xhdpi-v14/menu_normal.png \
|
||||
res/drawable-land-xhdpi-v14/menu_pressed.png \
|
||||
res/drawable-land-xhdpi-v14/reader.png \
|
||||
res/drawable-land-xhdpi-v14/site_security_identified.png \
|
||||
res/drawable-land-xhdpi-v14/site_security_verified.png \
|
||||
@ -799,8 +788,6 @@ RES_DRAWABLE_LARGE_MDPI_V11 = \
|
||||
res/drawable-large-mdpi-v11/site_security_identified.png \
|
||||
res/drawable-large-mdpi-v11/site_security_verified.png \
|
||||
res/drawable-large-mdpi-v11/menu.png \
|
||||
res/drawable-large-mdpi-v11/menu_normal.png \
|
||||
res/drawable-large-mdpi-v11/menu_pressed.png \
|
||||
res/drawable-large-mdpi-v11/tabs_carat.png \
|
||||
$(NULL)
|
||||
|
||||
@ -826,8 +813,6 @@ RES_DRAWABLE_LARGE_HDPI_V11 = \
|
||||
res/drawable-large-hdpi-v11/site_security_identified.png \
|
||||
res/drawable-large-hdpi-v11/site_security_verified.png \
|
||||
res/drawable-large-hdpi-v11/menu.png \
|
||||
res/drawable-large-hdpi-v11/menu_normal.png \
|
||||
res/drawable-large-hdpi-v11/menu_pressed.png \
|
||||
res/drawable-large-hdpi-v11/tabs_carat.png \
|
||||
$(NULL)
|
||||
|
||||
@ -853,8 +838,6 @@ RES_DRAWABLE_LARGE_XHDPI_V11 = \
|
||||
res/drawable-large-xhdpi-v11/site_security_identified.png \
|
||||
res/drawable-large-xhdpi-v11/site_security_verified.png \
|
||||
res/drawable-large-xhdpi-v11/menu.png \
|
||||
res/drawable-large-xhdpi-v11/menu_normal.png \
|
||||
res/drawable-large-xhdpi-v11/menu_pressed.png \
|
||||
res/drawable-large-xhdpi-v11/tabs_carat.png \
|
||||
$(NULL)
|
||||
|
||||
|
79
mobile/android/base/MenuButton.java
Normal file
@ -0,0 +1,79 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
public class MenuButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
Path mPath;
|
||||
CurveTowards mSide;
|
||||
CanvasDelegate mCanvasDelegate;
|
||||
|
||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
|
||||
public MenuButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
||||
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x02);
|
||||
a.recycle();
|
||||
|
||||
if (curveTowards == 0x00)
|
||||
mSide = CurveTowards.NONE;
|
||||
else if (curveTowards == 0x01)
|
||||
mSide = CurveTowards.LEFT;
|
||||
else
|
||||
mSide = CurveTowards.RIGHT;
|
||||
|
||||
// Path is clipped.
|
||||
mPath = new Path();
|
||||
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
int width = getMeasuredWidth();
|
||||
int height = getMeasuredHeight();
|
||||
float curve = height * 1.125f;
|
||||
|
||||
mPath.reset();
|
||||
|
||||
// Clipping happens on opposite side for menu.
|
||||
if (mSide == CurveTowards.RIGHT) {
|
||||
mPath.moveTo(0, 0);
|
||||
mPath.cubicTo(curve * 0.75f, 0,
|
||||
curve * 0.25f, height,
|
||||
curve, height);
|
||||
mPath.lineTo(0, height);
|
||||
mPath.lineTo(0, 0);
|
||||
} else if (mSide == CurveTowards.LEFT) {
|
||||
mPath.moveTo(width, 0);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), 0,
|
||||
(width - (curve * 0.25f)), height,
|
||||
(width - curve), height);
|
||||
mPath.lineTo(width, height);
|
||||
mPath.lineTo(width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 9.7 KiB |
@ -7,8 +7,8 @@
|
||||
|
||||
<item android:maxLevel="1">
|
||||
<selector>
|
||||
<item android:state_pressed="true" android:drawable="@drawable/menu_pressed"/>
|
||||
<item android:drawable="@drawable/menu_normal"/>
|
||||
<item android:state_pressed="true" android:drawable="@drawable/highlight"/>
|
||||
<item android:drawable="@android:color/black"/>
|
||||
</selector>
|
||||
</item>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton.Unused"/>
|
||||
|
||||
<org.mozilla.gecko.TabsButton android:id="@+id/tabs"
|
||||
|
@ -32,7 +32,7 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="65dip"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@ -8,14 +8,14 @@
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="65dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/menu"
|
||||
android:contentDescription="@string/menu"
|
||||
android:background="@drawable/menu_normal"
|
||||
android:background="@android:color/black"
|
||||
android:paddingLeft="35dip"
|
||||
android:paddingRight="10dip"
|
||||
android:enabled="false"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="90dip"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@ -8,14 +8,14 @@
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="90dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/menu"
|
||||
android:contentDescription="@string/menu"
|
||||
android:background="@drawable/menu_normal"
|
||||
android:background="@android:color/black"
|
||||
android:paddingLeft="48dip"
|
||||
android:paddingRight="14dip"
|
||||
android:enabled="false"/>
|
||||
|
@ -33,10 +33,11 @@
|
||||
android:layout_alignLeft="@id/tabs"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="56dip"
|
||||
android:layout_alignParentRight="true"
|
||||
gecko:curveTowards="none"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/menu"
|
||||
android:contentDescription="@string/menu"
|
||||
|
@ -32,7 +32,7 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton.Unused"/>
|
||||
|
||||
<org.mozilla.gecko.TabsButton android:id="@+id/tabs"
|
||||
|
@ -32,7 +32,7 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="78dip"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@ -8,14 +8,14 @@
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
<org.mozilla.gecko.MenuButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="78dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/menu"
|
||||
android:contentDescription="@string/menu"
|
||||
android:background="@drawable/menu_normal"
|
||||
android:background="@android:color/black"
|
||||
android:paddingLeft="42dip"
|
||||
android:paddingRight="12dip"
|
||||
android:enabled="false"/>
|
||||
|