From 81d79dded8e9ba1fc15b2411e8a7d39ec2efd052 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 29 Feb 2016 17:57:46 -0800 Subject: Fixes #652: Add Show Artist/Album context menu items to search/starred songs --- .../daneren2005/dsub/fragments/SearchFragment.java | 5 +++++ .../dsub/fragments/SelectDirectoryFragment.java | 9 +++++---- .../daneren2005/dsub/fragments/SubsonicFragment.java | 15 +++++++++++++-- app/src/main/res/menu/select_album_context.xml | 9 +++++---- app/src/main/res/menu/select_album_context_offline.xml | 6 ++++++ app/src/main/res/menu/select_song_context.xml | 18 +++++++++++++----- app/src/main/res/menu/select_song_context_offline.xml | 10 ++++++++++ 7 files changed, 57 insertions(+), 15 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java index 9a7823a5..1aef5982 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java @@ -187,6 +187,11 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O return selectedMedia; } + @Override + protected boolean isShowArtistEnabled() { + return true; + } + public void search(final String query, final boolean autoplay) { if(skipSearch) { skipSearch = false; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index f4f0ac30..f1a52399 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -312,10 +312,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section if(!entry.isVideo() && !Util.isOffline(context) && (playlistId == null || !playlistOwner) && (podcastId == null || Util.isOffline(context) && podcastId != null)) { menu.removeItem(R.id.song_menu_remove_playlist); } - // Remove show artists if parent is not set and if not on a album list - if((albumListType == null || (entry.getParent() == null && entry.getArtistId() == null)) && !Util.isOffline(context)) { - menu.removeItem(R.id.album_menu_show_artist); - } recreateContextMenu(menu); } @@ -388,6 +384,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section } } + @Override + protected boolean isShowArtistEnabled() { + return albumListType != null; + } + private void load(boolean refresh) { if(refreshListing) { refresh = true; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java index a7896763..606c79e6 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -272,7 +272,6 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR menu.removeItem(R.id.menu_rate); } } - menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } else if(!entry.isVideo()) { if(Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_context_offline, menu); @@ -284,7 +283,6 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR menu.removeItem(R.id.bookmark_menu_delete); } } - menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } else { if(Util.isOffline(context)) { menuInflater.inflate(R.menu.select_video_context_offline, menu); @@ -293,6 +291,15 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR menuInflater.inflate(R.menu.select_video_context, menu); } } + + MenuItem starMenu = menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star); + if(starMenu != null) { + starMenu.setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); + } + + if(!isShowArtistEnabled() || entry.getParent() == null || (Util.isTagBrowsing(context) && entry.getArtistId() == null)) { + menu.setGroupVisible(R.id.hide_show_artist, false); + } } else if(selected instanceof Artist) { Artist artist = (Artist) selected; if(Util.isOffline(context)) { @@ -1908,6 +1915,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR UpdateHelper.toggleStarred(context, getSelectedEntries()); } + protected boolean isShowArtistEnabled() { + return false; + } + public abstract class RecursiveLoader extends LoadingTask { protected MusicService musicService; protected static final int MAX_SONGS = 500; diff --git a/app/src/main/res/menu/select_album_context.xml b/app/src/main/res/menu/select_album_context.xml index e4a901ac..0415da3c 100644 --- a/app/src/main/res/menu/select_album_context.xml +++ b/app/src/main/res/menu/select_album_context.xml @@ -1,6 +1,5 @@ - @@ -47,9 +46,11 @@ android:title="@string/menu.delete_cache"/> - + + + + + + + - - + + android:title="@string/common.info"/> + + + + + + + + + + + + +