From 9a267552f7464776620276f83bc19ce1342ab019 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 20 Aug 2014 13:13:52 -0700 Subject: Add Delete bookmark to song context menu --- res/menu/select_song_context.xml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'res/menu') diff --git a/res/menu/select_song_context.xml b/res/menu/select_song_context.xml index 94283f70..5123a0ae 100644 --- a/res/menu/select_song_context.xml +++ b/res/menu/select_song_context.xml @@ -59,4 +59,10 @@ android:id="@+id/song_menu_share" android:title="@string/menu.share"/> + + + + -- cgit v1.2.3 From c2f5c3898049bb110beb1a68419d322e9b3261db Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 20 Aug 2014 13:22:26 -0700 Subject: Add show artist method to bookmark context menu --- res/menu/select_bookmark_context.xml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'res/menu') diff --git a/res/menu/select_bookmark_context.xml b/res/menu/select_bookmark_context.xml index 724c4c78..7e3117f8 100644 --- a/res/menu/select_bookmark_context.xml +++ b/res/menu/select_bookmark_context.xml @@ -6,6 +6,10 @@ android:id="@+id/bookmark_menu_info" android:title="@string/common.info"/> + + -- cgit v1.2.3 From 5a639da5d71f6dbe8a5609f103c6d19ff621f7a0 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 20 Aug 2014 22:48:34 -0700 Subject: Fixes to more of the bookmark playing --- res/menu/select_bookmark_context.xml | 8 +- .../dsub/fragments/SelectBookmarkFragment.java | 42 +--------- .../dsub/fragments/SelectDirectoryFragment.java | 1 + .../dsub/fragments/SubsonicFragment.java | 94 ++++++++++++++++++++-- .../daneren2005/dsub/service/DownloadService.java | 4 +- 5 files changed, 100 insertions(+), 49 deletions(-) (limited to 'res/menu') diff --git a/res/menu/select_bookmark_context.xml b/res/menu/select_bookmark_context.xml index 7e3117f8..2b1b83fd 100644 --- a/res/menu/select_bookmark_context.xml +++ b/res/menu/select_bookmark_context.xml @@ -5,10 +5,14 @@ + + + android:id="@+id/song_menu_show_artist" + android:title="@string/menu.show_artist"/> (context) { @Override protected Void doInBackground() throws Throwable { - downloadService.download(Arrays.asList(bookmark), false, true, false, false, bookmark.getBookmark().getPosition()); + downloadService.download(Arrays.asList(bookmark), false, true, false, false, 0, bookmark.getBookmark().getPosition()); return null; } @@ -132,38 +132,4 @@ public class SelectBookmarkFragment extends SelectListFragment(context, false) { - @Override - protected Void doInBackground() throws Throwable { - MusicService musicService = MusicServiceFactory.getMusicService(context); - musicService.deleteBookmark(entry.getId(), Util.getParentFromEntry(context, entry), context, null); - return null; - } - - @Override - protected void done(Void result) { - adapter.remove(entry); - adapter.notifyDataSetChanged(); - Util.toast(context, context.getResources().getString(R.string.bookmark_deleted, entry.getTitle())); - } - - @Override - protected void error(Throwable error) { - String msg; - if (error instanceof OfflineException || error instanceof ServerTooOldException) { - msg = getErrorMessage(error); - } else { - msg = context.getResources().getString(R.string.bookmark_deleted_error, entry.getTitle()) + " " + getErrorMessage(error); - } - - Util.toast(context, msg, false); - } - }.execute(); - } - }); - } } diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index fbd87ec7..50b03d1e 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -849,6 +849,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter if(!append && !save && autoplay && !playNext && !shuffle) { // Call playNow which goes through and tries to use bookmark information playNow(songs); + return; } LoadingTask onValid = new LoadingTask(context) { diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index be4a76eb..216f526c 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -39,6 +39,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AbsListView; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; @@ -324,7 +325,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR displaySongInfo(entry); break; case R.id.album_menu_show_artist: - showArtist((Entry) selectedItem); + showAlbumArtist((Entry) selectedItem); break; case R.id.album_menu_share: createShare(songs); @@ -365,6 +366,15 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR case R.id.song_menu_share: createShare(songs); break; + case R.id.song_menu_show_album: + showAlbum((Entry) selectedItem); + break; + case R.id.song_menu_show_artist: + showArtist((Entry) selectedItem); + break; + case R.id.bookmark_menu_delete: + deleteBookmark(entry, null); + break; default: return false; } @@ -1242,7 +1252,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } } - public void showArtist(Entry entry) { + public void showAlbumArtist(Entry entry) { SubsonicFragment fragment = new SelectDirectoryFragment(); Bundle args = new Bundle(); if(Util.isTagBrowsing(context)) { @@ -1256,6 +1266,37 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR replaceFragment(fragment, true); } + public void showArtist(Entry entry) { + SubsonicFragment fragment = new SelectDirectoryFragment(); + Bundle args = new Bundle(); + if(Util.isTagBrowsing(context)) { + args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getArtistId()); + } else { + if(entry.getGrandParent() == null) { + args.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getParent()); + } else { + args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getGrandParent()); + } + } + args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getArtist()); + args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); + fragment.setArguments(args); + + replaceFragment(fragment, true); + } + public void showAlbum(Entry entry) { + SubsonicFragment fragment = new SelectDirectoryFragment(); + Bundle args = new Bundle(); + if(Util.isTagBrowsing(context)) { + args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getAlbumId()); + } else { + args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getParent()); + } + args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getAlbum()); + fragment.setArguments(args); + + replaceFragment(fragment, true); + } public void createShare(final List entries) { new LoadingTask>(context, true) { @@ -1313,7 +1354,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR .setPositiveButton(R.string.bookmark_action_resume, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { - playNow(entries, song, position); + playNow(songs, song, position); } }) .setNegativeButton(R.string.bookmark_action_start_over, new DialogInterface.OnClickListener() { @@ -1342,7 +1383,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } }.execute(); - playNow(entries, 0); + playNow(songs, 0); } }); AlertDialog dialog = builder.create(); @@ -1367,16 +1408,55 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR } } protected void playNow(List entries, int position) { - playNow(entries, 0, position); + playNow(entries, entries.get(0), position); } protected void playNow(List entries, Entry song, int position) { DownloadService downloadService = getDownloadService(); - if(downloadService() == null) { + if(downloadService == null) { return; } downloadService.clear(); - downloadService.download(songs, false, true, true, false, entries.indexOf(song), position); + downloadService.download(entries, false, true, true, false, entries.indexOf(song), position); Util.startActivityWithoutTransition(context, DownloadActivity.class); } + + protected void deleteBookmark(final MusicDirectory.Entry entry, final ArrayAdapter adapter) { + Util.confirmDialog(context, R.string.bookmark_delete_title, entry.getTitle(), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new LoadingTask(context, false) { + @Override + protected Void doInBackground() throws Throwable { + MusicService musicService = MusicServiceFactory.getMusicService(context); + musicService.deleteBookmark(entry.getId(), Util.getParentFromEntry(context, entry), context, null); + + entry.setBookmark(null); + return null; + } + + @Override + protected void done(Void result) { + if(adapter != null) { + adapter.remove(entry); + adapter.notifyDataSetChanged(); + } + Util.toast(context, context.getResources().getString(R.string.bookmark_deleted, entry.getTitle())); + } + + @Override + protected void error(Throwable error) { + String msg; + if (error instanceof OfflineException || error instanceof ServerTooOldException) { + msg = getErrorMessage(error); + } else { + msg = context.getResources().getString(R.string.bookmark_deleted_error, entry.getTitle()) + " " + getErrorMessage(error); + } + + Util.toast(context, msg, false); + } + }.execute(); + } + }); + } } diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index a813e724..15777c8e 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -297,7 +297,7 @@ public class DownloadService extends Service { public synchronized void download(List songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) { download(songs, save, autoplay, playNext, shuffle, 0, 0); } - public synchronized void download(List songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int index, int position) { + public synchronized void download(List songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int start, int position) { setShufflePlayEnabled(false); int offset = 1; @@ -336,7 +336,7 @@ public class DownloadService extends Service { } if (autoplay) { - play(index, true, position); + play(start, true, position); } else { if (currentPlaying == null) { currentPlaying = downloadList.get(0); -- cgit v1.2.3