Bug 1403596 - Adjust menu buttons position on tabs panel. r?nechen
MozReview-Commit-ID: 3i5rP6YLO0e
--- a/mobile/android/app/src/main/res/layout/tabs_panel_default.xml
+++ b/mobile/android/app/src/main/res/layout/tabs_panel_default.xml
@@ -38,40 +38,30 @@
android:layout_height="match_parent"
android:tabStripEnabled="false"
android:layout="@layout/tabs_panel_indicator"/>
<View android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
- <ImageButton android:id="@+id/add_tab"
- style="@style/UrlBar.ImageButton"
- android:layout_width="@dimen/tabs_panel_button_width"
- android:padding="@dimen/browser_toolbar_button_padding"
- android:src="@drawable/tab_new"
- android:contentDescription="@string/new_tab"
- android:background="@drawable/action_bar_button_inverse"/>
+ <org.mozilla.gecko.toolbar.ToolbarRoundButton
+ android:id="@+id/add_tab"
+ style="@style/TabsTray.AddTab"
+ android:background="@drawable/action_bar_button_inverse"
+ android:contentDescription="@string/new_tab"
+ android:src="@drawable/tab_new"/>
- <FrameLayout android:id="@+id/tabs_menu"
- style="@style/UrlBar.ImageButton"
- android:layout_width="@dimen/tabs_panel_button_width"
- android:background="@drawable/action_bar_button_inverse"
- android:contentDescription="@string/menu">
-
- <ImageView
- style="@style/UrlBar.ImageButton"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/browser_toolbar_menu_icon_height"
- android:layout_gravity="center"
- android:scaleType="centerInside"
- android:src="@drawable/menu"
- android:tint="@color/tabs_tray_icon_grey"/>
-
- </FrameLayout>
+ <org.mozilla.gecko.toolbar.ToolbarRoundButton
+ android:id="@+id/tabs_menu"
+ style="@style/TabsTray.Menu"
+ android:background="@drawable/action_bar_button_inverse"
+ android:contentDescription="@string/menu"
+ android:src="@drawable/ic_overflow"
+ android:tint="@color/tabs_tray_icon_grey"/>
</view>
<View android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#1A000000"/>
--- a/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/ToolbarRoundButton.java
+++ b/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/ToolbarRoundButton.java
@@ -1,35 +1,48 @@
/* 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.toolbar;
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Path;
import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
+import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import org.mozilla.gecko.R;
class ToolbarRoundButton extends ShapedButton {
+ private Drawable mBackgroundDrawable;
+
public ToolbarRoundButton(Context context) {
this(context, null);
}
public ToolbarRoundButton(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ToolbarRoundButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ final TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.background });
+ mBackgroundDrawable = a.getDrawable(0);
+ if (mBackgroundDrawable == null) {
+ // Use default value if no background specified.
+ mBackgroundDrawable = ContextCompat.getDrawable(context, R.drawable.url_bar_action_button);
+ }
+ a.recycle();
+
setPrivateMode(false);
}
@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
super.onSizeChanged(width, height, oldWidth, oldHeight);
mPath.reset();
@@ -40,16 +53,16 @@ class ToolbarRoundButton extends ShapedB
final int hSpace = res.getDimensionPixelSize(R.dimen.browser_toolbar_image_button_h_spacing);
final RectF rect = new RectF(hSpace, vSpace, width - hSpace, height - vSpace);
final int radius = res.getDimensionPixelSize(R.dimen.browser_toolbar_menu_radius);
mPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
}
@Override
public void onLightweightThemeChanged() {
- setBackgroundResource(R.drawable.url_bar_action_button);
+ setBackground(mBackgroundDrawable);
}
@Override
public void onLightweightThemeReset() {
- setBackgroundResource(R.drawable.url_bar_action_button);
+ setBackground(mBackgroundDrawable);
}
}
--- a/mobile/android/app/src/photon/res/layout/browser_toolbar.xml
+++ b/mobile/android/app/src/photon/res/layout/browser_toolbar.xml
@@ -37,23 +37,25 @@
android:focusable="false"
android:scaleType="fitXY"
android:src="@android:color/transparent"
android:visibility="invisible"/>
<org.mozilla.gecko.toolbar.ToolbarRoundButton
android:id="@+id/menu"
style="@style/UrlBar.Menu"
+ android:background="@drawable/url_bar_action_button"
android:contentDescription="@string/menu"
android:src="@drawable/ic_overflow"/>
<org.mozilla.gecko.toolbar.ToolbarRoundButton
android:id="@+id/tabs"
style="@style/UrlBar.Tabs"
- android:layout_alignWithParentIfMissing="true"/>
+ android:layout_alignWithParentIfMissing="true"
+ android:background="@drawable/url_bar_action_button"/>
<org.mozilla.gecko.toolbar.TabCounter
android:id="@+id/tabs_counter"
style="@style/UrlBar.TabCounter"
android:layout_height="24dip"
android:layout_centerVertical="true"
android:clipChildren="false"
android:clipToPadding="false"
--- a/mobile/android/app/src/photon/res/values-large-v17/styles.xml
+++ b/mobile/android/app/src/photon/res/values-large-v17/styles.xml
@@ -83,9 +83,17 @@
<style name="UrlBar.SiteIdentity" parent="UrlBar.V17.SiteIdentity" />
<style name="UrlBar.V17.SiteIdentity" parent="UrlBar.Base.SiteIdentity">
<item name="android:layout_marginStart">8dp</item>
<item name="android:paddingEnd">@dimen/browser_toolbar_site_security_margin_end</item>
</style>
+ <style name="TabsTray.AddTab" parent="TabsTray.V17.AddTab"/>
+ <style name="TabsTray.V17.AddTab" parent="TabsTray.Base.AddTab"/>
+
+ <style name="TabsTray.Menu" parent="TabsTray.V17.Menu"/>
+ <style name="TabsTray.V17.Menu" parent="TabsTray.Base.Menu">
+ <item name="android:layout_marginEnd">6dp</item>
+ </style>
+
</resources>
--- a/mobile/android/app/src/photon/res/values-large/styles.xml
+++ b/mobile/android/app/src/photon/res/values-large/styles.xml
@@ -202,9 +202,17 @@
<style name="UrlBar.SiteIdentity" parent="UrlBar.V15.SiteIdentity" />
<style name="UrlBar.V15.SiteIdentity" parent="UrlBar.Base.SiteIdentity">
<item name="android:layout_marginLeft">8dp</item>
<item name="android:paddingRight">@dimen/browser_toolbar_site_security_margin_end</item>
</style>
+ <style name="TabsTray.AddTab" parent="TabsTray.V15.AddTab"/>
+ <style name="TabsTray.V15.AddTab" parent="TabsTray.Base.AddTab"/>
+
+ <style name="TabsTray.Menu" parent="TabsTray.V15.Menu"/>
+ <style name="TabsTray.V15.Menu" parent="TabsTray.Base.Menu">
+ <item name="android:layout_marginRight">6dp</item>
+ </style>
+
</resources>
--- a/mobile/android/app/src/photon/res/values-v17/styles.xml
+++ b/mobile/android/app/src/photon/res/values-v17/styles.xml
@@ -72,15 +72,23 @@
<item name="android:layout_alignEnd">@id/url_bar_entry</item>
</style>
<style name="UrlBar.QRCode" parent="UrlBar.V17.QRCode"/>
<style name="UrlBar.V17.QRCode" parent="UrlBar.ImageButton">
<item name="android:layout_marginRight">-3dp</item>
</style>
+ <style name="TabsTray.AddTab" parent="TabsTray.V17.AddTab" />
+ <style name="TabsTray.V17.AddTab" parent="TabsTray.Base.AddTab">
+ <item name="android:layout_marginEnd">-3dp</item>
+ </style>
+
+ <style name="TabsTray.Menu" parent="TabsTray.V17.Menu" />
+ <style name="TabsTray.V17.Menu" parent="TabsTray.Base.Menu"/>
+
<style name="TabStrip.Favicon" parent="TabStrip.V17.Favicon"/>
<style name="TabStrip.V17.Favicon" parent="TabStrip.Base.Favicon">
<item name="android:layout_marginStart">12dp</item>
<item name="android:layout_marginEnd">8dp</item>
</style>
</resources>
--- a/mobile/android/app/src/photon/res/values/dimens.xml
+++ b/mobile/android/app/src/photon/res/values/dimens.xml
@@ -24,17 +24,16 @@
(4dp). This value should change when the height of the view changes. -->
<dimen name="tabs_panel_indicator_selected_padding_top">52dp</dimen>
<!-- We use two different values for browser_toolbar_height on tablet
which is inconsistent. Temporary value until bug 1150730 is fixed. -->
<dimen name="browser_toolbar_height_flipper">@dimen/browser_toolbar_height</dimen>
<dimen name="browser_toolbar_button_padding">12dp</dimen>
<dimen name="browser_toolbar_icon_width">48dp</dimen>
- <dimen name="browser_toolbar_menu_icon_height">16dp</dimen>
<dimen name="browser_toolbar_menu_radius">2dp</dimen>
<dimen name="browser_toolbar_url_height">32dp</dimen>
<!-- favicon_size includes 4dp of right padding. We can't use margin (which would allow us to
specify the actual size) because that would decrease the size of our hit target. -->
<dimen name="browser_toolbar_favicon_size">21.33dip</dimen>
<dimen name="browser_toolbar_shadow_size">1dp</dimen>
--- a/mobile/android/app/src/photon/res/values/styles.xml
+++ b/mobile/android/app/src/photon/res/values/styles.xml
@@ -918,16 +918,30 @@
<item name="android:layout_alignRight">@id/url_bar_entry</item>
</style>
<style name="UrlBar.QRCode" parent="UrlBar.V15.QRCode"/>
<style name="UrlBar.V15.QRCode" parent="UrlBar.ImageButton">
<item name="android:layout_marginRight">-3dp</item>
</style>
+ <style name="TabsTray.AddTab" parent="TabsTray.V15.AddTab"/>
+ <style name="TabsTray.V15.AddTab" parent="TabsTray.Base.AddTab">
+ <item name="android:layout_marginRight">-3dp</item>
+ </style>
+ <style name="TabsTray.Base.AddTab" parent="UrlBar.ImageButton">
+ <item name="drawableTintList">@null</item>
+ </style>
+
+ <style name="TabsTray.Menu" parent="TabsTray.V15.Menu"/>
+ <style name="TabsTray.V15.Menu" parent="TabsTray.Base.Menu"/>
+ <style name="TabsTray.Base.Menu" parent="UrlBar.ImageButton">
+ <item name="drawableTintList">@null</item>
+ </style>
+
<!-- TabStrip -->
<style name="TabStrip"/>
<style name="TabStrip.Base">
<item name="android:layout_width">@dimen/tablet_tab_strip_item_width</item>
<item name="android:layout_height">@dimen/tablet_tab_strip_item_height</item>
</style>