From 2212922e1d10e6d1097064199ae733cdb4a55c52 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 May 2013 21:27:04 -0700 Subject: #128 Make Shuffle Play persistent --- .../daneren2005/dsub/service/DownloadServiceImpl.java | 13 ++++++++++++- .../src/github/daneren2005/dsub/util/Constants.java | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'subsonic-android') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index d157b46a..fbb15b73 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -264,7 +264,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized void download(List songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) { - shufflePlay = false; + setShufflePlayEnabled(false); int offset = 1; if (songs.isEmpty()) { @@ -320,7 +320,15 @@ public class DownloadServiceImpl extends Service implements DownloadService { } public void restore(List songs, int currentPlayingIndex, int currentPlayingPosition) { + SharedPreferences prefs = Util.getPreferences(this); + boolean startShufflePlay = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, false); download(songs, false, false, false, false); + if(startShufflePlay) { + shufflePlay = true; + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, true); + editor.commit(); + } if (currentPlayingIndex != -1) { while(mediaPlayer == null) { Util.sleepQuietly(50L); @@ -341,6 +349,9 @@ public class DownloadServiceImpl extends Service implements DownloadService { clear(); checkDownloads(); } + SharedPreferences.Editor editor = Util.getPreferences(this).edit(); + editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, enabled); + editor.commit(); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index 12ee9e90..b6cb3d89 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -100,6 +100,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_SHUFFLE_MODE = "shuffleMode"; public static final String MAIN_BACK_STACK = "backStackIds"; public static final String MAIN_BACK_STACK_SIZE = "backStackIdsSize"; -- cgit v1.2.3