Bug 1303292 - Media notification: Use icons that have at least the target size. r=ahunt
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 23 Sep 2016 13:36:27 +0200
changeset 315344 a574544a7c7e056b8b92ec6fafffb1ad0ad98778
parent 315343 e8583aacde9010fcf9fc17f045e354c40da45046
child 315345 29af8ec8706ea4d82d861aa0c1862486648d0ee6
push id30748
push usercbook@mozilla.com
push dateWed, 28 Sep 2016 13:53:19 +0000
treeherdermozilla-central@8c84b7618840 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahunt
bugs1303292
milestone52.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 1303292 - Media notification: Use icons that have at least the target size. r=ahunt MozReview-Commit-ID: 7pNfrFEtyUd
mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
--- a/mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
@@ -51,16 +51,17 @@ public class MediaControlService extends
     private PrefsHelper.PrefHandler mPrefsObserver;
     private final String[] mPrefs = { MEDIA_CONTROL_PREF };
 
     private boolean mInitialize = false;
     private boolean mIsMediaControlPrefOn = true;
 
     private static WeakReference<Tab> mTabReference = new WeakReference<>(null);
 
+    private int minCoverSize;
     private int coverSize;
 
     @Override
     public void onCreate() {
         initialize();
     }
 
     @Override
@@ -122,16 +123,17 @@ public class MediaControlService extends
             return;
         }
 
         Log.d(LOGTAG, "initialize");
         getGeckoPreference();
         initMediaSession();
 
         coverSize = (int) getResources().getDimension(R.dimen.notification_media_cover);
+        minCoverSize = getResources().getDimensionPixelSize(R.dimen.favicon_bg);
 
         Tabs.registerOnTabsChangedListener(this);
         mInitialize = true;
     }
 
     private void shutdown() {
         if (!mInitialize) {
             return;
@@ -374,17 +376,17 @@ public class MediaControlService extends
         intent.setAction(ACTION_STOP);
         return  PendingIntent.getService(getApplicationContext(), 1, intent, 0);
     }
 
     private Bitmap generateCoverArt(Tab tab) {
         final Bitmap favicon = tab.getFavicon();
 
         // If we do not have a favicon or if it's smaller than 72 pixels then just use the default icon.
-        if (favicon == null || favicon.getWidth() < 72 || favicon.getHeight() < 72) {
+        if (favicon == null || favicon.getWidth() < minCoverSize || favicon.getHeight() < minCoverSize) {
             // Use the launcher icon as fallback
             return BitmapFactory.decodeResource(getResources(), R.drawable.notification_media);
         }
 
         // Favicon should at least have half of the size of the cover
         int width = Math.max(favicon.getWidth(), coverSize / 2);
         int height = Math.max(favicon.getHeight(), coverSize / 2);