aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-07-01 19:25:08 -0700
committerScott Jackson <daneren2005@gmail.com>2013-07-01 19:25:08 -0700
commit00dafb14fbb3d90d481550f1953ea0d789eec093 (patch)
tree6a8f251f7c3add00c60847e531eeb9528ee58815 /subsonic-android
parent7dece3a6e11b113db602db8a6b2dadd5f30ce209 (diff)
downloaddsub-00dafb14fbb3d90d481550f1953ea0d789eec093.tar.gz
dsub-00dafb14fbb3d90d481550f1953ea0d789eec093.tar.bz2
dsub-00dafb14fbb3d90d481550f1953ea0d789eec093.zip
Abstracted out confirm dialog
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/values/strings.xml2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java11
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java15
3 files changed, 16 insertions, 12 deletions
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index cc638a23..fa672f82 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -21,6 +21,7 @@
<string name="common.play_external">Play Video</string>
<string name="common.stream_external">Stream Video</string>
<string name="common.confirm">Confirm</string>
+ <string name="common.confirm_message">Do you want to %1$s %2$s</string>
<string name="button_bar.home">Home</string>
<string name="button_bar.browse">Library</string>
@@ -185,7 +186,6 @@
<string name="updated_playlist">Added %1$s songs to \"%2$s\"</string>
<string name="updated_playlist_error">Failed to update \"%s\", please try later.</string>
<string name="removed_playlist">Removed %1$s songs from \"%2$s\"</string>
- <string name="delete_playlist">Do you want to delete %1$s</string>
<string name="song_details.all">%1$s %2$s</string>
<string name="song_details.kbps">%d kbps</string>
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index aa0ffcf8..00830b72 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -184,11 +184,7 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
}
private void deletePlaylist(final Playlist playlist) {
- new AlertDialog.Builder(context)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setTitle(R.string.common_confirm)
- .setMessage(context.getResources().getString(R.string.delete_playlist, playlist.getName()))
- .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
+ Util.confirmDialog(context, R.string.common_delete, playlist.getName(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new LoadingTask<Void>(context, false) {
@@ -219,10 +215,7 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
}
}.execute();
}
-
- })
- .setNegativeButton(R.string.common_cancel, null)
- .show();
+ });
}
private void displayPlaylistInfo(final Playlist playlist) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 702c732a..4aa9461c 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -22,9 +22,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
-import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -565,6 +563,19 @@ public final class Util {
}
toast.show();
}
+
+ public static void confirmDialog(Context context, int action, String subject, DialogInterface.OnClickListener onClick) {
+ Util.confirmDialog(context, context.getResources().getString(action), subject, onClick);
+ }
+ public static void confirmDialog(Context context, String action, String subject, DialogInterface.OnClickListener onClick) {
+ new AlertDialog.Builder(context)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setTitle(R.string.common_confirm)
+ .setMessage(context.getResources().getString(R.string.common_confirm_message, action, subject))
+ .setPositiveButton(R.string.common_ok, onClick)
+ .setNegativeButton(R.string.common_cancel, null)
+ .show();
+ }
/**
* Converts a byte-count to a formatted string suitable for display to the user.