aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-09 09:48:25 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-09 09:48:25 -0700
commit103e8d074f6b6ef6c57cb5a2a2b38a7630926a3a (patch)
tree6888368e66253ba956965c60274a3453b28be138 /src
parentb2c79de472485c9579789289d599c9d42f575564 (diff)
downloaddsub-103e8d074f6b6ef6c57cb5a2a2b38a7630926a3a.tar.gz
dsub-103e8d074f6b6ef6c57cb5a2a2b38a7630926a3a.tar.bz2
dsub-103e8d074f6b6ef6c57cb5a2a2b38a7630926a3a.zip
#375 Use standard expanded view with x for persistent notifications
There isn't enough room to add a x to the small version, so still needs to show the reconstructed version. For the expanded view use the standard notification layout, but show the x for closing the app.
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/util/Notifications.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/util/Notifications.java b/src/github/daneren2005/dsub/util/Notifications.java
index de4129e9..142fffcb 100644
--- a/src/github/daneren2005/dsub/util/Notifications.java
+++ b/src/github/daneren2005/dsub/util/Notifications.java
@@ -65,13 +65,13 @@ public final class Notifications {
boolean remote = downloadService.isRemoteEnabled();
if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.JELLY_BEAN){
RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded);
- setupViews(expandedContentView,context,song, playing, remote);
+ setupViews(expandedContentView ,context, song, true, playing, remote);
notification.bigContentView = expandedContentView;
notification.priority = Notification.PRIORITY_HIGH;
}
RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification);
- setupViews(smallContentView, context, song, playing, remote);
+ setupViews(smallContentView, context, song, false, playing, remote);
notification.contentView = smallContentView;
Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
@@ -103,7 +103,7 @@ public final class Notifications {
DSubWidgetProvider.notifyInstances(context, downloadService, playing);
}
- private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing, boolean remote){
+ private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean expanded, boolean playing, boolean remote){
// Use the same text for the ticker and the expanded notification
String title = song.getTitle();
@@ -141,7 +141,8 @@ public final class Notifications {
rv.setTextColor(R.id.notification_artist, colors.getSecond());
}
- if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false)) {
+ boolean persistent = Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false);
+ if(persistent && !expanded) {
rv.setImageViewResource(R.id.control_previous, playing ? R.drawable.notification_pause : R.drawable.notification_play);
rv.setImageViewResource(R.id.control_pause, R.drawable.notification_next);
rv.setImageViewResource(R.id.control_next, R.drawable.notification_close);
@@ -150,7 +151,7 @@ public final class Notifications {
// Create actions for media buttons
PendingIntent pendingIntent;
int previous = 0, pause = 0, next = 0, close = 0;
- if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false)) {
+ if(persistent && !expanded) {
pause = R.id.control_previous;
next = R.id.control_pause;
close = R.id.control_next;
@@ -160,7 +161,7 @@ public final class Notifications {
next = R.id.control_next;
}
- if(remote && close == 0) {
+ if((remote || persistent) && close == 0) {
close = R.id.notification_close;
rv.setViewVisibility(close, View.VISIBLE);
}