diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-10-19 21:36:57 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-10-19 21:36:57 -0700 |
commit | dc1e1b7edce936d867b9c8f6a32fac461461b082 (patch) | |
tree | 2c93106e579c9d5c1be481ee62138e44acde9c95 /app/src/main/java | |
parent | 7bf60cbee7650834d64656f49748e4c70848d991 (diff) | |
download | dsub-dc1e1b7edce936d867b9c8f6a32fac461461b082.tar.gz dsub-dc1e1b7edce936d867b9c8f6a32fac461461b082.tar.bz2 dsub-dc1e1b7edce936d867b9c8f6a32fac461461b082.zip |
#572 Add option to never try to resume from remote play queue
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 75 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/Constants.java | 1 |
2 files changed, 54 insertions, 22 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 8d3bf099..0dbb643f 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -32,11 +32,13 @@ import android.os.Handler; import android.preference.PreferenceManager; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.CheckBox; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; @@ -673,6 +675,10 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo }.execute(); } private void loadRemotePlayQueue() { + if(Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_RESUME_PLAY_QUEUE_NEVER, false)) { + return; + } + final SubsonicActivity context = this; new SilentBackgroundTask<Void>(this) { private PlayerQueue playerQueue; @@ -715,32 +721,57 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo }.execute(); } private void promptRestoreFromRemoteQueue(final PlayerQueue remoteState) { - Util.confirmDialog(this, R.string.download_restore_play_queue, Util.formatDate(remoteState.changed), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + String message = getResources().getString(R.string.common_confirm_message, getResources().getString(R.string.download_restore_play_queue).toLowerCase(), Util.formatDate(remoteState.changed)); + builder.setIcon(android.R.drawable.ic_dialog_alert) + .setTitle(R.string.common_confirm) + .setMessage(message) + .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override - protected Void doInBackground() throws Throwable { - DownloadService downloadService = getDownloadService(); - downloadService.clear(); - downloadService.download(remoteState.songs, false, false, false, false, remoteState.currentPlayingIndex, remoteState.currentPlayingPosition); - return null; + public void onClick(DialogInterface dialogInterface, int i) { + new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { + @Override + protected Void doInBackground() throws Throwable { + DownloadService downloadService = getDownloadService(); + downloadService.clear(); + downloadService.download(remoteState.songs, false, false, false, false, remoteState.currentPlayingIndex, remoteState.currentPlayingPosition); + return null; + } + }.execute(); } - }.execute(); - } - }, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { + }) + .setNeutralButton(R.string.common_cancel, new DialogInterface.OnClickListener() { @Override - protected Void doInBackground() throws Throwable { - DownloadService downloadService = getDownloadService(); - downloadService.serializeQueue(false); - return null; + public void onClick(DialogInterface dialogInterface, int i) { + new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { + @Override + protected Void doInBackground() throws Throwable { + DownloadService downloadService = getDownloadService(); + downloadService.serializeQueue(false); + return null; + } + }.execute(); } - }.execute(); - } - }); + }) + .setNegativeButton(R.string.common_never, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { + @Override + protected Void doInBackground() throws Throwable { + DownloadService downloadService = getDownloadService(); + downloadService.serializeQueue(false); + + SharedPreferences.Editor editor = Util.getPreferences(SubsonicFragmentActivity.this).edit(); + editor.putBoolean(Constants.PREFERENCES_KEY_RESUME_PLAY_QUEUE_NEVER, true); + editor.commit(); + return null; + } + }.execute(); + } + }); + + builder.create().show(); } private void createAccount() { diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java index 22463d9d..3ac5ee90 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java @@ -166,6 +166,7 @@ public final class Constants { public static final String PREFERENCES_KEY_START_ON_HEADPHONES = "startOnHeadphones"; public static final String PREFERENCES_KEY_COLOR_ACTION_BAR = "colorActionBar"; public static final String PREFERENCES_KEY_SHUFFLE_BY_ALBUM = "shuffleByAlbum"; + public static final String PREFERENCES_KEY_RESUME_PLAY_QUEUE_NEVER = "neverResumePlayQueue"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; |