Bug 1100021 - Correct new tablet toolbar layout for devices with hardware menu key. r=lucasr
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 20 Nov 2014 12:36:10 -0800
changeset 241649 75599db3d71d260674b0d1b58ee47f69529b0f59
parent 241648 a5c944be6248aa7b361d80196de09312b6f8fe36
child 241650 25e663c7f5b0a9f2db35cebf0b96afc1d69703b6
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs1100021
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1100021 - Correct new tablet toolbar layout for devices with hardware menu key. r=lucasr
mobile/android/base/newtablet/res/layout-large-v11/new_tablet_browser_toolbar.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/toolbar/BrowserToolbarNewTablet.java
--- a/mobile/android/base/newtablet/res/layout-large-v11/new_tablet_browser_toolbar.xml
+++ b/mobile/android/base/newtablet/res/layout-large-v11/new_tablet_browser_toolbar.xml
@@ -57,16 +57,17 @@
                   android:layout_marginLeft="6dp"
                   android:orientation="horizontal"
                   android:layout_toLeftOf="@id/tabs"/>
 
     <org.mozilla.gecko.widget.ThemedImageButton
             android:id="@+id/tabs"
             style="@style/UrlBar.ImageButton.NewTablet"
             android:layout_toLeftOf="@id/menu"
+            android:layout_alignWithParentIfMissing="true"
             android:background="@drawable/new_tablet_action_bar_button"/>
 
     <!-- In a 56x60dp space, centering 24dp image will leave 16x18dp. -->
     <org.mozilla.gecko.toolbar.TabCounter android:id="@+id/tabs_counter"
                         style="@style/UrlBar.ImageButton.TabCount.NewTablet"
                         android:layout_alignLeft="@id/tabs"
                         android:layout_alignRight="@id/tabs"
                         android:layout_alignTop="@id/tabs"
@@ -76,17 +77,16 @@
                         android:layout_marginLeft="16dp"
                         android:layout_marginRight="16dp"
                         android:layout="@layout/new_tablet_tabs_counter"/>
 
     <org.mozilla.gecko.widget.ThemedImageButton
             android:id="@+id/menu"
             style="@style/UrlBar.ImageButton.NewTablet"
             android:layout_alignParentRight="true"
-            android:layout_marginRight="6dp"
             android:contentDescription="@string/menu"
             android:background="@drawable/new_tablet_action_bar_button"
             android:visibility="gone"/>
 
     <org.mozilla.gecko.widget.ThemedImageView
             android:id="@+id/menu_icon"
             style="@style/UrlBar.ImageButton.NewTablet"
             android:layout_alignLeft="@id/menu"
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -28,16 +28,17 @@
     <dimen name="new_tablet_tab_strip_favicon_size">16dp</dimen>
     <dimen name="new_tablet_site_security_height">60dp</dimen>
     <dimen name="new_tablet_site_security_width">34dp</dimen>
     <!-- We primarily use padding (instead of margins) to increase the hit area. -->
     <dimen name="new_tablet_site_security_padding_vertical">21dp</dimen>
     <dimen name="new_tablet_site_security_padding_horizontal">8dp</dimen>
     <dimen name="new_tablet_site_security_right_margin">1dp</dimen>
     <dimen name="new_tablet_browser_toolbar_height">60dp</dimen>
+    <dimen name="new_tablet_browser_toolbar_menu_right_margin">6dp</dimen>
     <dimen name="new_tablet_browser_toolbar_menu_item_width">56dp</dimen>
     <!-- Padding combines with an 18dp image to form the menu item width and height. -->
     <dimen name="new_tablet_browser_toolbar_menu_item_padding_horizontal">19dp</dimen>
     <dimen name="new_tablet_browser_toolbar_menu_item_inset_vertical">5dp</dimen>
     <dimen name="new_tablet_browser_toolbar_menu_item_inset_horizontal">3dp</dimen>
     <dimen name="new_tablet_browser_toolbar_menu_item_corner_radius">5dp</dimen>
     <dimen name="new_tablet_tab_strip_button_inset">5dp</dimen>
     <dimen name="forward_default_offset">-13dip</dimen>
--- a/mobile/android/base/toolbar/BrowserToolbarNewTablet.java
+++ b/mobile/android/base/toolbar/BrowserToolbarNewTablet.java
@@ -5,17 +5,17 @@
 
 package org.mozilla.gecko.toolbar;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.ViewHelper;
 
 import android.content.Context;
-import android.graphics.drawable.Drawable;
+import android.content.res.Resources;
 import android.util.AttributeSet;
 
 /**
  * A toolbar implementation for the tablet redesign (bug 1014156).
  * Expected to replace BrowserToolbarTablet once complete.
  */
 class BrowserToolbarNewTablet extends BrowserToolbarTabletBase {
 
@@ -46,16 +46,26 @@ class BrowserToolbarNewTablet extends Br
 
         // TODO: Move this to *TabletBase when old tablet is removed.
         // We don't want users clicking the forward button in transitions, but we don't want it to
         // look disabled to avoid flickering complications (e.g. disabled in editing mode), so undo
         // the work of the super class' constructor.
         setButtonEnabled(forwardButton, true);
 
         updateForwardButtonState(ForwardButtonState.HIDDEN);
+
+        setRightMargin();
+    }
+
+    private void setRightMargin() {
+        // TODO: Remove this hack in favor of resources when old tablet is removed.
+        final Resources res = getContext().getResources();
+        final int rightMargin =
+                res.getDimensionPixelOffset(R.dimen.new_tablet_browser_toolbar_menu_right_margin);
+        setPadding(getPaddingLeft(), getPaddingTop(), rightMargin, getPaddingBottom());
     }
 
     private void updateForwardButtonState(final ForwardButtonState state) {
         forwardButtonState = state;
         forwardButton.setEnabled(forwardButtonState == ForwardButtonState.DISPLAYED);
     }
 
     @Override