From cbe2f2058f391cef78315253dbea3524aba7d81a Mon Sep 17 00:00:00 2001 From: "Kevin T. Berstene" Date: Sun, 11 Jun 2017 21:24:37 -0400 Subject: Fixed previous and next button behavior while long song is paused --- .../daneren2005/dsub/service/DownloadService.java | 4 +- .../daneren2005/dsub/util/Notifications.java | 46 +++++++++++++--------- 2 files changed, 29 insertions(+), 21 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 636745d6..4d3107b3 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1202,7 +1202,7 @@ public class DownloadService extends Service { } // If only one song, just skip within song - if(size() == 1 || (currentPlaying != null && !currentPlaying.isSong())) { + if(size() == 1) { rewind(); return; } @@ -1228,7 +1228,7 @@ public class DownloadService extends Service { } public synchronized void next(boolean forceCutoff, boolean forceStart) { // If only one song, just skip within song - if(size() == 1 || (currentPlaying != null && !currentPlaying.isSong())) { + if(size() == 1) { fastForward(); return; } else if(playerState == PREPARING || playerState == PREPARED) { 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..7444911f 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java @@ -200,31 +200,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 (isLongFile && playing) { + 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(isLongFile && playing) { + 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 +253,7 @@ public final class Notifications { } } + PendingIntent pendingIntent; if(previous > 0) { Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS"); prevIntent.setComponent(new ComponentName(context, DownloadService.class)); -- cgit v1.2.3