From dc1e1b7edce936d867b9c8f6a32fac461461b082 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 19 Oct 2015 21:36:57 -0700 Subject: #572 Add option to never try to resume from remote play queue --- .../dsub/activity/SubsonicFragmentActivity.java | 75 +++++++++++++++------- .../github/daneren2005/dsub/util/Constants.java | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 55 insertions(+), 22 deletions(-) (limited to 'app') 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(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(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(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(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(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(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"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7c682930..8f5cec71 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,6 +28,7 @@ Close No Yes + Never Home Library -- cgit v1.2.3