Bug 1106935 - Remove new tablet branch in selecting default toolbar favicons. r=mhaigh
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 03 Feb 2015 18:18:21 -0800
changeset 229805 d34cbc2d93284c19ea2575e32471203bd4fa2ab2
parent 229804 2ba0223fe2b437cf39de06d3dce0d95528649f47
child 229806 85da107747057857d8518259e539d9ca53e2f83b
push id11395
push usermichael.l.comella@gmail.com
push dateThu, 19 Feb 2015 17:50:23 +0000
treeherderfx-team@42b42d67f1a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1106935
milestone38.0a1
Bug 1106935 - Remove new tablet branch in selecting default toolbar favicons. r=mhaigh As a cleanup, this required the move of favicon -> favicon_globe and the creation of new resources toolbar_favicon_default, which is aliased to favicon_globe on phones.
mobile/android/base/favicons/Favicons.java
mobile/android/base/home/TopSitesGridItemView.java
mobile/android/base/home/TopSitesPanel.java
mobile/android/base/resources/drawable-hdpi/favicon.png
mobile/android/base/resources/drawable-hdpi/favicon_globe.png
mobile/android/base/resources/drawable-large-hdpi-v11/new_tablet_default_favicon.png
mobile/android/base/resources/drawable-large-hdpi-v11/toolbar_favicon_default.png
mobile/android/base/resources/drawable-large-mdpi-v11/new_tablet_default_favicon.png
mobile/android/base/resources/drawable-large-mdpi-v11/toolbar_favicon_default.png
mobile/android/base/resources/drawable-large-v11/new_tablet_site_security_unknown.xml
mobile/android/base/resources/drawable-large-xhdpi-v11/new_tablet_default_favicon.png
mobile/android/base/resources/drawable-large-xhdpi-v11/toolbar_favicon_default.png
mobile/android/base/resources/drawable-large-xxhdpi-v11/new_tablet_default_favicon.png
mobile/android/base/resources/drawable-large-xxhdpi-v11/toolbar_favicon_default.png
mobile/android/base/resources/drawable-mdpi/favicon.png
mobile/android/base/resources/drawable-mdpi/favicon_globe.png
mobile/android/base/resources/drawable-xhdpi/favicon.png
mobile/android/base/resources/drawable-xhdpi/favicon_globe.png
mobile/android/base/resources/drawable/new_tablet_default_favicon.xml
mobile/android/base/resources/drawable/toolbar_favicon_default.xml
mobile/android/base/resources/layout/two_line_page_row.xml
mobile/android/base/tabs/TabStripItemView.java
mobile/android/base/toolbar/ToolbarDisplayLayout.java
mobile/android/base/widget/FaviconView.java
--- a/mobile/android/base/favicons/Favicons.java
+++ b/mobile/android/base/favicons/Favicons.java
@@ -445,25 +445,19 @@ public class Favicons {
      * @param context A reference to the GeckoApp instance.
      */
     public static void initializeWithContext(Context context) throws IllegalStateException {
         // Prevent multiple-initialisation.
         if (!isInitialized.compareAndSet(false, true)) {
             return;
         }
 
-        final boolean isNewTabletEnabled = NewTabletUI.isEnabled(context);
         final Resources res = context.getResources();
 
-        // Decode the default Favicon ready for use. We'd preferably override the drawable for
-        // different screen sizes, but since we need phone's default favicon on tablet (in
-        // ToolbarDisplayLayout), we can't.
-        final int defaultFaviconDrawableID =
-                isNewTabletEnabled ? R.drawable.new_tablet_default_favicon : R.drawable.favicon;
-        defaultFavicon = BitmapFactory.decodeResource(res, defaultFaviconDrawableID);
+        defaultFavicon = BitmapFactory.decodeResource(res, R.drawable.toolbar_favicon_default);
         if (defaultFavicon == null) {
             throw new IllegalStateException("Null default favicon was returned from the resources system!");
         }
 
         defaultFaviconSize = res.getDimensionPixelSize(R.dimen.favicon_bg);
 
         // Screen-density-adjusted upper limit on favicon size. Favicons larger than this are
         // downscaled to this size or discarded.
--- a/mobile/android/base/home/TopSitesGridItemView.java
+++ b/mobile/android/base/home/TopSitesGridItemView.java
@@ -30,16 +30,18 @@ public class TopSitesGridItemView extend
     // Empty state, to denote there is no valid url.
     private static final int[] STATE_EMPTY = { android.R.attr.state_empty };
 
     private static final ScaleType SCALE_TYPE_FAVICON   = ScaleType.CENTER;
     private static final ScaleType SCALE_TYPE_RESOURCE  = ScaleType.CENTER;
     private static final ScaleType SCALE_TYPE_THUMBNAIL = ScaleType.CENTER_CROP;
     private static final ScaleType SCALE_TYPE_URL       = ScaleType.CENTER_INSIDE;
 
+    private static final int THUMBNAIL_DEFAULT_FAVICON_ID = R.drawable.favicon_globe;
+
     // Child views.
     private final TextView mTitleView;
     private final TopSitesThumbnailView mThumbnailView;
 
     // Data backing this view.
     private String mTitle;
     private String mUrl;
     private String mFaviconURL;
@@ -211,17 +213,17 @@ public class TopSitesGridItemView extend
     /**
      * Display the thumbnail from a bitmap.
      *
      * @param thumbnail The bitmap to show as thumbnail.
      */
     public void displayThumbnail(Bitmap thumbnail) {
         if (thumbnail == null) {
             // Show a favicon based view instead.
-            displayThumbnail(R.drawable.favicon);
+            displayThumbnail(THUMBNAIL_DEFAULT_FAVICON_ID);
             return;
         }
         mThumbnailSet = true;
         Favicons.cancelFaviconLoad(mLoadId);
         ImageLoader.with(getContext()).cancelRequest(mThumbnailView);
 
         mThumbnailView.setScaleType(SCALE_TYPE_THUMBNAIL);
         mThumbnailView.setImageBitmap(thumbnail, true);
@@ -237,17 +239,17 @@ public class TopSitesGridItemView extend
     public void displayThumbnail(final String imageUrl, final int bgColor) {
         mThumbnailView.setScaleType(SCALE_TYPE_URL);
         mThumbnailView.setBackgroundColor(bgColor);
         mThumbnailSet = true;
 
         ImageLoader.with(getContext())
                    .load(imageUrl)
                    .noFade()
-                   .error(R.drawable.favicon)
+                   .error(THUMBNAIL_DEFAULT_FAVICON_ID)
                    .into(mThumbnailView);
     }
 
     public void displayFavicon(Bitmap favicon, String faviconURL, int expectedLoadId) {
         if (mLoadId != Favicons.NOT_LOADING &&
             mLoadId != expectedLoadId) {
             // View recycled.
             return;
@@ -265,17 +267,17 @@ public class TopSitesGridItemView extend
     public void displayFavicon(Bitmap favicon, String faviconURL) {
         if (mThumbnailSet) {
             // Already showing a thumbnail; do nothing.
             return;
         }
 
         if (favicon == null) {
             // Should show default favicon.
-            displayThumbnail(R.drawable.favicon);
+            displayThumbnail(THUMBNAIL_DEFAULT_FAVICON_ID);
             return;
         }
 
         if (faviconURL != null) {
             mFaviconURL = faviconURL;
         }
 
         mThumbnailView.setScaleType(SCALE_TYPE_FAVICON);
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -654,17 +654,17 @@ public class TopSitesPanel extends HomeF
             LoadIDAwareFaviconLoadedListener listener = new LoadIDAwareFaviconLoadedListener(view);
             final int loadId = Favicons.getSizedFaviconForPageFromLocal(context, url, listener);
             if (loadId == Favicons.LOADED) {
                 // Great!
                 return;
             }
 
             // Otherwise, do this until the async lookup returns.
-            view.displayThumbnail(R.drawable.favicon);
+            view.displayThumbnail(R.drawable.favicon_globe);
 
             // Give each side enough information to shake hands later.
             listener.setLoadId(loadId);
             view.setLoadId(loadId);
         }
 
         @Override
         public View newView(Context context, Cursor cursor, ViewGroup parent) {
rename from mobile/android/base/resources/drawable-hdpi/favicon.png
rename to mobile/android/base/resources/drawable-hdpi/favicon_globe.png
rename from mobile/android/base/resources/drawable-large-hdpi-v11/new_tablet_default_favicon.png
rename to mobile/android/base/resources/drawable-large-hdpi-v11/toolbar_favicon_default.png
rename from mobile/android/base/resources/drawable-large-mdpi-v11/new_tablet_default_favicon.png
rename to mobile/android/base/resources/drawable-large-mdpi-v11/toolbar_favicon_default.png
--- a/mobile/android/base/resources/drawable-large-v11/new_tablet_site_security_unknown.xml
+++ b/mobile/android/base/resources/drawable-large-v11/new_tablet_site_security_unknown.xml
@@ -2,11 +2,11 @@
 <!-- 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/. -->
 
 <!-- The favicon drawable is not the same dimensions as the site security
      lock icons so we offset it using this drawable to compensate. -->
 <inset
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:drawable="@drawable/favicon"
+    android:drawable="@drawable/favicon_globe"
     android:insetTop="@dimen/new_tablet_site_security_unknown_inset_top"
     android:insetBottom="@dimen/new_tablet_site_security_unknown_inset_bottom"/>
rename from mobile/android/base/resources/drawable-large-xhdpi-v11/new_tablet_default_favicon.png
rename to mobile/android/base/resources/drawable-large-xhdpi-v11/toolbar_favicon_default.png
rename from mobile/android/base/resources/drawable-large-xxhdpi-v11/new_tablet_default_favicon.png
rename to mobile/android/base/resources/drawable-large-xxhdpi-v11/toolbar_favicon_default.png
rename from mobile/android/base/resources/drawable-mdpi/favicon.png
rename to mobile/android/base/resources/drawable-mdpi/favicon_globe.png
rename from mobile/android/base/resources/drawable-xhdpi/favicon.png
rename to mobile/android/base/resources/drawable-xhdpi/favicon_globe.png
deleted file mode 100644
--- a/mobile/android/base/resources/drawable/new_tablet_default_favicon.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?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/. -->
-
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
-        android:src="@null"/>
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/drawable/toolbar_favicon_default.xml
@@ -0,0 +1,7 @@
+<?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/. -->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+        android:src="@drawable/favicon_globe" />
--- a/mobile/android/base/resources/layout/two_line_page_row.xml
+++ b/mobile/android/base/resources/layout/two_line_page_row.xml
@@ -7,17 +7,17 @@
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:gecko="http://schemas.android.com/apk/res-auto"
        tools:context=".BrowserApp">
 
     <org.mozilla.gecko.widget.FaviconView android:id="@+id/icon"
                                           android:layout_width="@dimen/favicon_bg"
                                           android:layout_height="@dimen/favicon_bg"
                                           android:layout_margin="16dp"
-                                          tools:background="@drawable/favicon"/>
+                                          tools:background="@drawable/favicon_globe"/>
 
     <LinearLayout android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="center_vertical"
                   android:orientation="vertical"
                   android:paddingRight="25dp">
 
         <org.mozilla.gecko.widget.FadedSingleColorTextView
--- a/mobile/android/base/tabs/TabStripItemView.java
+++ b/mobile/android/base/tabs/TabStripItemView.java
@@ -204,17 +204,17 @@ public class TabStripItemView extends Th
             titleView.setText(tab.getDisplayTitle());
         }
 
     }
 
     private void updateFavicon(final Bitmap favicon) {
         if (favicon == null) {
             lastFavicon = null;
-            faviconView.setImageResource(R.drawable.new_tablet_default_favicon);
+            faviconView.setImageResource(R.drawable.toolbar_favicon_default);
             return;
         }
         if (favicon == lastFavicon) {
             return;
         }
 
         // Cache the original so we can debounce without scaling.
         lastFavicon = favicon;
--- a/mobile/android/base/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/toolbar/ToolbarDisplayLayout.java
@@ -404,17 +404,17 @@ public class ToolbarDisplayLayout extend
         mLastFavicon = image;
 
         Log.d(LOGTAG, "updateFavicon(" + image + ")");
 
         if (image != null) {
             image = Bitmap.createScaledBitmap(image, mFaviconSize, mFaviconSize, false);
             mFavicon.setImageBitmap(image);
         } else {
-            mFavicon.setImageResource(R.drawable.favicon);
+            mFavicon.setImageResource(R.drawable.favicon_globe);
         }
     }
 
     private void updateSiteIdentity(Tab tab, EnumSet<UpdateFlags> flags) {
         final SiteIdentity siteIdentity;
         if (tab == null) {
             siteIdentity = null;
         } else {
--- a/mobile/android/base/widget/FaviconView.java
+++ b/mobile/android/base/widget/FaviconView.java
@@ -209,17 +209,17 @@ public class FaviconView extends ImageVi
         mIconKey = key;
         mScalingExpected = allowScaling;
 
         // Possibly update the display.
         formatImage();
     }
 
     public void showDefaultFavicon() {
-        setImageResource(R.drawable.favicon);
+        setImageResource(R.drawable.favicon_globe);
         mDominantColor = 0;
     }
 
     private void showNoImage() {
         setImageDrawable(null);
         mDominantColor = 0;
     }