[Android] [PATCH] Adapted notification colors for Lollipop
Geoffrey Métais
geoffrey.metais at gmail.com
Fri Nov 21 16:10:32 CET 2014
Plus public visibility, for being available on lockscreen
---
vlc-android/res/layout-v21/notification.xml | 74 ++++++++++++++
.../res/layout-v21/notification_expanded.xml | 107 +++++++++++++++++++++
.../src/org/videolan/vlc/audio/AudioService.java | 8 +-
3 files changed, 187 insertions(+), 2 deletions(-)
create mode 100644 vlc-android/res/layout-v21/notification.xml
create mode 100644 vlc-android/res/layout-v21/notification_expanded.xml
diff --git a/vlc-android/res/layout-v21/notification.xml b/vlc-android/res/layout-v21/notification.xml
new file mode 100644
index 0000000..798308c
--- /dev/null
+++ b/vlc-android/res/layout-v21/notification.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:clickable="true"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ tools:targetApi="jelly_bean" >
+
+ <ImageView
+ android:id="@+id/cover"
+ android:layout_width="64dp"
+ android:layout_height="64dp"
+ android:src="@drawable/icon" />
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:layout_weight="1"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/songName"
+ style="@android:style/TextAppearance.Material.Notification.Title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:text="@string/title" />
+
+ <TextView
+ android:id="@+id/artist"
+ style="@android:style/TextAppearance.Material.Notification.Info"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:text="@string/artist" />
+ </LinearLayout>
+
+ <ImageButton
+ android:id="@+id/play_pause"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_margin="5dp"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="fitXY"
+ android:src="@drawable/ic_play" />
+
+ <ImageButton
+ android:id="@+id/forward"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_margin="5dp"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="fitXY"
+ android:src="@drawable/ic_next" />
+
+ <ImageButton
+ android:id="@+id/stop"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_margin="5dp"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="fitXY"
+ android:src="@drawable/ic_stop" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/vlc-android/res/layout-v21/notification_expanded.xml b/vlc-android/res/layout-v21/notification_expanded.xml
new file mode 100644
index 0000000..c7c0644
--- /dev/null
+++ b/vlc-android/res/layout-v21/notification_expanded.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/content"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:clickable="true"
+ tools:targetApi="jelly_bean" >
+
+ <ImageView
+ android:id="@+id/cover"
+ android:layout_width="128dp"
+ android:layout_height="128dp"
+ android:layout_marginRight="8dp"
+ android:src="@drawable/icon" />
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_above="@+id/buttons"
+ android:layout_toRightOf="@+id/cover"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/songName"
+ style="@android:style/TextAppearance.Material.Notification.Title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="40dp"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:text="@string/title" />
+
+ <TextView
+ android:id="@+id/artist"
+ style="@android:style/TextAppearance.Material.Notification.Line2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:text="@string/artist" />
+
+ <TextView
+ android:id="@+id/album"
+ style="@android:style/TextAppearance.Material.Notification.Info"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:singleLine="true"
+ android:text="@string/album" />
+ </LinearLayout>
+
+ <ImageButton
+ android:id="@+id/stop"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_alignParentRight="true"
+ android:layout_margin="5dp"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="fitXY"
+ android:src="@drawable/ic_stop" />
+
+ <LinearLayout
+ android:id="@+id/buttons"
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:layout_alignBottom="@id/cover"
+ android:layout_alignParentRight="true"
+ android:layout_toRightOf="@+id/cover"
+ android:orientation="horizontal" >
+
+ <ImageButton
+ android:id="@+id/backward"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_previous" />
+
+ <ImageButton
+ android:id="@+id/play_pause"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_marginLeft="30dp"
+ android:layout_marginRight="30dp"
+ android:layout_weight="1"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_play" />
+
+ <ImageButton
+ android:id="@+id/forward"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:background="#00ffffff"
+ android:clickable="true"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_next" />
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index b57ae96..bf4e85f 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -726,6 +726,8 @@ public class AudioService extends Service {
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (LibVlcUtil.isJellyBeanOrLater()) {
+ int pause = LibVlcUtil.isLolliPopOrLater() ? R.drawable.ic_pause : R.drawable.ic_pause_w;
+ int play = LibVlcUtil.isLolliPopOrLater() ? R.drawable.ic_play : R.drawable.ic_play_w;
Intent iBackward = new Intent(ACTION_REMOTE_BACKWARD);
Intent iPlay = new Intent(ACTION_REMOTE_PLAYPAUSE);
Intent iForward = new Intent(ACTION_REMOTE_FORWARD);
@@ -740,7 +742,7 @@ public class AudioService extends Service {
view.setImageViewBitmap(R.id.cover, cover);
view.setTextViewText(R.id.songName, title);
view.setTextViewText(R.id.artist, artist);
- view.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? R.drawable.ic_pause_w : R.drawable.ic_play_w);
+ view.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? pause : play);
view.setOnClickPendingIntent(R.id.play_pause, piPlay);
view.setOnClickPendingIntent(R.id.forward, piForward);
view.setOnClickPendingIntent(R.id.stop, piStop);
@@ -752,13 +754,15 @@ public class AudioService extends Service {
view_expanded.setTextViewText(R.id.songName, title);
view_expanded.setTextViewText(R.id.artist, artist);
view_expanded.setTextViewText(R.id.album, album);
- view_expanded.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? R.drawable.ic_pause_w : R.drawable.ic_play_w);
+ view_expanded.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? pause : play);
view_expanded.setOnClickPendingIntent(R.id.backward, piBackward);
view_expanded.setOnClickPendingIntent(R.id.play_pause, piPlay);
view_expanded.setOnClickPendingIntent(R.id.forward, piForward);
view_expanded.setOnClickPendingIntent(R.id.stop, piStop);
view_expanded.setOnClickPendingIntent(R.id.content, pendingIntent);
+ if (LibVlcUtil.isLolliPopOrLater())
+ builder.setVisibility(Notification.VISIBILITY_PUBLIC);
notification = builder.build();
notification.contentView = view;
notification.bigContentView = view_expanded;
--
1.9.1
More information about the Android
mailing list