diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-07-25 19:58:53 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-07-25 19:58:53 -0700 |
commit | 2e210b2632b0a4c4d90ab4b0961a47f693d0a66f (patch) | |
tree | 4c46a8cd26c7b8919fc93bd5f80a3b2cf1e6f165 | |
parent | b3ae86281bcd3f94f4e5f2497dbc2bb1a77803d4 (diff) | |
download | dsub-2e210b2632b0a4c4d90ab4b0961a47f693d0a66f.tar.gz dsub-2e210b2632b0a4c4d90ab4b0961a47f693d0a66f.tar.bz2 dsub-2e210b2632b0a4c4d90ab4b0961a47f693d0a66f.zip |
Play Shuffled added to everything with a Play Now option (tombriden)
12 files changed, 87 insertions, 31 deletions
diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml index 5da91019..6bbae1cb 100644 --- a/subsonic-android/AndroidManifest.xml +++ b/subsonic-android/AndroidManifest.xml @@ -2,8 +2,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.daneren2005.subphonic"
android:installLocation="auto"
- android:versionCode="3"
- android:versionName="3.3.1.2">
+ android:versionCode="5"
+ android:versionName="3.3.3">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
diff --git a/subsonic-android/res/layout/select_album.xml b/subsonic-android/res/layout/select_album.xml index f2adf21b..2c9a00aa 100644 --- a/subsonic-android/res/layout/select_album.xml +++ b/subsonic-android/res/layout/select_album.xml @@ -92,6 +92,17 @@ android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"/>
+
+ <Button android:id="@+id/select_album_play_shuffled"
+ android:text="@string/common.play_shuffled"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:visibility="gone"
+ android:layout_marginLeft="3dp"
+ android:layout_marginRight="3dp"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"/>
+
<Button android:id="@+id/select_album_play_last"
android:text="@string/common.play_last"
diff --git a/subsonic-android/res/menu/select_album_context.xml b/subsonic-android/res/menu/select_album_context.xml index 299d4d01..a43ef78a 100644 --- a/subsonic-android/res/menu/select_album_context.xml +++ b/subsonic-android/res/menu/select_album_context.xml @@ -5,6 +5,11 @@ android:id="@+id/album_menu_play_now" android:title="@string/common.play_now" /> + + <item + android:id="@+id/album_menu_play_shuffled" + android:title="@string/common.play_shuffled" + /> <item android:id="@+id/album_menu_play_last" diff --git a/subsonic-android/res/menu/select_artist_context.xml b/subsonic-android/res/menu/select_artist_context.xml index fc4a45ba..c1b201f7 100644 --- a/subsonic-android/res/menu/select_artist_context.xml +++ b/subsonic-android/res/menu/select_artist_context.xml @@ -5,6 +5,11 @@ android:id="@+id/artist_menu_play_now" android:title="@string/common.play_now" /> + + <item + android:id="@+id/artist_menu_play_shuffled" + android:title="@string/common.play_shuffled" + /> <item android:id="@+id/artist_menu_play_last" diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 9a10b0ec..7a257105 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -6,6 +6,7 @@ <string name="common.save">Save</string>
<string name="common.cancel">Cancel</string>
<string name="common.play_now">Play now</string>
+ <string name="common.play_shuffled">Play shuffled</string>
<string name="common.play_next">Play next</string>
<string name="common.play_last">Play last</string>
<string name="common.pin">Pin</string>
diff --git a/subsonic-android/src/github/daneren2005/subphonic/activity/SearchActivity.java b/subsonic-android/src/github/daneren2005/subphonic/activity/SearchActivity.java index 8bfc5b5b..0c3e1dc5 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/activity/SearchActivity.java +++ b/subsonic-android/src/github/daneren2005/subphonic/activity/SearchActivity.java @@ -219,13 +219,16 @@ public class SearchActivity extends SubsonicTabActivity { switch (menuItem.getItemId()) { case R.id.album_menu_play_now: - downloadRecursively(id, false, false, true); + downloadRecursively(id, false, false, true, false); break; + case R.id.album_menu_play_shuffled: + downloadRecursively(id, false, false, true, true); + break; case R.id.album_menu_play_last: - downloadRecursively(id, false, true, false); + downloadRecursively(id, false, true, false, false); break; case R.id.album_menu_pin: - downloadRecursively(id, true, true, false); + downloadRecursively(id, true, true, false, false); break; case R.id.song_menu_play_now: onSongSelected(entry, false, false, true, false); @@ -361,7 +364,7 @@ public class SearchActivity extends SubsonicTabActivity { if (!append) { downloadService.clear(); } - downloadService.download(Arrays.asList(song), save, false, playNext); + downloadService.download(Arrays.asList(song), save, false, playNext, false); if (autoplay) { downloadService.play(downloadService.size() - 1); } diff --git a/subsonic-android/src/github/daneren2005/subphonic/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/subphonic/activity/SelectAlbumActivity.java index 4125ee1b..7e6c0f70 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/subphonic/activity/SelectAlbumActivity.java @@ -57,6 +57,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { private View emptyView; private Button selectButton; private Button playNowButton; + private Button playShuffledButton; private Button playLastButton; private Button pinButton; private Button unpinButton; @@ -100,6 +101,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { coverArtView = (ImageView) findViewById(R.id.actionbar_home_icon); selectButton = (Button) findViewById(R.id.select_album_select); playNowButton = (Button) findViewById(R.id.select_album_play_now); + playShuffledButton = (Button) findViewById(R.id.select_album_play_shuffled); playLastButton = (Button) findViewById(R.id.select_album_play_last); pinButton = (Button) findViewById(R.id.select_album_pin); unpinButton = (Button) findViewById(R.id.select_album_unpin); @@ -116,21 +118,28 @@ public class SelectAlbumActivity extends SubsonicTabActivity { playNowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - download(false, false, true, false); + download(false, false, true, false, false); + selectAll(false, false); + } + }); + playShuffledButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + download(false, false, true, false, true); selectAll(false, false); } }); playLastButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - download(true, false, false, false); + download(true, false, false, false, false); selectAll(false, false); } }); pinButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - download(true, true, false, false); + download(true, true, false, false, false); selectAll(false, false); } }); @@ -176,7 +185,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { playAllButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - playAll(); + playAll(false); } }); @@ -209,7 +218,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { }); } - private void playAll() { + private void playAll(final boolean shuffle) { boolean hasSubFolders = false; for (int i = 0; i < entryList.getCount(); i++) { MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(i); @@ -221,10 +230,10 @@ public class SelectAlbumActivity extends SubsonicTabActivity { String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID); if (hasSubFolders && id != null) { - downloadRecursively(id, false, false, true); + downloadRecursively(id, false, false, true, shuffle); } else { selectAll(true, false); - download(false, false, true, false); + download(false, false, true, false, shuffle); selectAll(false, false); } } @@ -261,22 +270,25 @@ public class SelectAlbumActivity extends SubsonicTabActivity { songs.add((MusicDirectory.Entry) entryList.getItemAtPosition(info.position)); switch (menuItem.getItemId()) { case R.id.album_menu_play_now: - downloadRecursively(entry.getId(), false, false, true); + downloadRecursively(entry.getId(), false, false, true, false); + break; + case R.id.album_menu_play_shuffled: + downloadRecursively(entry.getId(), false, false, true, true); break; case R.id.album_menu_play_last: - downloadRecursively(entry.getId(), false, true, false); + downloadRecursively(entry.getId(), false, true, false, false); break; case R.id.album_menu_pin: - downloadRecursively(entry.getId(), true, true, false); + downloadRecursively(entry.getId(), true, true, false, false); break; case R.id.song_menu_play_now: - getDownloadService().download(songs, false, true, true); + getDownloadService().download(songs, false, true, true, false); break; case R.id.song_menu_play_next: - getDownloadService().download(songs, false, false, true); + getDownloadService().download(songs, false, false, true, false); break; case R.id.song_menu_play_last: - getDownloadService().download(songs, false, false, false); + getDownloadService().download(songs, false, false, false, false); break; default: return super.onContextItemSelected(menuItem); @@ -407,6 +419,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } playNowButton.setEnabled(enabled); + playShuffledButton.setEnabled(enabled); playLastButton.setEnabled(enabled); pinButton.setEnabled(enabled && !Util.isOffline(this)); unpinButton.setEnabled(unpinEnabled); @@ -424,7 +437,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { return songs; } - private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext) { + private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext, final boolean shuffle) { if (getDownloadService() == null) { return; } @@ -438,7 +451,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } warnIfNetworkOrStorageUnavailable(); - getDownloadService().download(songs, save, autoplay, playNext); + getDownloadService().download(songs, save, autoplay, playNext, shuffle); String playlistName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME); if (playlistName != null) { getDownloadService().setSuggestedPlaylistName(playlistName); @@ -563,6 +576,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { entryList.addFooterView(footer); selectButton.setVisibility(View.VISIBLE); playNowButton.setVisibility(View.VISIBLE); + playShuffledButton.setVisibility(View.VISIBLE); playLastButton.setVisibility(View.VISIBLE); pinButton.setVisibility(View.VISIBLE); unpinButton.setVisibility(View.VISIBLE); @@ -578,7 +592,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { boolean playAll = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false); if (playAll && songCount > 0) { - playAll(); + playAll(getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)); } } } diff --git a/subsonic-android/src/github/daneren2005/subphonic/activity/SelectArtistActivity.java b/subsonic-android/src/github/daneren2005/subphonic/activity/SelectArtistActivity.java index bf9ff9ba..4bd525d8 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/activity/SelectArtistActivity.java +++ b/subsonic-android/src/github/daneren2005/subphonic/activity/SelectArtistActivity.java @@ -220,13 +220,16 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter if (artist != null) { switch (menuItem.getItemId()) { case R.id.artist_menu_play_now: - downloadRecursively(artist.getId(), false, false, true); + downloadRecursively(artist.getId(), false, false, true, false); + break; + case R.id.artist_menu_play_shuffled: + downloadRecursively(artist.getId(), false, false, true, true); break; case R.id.artist_menu_play_last: - downloadRecursively(artist.getId(), false, true, false); + downloadRecursively(artist.getId(), false, true, false, false); break; case R.id.artist_menu_pin: - downloadRecursively(artist.getId(), true, true, false); + downloadRecursively(artist.getId(), true, true, false, false); break; default: return super.onContextItemSelected(menuItem); diff --git a/subsonic-android/src/github/daneren2005/subphonic/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/subphonic/activity/SelectPlaylistActivity.java index c2153de0..6903eaba 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/activity/SelectPlaylistActivity.java +++ b/subsonic-android/src/github/daneren2005/subphonic/activity/SelectPlaylistActivity.java @@ -43,6 +43,7 @@ import java.util.List; public class SelectPlaylistActivity extends SubsonicTabActivity implements AdapterView.OnItemClickListener { private static final int MENU_ITEM_PLAY_ALL = 1; + private static final int MENU_ITEM_PLAY_SHUFFLED = 2; private ListView list; private View emptyTextView; @@ -124,6 +125,7 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); menu.add(Menu.NONE, MENU_ITEM_PLAY_ALL, MENU_ITEM_PLAY_ALL, R.string.common_play_now); + menu.add(Menu.NONE, MENU_ITEM_PLAY_SHUFFLED, MENU_ITEM_PLAY_SHUFFLED, R.string.common_play_shuffled); } @Override @@ -131,14 +133,23 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); Playlist playlist = (Playlist) list.getItemAtPosition(info.position); + Intent intent; switch (menuItem.getItemId()) { case MENU_ITEM_PLAY_ALL: - Intent intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class); + intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class); intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId()); intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName()); intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true); Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent); break; + case MENU_ITEM_PLAY_SHUFFLED: + intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class); + intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId()); + intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName()); + intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true); + intent.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true); + Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent); + break; default: return super.onContextItemSelected(menuItem); } diff --git a/subsonic-android/src/github/daneren2005/subphonic/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/subphonic/activity/SubsonicTabActivity.java index f682dba8..8d3543aa 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/activity/SubsonicTabActivity.java +++ b/subsonic-android/src/github/daneren2005/subphonic/activity/SubsonicTabActivity.java @@ -271,7 +271,7 @@ public class SubsonicTabActivity extends Activity { return IMAGE_LOADER; } - protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay) { + protected void downloadRecursively(final String id, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle) { ModalBackgroundTask<List<MusicDirectory.Entry>> task = new ModalBackgroundTask<List<MusicDirectory.Entry>>(this, false) { private static final int MAX_SONGS = 500; @@ -309,7 +309,7 @@ public class SubsonicTabActivity extends Activity { downloadService.clear(); } warnIfNetworkOrStorageUnavailable(); - downloadService.download(songs, save, autoplay, false); + downloadService.download(songs, save, autoplay, false, shuffle); Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class); } } diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/DownloadService.java b/subsonic-android/src/github/daneren2005/subphonic/service/DownloadService.java index f6b5b3ee..58b9e8e8 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/subphonic/service/DownloadService.java @@ -32,7 +32,7 @@ import github.daneren2005.subphonic.domain.RepeatMode; */ public interface DownloadService { - void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext); + void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle); void setShufflePlayEnabled(boolean enabled); diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/subphonic/service/DownloadServiceImpl.java index aec2963d..c7256a84 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/subphonic/service/DownloadServiceImpl.java @@ -179,7 +179,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { } @Override - public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext) { + public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) { shufflePlay = false; int offset = 1; @@ -204,6 +204,9 @@ public class DownloadServiceImpl extends Service implements DownloadService { revision++; } updateJukeboxPlaylist(); + + if(shuffle) + shuffle(); if (autoplay) { play(0); @@ -223,7 +226,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { } public void restore(List<MusicDirectory.Entry> songs, int currentPlayingIndex, int currentPlayingPosition) { - download(songs, false, false, false); + download(songs, false, false, false, false); if (currentPlayingIndex != -1) { play(currentPlayingIndex, false); if (currentPlaying.isCompleteFileAvailable()) { |