diff options
Diffstat (limited to 'src/github/daneren2005')
3 files changed, 40 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index a2086133..13bfd53d 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -515,6 +515,9 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if(downloadService != null && downloadService.getKeepScreenOn()) {
menu.findItem(R.id.menu_screen_on_off).setChecked(true);
}
+ if(downloadService != null && downloadService.isRemovePlayed()) {
+ menu.findItem(R.id.menu_remove_played).setChecked(true);
+ }
if(downloadService != null) {
MenuItem mediaRouteItem = menu.findItem(R.id.menu_mediaroute);
if(mediaRouteItem != null) {
@@ -692,6 +695,14 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis }
context.supportInvalidateOptionsMenu();
return true;
+ case R.id.menu_remove_played:
+ if (getDownloadService().isRemovePlayed()) {
+ getDownloadService().setRemovePlayed(false);
+ } else {
+ getDownloadService().setRemovePlayed(true);
+ }
+ context.supportInvalidateOptionsMenu();
+ return true;
case R.id.menu_shuffle:
new SilentBackgroundTask<Void>(context) {
@Override
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 4fdc4dc9..9aba5201 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -118,6 +118,7 @@ public class DownloadService extends Service { private SilentBackgroundTask nextPlayingTask; private PlayerState playerState = IDLE; private PlayerState nextPlayerState = IDLE; + private boolean removePlayed; private boolean shufflePlay; private long revision; private static DownloadService instance; @@ -376,6 +377,9 @@ public class DownloadService extends Service { String id = prefs.getString(Constants.PREFERENCES_KEY_CONTROL_ID, null); setRemoteState(remoteState, null, id); } + if(prefs.getBoolean(Constants.PREFERENCES_KEY_REMOVE_PLAYED, false)) { + removePlayed = true; + } boolean startShufflePlay = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, false); download(songs, false, false, false, false); if(startShufflePlay) { @@ -400,6 +404,19 @@ public class DownloadService extends Service { } } + public synchronized void setRemovePlayed(boolean enabled) { + removePlayed = enabled; + if(removePlayed) { + checkDownloads(); + } + SharedPreferences.Editor editor = Util.getPreferences(this).edit(); + editor.putBoolean(Constants.PREFERENCES_KEY_REMOVE_PLAYED, enabled); + editor.commit(); + } + public boolean isRemovePlayed() { + return removePlayed; + } + public synchronized void setShufflePlayEnabled(boolean enabled) { shufflePlay = enabled; if (shufflePlay) { @@ -1569,6 +1586,9 @@ public class DownloadService extends Service { return; } + if(removePlayed) { + checkRemovePlayed(); + } if (shufflePlay) { checkShufflePlay(); } @@ -1658,6 +1678,14 @@ public class DownloadService extends Service { cleanup(); } + private synchronized void checkRemovePlayed() { + while(currentPlayingIndex > 0) { + downloadList.remove(0); + currentPlayingIndex = downloadList.indexOf(currentPlaying); + revision++; + } + } + private synchronized void checkShufflePlay() { // Get users desired random playlist size diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index ab57bcd0..2b7f8757 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -113,6 +113,7 @@ public final class Constants { public static final String PREFERENCES_EQUALIZER_SETTINGS = "equalizerSettings"; public static final String PREFERENCES_KEY_PERSISTENT_NOTIFICATION = "persistentNotification"; public static final String PREFERENCES_KEY_GAPLESS_PLAYBACK = "gaplessPlayback"; + public static final String PREFERENCES_KEY_REMOVE_PLAYED = "removePlayed"; public static final String PREFERENCES_KEY_SHUFFLE_MODE = "shuffleMode"; public static final String PREFERENCES_KEY_CHAT_REFRESH = "chatRefreshRate"; public static final String PREFERENCES_KEY_CHAT_ENABLED = "chatEnabled"; |