diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-07-27 18:01:58 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-07-27 18:01:58 -0700 |
commit | 7c3e7ebd7938ab05c375f5c64ceb85518b355656 (patch) | |
tree | 3d0982cbf4f122a1acf7d4066bb41ee3c68d83e7 /app/src/main/java/github | |
parent | 4de0a87270bc3801041f6b4c9cd52e4c3bcd2e93 (diff) | |
download | dsub-7c3e7ebd7938ab05c375f5c64ceb85518b355656.tar.gz dsub-7c3e7ebd7938ab05c375f5c64ceb85518b355656.tar.bz2 dsub-7c3e7ebd7938ab05c375f5c64ceb85518b355656.zip |
Fixes #714: Add different options for action when pressing a song
Diffstat (limited to 'app/src/main/java/github')
11 files changed, 90 insertions, 90 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java index c9b94c9a..e971bfb6 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -127,19 +127,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i if (entry.isVideo()) { playVideo(entry); } else { - List<Entry> songs = new ArrayList<Entry>(); - - if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, true)) { - for (Entry song : entries) { - if (!song.isDirectory() && !song.isVideo()) { - songs.add(song); - } - } - playNow(songs, entry, 0); - } else { - songs.add(entry); - playNow(songs); - } + onSongPress(entries, entry); } } } 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 03c6663a..c320f3c1 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -91,7 +91,8 @@ public class SelectBookmarkFragment extends SelectRecyclerFragment<MusicDirector return; } - if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, true) && ((!Util.isTagBrowsing(context) && bookmark.getParent() != null) || (Util.isTagBrowsing(context) && bookmark.getAlbumId() != null)) && !bookmark.isPodcast()) { + boolean allowPlayAll = ((!Util.isTagBrowsing(context) && bookmark.getParent() != null) || (Util.isTagBrowsing(context) && bookmark.getAlbumId() != null)) && !bookmark.isPodcast(); + if(allowPlayAll && "all".equals(Util.getSongPressAction(context))) { new RecursiveLoader(context) { @Override protected Boolean doInBackground() throws Throwable { @@ -111,7 +112,7 @@ public class SelectBookmarkFragment extends SelectRecyclerFragment<MusicDirector } }.execute(); } else { - playNow(Arrays.asList(bookmark), bookmark, bookmark.getBookmark().getPosition()); + onSongPress(Arrays.asList(bookmark), bookmark, bookmark.getBookmark().getPosition(), 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 de74d0ed..05a46b9d 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -359,21 +359,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section return; } - playNow(Arrays.asList(entry)); + onSongPress(Arrays.asList(entry), entry, false); } else { - List<Entry> songs = new ArrayList<Entry>(); - - if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, true) && (albumListType == null || "starred".equals(albumListType))) { - for(Entry song: entries) { - if(!song.isDirectory() && !song.isVideo()) { - songs.add(song); - } - } - playNow(songs, entry, 0); - } else { - songs.add(entry); - playNow(songs); - } + onSongPress(entries, entry, albumListType == null || "starred".equals(albumListType)); } } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java index 2e2a16b3..9011b4c5 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java @@ -239,7 +239,7 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable> return; } - playNow(Arrays.asList((MusicDirectory.Entry) episode)); + onSongPress(Arrays.asList((MusicDirectory.Entry) episode), episode, false); } } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java index b2ac715a..ad064d01 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java @@ -78,6 +78,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared private ListPreference pauseDisconnect; private Preference addServerPreference; private PreferenceCategory serversCategory; + private ListPreference songPressAction; private ListPreference videoPlayer; private ListPreference syncInterval; private CheckBoxPreference syncEnabled; @@ -217,6 +218,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared serversCategory = (PreferenceCategory) this.findPreference(Constants.PREFERENCES_KEY_SERVER_KEY); addServerPreference = this.findPreference(Constants.PREFERENCES_KEY_SERVER_ADD); videoPlayer = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_VIDEO_PLAYER); + songPressAction = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_SONG_PRESS_ACTION); syncInterval = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_SYNC_INTERVAL); syncEnabled = (CheckBoxPreference) this.findPreference(Constants.PREFERENCES_KEY_SYNC_ENABLED); syncWifi = (CheckBoxPreference) this.findPreference(Constants.PREFERENCES_KEY_SYNC_WIFI); @@ -384,6 +386,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared keepPlayedCount.setSummary(keepPlayedCount.getEntry()); tempLoss.setSummary(tempLoss.getEntry()); pauseDisconnect.setSummary(pauseDisconnect.getEntry()); + songPressAction.setSummary(songPressAction.getEntry()); videoPlayer.setSummary(videoPlayer.getEntry()); if(replayGain.isChecked()) { 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 ab3db50f..f6e65c0e 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -1663,6 +1663,33 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR dialog.show(); } + protected void onSongPress(List<Entry> entries, Entry entry) { + onSongPress(entries, entry, 0, true); + } + protected void onSongPress(List<Entry> entries, Entry entry, boolean allowPlayAll) { + onSongPress(entries, entry, 0, allowPlayAll); + } + protected void onSongPress(List<Entry> entries, Entry entry, int position, boolean allowPlayAll) { + List<Entry> songs = new ArrayList<Entry>(); + + String songPressAction = Util.getSongPressAction(context); + if("all".equals(songPressAction) && allowPlayAll) { + for(Entry song: entries) { + if(!song.isDirectory() && !song.isVideo()) { + songs.add(song); + } + } + playNow(songs, entry, position); + } else if("next".equals(songPressAction)) { + getDownloadService().download(Arrays.asList(entry), false, false, true, false); + } else if("last".equals(songPressAction)) { + getDownloadService().download(Arrays.asList(entry), false, false, false, false); + } else { + songs.add(entry); + playNow(songs); + } + } + protected void playNow(List<Entry> entries) { playNow(entries, null, null); } diff --git a/app/src/main/java/github/daneren2005/dsub/updates/Updater.java b/app/src/main/java/github/daneren2005/dsub/updates/Updater.java index a2870941..bc053b1e 100644 --- a/app/src/main/java/github/daneren2005/dsub/updates/Updater.java +++ b/app/src/main/java/github/daneren2005/dsub/updates/Updater.java @@ -37,13 +37,17 @@ public class Updater { protected Context context; public Updater(int version) { + // 5.2 should show as 520 instead of 52 + if(version < 100) { + version *= 10; + } this.version = version; } public void checkUpdates(Context context) { this.context = context; List<Updater> updaters = new ArrayList<Updater>(); - updaters.add(new Updater403()); + updaters.add(new UpdaterSongPress()); SharedPreferences prefs = Util.getPreferences(context); int lastVersion = prefs.getInt(Constants.LAST_VERSION, 0); diff --git a/app/src/main/java/github/daneren2005/dsub/updates/Updater403.java b/app/src/main/java/github/daneren2005/dsub/updates/Updater403.java deleted file mode 100644 index 4f2cbf43..00000000 --- a/app/src/main/java/github/daneren2005/dsub/updates/Updater403.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - 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 2009 (C) Sindre Mehus - */ -package github.daneren2005.dsub.updates; - -import android.content.Context; -import android.util.Log; -import github.daneren2005.dsub.updates.Updater; -import github.daneren2005.dsub.util.Constants; -import github.daneren2005.dsub.util.FileUtil; -import java.io.File; - -/** - * - * @author Scott - */ -public class Updater403 extends Updater { - public Updater403() { - super(403); - TAG = Updater403.class.getSimpleName(); - } - - @Override - public void update(Context context) { - // Rename cover.jpeg to cover.jpg - Log.i(TAG, "Running Updater403: updating cover.jpg to albumart.jpg"); - File dir = FileUtil.getMusicDirectory(context); - if(dir != null) { - moveArt(dir); - } - } - - private void moveArt(File dir) { - for(File file: dir.listFiles()) { - if(file.isDirectory()) { - moveArt(file); - } else if("cover.jpg".equals(file.getName()) || "cover.jpeg".equals(file.getName())) { - File renamed = new File(dir, Constants.ALBUM_ART_FILE); - file.renameTo(renamed); - } - } - } -} diff --git a/app/src/main/java/github/daneren2005/dsub/updates/UpdaterSongPress.java b/app/src/main/java/github/daneren2005/dsub/updates/UpdaterSongPress.java new file mode 100644 index 00000000..7efa18e4 --- /dev/null +++ b/app/src/main/java/github/daneren2005/dsub/updates/UpdaterSongPress.java @@ -0,0 +1,42 @@ +/* + 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 2016 (C) Scott Jackson +*/ + +package github.daneren2005.dsub.updates; + +import android.content.Context; +import android.content.SharedPreferences; + +import github.daneren2005.dsub.util.Constants; +import github.daneren2005.dsub.util.Util; + +public class UpdaterSongPress extends Updater { + public UpdaterSongPress() { + super(521); + TAG = this.getClass().getSimpleName(); + } + + @Override + public void update(Context context) { + SharedPreferences prefs = Util.getPreferences(context); + boolean playNowAfter = prefs.getBoolean("playNowAfter", true); + + // Migrate the old preference so behavior stays the same + if(playNowAfter == false) { + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(Constants.PREFERENCES_KEY_SONG_PRESS_ACTION, "single"); + editor.commit(); + } + } +} diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java index c8c580ff..4109ea67 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java @@ -148,7 +148,8 @@ public final class Constants { public static final String PREFERENCES_KEY_BROWSE_TAGS = "browseTags"; public static final String PREFERENCES_KEY_OPEN_TO_TAB = "openToTab"; public static final String PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE = "overrideSystemLanguage"; - public static final String PREFERENCES_KEY_PLAY_NOW_AFTER = "playNowAfter"; + // public static final String PREFERENCES_KEY_PLAY_NOW_AFTER = "playNowAfter"; + public static final String PREFERENCES_KEY_SONG_PRESS_ACTION = "songPressAction"; public static final String PREFERENCES_KEY_LARGE_ALBUM_ART = "largeAlbumArt"; public static final String PREFERENCES_KEY_ADMIN_ENABLED = "adminEnabled"; public static final String PREFERENCES_KEY_PLAYLIST_NAME = "suggestedPlaylistName"; diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index e22b55f0..fc7292f6 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -705,6 +705,10 @@ public final class Util { return prefs.getBoolean(Constants.PREFERENCES_KEY_START_ON_HEADPHONES, false); } + public static String getSongPressAction(Context context) { + return getPreferences(context).getString(Constants.PREFERENCES_KEY_SONG_PRESS_ACTION, "all"); + } + /** * Get the contents of an <code>InputStream</code> as a <code>byte[]</code>. * <p/> |