Bug 1054343 - Draw toolbar shadow instead of using a view (r=mcomella)
authorLucas Rocha <lucasr@mozilla.com>
Mon, 18 Aug 2014 10:40:10 +0100
changeset 221690 b28df3d24a877655b4e220ac830d0e92da21c0b9
parent 221689 695e23d833b62443f01bc2dba83e04e372080864
child 221691 1338cfd64cc6a468e6ab2a834f3b73a2398b7f0b
child 221744 f7d6385d2d69f1b1ebb14a72619ee1360c380cb8
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1054343
milestone34.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 1054343 - Draw toolbar shadow instead of using a view (r=mcomella)
mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
mobile/android/base/resources/layout/browser_toolbar.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/toolbar/BrowserToolbar.java
--- a/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
@@ -96,23 +96,16 @@
     <org.mozilla.gecko.widget.ThemedImageView android:id="@+id/menu_icon"
                                               style="@style/UrlBar.ImageButton"
                                               android:layout_alignLeft="@id/menu"
                                               android:layout_alignRight="@id/menu"
                                               android:gravity="center_vertical"
                                               android:src="@drawable/menu_level"
                                               android:visibility="gone"/>
 
-    <ImageView android:id="@+id/shadow"
-               android:layout_width="match_parent"
-               android:layout_height="2dp"
-               android:layout_alignParentBottom="true"
-               android:background="@color/url_bar_shadow"
-               android:contentDescription="@null"/>
-
     <!-- We draw after the menu items so when they are hidden, the cancel button,
          which is thus drawn on top, may be pressed. -->
     <org.mozilla.gecko.widget.ThemedImageView
             android:id="@+id/edit_cancel"
             style="@style/UrlBar.ImageButton"
             android:layout_alignParentRight="true"
             android:src="@drawable/close_edit_mode_selector"
             android:background="@drawable/action_bar_button"
--- a/mobile/android/base/resources/layout/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout/browser_toolbar.xml
@@ -112,16 +112,9 @@
 
     <org.mozilla.gecko.toolbar.ToolbarDisplayLayout android:id="@+id/display_layout"
                   style="@style/UrlBar.Button"
                   android:layout_alignLeft="@id/url_bar_entry"
                   android:layout_alignRight="@id/url_bar_entry"
                   android:paddingLeft="4dip"
                   android:paddingRight="4dip"/>
 
-    <ImageView android:id="@+id/shadow"
-               android:layout_width="match_parent"
-               android:layout_height="2dp"
-               android:layout_alignParentBottom="true"
-               android:background="@color/url_bar_shadow"
-               android:contentDescription="@null"/>
-
 </merge>
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -8,16 +8,17 @@
     <dimen name="autocomplete_min_width">200dp</dimen>
     <dimen name="autocomplete_row_height">32dp</dimen>
 
     <dimen name="browser_toolbar_height">48dp</dimen>
     <dimen name="browser_toolbar_button_padding">12dp</dimen>
     <dimen name="browser_toolbar_icon_width">48dp</dimen>
     <dimen name="browser_toolbar_lock_width">20dp</dimen>
     <dimen name="browser_toolbar_favicon_size">25.33dip</dimen>
+    <dimen name="browser_toolbar_shadow_size">2dp</dimen>
 
     <!-- Dimensions used by Favicons and FaviconView -->
     <dimen name="favicon_size_small">16dp</dimen>
     <dimen name="favicon_size_large">32dp</dimen>
     <dimen name="favicon_bg">32dp</dimen>
     <dimen name="favicon_bg_radius">1dp</dimen>
     <!-- Set the upper limit on the size of favicon that will be processed. Favicons larger than
          this will be downscaled to this value. If you need to use larger Favicons (Due to a UI
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -161,16 +161,19 @@ public class BrowserToolbar extends Them
     private boolean isAnimatingEntry;
 
     private int urlBarViewOffset;
     private int defaultForwardMargin;
 
     private Path roundCornerShape;
     private Paint roundCornerPaint;
 
+    private final Paint shadowPaint;
+    private final int shadowSize;
+
     private static final Interpolator buttonsInterpolator = new AccelerateInterpolator();
 
     private static final int FORWARD_ANIMATION_DURATION = 450;
 
     private final LightweightTheme theme;
     private final ToolbarPrefs prefs;
 
     public BrowserToolbar(Context context) {
@@ -261,16 +264,22 @@ public class BrowserToolbar extends Them
             roundCornerShape.lineTo(0, 0);
 
             roundCornerPaint = new Paint();
             roundCornerPaint.setAntiAlias(true);
             roundCornerPaint.setColor(res.getColor(R.color.background_tabs));
             roundCornerPaint.setStrokeWidth(0.0f);
         }
 
+        shadowSize = res.getDimensionPixelSize(R.dimen.browser_toolbar_shadow_size);
+
+        shadowPaint = new Paint();
+        shadowPaint.setColor(res.getColor(R.color.url_bar_shadow));
+        shadowPaint.setStrokeWidth(0.0f);
+
         setUIMode(UIMode.DISPLAY);
 
         // Create these listeners here, once, to avoid constructing new listeners
         // each time they are set on an animator (i.e. each time the url bar is clicked).
         showEditingPhoneAnimationListener = new PropertyAnimator.PropertyAnimationListener() {
             @Override
             public void onPropertyAnimationStart() { /* Do nothing */ }
 
@@ -501,16 +510,19 @@ public class BrowserToolbar extends Them
 
     @Override
     public void draw(Canvas canvas) {
         super.draw(canvas);
 
         if (!HardwareUtils.isTablet() && uiMode == UIMode.DISPLAY) {
             canvas.drawPath(roundCornerShape, roundCornerPaint);
         }
+
+        final int height = getHeight();
+        canvas.drawRect(0, height - shadowSize, getWidth(), height, shadowPaint);
     }
 
     public void setProgressBar(ToolbarProgressView progressBar) {
         this.progressBar = progressBar;
     }
 
     public void refresh() {
         urlDisplayLayout.dismissSiteIdentityPopup();