Bug 935628 - Remove BrowserToolbarBackground from toolbar (r=sriram)
☠☠ backed out by 0053063dd872 ☠ ☠
authorLucas Rocha <lucasr@mozilla.com>
Mon, 11 Nov 2013 18:33:49 +0000
changeset 154354 da1a4740a72209c41f0314d6a45311e279d9dee1
parent 154353 f16921967806d5dfd9e40dae2c5c04a14f550d8a
child 154355 5fdcf5a9697feac43370e3f871da844c623827a6
push id3458
push userlrocha@mozilla.com
push dateMon, 11 Nov 2013 18:34:25 +0000
treeherderfx-team@5fdcf5a9697f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs935628
milestone28.0a1
Bug 935628 - Remove BrowserToolbarBackground from toolbar (r=sriram)
mobile/android/base/BrowserToolbar.java
mobile/android/base/BrowserToolbarBackground.java
mobile/android/base/moz.build
mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
mobile/android/base/resources/layout/browser_toolbar.xml
mobile/android/base/resources/layout/gecko_app.xml
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -115,17 +115,16 @@ public class BrowserToolbar extends Geck
         public void onStopEditing();
     }
 
     private View mUrlDisplayContainer;
     private View mUrlEditContainer;
     private CustomEditText mUrlEditText;
     private View mUrlBarEntry;
     private ImageView mUrlBarRightEdge;
-    private BrowserToolbarBackground mUrlBarBackground;
     private GeckoTextView mTitle;
     private int mTitlePadding;
     private boolean mSiteSecurityVisible;
     private boolean mSwitchingTabs;
     private ShapedButton mTabs;
     private ImageButton mBack;
     private ImageButton mForward;
     private ImageButton mFavicon;
@@ -180,27 +179,30 @@ public class BrowserToolbar extends Geck
     private static final int TABS_EXPANDED = 2;
 
     private static final int FORWARD_ANIMATION_DURATION = 450;
     private final ForegroundColorSpan mUrlColor;
     private final ForegroundColorSpan mBlockedColor;
     private final ForegroundColorSpan mDomainColor;
     private final ForegroundColorSpan mPrivateDomainColor;
 
+    private final LightweightTheme mTheme;
+
     private boolean mShowUrl;
     private boolean mTrimURLs;
 
     private Integer mPrefObserverId;
 
     public BrowserToolbar(Context context) {
         this(context, null);
     }
 
     public BrowserToolbar(Context context, AttributeSet attrs) {
         super(context, attrs);
+        mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
 
         // BrowserToolbar is attached to BrowserApp only.
         mActivity = (BrowserApp) context;
 
         // Inflate the content.
         LayoutInflater.from(context).inflate(R.layout.browser_toolbar, this);
 
         Tabs.registerOnTabsChangedListener(this);
@@ -267,17 +269,16 @@ public class BrowserToolbar extends Geck
 
         registerEventListener("Reader:Click");
         registerEventListener("Reader:LongClick");
 
         mShowSiteSecurity = false;
 
         mAnimatingEntry = false;
 
-        mUrlBarBackground = (BrowserToolbarBackground) findViewById(R.id.url_bar_bg);
         mUrlBarViewOffset = res.getDimensionPixelSize(R.dimen.url_bar_offset_left);
         mDefaultForwardMargin = res.getDimensionPixelSize(R.dimen.forward_default_offset);
         mUrlDisplayContainer = findViewById(R.id.url_display_container);
         mUrlBarEntry = findViewById(R.id.url_bar_entry);
 
         mUrlEditContainer = findViewById(R.id.url_edit_container);
         mUrlEditText = (CustomEditText) findViewById(R.id.url_edit_text);
 
@@ -1767,17 +1768,16 @@ public class BrowserToolbar extends Geck
             setFavicon(tab.getFavicon());
             setProgressVisibility(tab.getState() == Tab.STATE_LOADING);
             setSecurityMode(tab.getSecurityMode());
             setPageActionVisibility(mStop.getVisibility() == View.VISIBLE);
             updateBackButton(tab.canDoBack());
             updateForwardButton(tab.canDoForward());
 
             final boolean isPrivate = tab.isPrivate();
-            mUrlBarBackground.setPrivateMode(isPrivate);
             setPrivateMode(isPrivate);
             mTabs.setPrivateMode(isPrivate);
             mTitle.setPrivateMode(isPrivate);
             mMenu.setPrivateMode(isPrivate);
             mMenuIcon.setPrivateMode(isPrivate);
             mUrlEditText.setPrivateMode(isPrivate);
 
             if (mBack instanceof BackButton)
@@ -1855,9 +1855,27 @@ public class BrowserToolbar extends Geck
             }
         } else if (event.equals("Reader:LongClick")) {
             Tab tab = Tabs.getInstance().getSelectedTab();
             if (tab != null) {
                 tab.addToReadingList();
             }
         }
     }
