aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorowner <owner@DeeDee-Laptop>2012-10-20 19:09:15 -0700
committerowner <owner@DeeDee-Laptop>2012-10-20 19:09:15 -0700
commitc78f40d66b9d17a1d191b54bf1ff78b4b1a93c91 (patch)
tree58122e6e63bb8f910624983fccefc792ed28f0d7
parent52c1b1affb42ebe5d8b6830cfa17060e36b71c08 (diff)
downloaddsub-c78f40d66b9d17a1d191b54bf1ff78b4b1a93c91.tar.gz
dsub-c78f40d66b9d17a1d191b54bf1ff78b4b1a93c91.tar.bz2
dsub-c78f40d66b9d17a1d191b54bf1ff78b4b1a93c91.zip
Started adding support in album activity for adding to playlist
-rw-r--r--subsonic-android/res/menu/select_album.xml4
-rw-r--r--subsonic-android/res/values/strings.xml3
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java50
3 files changed, 49 insertions, 8 deletions
diff --git a/subsonic-android/res/menu/select_album.xml b/subsonic-android/res/menu/select_album.xml
index 204461b2..cd49e44f 100644
--- a/subsonic-android/res/menu/select_album.xml
+++ b/subsonic-android/res/menu/select_album.xml
@@ -41,6 +41,10 @@
android:icon="@drawable/action_remove_all"
android:title="@string/common.delete"
android:showAsAction="ifRoom|withText"/>
+
+ <item
+ android:id="@+id/menu_add_playlist"
+ android:title="@string/menu.add_playlist"/>
<item
android:id="@+id/menu_play_last"
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index 5e6b7371..ecfd95de 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -128,6 +128,9 @@
<string name="starring_content_starred">Starred \"%s\"</string>
<string name="starring_content_unstarred">Unstarred \"%s\"</string>
<string name="starring_content_error">Failed to update \"%s\", please try later.</string>
+
+ <string name="updated_playlist">Updated \"%s\"</string>
+ <string name="updated_playlist_error">Failed to update \"%s\", please try later.</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/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index 3cd80957..306882a1 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -37,14 +37,14 @@ import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
-import github.daneren2005.dsub.util.Constants;
-import github.daneren2005.dsub.util.EntryAdapter;
-import github.daneren2005.dsub.util.Pair;
-import github.daneren2005.dsub.util.TabActivityBackgroundTask;
-import github.daneren2005.dsub.util.Util;
+import github.daneren2005.dsub.service.OfflineException;
+import github.daneren2005.dsub.service.ServerTooOldException;
+import github.daneren2005.dsub.util.*;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public class SelectAlbumActivity extends SubsonicTabActivity {
@@ -164,9 +164,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
delete();
selectAll(false, false);
return true;
- /*case R.id.menu_add_playlist:
-
- return true;*/
+ case R.id.menu_add_playlist:
+ addToPlaylist();
+ return true;
case R.id.menu_exit:
intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -467,6 +467,40 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
getDownloadService().unpin(getSelectedSongs());
}
}
+
+ private void addToPlaylist() {
+ addToPlaylist("Test");
+ }
+
+ private void addToPlaylist(final String playlist) {
+ final List<MusicDirectory.Entry> songs = getSelectedSongs();
+
+ new SilentBackgroundTask<Void>(this) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(SelectAlbumActivity.this);
+ musicService.addToPlaylist(playlist, songs, SelectAlbumActivity.this, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(SelectAlbumActivity.this, getResources().getString(R.string.updated_playlist, playlist));
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ String msg;
+ if (error instanceof OfflineException || error instanceof ServerTooOldException) {
+ msg = getErrorMessage(error);
+ } else {
+ msg = getResources().getString(R.string.updated_playlist_error, playlist) + " " + getErrorMessage(error);
+ }
+
+ Util.toast(SelectAlbumActivity.this, msg, false);
+ }
+ }.execute();
+ }
private void playVideo(MusicDirectory.Entry entry) {
Intent intent = new Intent(Intent.ACTION_VIEW);