aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-07-29 17:32:30 -0700
committerScott Jackson <daneren2005@gmail.com>2015-07-29 17:32:30 -0700
commit526dc8793697688bd65cda974716ba114161c70a (patch)
treebdbf1611c803cd1e5e4d74c3e75bd75d5a02523e /app
parentc613b6474970000495057121e44abbdc913a8b2a (diff)
downloaddsub-526dc8793697688bd65cda974716ba114161c70a.tar.gz
dsub-526dc8793697688bd65cda974716ba114161c70a.tar.bz2
dsub-526dc8793697688bd65cda974716ba114161c70a.zip
Update Multi selection to work from different fragments
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java22
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java107
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java186
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/MenuUtil.java55
-rw-r--r--app/src/main/res/menu/abstract_top_menu.xml2
-rw-r--r--app/src/main/res/menu/main.xml4
-rw-r--r--app/src/main/res/menu/multiselect_media.xml47
-rw-r--r--app/src/main/res/menu/multiselect_media_offline.xml31
-rw-r--r--app/src/main/res/menu/search.xml2
-rw-r--r--app/src/main/res/menu/select_artist.xml4
-rw-r--r--app/src/main/res/menu/select_podcasts.xml2
-rw-r--r--app/src/main/res/menu/select_song.xml8
15 files changed, 340 insertions, 140 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
index a0008a73..78ef13ed 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
@@ -17,15 +17,19 @@ package github.daneren2005.dsub.adapter;
import android.content.Context;
import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
+import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.MusicDirectory.Entry;
import github.daneren2005.dsub.util.ImageLoader;
+import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.AlbumView;
import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
@@ -41,6 +45,7 @@ public class EntryGridAdapter extends SectionAdapter<Entry> {
private ImageLoader imageLoader;
private boolean largeAlbums;
private boolean showArtist = false;
+ private boolean removeFromPlaylist = false;
private View header;
public EntryGridAdapter(Context context, List<Entry> entries, ImageLoader imageLoader, boolean largeCell) {
@@ -120,4 +125,21 @@ public class EntryGridAdapter extends SectionAdapter<Entry> {
sections.get(0).remove(index);
notifyItemRemoved(index);
}
+
+ public void setRemoveFromPlaylist(boolean removeFromPlaylist) {
+ this.removeFromPlaylist = removeFromPlaylist;
+ }
+
+ @Override
+ public void onCreateActionModeMenu(Menu menu, MenuInflater menuInflater) {
+ if(Util.isOffline(context)) {
+ menuInflater.inflate(R.menu.multiselect_media_offline, menu);
+ } else {
+ menuInflater.inflate(R.menu.multiselect_media, menu);
+ }
+
+ if(!removeFromPlaylist) {
+ menu.removeItem(R.id.menu_remove_playlist);
+ }
+ }
}
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
index 3f6086d5..75f4a053 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
@@ -39,6 +39,7 @@ import java.util.List;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
+import github.daneren2005.dsub.util.MenuUtil;
import github.daneren2005.dsub.view.BasicHeaderView;
import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.view.UpdateView.UpdateViewHolder;
@@ -383,6 +384,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
public void setChecked(UpdateView updateView, boolean checked) {
updateView.setChecked(checked);
}
+ public void onCreateActionModeMenu(Menu menu, MenuInflater menuInflater) {}
private void startActionMode(final UpdateView.UpdateViewHolder<T> holder) {
final UpdateView<T> updateView = holder.getUpdateView();
@@ -394,7 +396,8 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
currentActionMode = mode;
- fragmentActivity.onCreateOptionsMenu(menu);
+ onCreateActionModeMenu(menu, mode.getMenuInflater());
+ MenuUtil.hideMenuItems(context, menu);
T item = holder.getItem();
selected.add(item);
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index 7b55c5c3..f9abad9a 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -584,7 +584,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
menu.findItem(R.id.menu_show_artist).setVisible(false);
}
- hideMenuItems(menu, updateView);
+ MenuUtil.hideMenuItems(context, menu);
}
@Override
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index e326e3e2..f45c1af9 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -31,6 +31,7 @@ import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.MusicService;
+import github.daneren2005.dsub.util.MenuUtil;
import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.Util;
@@ -46,7 +47,7 @@ public class SelectBookmarkFragment extends SelectRecyclerFragment<MusicDirector
@Override
public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView<MusicDirectory.Entry> updateView, MusicDirectory.Entry item) {
menuInflater.inflate(R.menu.select_bookmark_context, menu);
- hideMenuItems(menu, updateView);
+ MenuUtil.hideMenuItems(context, menu);
}
@Override
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 c41a4ea5..3b6a687a 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -274,37 +274,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.menu_play_now:
- playNow(false, false);
- return true;
- case R.id.menu_play_last:
- playNow(false, true);
- return true;
- case R.id.menu_play_next:
- playNow(false, true, true);
- return true;
- case R.id.menu_shuffle:
- playNow(true, false);
- return true;
- case R.id.menu_download:
- downloadBackground(false);
- entryGridAdapter.clearSelected();
- return true;
- case R.id.menu_cache:
- downloadBackground(true);
- entryGridAdapter.clearSelected();
- return true;
- case R.id.menu_delete:
- delete();
- entryGridAdapter.clearSelected();
- return true;
- case R.id.menu_add_playlist:
- List<Entry> songs = getSelectedEntries();
- if(songs.isEmpty()) {
- songs = entries;
- }
- addToPlaylist(songs);
- return true;
case R.id.menu_remove_playlist:
removeFromPlaylist(playlistId, playlistName, getSelectedIndexes());
return true;
@@ -683,6 +652,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
}
}
+ @Override
+ protected SectionAdapter<Entry> getCurrentAdapter() {
+ return entryGridAdapter;
+ }
+
private void finishLoading() {
boolean validData = !entries.isEmpty() || !albums.isEmpty();
if(!validData) {
@@ -695,6 +669,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
if(albumListType == null || "starred".equals(albumListType)) {
entryGridAdapter = new EntryGridAdapter(context, entries, getImageLoader(), largeAlbums);
+ entryGridAdapter.setRemoveFromPlaylist(playlistId != null);
} else {
entryGridAdapter = new EntryInfiniteGridAdapter(context, entries, getImageLoader(), largeAlbums);
@@ -805,10 +780,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
}
}
- private void playNow(final boolean shuffle, final boolean append) {
- playNow(shuffle, append, false);
- }
- private void playNow(final boolean shuffle, final boolean append, final boolean playNext) {
+ @Override
+ protected void playNow(final boolean shuffle, final boolean append, final boolean playNext) {
List<Entry> songs = getSelectedEntries();
if(!songs.isEmpty()) {
download(songs, append, false, !append, playNext, shuffle);
@@ -830,10 +803,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
}
}
- private List<Entry> getSelectedEntries() {
- return entryGridAdapter.getSelected();
- }
-
private List<Integer> getSelectedIndexes() {
List<Entry> selected = entryGridAdapter.getSelected();
List<Integer> indexes = new ArrayList<Integer>();
@@ -845,55 +814,13 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
return indexes;
}
- private void download(final List<Entry> entries, final boolean append, final boolean save, final boolean autoplay, final boolean playNext, final boolean shuffle) {
- if (getDownloadService() == null) {
- return;
- }
-
- warnIfStorageUnavailable();
-
- // Conditions for using play now button
- if(!append && !save && autoplay && !playNext && !shuffle) {
- // Call playNow which goes through and tries to use bookmark information
- playNow(entries, playlistName, playlistId);
- return;
- }
-
- RecursiveLoader onValid = new RecursiveLoader(context) {
- @Override
- protected Boolean doInBackground() throws Throwable {
- if (!append) {
- getDownloadService().clear();
- }
- getSongsRecursively(entries, songs);
-
- DownloadService downloadService = getDownloadService();
- downloadService.download(songs, save, autoplay, playNext, shuffle);
- if (playlistName != null) {
- downloadService.setSuggestedPlaylistName(playlistName, playlistId);
- } else {
- downloadService.setSuggestedPlaylistName(null, null);
- }
- return null;
- }
-
- @Override
- protected void done(Boolean result) {
- if (autoplay) {
- context.openNowPlaying();
- } else if (save) {
- Util.toast(context,
- context.getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
- } else if (append) {
- Util.toast(context,
- context.getResources().getQuantityString(R.plurals.select_album_n_songs_added, songs.size(), songs.size()));
- }
- }
- };
-
+ @Override
+ protected void executeOnValid(RecursiveLoader onValid) {
checkLicenseAndTrialPeriod(onValid);
}
- private void downloadBackground(final boolean save) {
+
+ @Override
+ protected void downloadBackground(final boolean save) {
List<Entry> songs = getSelectedEntries();
if(playlistId != null) {
songs = entries;
@@ -906,7 +833,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
downloadBackground(save, songs);
}
}
- private void downloadBackground(final boolean save, final List<Entry> entries) {
+ @Override
+ protected void downloadBackground(final boolean save, final List<Entry> entries) {
if (getDownloadService() == null) {
return;
}
@@ -929,7 +857,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
checkLicenseAndTrialPeriod(onValid);
}
- private void delete() {
+ @Override
+ protected void delete() {
List<Entry> songs = getSelectedEntries();
if(songs.isEmpty()) {
for(Entry entry: entries) {
@@ -1030,7 +959,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
public void onClick(DialogInterface dialog, int which) {
new LoadingTask<Void>(context, true) {
@Override
- protected Void doInBackground() throws Throwable {
+ protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
musicService.deletePodcastEpisode(episode.getEpisodeId(), episode.getParent(), null, context);
if (getDownloadService() != null) {
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 6925b2da..8dcac6ff 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -73,6 +73,7 @@ import github.daneren2005.dsub.service.ServerTooOldException;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.ImageLoader;
+import github.daneren2005.dsub.util.MenuUtil;
import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.LoadingTask;
@@ -174,10 +175,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.menu_shuffle:
+ case R.id.menu_global_shuffle:
onShuffleRequested();
return true;
- case R.id.menu_search:
+ case R.id.menu_global_search:
context.onSearchRequested();
return true;
case R.id.menu_exit:
@@ -186,6 +187,35 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
case R.id.menu_refresh:
refresh();
return true;
+ case R.id.menu_play_now:
+ playNow(false, false);
+ return true;
+ case R.id.menu_play_last:
+ playNow(false, true);
+ return true;
+ case R.id.menu_play_next:
+ playNow(false, true, true);
+ return true;
+ case R.id.menu_shuffle:
+ playNow(true, false);
+ return true;
+ case R.id.menu_download:
+ downloadBackground(false);
+ clearSelected();
+ return true;
+ case R.id.menu_cache:
+ downloadBackground(true);
+ clearSelected();
+ return true;
+ case R.id.menu_delete:
+ delete();
+ clearSelected();
+ return true;
+ case R.id.menu_add_playlist:
+ List<Entry> songs = getSelectedEntries();
+ addToPlaylist(songs);
+ clearSelected();
+ return true;
}
return false;
@@ -249,37 +279,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}
- hideMenuItems(menu, updateView);
- }
-
- protected void hideMenuItems(Menu menu, UpdateView updateView) {
- if(!ServerInfo.checkServerVersion(context, "1.8")) {
- menu.setGroupVisible(R.id.server_1_8, false);
- menu.setGroupVisible(R.id.hide_star, false);
- }
- if(!ServerInfo.checkServerVersion(context, "1.9")) {
- menu.setGroupVisible(R.id.server_1_9, false);
- }
- if(!ServerInfo.checkServerVersion(context, "1.10.1")) {
- menu.setGroupVisible(R.id.server_1_10, false);
- }
-
- SharedPreferences prefs = Util.getPreferences(context);
- if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) {
- menu.setGroupVisible(R.id.hide_play_next, false);
- }
- if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) {
- menu.setGroupVisible(R.id.hide_play_last, false);
- }
- if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) {
- menu.setGroupVisible(R.id.hide_star, false);
- }
- if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_SHARED, true) || !UserUtil.canShare()) {
- menu.setGroupVisible(R.id.hide_share, false);
- }
- if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true)) {
- menu.setGroupVisible(R.id.hide_rating, false);
- }
+ MenuUtil.hideMenuItems(context, menu);
}
protected void recreateContextMenu(Menu menu) {
@@ -717,6 +717,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
public void toggleStarred(Entry entry) {
toggleStarred(entry, null);
}
+
public void toggleStarred(final Entry entry, final OnStarChange onStarChange) {
final boolean starred = !entry.isStarred();
entry.setStarred(starred);
@@ -822,9 +823,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
protected void downloadPlaylist(final String id, final String name, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background) {
downloadRecursively(id, name, false, save, append, autoplay, shuffle, background);
}
+
protected void downloadRecursively(final String id, final String name, final boolean isDirectory, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background) {
downloadRecursively(id, name, isDirectory, save, append, autoplay, shuffle, background, false);
}
+
protected void downloadRecursively(final String id, final String name, final boolean isDirectory, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext) {
new RecursiveLoader(context) {
@Override
@@ -1360,6 +1363,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
deleteRecursively(FileUtil.getAlbumDirectory(context, album));
}
+
public void deleteRecursively(final File dir) {
if(dir == null) {
return;
@@ -1416,6 +1420,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
replaceFragment(fragment, true);
}
+
public void showAlbum(Entry entry) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
@@ -1480,6 +1485,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
protected void playBookmark(List<Entry> songs, Entry song) {
playBookmark(songs, song, null, null);
}
+
protected void playBookmark(final List<Entry> songs, final Entry song, final String playlistName, final String playlistId) {
final Integer position = song.getBookmark().getPosition();
@@ -1567,9 +1573,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
Entry selected = entries.isEmpty() ? null : entries.get(0);
playNow(entries, selected, position, playlistName, playlistId);
}
+
protected void playNow(List<Entry> entries, Entry song, int position) {
playNow(entries, song, position, null, null);
}
+
protected void playNow(final List<Entry> entries, final Entry song, final int position, final String playlistName, final String playlistId) {
new LoadingTask<Void>(context) {
@Override
@@ -1716,6 +1724,118 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}.execute();
}
+ protected SectionAdapter<Entry> getCurrentAdapter() { return null; }
+ protected void clearSelected() {
+ if(getCurrentAdapter() != null) {
+ getCurrentAdapter().clearSelected();
+ }
+ }
+ protected List<Entry> getSelectedEntries() {
+ return getCurrentAdapter().getSelected();
+ }
+
+ protected void playNow(final boolean shuffle, final boolean append) {
+ playNow(shuffle, append, false);
+ }
+ protected void playNow(final boolean shuffle, final boolean append, final boolean playNext) {
+ List<Entry> songs = getSelectedEntries();
+ if(!songs.isEmpty()) {
+ download(songs, append, false, !append, playNext, shuffle);
+ clearSelected();
+ }
+ }
+
+ protected void download(List<Entry> entries, boolean append, boolean save, boolean autoplay, boolean playNext, boolean shuffle) {
+ download(entries, append, save, autoplay, playNext, shuffle, null, null);
+ }
+ protected void download(final List<Entry> entries, final boolean append, final boolean save, final boolean autoplay, final boolean playNext, final boolean shuffle, final String playlistName, final String playlistId) {
+ final DownloadService downloadService = getDownloadService();
+ if (downloadService == null) {
+ return;
+ }
+ warnIfStorageUnavailable();
+
+ // Conditions for using play now button
+ if(!append && !save && autoplay && !playNext && !shuffle) {
+ // Call playNow which goes through and tries to use bookmark information
+ playNow(entries, playlistName, playlistId);
+ return;
+ }
+
+ RecursiveLoader onValid = new RecursiveLoader(context) {
+ @Override
+ protected Boolean doInBackground() throws Throwable {
+ if (!append) {
+ getDownloadService().clear();
+ }
+ getSongsRecursively(entries, songs);
+
+ downloadService.download(songs, save, autoplay, playNext, shuffle);
+ if (playlistName != null) {
+ downloadService.setSuggestedPlaylistName(playlistName, playlistId);
+ } else {
+ downloadService.setSuggestedPlaylistName(null, null);
+ }
+ return null;
+ }
+
+ @Override
+ protected void done(Boolean result) {
+ if (autoplay) {
+ context.openNowPlaying();
+ } else if (save) {
+ Util.toast(context,
+ context.getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
+ } else if (append) {
+ Util.toast(context,
+ context.getResources().getQuantityString(R.plurals.select_album_n_songs_added, songs.size(), songs.size()));
+ }
+ }
+ };
+
+ executeOnValid(onValid);
+ }
+ protected void executeOnValid(RecursiveLoader onValid) {
+ onValid.execute();
+ }
+ protected void downloadBackground(final boolean save) {
+ List<Entry> songs = getSelectedEntries();
+ if(!songs.isEmpty()) {
+ downloadBackground(save, songs);
+ }
+ }
+
+ protected void downloadBackground(final boolean save, final List<Entry> entries) {
+ if (getDownloadService() == null) {
+ return;
+ }
+
+ warnIfStorageUnavailable();
+ new RecursiveLoader(context) {
+ @Override
+ protected Boolean doInBackground() throws Throwable {
+ getSongsRecursively(entries, songs);
+ getDownloadService().downloadBackground(songs, save);
+ return null;
+ }
+
+ @Override
+ protected void done(Boolean result) {
+ Util.toast(context, context.getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
+ }
+ }.execute();
+ }
+
+ protected void delete() {
+ List<Entry> songs = getSelectedEntries();
+ if(!songs.isEmpty()) {
+ DownloadService downloadService = getDownloadService();
+ if(downloadService != null) {
+ downloadService.delete(songs);
+ }
+ }
+ }
+
protected abstract class EntryInstanceUpdater {
private Entry entry;
diff --git a/app/src/main/java/github/daneren2005/dsub/util/MenuUtil.java b/app/src/main/java/github/daneren2005/dsub/util/MenuUtil.java
new file mode 100644
index 00000000..cd899bb4
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/util/MenuUtil.java
@@ -0,0 +1,55 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2015 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.view.Menu;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.ServerInfo;
+
+public final class MenuUtil {
+ public static void hideMenuItems(Context context, Menu menu) {
+ if(!ServerInfo.checkServerVersion(context, "1.8")) {
+ menu.setGroupVisible(R.id.server_1_8, false);
+ menu.setGroupVisible(R.id.hide_star, false);
+ }
+ if(!ServerInfo.checkServerVersion(context, "1.9")) {
+ menu.setGroupVisible(R.id.server_1_9, false);
+ }
+ if(!ServerInfo.checkServerVersion(context, "1.10.1")) {
+ menu.setGroupVisible(R.id.server_1_10, false);
+ }
+
+ SharedPreferences prefs = Util.getPreferences(context);
+ if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_NEXT, true)) {
+ menu.setGroupVisible(R.id.hide_play_next, false);
+ }
+ if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_PLAY_LAST, true)) {
+ menu.setGroupVisible(R.id.hide_play_last, false);
+ }
+ if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) {
+ menu.setGroupVisible(R.id.hide_star, false);
+ }
+ if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_SHARED, true) || !UserUtil.canShare()) {
+ menu.setGroupVisible(R.id.hide_share, false);
+ }
+ if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true)) {
+ menu.setGroupVisible(R.id.hide_rating, false);
+ }
+ }
+}
diff --git a/app/src/main/res/menu/abstract_top_menu.xml b/app/src/main/res/menu/abstract_top_menu.xml
index 22499ae9..7c8d414d 100644
--- a/app/src/main/res/menu/abstract_top_menu.xml
+++ b/app/src/main/res/menu/abstract_top_menu.xml
@@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_search"
+ android:id="@+id/menu_global_search"
android:icon="?attr/search"
android:title="@string/menu.search"
compat:showAsAction="always|withText"/>
diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml
index 549c5fb6..0970c8ce 100644
--- a/app/src/main/res/menu/main.xml
+++ b/app/src/main/res/menu/main.xml
@@ -2,13 +2,13 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_search"
+ android:id="@+id/menu_global_search"
android:icon="?attr/search"
android:title="@string/menu.search"
compat:showAsAction="always|withText"/>
<item
- android:id="@+id/menu_shuffle"
+ android:id="@+id/menu_global_shuffle"
android:icon="?attr/shuffle"
android:title="@string/menu.shuffle"
compat:showAsAction="always|withText"/>
diff --git a/app/src/main/res/menu/multiselect_media.xml b/app/src/main/res/menu/multiselect_media.xml
new file mode 100644
index 00000000..75865a14
--- /dev/null
+++ b/app/src/main/res/menu/multiselect_media.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:compat="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/menu_play_now"
+ android:icon="?attr/actionbar_start"
+ android:title="@string/menu.play"
+ compat:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/menu_shuffle"
+ android:icon="?attr/shuffle"
+ android:title="@string/menu.shuffle"
+ compat:showAsAction="ifRoom|withText"/>
+
+ <item
+ android:id="@+id/menu_download"
+ android:title="@string/common.download"/>
+
+ <item
+ android:id="@+id/menu_cache"
+ android:title="@string/common.pin"/>
+
+ <item
+ android:id="@+id/menu_delete"
+ android:title="@string/menu.delete_cache"/>
+
+ <item
+ android:id="@+id/menu_add_playlist"
+ android:title="@string/menu.add_playlist"/>
+
+ <item
+ android:id="@+id/menu_remove_playlist"
+ android:title="@string/menu.remove_playlist"/>
+
+ <group android:id="@+id/hide_play_next">
+ <item
+ android:id="@+id/menu_play_next"
+ android:title="@string/common.play_next"/>
+ </group>
+
+ <group android:id="@+id/hide_play_last">
+ <item
+ android:id="@+id/menu_play_last"
+ android:title="@string/menu.play_last"/>
+ </group>
+</menu>
diff --git a/app/src/main/res/menu/multiselect_media_offline.xml b/app/src/main/res/menu/multiselect_media_offline.xml
new file mode 100644
index 00000000..5587c106
--- /dev/null
+++ b/app/src/main/res/menu/multiselect_media_offline.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:compat="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/menu_play_now"
+ android:icon="?attr/actionbar_start"
+ android:title="@string/menu.play"
+ compat:showAsAction="always|withText"/>
+
+ <item
+ android:id="@+id/menu_shuffle"
+ android:icon="?attr/shuffle"
+ android:title="@string/menu.shuffle"
+ compat:showAsAction="ifRoom|withText"/>
+
+ <item
+ android:id="@+id/menu_delete"
+ android:title="@string/menu.delete_cache"/>
+
+ <group android:id="@+id/hide_play_next">
+ <item
+ android:id="@+id/menu_play_next"
+ android:title="@string/common.play_next"/>
+ </group>
+
+ <group android:id="@+id/hide_play_last">
+ <item
+ android:id="@+id/menu_play_last"
+ android:title="@string/menu.play_last"/>
+ </group>
+</menu>
diff --git a/app/src/main/res/menu/search.xml b/app/src/main/res/menu/search.xml
index cab9c4f6..e9377d68 100644
--- a/app/src/main/res/menu/search.xml
+++ b/app/src/main/res/menu/search.xml
@@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_search"
+ android:id="@+id/menu_global_search"
android:icon="?attr/search"
android:title="@string/menu.search"
compat:showAsAction="ifRoom|withText"/>
diff --git a/app/src/main/res/menu/select_artist.xml b/app/src/main/res/menu/select_artist.xml
index 603f0a3b..66ba37ba 100644
--- a/app/src/main/res/menu/select_artist.xml
+++ b/app/src/main/res/menu/select_artist.xml
@@ -2,13 +2,13 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_shuffle"
+ android:id="@+id/menu_global_shuffle"
android:icon="?attr/shuffle"
android:title="@string/menu.shuffle"
compat:showAsAction="always|withText"/>
<item
- android:id="@+id/menu_search"
+ android:id="@+id/menu_global_search"
android:icon="?attr/search"
android:title="@string/menu.search"
compat:showAsAction="ifRoom|withText"/>
diff --git a/app/src/main/res/menu/select_podcasts.xml b/app/src/main/res/menu/select_podcasts.xml
index f30429ce..41ad62fa 100644
--- a/app/src/main/res/menu/select_podcasts.xml
+++ b/app/src/main/res/menu/select_podcasts.xml
@@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_search"
+ android:id="@+id/menu_global_search"
android:icon="?attr/search"
android:title="@string/menu.search"
compat:showAsAction="always|withText"/>
diff --git a/app/src/main/res/menu/select_song.xml b/app/src/main/res/menu/select_song.xml
index d47ad933..5718866a 100644
--- a/app/src/main/res/menu/select_song.xml
+++ b/app/src/main/res/menu/select_song.xml
@@ -32,14 +32,6 @@
<item
android:id="@+id/menu_delete"
android:title="@string/menu.delete_cache"/>
-
- <item
- android:id="@+id/menu_add_playlist"
- android:title="@string/menu.add_playlist"/>
-
- <item
- android:id="@+id/menu_remove_playlist"
- android:title="@string/menu.remove_playlist"/>
<group android:id="@+id/hide_play_next">
<item