aboutsummaryrefslogtreecommitdiff
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
parentcc22988ff7aad3d37bd7546b4c0a5b20656e0116 (diff)
downloaddsub-6152bb642d02c87977a21fe2d0814842de6756d4.tar.gz
dsub-6152bb642d02c87977a21fe2d0814842de6756d4.tar.bz2
dsub-6152bb642d02c87977a21fe2d0814842de6756d4.zip
Added options to update name/comment of a playlist
-rw-r--r--subsonic-android/res/layout/update_playlist.xml26
-rw-r--r--subsonic-android/res/menu/select_playlist_context.xml5
-rw-r--r--subsonic-android/res/values/strings.xml7
-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
8 files changed, 113 insertions, 2 deletions
diff --git a/subsonic-android/res/layout/update_playlist.xml b/subsonic-android/res/layout/update_playlist.xml
new file mode 100644
index 00000000..c73d93ef
--- /dev/null
+++ b/subsonic-android/res/layout/update_playlist.xml
@@ -0,0 +1,26 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <EditText
+ android:id="@+id/get_playlist_name"
+ android:inputType="text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:layout_marginLeft="4dp"
+ android:layout_marginRight="4dp"
+ android:layout_marginBottom="4dp"
+ android:hint="@string/common.name" />
+ <EditText
+ android:id="@+id/get_playlist_comment"
+ android:inputType="text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="4dp"
+ android:layout_marginLeft="4dp"
+ android:layout_marginRight="4dp"
+ android:layout_marginBottom="16dp"
+ android:hint="@string/common.comment"/>
+</LinearLayout> \ No newline at end of file
diff --git a/subsonic-android/res/menu/select_playlist_context.xml b/subsonic-android/res/menu/select_playlist_context.xml
index a376ec58..6d844a16 100644
--- a/subsonic-android/res/menu/select_playlist_context.xml
+++ b/subsonic-android/res/menu/select_playlist_context.xml
@@ -25,6 +25,11 @@
android:id="@+id/playlist_menu_pin"
android:title="@string/common.pin"
/>
+
+ <item
+ android:id="@+id/playlist_update_info"
+ android:title="@string/playlist.update_info"
+ />
<item
android:id="@+id/playlist_menu_delete"
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index bf2f448a..ddaf4a9d 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -14,7 +14,9 @@
<string name="common.delete">Delete</string>
<string name="common.star">Star</string>
<string name="common.unstar">Unstar</string>
- <string name="common.info">Info</string>
+ <string name="common.info">Details</string>
+ <string name="common.name">Name</string>
+ <string name="common.comment">Comment</string>
<string name="button_bar.home">DSub home</string>
<string name="button_bar.browse">Media library</string>
@@ -51,6 +53,9 @@
<string name="menu.deleted_playlist_error">Failed to delete playlist %s</string>
<string name="playlist.label">Playlists</string>
+ <string name="playlist.update_info">Update Information</string>
+ <string name="playlist.updated_info">Updated playlist information for %s</string>
+ <string name="playlist.updated_info_error">Failed to update playlist information for %s</string>
<string name="help.label">Help</string>
<string name="help.title">Welcome to DSub!</string>
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 {