Show cover art in notification
This commit is contained in:
parent
8508b6f00e
commit
724e3cfe23
@ -22,15 +22,17 @@ THE SOFTWARE.
|
|||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:maxWidth="80dip"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_marginRight="5dip" />
|
||||||
android:padding="10dip" />
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -89,6 +89,9 @@ THE SOFTWARE.
|
|||||||
<string name="enqueue_all">Enqueue All</string>
|
<string name="enqueue_all">Enqueue All</string>
|
||||||
<string name="all_songs">All Songs</string>
|
<string name="all_songs">All Songs</string>
|
||||||
|
|
||||||
|
<!-- Notification -->
|
||||||
|
<string name="notification_title_paused">%s (Paused)</string>
|
||||||
|
|
||||||
<!-- Preferences -->
|
<!-- Preferences -->
|
||||||
<plurals name="seconds">
|
<plurals name="seconds">
|
||||||
<item quantity="one">01 second</item>
|
<item quantity="one">01 second</item>
|
||||||
|
@ -1396,11 +1396,20 @@ public final class PlaybackService extends Service implements Handler.Callback,
|
|||||||
*/
|
*/
|
||||||
public Notification createNotification(Song song, int state)
|
public Notification createNotification(Song song, int state)
|
||||||
{
|
{
|
||||||
int statusIcon = (state & FLAG_PLAYING) != 0 ? R.drawable.status_icon : R.drawable.status_icon_paused;
|
boolean playing = (state & FLAG_PLAYING) != 0;
|
||||||
|
|
||||||
RemoteViews views = new RemoteViews(getPackageName(), R.layout.notification);
|
RemoteViews views = new RemoteViews(getPackageName(), R.layout.notification);
|
||||||
views.setImageViewResource(R.id.icon, statusIcon);
|
|
||||||
|
if (!Song.mDisableCoverArt && song.hasCover(this)) {
|
||||||
|
views.setImageViewUri(R.id.icon, song.getCoverUri());
|
||||||
|
} else {
|
||||||
|
views.setImageViewResource(R.id.icon, R.drawable.icon);
|
||||||
|
}
|
||||||
|
if (playing) {
|
||||||
views.setTextViewText(R.id.title, song.title);
|
views.setTextViewText(R.id.title, song.title);
|
||||||
|
} else {
|
||||||
|
views.setTextViewText(R.id.title, getResources().getString(R.string.notification_title_paused, song.title));
|
||||||
|
}
|
||||||
views.setTextViewText(R.id.artist, song.artist);
|
views.setTextViewText(R.id.artist, song.artist);
|
||||||
|
|
||||||
if (mInvertNotification) {
|
if (mInvertNotification) {
|
||||||
@ -1413,7 +1422,7 @@ public final class PlaybackService extends Service implements Handler.Callback,
|
|||||||
|
|
||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
notification.contentView = views;
|
notification.contentView = views;
|
||||||
notification.icon = statusIcon;
|
notification.icon = playing ? R.drawable.status_icon : R.drawable.status_icon_paused;
|
||||||
notification.flags |= Notification.FLAG_ONGOING_EVENT;
|
notification.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
notification.contentIntent = mNotificationAction;
|
notification.contentIntent = mNotificationAction;
|
||||||
return notification;
|
return notification;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user