Bug 1323105 - Upgrade topsites, AS topsites, and AS contextmenu to VectorDrawable pin r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 01 Feb 2017 14:43:03 -0800
changeset 332231 78f40cf59c5d
parent 332230 2cffde862591
child 332232 1a813d8f06dc
push id31299
push userkwierso@gmail.com
push date2017-02-02 23:55 +0000
treeherdermozilla-central@b4b23e49820c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1323105
milestone54.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 1323105 - Upgrade topsites, AS topsites, and AS contextmenu to VectorDrawable pin r=sebastian MozReview-Commit-ID: Dpot8wrYFZI
mobile/android/base/java/org/mozilla/gecko/home/TopSitesGridItemView.java
mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesCard.java
mobile/android/base/resources/menu/activitystream_contextmenu.xml
--- a/mobile/android/base/java/org/mozilla/gecko/home/TopSitesGridItemView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TopSitesGridItemView.java
@@ -2,29 +2,31 @@
  * 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.home;
 
 import android.content.Context;
 import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
 import android.support.v4.widget.TextViewCompat;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.widget.ImageView.ScaleType;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.db.BrowserContract.TopSites;
 import org.mozilla.gecko.icons.IconCallback;
 import org.mozilla.gecko.icons.IconResponse;
 import org.mozilla.gecko.icons.Icons;
+import org.mozilla.gecko.util.DrawableUtil;
 
 import java.util.concurrent.Future;
 
 /**
  * A view that displays the thumbnail and the title/url for a top/pinned site.
  * If the title/url is longer than the width of the view, they are faded out.
  * If there is no valid url, a default string is shown at 50% opacity.
  * This is denoted by the empty state.
@@ -272,18 +274,23 @@ public class TopSitesGridItemView extend
     private boolean updateType(int type) {
         if (mType == type) {
             return false;
         }
 
         mType = type;
         refreshDrawableState();
 
-        int pinResourceId = (type == TopSites.TYPE_PINNED ? R.drawable.pin : 0);
-        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mTitleView, pinResourceId, 0, 0, 0);
+        final Drawable pinDrawable;
+        if (type == TopSites.TYPE_PINNED) {
+            pinDrawable = DrawableUtil.tintDrawable(getContext(), R.drawable.as_pin, getResources().getColor(R.color.placeholder_grey));
+        } else {
+            pinDrawable = null;
+        }
+        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mTitleView, pinDrawable, null, null, null);
 
         return true;
     }
 
     /**
      * Update the title shown by this view. If both title and url
      * are empty, mark the state as STATE_EMPTY and show a default text.
      */
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesCard.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesCard.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * 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.home.activitystream.topsites;
 
 import android.graphics.Color;
+import android.graphics.drawable.Drawable;
 import android.support.v4.widget.TextViewCompat;
 import android.support.v7.widget.RecyclerView;
 import android.view.View;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.TextView;
 
 import org.mozilla.gecko.R;
@@ -98,18 +99,24 @@ import java.util.concurrent.Future;
         }
 
         ongoingIconLoad = Icons.with(itemView.getContext())
                 .pageUrl(topSite.getUrl())
                 .skipNetwork()
                 .build()
                 .execute(this);
 
-        final int pinResourceId = (topSite.isPinned() ? R.drawable.pin : 0);
-        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(title, pinResourceId, 0, 0, 0);
+        final Drawable pinDrawable;
+        if (topSite.isPinned()) {
+            pinDrawable = DrawableUtil.tintDrawable(itemView.getContext(), R.drawable.as_pin, itemView.getResources().getColor(R.color.placeholder_grey));
+        } else {
+            pinDrawable = null;
+        }
+        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(title, pinDrawable, null, null, null);
+
     }
 
     @Override
     public void onIconResponse(IconResponse response) {
         faviconView.updateImage(response);
 
         final int tintColor = !response.hasColor() || response.getColor() == Color.WHITE ? Color.LTGRAY : Color.WHITE;
 
--- a/mobile/android/base/resources/menu/activitystream_contextmenu.xml
+++ b/mobile/android/base/resources/menu/activitystream_contextmenu.xml
@@ -35,16 +35,16 @@
             android:icon="@drawable/as_share"
             android:title="@string/share"/>
         <item
             android:id="@+id/copy_url"
             android:icon="@drawable/as_copy"
             android:title="@string/contextmenu_copyurl"/>
         <item
             android:id="@+id/pin"
-            android:icon="@drawable/pin"
+            android:icon="@drawable/as_pin"
             android:title="@string/contextmenu_top_sites_pin"/>
         <item
             android:id="@+id/add_homescreen"
             android:icon="@drawable/as_home"
             android:title="@string/contextmenu_add_to_launcher"/>
     </group>
 </menu>
\ No newline at end of file