Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3492)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java

Issue 2649173002: [Media>UI] Don't scale the icon if it's smaller than the ideal size (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
index ff0529ece0607c7b1639dd0bef2502ca81c313dc..f13bd44ac299aaa35ba3914f4ddec5f6bc7e948e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
@@ -483,18 +483,22 @@ public class MediaNotificationManager {
}
/**
- * Scales |icon| to the size returned by {@link getIdealMediaImageSize()}. Returns null if
- * |icon| is null.
+ * Downscale |icon| for display in the notification if needed. Returns null if |icon| is null.
+ * If |icon| is larger than {@link getIdealMediaImageSize()}, scale it down to
+ * {@link getIdealMediaImageSize()} and return. Otherwise return the original |icon|.
* @param icon The icon to be scaled.
*/
@Nullable
- public static Bitmap scaleIconToIdealSize(Bitmap icon) {
+ public static Bitmap downscaleIconToIdealSize(@Nullable Bitmap icon) {
if (icon == null) return null;
int targetSize = getIdealMediaImageSize();
Matrix m = new Matrix();
int dominantLength = Math.max(icon.getWidth(), icon.getHeight());
+
+ if (dominantLength < getIdealMediaImageSize()) return icon;
+
// Move the center to (0,0).
m.postTranslate(icon.getWidth() / -2.0f, icon.getHeight() / -2.0f);
// Scale to desired size.
@@ -843,7 +847,7 @@ public class MediaNotificationManager {
int resourceId = (mMediaNotificationInfo.defaultNotificationLargeIcon != 0)
? mMediaNotificationInfo.defaultNotificationLargeIcon
: R.drawable.audio_playing_square;
- mDefaultNotificationLargeIcon = scaleIconToIdealSize(
+ mDefaultNotificationLargeIcon = downscaleIconToIdealSize(
BitmapFactory.decodeResource(mContext.getResources(), resourceId));
}
builder.setLargeIcon(mDefaultNotificationLargeIcon);
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaSessionTabHelper.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698