Bug 1000149 - Part 3: Update close button size and toolbar spacing. r=lucasr
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 30 Apr 2014 10:25:51 -0700
changeset 181498 4a102d4f823fdab71bc43855c15474614d939c7b
parent 181497 9ee5def1b7807359d0c09a8d22afeaf2fbe0b7b3
child 181499 7b23977961947f55a2effff79d0c9506c936338b
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerslucasr
bugs1000149
milestone32.0a1
Bug 1000149 - Part 3: Update close button size and toolbar spacing. r=lucasr
mobile/android/base/resources/drawable-hdpi/close_edit_mode.png
mobile/android/base/resources/drawable-mdpi/close_edit_mode.png
mobile/android/base/resources/drawable-xhdpi/close_edit_mode.png
mobile/android/base/resources/layout/browser_toolbar.xml
mobile/android/base/toolbar/BrowserToolbar.java
index 70caf842d33e52296d730f9016c4c50bf89b0838..efb5ab8e7474a84d0cbf37fa22702768b2d0ffa6
GIT binary patch
literal 550
zc%17D@N?(olHy`uVBq!ia0vp^Y9P$P3?%12mYf5mSkfJR9T^xl_H+M9WCijSl0AZa
z85pX73L9D&7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10!Y05c#1%-#CuhVZrANdh
zre_x>q+|lQ#GwEG|Eo4Wj05TyDhcunW&i^@G0lw&75**xE5CHjHs8k;Kq1B?Z+91A
zp4~CifSfy?E{-7<r;kp#%hasE(b_)sS$x|2{~I<hb6M8Ay4U(8M?A-#xc^2LZ)V3c
zcwC*P$*J(cBs=-N6+`xyp1KLQEc4G-tG0hVm)U8QdS}~@f?jrkKbtHUKj4`sbGquH
z>eX3u{<So&xgC3<bmD5o&z=6qv>X{7_r3Dq_WZ#S9=lX1;s2DKPP?C+xc=mnnSwwO
z?_4&ENk?xy-1SNIb%9{)oz#zkN2hF@)b&f;#oP2Ax6w9Zqf@7=be>)QEY(?%8rj@`
z^U0lwiF^r?&%MI>jq@#i&aX~W`Z!zGwnXe!{~O+{2_oIc>}F2_`ct*UHKHUXu_V<h
zxhNG#F&G&bn&=vs=o*@b7#dp{8(W#0=^B_@85p!XIz^*s$jwj5OsmAL;hW5_=b)hW
MboFyt=akR{0E6?)RR910
index 608a80f47210fc07d464d5b672dbb2ebcf4cf2d3..eda09a3f6b27fb6772bab05f1541b4a2f79d3b34
GIT binary patch
literal 473
zc%17D@N?(olHy`uVBq!ia0vp^QXtI13?%1G+4BcTv7|ftIx;Y9?C1WI$O_~uBzpw;
zGB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpoC?BPlzj!j!({rj!#a>
z$OSTpMF0Q)zn~Z62h=QB666;Qq#1aG+LkE)S*^5Aan0{-9*fql0g5pudAqv^Rqx3G
zDVXf(;uxZFerwQMzQYO}I%~u1*4+ADe{<u`&|5x})uiiNWMtSaeCrJ=ZeHg&@KZVH
z_-?kHrVpeqvmbuNcY;0Xr^6wU8fBMdJFcoltGHd}RtXX@=o4Ie(sQ!m)lX{m*S<`N
zY$?7p>!*=)k)G;oySCs{`@|co1KI`789itzIl}KIr<=9mUe%PRFZHJ{=JC7vpTT}B
zyZ;Qf(^)#296;x(mbgZgq$HN4S|t~y0x1R~149#C0~1|C^AJO0D`R6TQ!`xyb1MUb
hc1NdZ6b-rgDVb@NxHWu}`SlzW0-mmZF6*2UngIQ-pEdvh
index 4b6f1f34fd46470288a7a999b0479f55ce51871c..8fd7a3d1d00f3a61c1bf29396fc19be4759ab8e8
GIT binary patch
literal 679
zc%17D@N?(olHy`uVBq!ia0vp^#vshW3=*k7AOWOU(j9#r85lP9bN@+X1@aY=J%W50
z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10A~wJ$#1%-#C8ftFXZQz&
z`38hk)V3s~WY#uyDk-amMa9J?riO&a0A<NQ|NsA=`|#&yparreL4LsuNI)}2P-WY@
z2EM;vzX<TxD}FeV_937VD9)JV?d~F1#HFAOWE*<AIEHu}e>?3qQ<DNuTc%prJk7Jh
z@Bh!zbYx<BweGg+=lkCt-cfmye@Smc!~@2M`y<pN<9>v0UVg&(GJimrX*HXPe^~g^
zl_yt;=kHnMdg(*>RLNO;p3T|*=B)_ho=EH8ukTzCDW2nch0$f264Q&8C5fyNC!-Z_
zO?&=T^Z2xvryp^#uS%PJ(&GNK3u}GCD=T6nt*(FF@rti7%17(jtlQt8C1n}D)G_(C
zt>YMrwT|C1TQS?oU2C86czS$Fe$oE#__PTdG?x`heUHpht7~yReWl;Y=v(`yGiA&Y
zY71wwHQZL@RpM`Y{%3FEJ^n@f0)NZ)tv5GTwBSB-$ggI3M`c0XyM$-bNqtGrw(b*u
zH|^QG+uSq$Hs35Rnjhrf9dO*P_Qc+~RVFL%+~zmFF!4XL*FUwl%$;j2PwbpL2^hx=
zswJ)wB`Jv|saDBFsX&Us$iUD<*T6*A&^*M@*vi=0%G6BPz}(8fpxx0a8bw2HeoAIq
WC2kGhWPUvdMWUyxpUXO@geCyZ*$1Tn
--- a/mobile/android/base/resources/layout/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout/browser_toolbar.xml
@@ -17,39 +17,37 @@
 
          Note 2: On devices where the editing mode cancel items are
          wider than the tabs and similar buttons (e.g. hardware menu
          button), the url bar will shrink, in which case the LayoutParams
          of this View are changed dynamically. -->
     <ImageView android:id="@+id/url_bar_entry"
                style="@style/UrlBar.Button"
                android:layout_marginLeft="4dp"
-               android:layout_marginRight="-19dp"
+               android:layout_marginRight="-15dp"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/tabs"
-               android:paddingRight="4dp"
                android:duplicateParentState="true"
                android:clickable="false"
                android:focusable="false"
                android:src="@drawable/url_bar_entry"
                android:scaleType="fitXY"/>
 
     <!-- A View that clips with url_bar_entry and translates
          around it to animate shrinking or growing the url bar,
          which occurs in the display/editing mode transitions. -->
     <ImageView android:id="@+id/url_bar_translating_edge"
                style="@style/UrlBar.Button"
                android:layout_alignLeft="@id/url_bar_entry"
                android:layout_toLeftOf="@+id/tabs"
                android:layout_alignTop="@id/url_bar_entry"
                android:layout_alignBottom="@id/url_bar_entry"
-               android:layout_marginRight="-19dp"
-               android:paddingRight="4dp"
+               android:layout_marginRight="-15dp"
                android:duplicateParentState="true"
                android:clickable="false"
                android:focusable="false"
                android:visibility="invisible"
                android:src="@drawable/url_bar_translating_edge"
                android:scaleType="fitXY"/>
 
     <LinearLayout android:id="@+id/menu_items"
@@ -98,27 +96,32 @@
                         android:layout_alignRight="@id/tabs"/>
 
     <!-- Note that the edit components are invisible so that the views
          depending on their location can properly layout. -->
     <ImageView android:id="@+id/edit_cancel"
                style="@style/UrlBar.ImageButton.Icon"
                android:layout_alignParentRight="true"
                android:src="@drawable/close_edit_mode"
+               android:layout_marginLeft="2dp"
+               android:layout_marginRight="2dp"
                android:contentDescription="@string/edit_mode_cancel"
                android:visibility="invisible"/>
 
+    <!-- The left margin of the cancel button is larger than the right because
+         the url bar drawable contains some whitespace, so we compensate by adding
+         a negative right margin (value determined through experimentation). -->
     <org.mozilla.gecko.toolbar.ToolbarEditLayout android:id="@+id/edit_layout"
                   style="@style/UrlBar.Button"
                   android:layout_toLeftOf="@id/edit_cancel"
                   android:layout_marginLeft="4dp"
-                  android:layout_marginRight="4dp"
+                  android:layout_marginRight="-2dp"
                   android:paddingLeft="8dp"
                   android:paddingRight="8dp"
-                  android:visibility="gone"/>
+                  android:visibility="invisible"/>
 
     <org.mozilla.gecko.toolbar.ToolbarDisplayLayout android:id="@+id/display_layout"
                   style="@style/UrlBar.Button"
                   android:layout_toLeftOf="@id/tabs"
                   android:layout_marginRight="-24dp"/>
 
     <ImageView android:id="@+id/shadow"
                android:layout_width="fill_parent"
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -32,16 +32,18 @@ import org.mozilla.gecko.util.GeckoEvent
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.MenuUtils;
 import org.mozilla.gecko.widget.ThemedImageButton;
 import org.mozilla.gecko.widget.ThemedImageView;
 import org.mozilla.gecko.widget.ThemedRelativeLayout;
 
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.StateListDrawable;
 import android.os.Build;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.KeyEvent;
@@ -131,17 +133,17 @@ public class BrowserToolbar extends Them
     private ToolbarProgressView progressBar;
     private TabCounter tabsCounter;
     private ThemedImageButton menuButton;
     private ThemedImageView menuIcon;
     private LinearLayout actionItemBar;
     private MenuPopup menuPopup;
     private List<View> focusOrder;
 
-    private final View editCancel;
+    private final ImageView editCancel;
 
     private boolean shouldShrinkURLBar = false;
 
     private OnActivateListener activateListener;
     private OnFocusChangeListener focusChangeListener;
     private OnStartEditingListener startEditingListener;
     private OnStopEditingListener stopEditingListener;
 
@@ -213,17 +215,17 @@ public class BrowserToolbar extends Them
         forwardButton = (ImageButton) findViewById(R.id.forward);
         setButtonEnabled(forwardButton, false);
 
         menuButton = (ThemedImageButton) findViewById(R.id.menu);
         menuIcon = (ThemedImageView) findViewById(R.id.menu_icon);
         actionItemBar = (LinearLayout) findViewById(R.id.menu_items);
         hasSoftMenuButton = !HardwareUtils.hasMenuButton();
 
-        editCancel = findViewById(R.id.edit_cancel);
+        editCancel = (ImageView) findViewById(R.id.edit_cancel);
 
         // We use different layouts on phones and tablets, so adjust the focus
         // order appropriately.
         focusOrder = new ArrayList<View>();
         if (HardwareUtils.isTablet()) {
             focusOrder.addAll(Arrays.asList(tabsButton, backButton, forwardButton, this));
             focusOrder.addAll(urlDisplayLayout.getFocusOrder());
             focusOrder.addAll(Arrays.asList(actionItemBar, menuButton));
@@ -598,20 +600,19 @@ public class BrowserToolbar extends Them
     }
 
     private int getUrlBarEntryTranslation() {
         if (editCancel == null) {
             // We are on tablet, and there is no animation so return a translation of 0.
             return 0;
         }
 
-        // We would ideally use the right-most point of the edit layout instead of the
-        // edit separator and its margin, but it is not inflated when this code initially runs.
-        final LayoutParams lp = (LayoutParams) editCancel.getLayoutParams();
-        return editCancel.getLeft() - lp.leftMargin - urlBarEntry.getRight();
+        // Subtract the right margin because it's negative.
+        final LayoutParams lp = (LayoutParams) urlEditLayout.getLayoutParams();
+        return urlEditLayout.getRight() - lp.rightMargin - urlBarEntry.getRight();
     }
 
     private int getUrlBarCurveTranslation() {
         return getWidth() - tabsButton.getLeft();
     }
 
     private boolean canDoBack(Tab tab) {
         return (tab.canDoBack() && !isEditing());
@@ -1097,16 +1098,20 @@ public class BrowserToolbar extends Them
         updateChildrenForEditing();
 
         if (stopEditingListener != null) {
             stopEditingListener.onStopEditing();
         }
 
         updateProgressVisibility();
 
+        // The animation looks cleaner if the text in the URL bar is
+        // not selected so clear the selection by clearing focus.
+        urlEditLayout.clearFocus();
+
         if (Build.VERSION.SDK_INT < 11) {
             stopEditingWithoutAnimation();
         } else if (HardwareUtils.isTablet()) {
             // No animation.
             hideUrlEditLayout();
         } else {
             stopEditingWithPhoneAnimation();
         }