diff options
Diffstat (limited to 'android/src/org/rockbox/Helper/RunForegroundManager.java')
-rw-r--r-- | android/src/org/rockbox/Helper/RunForegroundManager.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/android/src/org/rockbox/Helper/RunForegroundManager.java b/android/src/org/rockbox/Helper/RunForegroundManager.java index fbb6040005..5384e1b595 100644 --- a/android/src/org/rockbox/Helper/RunForegroundManager.java +++ b/android/src/org/rockbox/Helper/RunForegroundManager.java @@ -8,6 +8,10 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.Drawable; import android.widget.RemoteViews; public class RunForegroundManager @@ -20,6 +24,7 @@ public class RunForegroundManager private IRunForeground api; private Service mCurrentService; private Intent mWidgetUpdate; + private int iconheight; public RunForegroundManager(Service service) { @@ -31,6 +36,11 @@ public class RunForegroundManager Intent intent = new Intent(service, RockboxActivity.class); intent = intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + /* retrieve height of launcher icon. Used to scale down album art. */ + Resources resources = service.getResources(); + Drawable draw = resources.getDrawable(R.drawable.launcher); + iconheight = draw.getIntrinsicHeight(); + mNotification = new Notification(); mNotification.tickerText = service.getString(R.string.notification); mNotification.icon = R.drawable.notification; @@ -87,6 +97,27 @@ public class RunForegroundManager mNotification.tickerText = title; else mNotification.tickerText = title+" - "+artist; + + if (albumart != null) { + /* The notification area doesn't have permissions to access the SD card. + * Push the data as Bitmap instead of Uri. Scale down to size of + * launcher icon -- broadcasting the unscaled image may yield in + * too much data, causing UI hangs of Rockbox. */ + Bitmap b = BitmapFactory.decodeFile(albumart); + if(b != null) { + /* scale width to keep aspect ratio -- height is the constraint */ + int scaledwidth = Math.round(iconheight*((float)b.getWidth()/b.getHeight())); + views.setImageViewBitmap(R.id.artwork, + Bitmap.createScaledBitmap(b, scaledwidth, iconheight, false)); + } + else { + views.setImageViewResource(R.id.artwork, R.drawable.launcher); + } + } + else { + views.setImageViewResource(R.id.artwork, R.drawable.launcher); + } + mNM.notify(R.string.notification, mNotification); mWidgetUpdate = new Intent("org.rockbox.TrackUpdateInfo"); |