aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-10-22 21:31:57 -0700
committerScott Jackson <daneren2005@gmail.com>2012-10-22 21:31:57 -0700
commit6152bb642d02c87977a21fe2d0814842de6756d4 (patch)
treec432b484482411b1639776ebffa7097947bee47c /subsonic-android/src
parentcc22988ff7aad3d37bd7546b4c0a5b20656e0116 (diff)
downloaddsub-6152bb642d02c87977a21fe2d0814842de6756d4.tar.gz
dsub-6152bb642d02c87977a21fe2d0814842de6756d4.tar.bz2
dsub-6152bb642d02c87977a21fe2d0814842de6756d4.zip
Added options to update name/comment of a playlist
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java54
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/MusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java11
5 files changed, 76 insertions, 1 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
index 2249f0ec..028966a1 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
@@ -25,6 +25,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.*;
import android.widget.AdapterView;
+import android.widget.EditText;
import android.widget.ListView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
@@ -159,6 +160,9 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
case R.id.playlist_info:
displayPlaylistInfo(playlist);
break;
+ case R.id.playlist_update_info:
+ updatePlaylistInfo(playlist);
+ break;
default:
return super.onContextItemSelected(menuItem);
}
@@ -199,7 +203,7 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
}
@Override
- protected void error(Throwable error) {
+ protected void error(Throwable error) {
String msg;
if (error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
@@ -226,4 +230,52 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
"\nSong Count: " + playlist.getSongCount() + "\nCreation Date: " + playlist.getCreated().replace('T', ' '))
.show();
}
+
+ private void updatePlaylistInfo(final Playlist playlist) {
+ View dialogView = getLayoutInflater().inflate(R.layout.update_playlist, null);
+ final EditText nameBox = (EditText)dialogView.findViewById(R.id.get_playlist_name);
+ final EditText commentBox = (EditText)dialogView.findViewById(R.id.get_playlist_comment);
+
+ nameBox.setText(playlist.getName());
+ commentBox.setText(playlist.getComment());
+
+ new AlertDialog.Builder(this)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setTitle(R.string.playlist_update_info)
+ .setView(dialogView)
+ .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ new TabActivityBackgroundTask<Void>(SelectPlaylistActivity.this) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(SelectPlaylistActivity.this);
+ musicService.updatePlaylist(playlist.getId(), nameBox.getText().toString(), commentBox.getText().toString(), SelectPlaylistActivity.this, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ refresh();
+ Util.toast(SelectPlaylistActivity.this, getResources().getString(R.string.playlist_updated_info, playlist.getName()));
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ String msg;
+ if (error instanceof OfflineException || error instanceof ServerTooOldException) {
+ msg = getErrorMessage(error);
+ } else {
+ msg = getResources().getString(R.string.playlist_updated_info_error, playlist.getName()) + " " + getErrorMessage(error);
+ }
+
+ Util.toast(SelectPlaylistActivity.this, msg, false);
+ }
+ }.execute();
+ }
+
+ })
+ .setNegativeButton("Cancel", null)
+ .show();
+ }
} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
index 870e2370..baab4c5f 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -158,6 +158,11 @@ public class CachedMusicService implements MusicService {
public void addToPlaylist(String id, List<MusicDirectory.Entry> toAdd, Context context, ProgressListener progressListener) throws Exception {
musicService.addToPlaylist(id, toAdd, context, progressListener);
}
+
+ @Override
+ public void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception {
+ musicService.updatePlaylist(id, name, comment, context, progressListener);
+ }
@Override
public Lyrics getLyrics(String artist, String title, Context context, ProgressListener progressListener) throws Exception {
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
index c615134c..5f17c826 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
@@ -64,6 +64,8 @@ public interface MusicService {
void deletePlaylist(String id, Context context, ProgressListener progressListener) throws Exception;
void addToPlaylist(String id, List<MusicDirectory.Entry> toAdd, Context context, ProgressListener progressListener) throws Exception;
+
+ void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception;
Lyrics getLyrics(String artist, String title, Context context, ProgressListener progressListener) throws Exception;
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
index b2a964b2..9b7120ea 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -268,6 +268,11 @@ public class OfflineMusicService extends RESTMusicService {
public void addToPlaylist(String id, List<MusicDirectory.Entry> toAdd, Context context, ProgressListener progressListener) throws Exception {
throw new OfflineException("Updating playlist not available in offline mode");
}
+
+ @Override
+ public void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException("Updating playlist not available in offline mode");
+ }
@Override
public Lyrics getLyrics(String artist, String title, Context context, ProgressListener progressListener) throws Exception {
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index 2113caa1..4fc49a79 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -412,6 +412,17 @@ public class RESTMusicService implements MusicService {
Util.close(reader);
}
}
+
+ @Override
+ public void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception {
+ checkServerVersion(context, "1.8", "Updating playlists is not supported.");
+ Reader reader = getReader(context, progressListener, "updatePlaylist", null, Arrays.asList("playlistId", "name", "comment"), Arrays.<Object>asList(id, name, comment));
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
@Override
public Lyrics getLyrics(String artist, String title, Context context, ProgressListener progressListener) throws Exception {