From 7e59089c7326484217c81f3f411e599e018297cf Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 25 Jun 2013 22:13:35 -0700 Subject: Add starring to library context menus --- subsonic-android/res/menu/select_album_context_offline.xml | 4 ++++ subsonic-android/res/menu/select_song_context_offline.xml | 4 ++++ .../src/github/daneren2005/dsub/fragments/SubsonicFragment.java | 2 +- .../src/github/daneren2005/dsub/service/RESTMusicService.java | 5 ++++- subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java | 4 ++-- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/subsonic-android/res/menu/select_album_context_offline.xml b/subsonic-android/res/menu/select_album_context_offline.xml index af9272c2..70cf9da9 100644 --- a/subsonic-android/res/menu/select_album_context_offline.xml +++ b/subsonic-android/res/menu/select_album_context_offline.xml @@ -18,4 +18,8 @@ + + \ No newline at end of file diff --git a/subsonic-android/res/menu/select_song_context_offline.xml b/subsonic-android/res/menu/select_song_context_offline.xml index 8813d4a8..d19eaa70 100644 --- a/subsonic-android/res/menu/select_song_context_offline.xml +++ b/subsonic-android/res/menu/select_song_context_offline.xml @@ -24,4 +24,8 @@ + + diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 100fcbc6..8eb9e926 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -167,7 +167,7 @@ public class SubsonicFragment extends SherlockFragment { } } - if (!Util.isOffline(context) && !entry.isVideo()) { + if (!entry.isVideo()) { 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(selected instanceof Artist) { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index e5e41d00..ac564f29 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -939,11 +939,14 @@ public class RESTMusicService implements MusicService { } else { String search = offline.getString(Constants.OFFLINE_STAR_SEARCH + i, ""); try{ - SearchCritera critera = new SearchCritera(search, 0, 0, 1); + SearchCritera critera = new SearchCritera(search, 0, 1, 1); SearchResult result = searchNew(critera, context, progressListener); if(result.getSongs().size() == 1){ Log.i(TAG, "Query '" + search + "' returned song " + result.getSongs().get(0).getTitle() + " by " + result.getSongs().get(0).getArtist() + " with id " + result.getSongs().get(0).getId()); setStarred(result.getSongs().get(0).getId(), starred, context, progressListener); + } else if(result.getAlbums().size() == 1){ + Log.i(TAG, "Query '" + search + "' returned song " + result.getAlbums().get(0).getTitle() + " by " + result.getAlbums().get(0).getArtist() + " with id " + result.getAlbums().get(0).getId()); + setStarred(result.getAlbums().get(0).getId(), starred, context, progressListener); } else{ throw new Exception("Song not found on server"); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java b/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java index ff6eb71b..3a7b895e 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java @@ -74,7 +74,7 @@ public class AlbumView extends UpdateView { artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE); imageLoader.loadImage(coverArtView, album, false, true); - starButton.setVisibility((Util.isOffline(getContext()) || !album.isStarred()) ? View.GONE : View.VISIBLE); + starButton.setVisibility(!album.isStarred() ? View.GONE : View.VISIBLE); starButton.setFocusable(false); update(); @@ -82,7 +82,7 @@ public class AlbumView extends UpdateView { @Override protected void update() { - starButton.setVisibility((Util.isOffline(getContext()) || !album.isStarred()) ? View.GONE : View.VISIBLE); + starButton.setVisibility(!album.isStarred() ? View.GONE : View.VISIBLE); File file = FileUtil.getAlbumDirectory(context, album); if(file.exists()) { moreButton.setImageResource(R.drawable.list_item_more_shaded); -- cgit v1.2.3