diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/res/layout/statusbar.xml | 17 | ||||
-rw-r--r-- | android/src/org/rockbox/Helper/RunForegroundManager.java | 31 |
2 files changed, 40 insertions, 8 deletions
diff --git a/android/res/layout/statusbar.xml b/android/res/layout/statusbar.xml index c795008225..cf49264eba 100644 --- a/android/res/layout/statusbar.xml +++ b/android/res/layout/statusbar.xml @@ -8,19 +8,20 @@ android:paddingBottom="0dp" android:orientation="horizontal"> + <ImageView android:id="@+id/artwork" + android:gravity="center" + android:padding="2dp" + android:scaleType="center" + android:adjustViewBounds="false" + android:layout_width="wrap_content" + android:layout_height="fill_parent"> + </ImageView> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> - - <ImageView android:src="@drawable/notification_small" - android:gravity="center" - android:paddingTop="2dp" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </ImageView> <TextView android:id="@+id/title" android:layout_width="wrap_content" @@ -38,7 +39,7 @@ <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="3dp" - android:orientation="vertical"> + android:orientation="horizontal"> <TextView android:id="@+id/content" android:layout_gravity="left" android:scrollHorizontally="true" 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"); |