+
+    @Override
+    public void onLightweightThemeChanged() {
+        Drawable drawable = mTheme.getDrawable(this);
+        if (drawable == null)
+            return;
+
+        StateListDrawable stateList = new StateListDrawable();
+        stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
+        stateList.addState(EMPTY_STATE_SET, drawable);
+
+        setBackgroundDrawable(stateList);
+    }
+
+    @Override
+    public void onLightweightThemeReset() {
+        setBackgroundResource(R.drawable.url_bar_bg);
+    }
 }
deleted file mode 100644
--- a/mobile/android/base/BrowserToolbarBackground.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* 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 org.mozilla.gecko.widget.GeckoLinearLayout;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.StateListDrawable;
-import android.util.AttributeSet;
-
-public class BrowserToolbarBackground extends GeckoLinearLayout {
-    private final LightweightTheme mTheme;
-
-    public BrowserToolbarBackground(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
-    }
-
-    @Override
-    public void onLightweightThemeChanged() {
-        final Drawable drawable = mTheme.getDrawable(this);
-        if (drawable == null)
-            return;
-
-        final StateListDrawable stateList = new StateListDrawable();
-        stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
-        stateList.addState(EMPTY_STATE_SET, drawable);
-
-        setBackgroundDrawable(stateList);
-    }
-
-    @Override
-    public void onLightweightThemeReset() {
-        setBackgroundResource(R.drawable.url_bar_bg);
-    }
-}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -94,17 +94,16 @@ gbjar.sources += [
     'animation/HeightChangeAnimation.java',
     'animation/PropertyAnimator.java',
     'animation/Rotate3DAnimation.java',
     'animation/ViewHelper.java',
     'BackButton.java',
     'BaseGeckoInterface.java',
     'BrowserApp.java',
     'BrowserToolbar.java',
-    'BrowserToolbarBackground.java',
     'CameraImageResultHandler.java',
     'CameraVideoResultHandler.java',
     'CanvasDelegate.java',
     'CheckableLinearLayout.java',
     'ClickableWhenDisabledEditText.java',
     'ContactService.java',
     'ContextGetter.java',
     'CustomEditText.java',
--- a/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
@@ -1,21 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- 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/. -->
 
 <merge xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
-    <org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/url_bar_bg"
-                                                android:layout_width="fill_parent"
-                                                android:layout_height="fill_parent"
-                                                android:background="@drawable/url_bar_bg"/>
-
     <org.mozilla.gecko.ShapedButton android:id="@+id/tabs"
                                     style="@style/UrlBar.ImageButton"
                                     android:layout_width="84dip"
                                     android:layout_alignParentLeft="true"
                                     gecko:curveTowards="left"
                                     android:background="@drawable/shaped_button"
                                     android:gravity="center_vertical"
                                     android:paddingLeft="6dip"
--- a/mobile/android/base/resources/layout/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout/browser_toolbar.xml
@@ -7,21 +7,16 @@
        xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
     <ImageButton android:id="@+id/back"
                  style="@style/UrlBar.ImageButton.Unused"/>
 
     <ImageButton android:id="@+id/forward"
                  style="@style/UrlBar.ImageButton.Unused"/>
 
-    <org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/url_bar_bg"
-                                                android:layout_width="fill_parent"
-                                                android:layout_height="fill_parent"
-                                                android:background="@drawable/url_bar_bg"/>
-
     <ImageView android:id="@+id/url_bar_entry"
                style="@style/UrlBar.Button"
                android:layout_marginLeft="4dp"
                android:layout_marginRight="-19dp"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/tabs"
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -67,17 +67,18 @@
              view. To make sure the EditText is not the first focusable view in
              the root view, BrowserToolbar should be specified as low in the
              view hierarchy as possible. -->
         <org.mozilla.gecko.BrowserToolbar android:id="@id/browser_toolbar"
                 style="@style/BrowserToolbar"
                 android:layout_width="fill_parent"
                 android:layout_height="@dimen/browser_toolbar_height"
                 android:clickable="true"
-                android:focusable="true"/>
+                android:focusable="true"
+                android:background="@drawable/url_bar_bg"/>
 
     </view>
 
     <LinearLayout android:id="@+id/toast"
                   style="@style/Toast">
 
         <TextView android:id="@+id/toast_message"
                   style="@style/ToastMessage" />