Bug 1303292 - Media notification: Use icons that have at least the target size. r=ahunt
MozReview-Commit-ID: 7pNfrFEtyUd
--- 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);