diff options
author | Scott Jackson <daneren2005@gmail.com> | 2017-06-19 11:38:58 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2017-06-19 11:38:58 -0700 |
commit | f863540f073fec131977d071605430b9770d57ae (patch) | |
tree | c79602121520cb90fb5ed289df76f5494a903b4d /app/src/main/java/github/daneren2005/dsub/util | |
parent | b0e0ab17a5689e726efb51a0a6a56da634aaa79f (diff) | |
parent | e41dfa468d47f4ae6b06117040e9903b62fe9aaa (diff) | |
download | dsub-f863540f073fec131977d071605430b9770d57ae.tar.gz dsub-f863540f073fec131977d071605430b9770d57ae.tar.bz2 dsub-f863540f073fec131977d071605430b9770d57ae.zip |
Merge branch 'master' into edge
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/util')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/Notifications.java | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java index d6a92b07..750ab40c 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java @@ -68,9 +68,10 @@ public final class Notifications { } boolean remote = downloadService.isRemoteEnabled(); boolean isSingle = downloadService.isCurrentPlayingSingle(); + boolean shouldFastForward = downloadService.shouldFastForward(); if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.JELLY_BEAN){ RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); - setupViews(expandedContentView ,context, song, true, playing, remote, isSingle); + setupViews(expandedContentView ,context, song, true, playing, remote, isSingle, shouldFastForward); notification.bigContentView = expandedContentView; notification.priority = Notification.PRIORITY_HIGH; } @@ -83,7 +84,7 @@ public final class Notifications { } RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification); - setupViews(smallContentView, context, song, false, playing, remote, isSingle); + setupViews(smallContentView, context, song, false, playing, remote, isSingle, shouldFastForward); notification.contentView = smallContentView; Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class); @@ -137,9 +138,7 @@ public final class Notifications { DSubWidgetProvider.notifyInstances(context, downloadService, playing); } - private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean expanded, boolean playing, boolean remote, boolean isSingleFile) { - boolean isLongFile = song.isAudioBook() || song.isPodcast(); - + private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean expanded, boolean playing, boolean remote, boolean isSingleFile, boolean shouldFastForward) { // Use the same text for the ticker and the expanded notification String title = song.getTitle(); String arist = song.getArtist(); @@ -174,7 +173,7 @@ public final class Notifications { if(expanded) { rv.setImageViewResource(R.id.control_pause, playing ? R.drawable.notification_pause : R.drawable.notification_start); - if(isLongFile && playing) { + if(shouldFastForward) { rv.setImageViewResource(R.id.control_previous, R.drawable.notification_rewind); rv.setImageViewResource(R.id.control_next, R.drawable.notification_fastforward); } else { @@ -183,14 +182,14 @@ public final class Notifications { } } else { rv.setImageViewResource(R.id.control_previous, playing ? R.drawable.notification_pause : R.drawable.notification_start); - if(isLongFile && playing) { + if(shouldFastForward) { rv.setImageViewResource(R.id.control_pause, R.drawable.notification_fastforward); } else { rv.setImageViewResource(R.id.control_pause, R.drawable.notification_forward); } rv.setImageViewResource(R.id.control_next, R.drawable.notification_close); } - } else if(isLongFile) { + } else if(shouldFastForward) { rv.setImageViewResource(R.id.control_previous, R.drawable.notification_rewind); rv.setImageViewResource(R.id.control_next, R.drawable.notification_fastforward); } else { @@ -200,31 +199,38 @@ public final class Notifications { } // Create actions for media buttons - PendingIntent pendingIntent; int previous = 0, pause = 0, next = 0, close = 0, rewind = 0, fastForward = 0; - if(persistent && !expanded) { - pause = R.id.control_previous; - if(isLongFile && playing) { - fastForward = R.id.control_pause; + if (expanded) { + if (shouldFastForward) { + rewind = R.id.control_previous; + pause = R.id.control_pause; + fastForward = R.id.control_next; } else { - next = R.id.control_pause; + previous = R.id.control_previous; + pause = R.id.control_pause; + next = R.id.control_next; + } + + if (remote || persistent) { + close = R.id.notification_close; + rv.setViewVisibility(close, View.VISIBLE); } - close = R.id.control_next; - } else if(isLongFile && (!persistent || (expanded && playing))) { - rewind = R.id.control_previous; - pause = R.id.control_pause; - fastForward = R.id.control_next; } else { - previous = R.id.control_previous; - pause = R.id.control_pause; - next = R.id.control_next; + if (persistent) { + pause = R.id.control_previous; + if(shouldFastForward) { + fastForward = R.id.control_pause; + } else { + next = R.id.control_pause; + } + close = R.id.control_next; + } else { + rewind = R.id.control_previous; + pause = R.id.control_pause; + fastForward = R.id.control_next; + } } - if((remote || persistent) && close == 0 && expanded) { - close = R.id.notification_close; - rv.setViewVisibility(close, View.VISIBLE); - } - if(isSingleFile) { if(previous > 0) { rv.setViewVisibility(previous, View.GONE); @@ -246,6 +252,7 @@ public final class Notifications { } } + PendingIntent pendingIntent; if(previous > 0) { Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS"); prevIntent.setComponent(new ComponentName(context, DownloadService.class)); |