diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-10-25 07:56:58 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-10-25 07:56:58 -0700 |
commit | 1fa2f0825f8371be4e2302380dcc285d92ed8e95 (patch) | |
tree | 4ba5c8cdf1b1d3e47e93a6a86d62a6a420c9ae6b /src | |
parent | 6b6b3bcbcf47de353ff7ad3f82d6c6228a04c9d8 (diff) | |
parent | 627eda88c2142c5d90b52fa4cbb0a85839007321 (diff) | |
download | dsub-1fa2f0825f8371be4e2302380dcc285d92ed8e95.tar.gz dsub-1fa2f0825f8371be4e2302380dcc285d92ed8e95.tar.bz2 dsub-1fa2f0825f8371be4e2302380dcc285d92ed8e95.zip |
Merge branch 'master' into Bookmarks
Diffstat (limited to 'src')
8 files changed, 70 insertions, 83 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index b6daea98..8fef07a8 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -111,7 +111,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis private View stopButton;
private View startButton;
private ImageButton repeatButton;
- private View toggleListButton;
+ private ImageButton shuffleButton;
private ImageButton starButton;
private ImageButton bookmarkButton;
private ImageButton rateBadButton;
@@ -187,7 +187,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark);
rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad);
rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good);
- toggleListButton =rootView.findViewById(R.id.download_toggle_list);
+ shuffleButton = (ImageButton) rootView.findViewById(R.id.download_shuffle);
starButton = (ImageButton)rootView.findViewById(R.id.download_star);
if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) {
@@ -350,7 +350,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis public void onClick(View view) {
RepeatMode repeatMode = getDownloadService().getRepeatMode().next();
getDownloadService().setRepeatMode(repeatMode);
- onDownloadListChanged();
+ updateButtons();
switch (repeatMode) {
case OFF:
Util.toast(context, R.string.download_repeat_off);
@@ -453,11 +453,18 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis }
});
- toggleListButton.setOnClickListener(new View.OnClickListener() {
+ shuffleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- toggleFullscreenAlbumArt();
+ DownloadService downloadService = getDownloadService();
+ downloadService.setShuffleMode(!downloadService.isShuffleMode());
+ updateButtons();
setControlsVisible(true);
+ if(downloadService.isShuffleMode()) {
+ Util.toast(context, R.string.download_shuffle_on);
+ } else {
+ Util.toast(context, R.string.download_shuffle_off);
+ }
}
});
@@ -544,7 +551,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if (downloadService != null && context.getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) {
context.getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE);
warnIfNetworkOrStorageUnavailable();
- downloadService.setShufflePlayEnabled(true);
+ downloadService.setShuffleRemote(true);
}
if(Build.MODEL.equals("Nexus 4") || Build.MODEL.equals("GT-I9100")) {
@@ -734,7 +741,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
- getDownloadService().setShufflePlayEnabled(false);
+ getDownloadService().setShuffleRemote(false);
getDownloadService().clear();
return null;
}
@@ -765,19 +772,9 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis }
context.supportInvalidateOptionsMenu();
return true;
- case R.id.menu_shuffle:
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() throws Throwable {
- getDownloadService().shuffle();
- return null;
- }
-
- @Override
- protected void done(Void result) {
- Util.toast(context, R.string.download_menu_shuffle_notification);
- }
- }.execute();
+ case R.id.menu_toggle_list:
+ toggleFullscreenAlbumArt();
+ setControlsVisible(true);
return true;
case R.id.menu_save_playlist:
List<Entry> entries = new LinkedList<Entry>();
@@ -949,6 +946,39 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis rateBadButton.setVisibility(View.VISIBLE);
rateGoodButton.setVisibility(View.VISIBLE);
}
+
+ DownloadService downloadService = getDownloadService();
+ if(downloadService == null) {
+ return;
+ }
+
+ switch (downloadService.getRepeatMode()) {
+ case OFF:
+ if("light".equals(SubsonicActivity.getThemeName()) | "light_fullscreen".equals(SubsonicActivity.getThemeName())) {
+ repeatButton.setImageResource(R.drawable.media_repeat_off_light);
+ } else {
+ repeatButton.setImageResource(R.drawable.media_repeat_off);
+ }
+ break;
+ case ALL:
+ repeatButton.setImageResource(R.drawable.media_repeat_all);
+ break;
+ case SINGLE:
+ repeatButton.setImageResource(R.drawable.media_repeat_single);
+ break;
+ default:
+ break;
+ }
+
+ if(downloadService.isShuffleMode()) {
+ shuffleButton.setImageResource(R.drawable.ic_menu_shuffle_selected);
+ } else {
+ if("light".equals(SubsonicActivity.getThemeName())) {
+ shuffleButton.setImageResource(R.drawable.ic_menu_shuffle_light);
+ } else {
+ shuffleButton.setImageResource(R.drawable.ic_menu_shuffle_dark);
+ }
+ }
}
// Scroll to current playing/downloading.
@@ -1113,7 +1143,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis List<DownloadFile> list;
list = downloadService.getSongs();
- if(downloadService.isShufflePlayEnabled()) {
+ if(downloadService.isShuffleRemote()) {
emptyTextView.setText(R.string.download_shuffle_loading);
}
else {
@@ -1132,24 +1162,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
currentRevision = downloadService.getDownloadListUpdateRevision();
-
- switch (downloadService.getRepeatMode()) {
- case OFF:
- if("light".equals(SubsonicActivity.getThemeName()) | "light_fullscreen".equals(SubsonicActivity.getThemeName())) {
- repeatButton.setImageResource(R.drawable.media_repeat_off_light);
- } else {
- repeatButton.setImageResource(R.drawable.media_repeat_off);
- }
- break;
- case ALL:
- repeatButton.setImageResource(R.drawable.media_repeat_all);
- break;
- case SINGLE:
- repeatButton.setImageResource(R.drawable.media_repeat_single);
- break;
- default:
- break;
- }
if(scrollWhenLoaded) {
scrollToCurrent();
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java index f73989fb..b7ef204f 100644 --- a/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -13,7 +13,6 @@ import android.view.Menu; import android.view.MenuInflater;
import android.view.View;
import android.view.MenuItem;
-import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
@@ -325,7 +324,7 @@ public class SearchFragment extends SubsonicFragment { if (!append) {
downloadService.clear();
}
- downloadService.download(Arrays.asList(song), save, false, playNext, false);
+ downloadService.download(Arrays.asList(song), save, false, playNext);
if (autoplay) {
downloadService.play(downloadService.size() - 1);
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index c26429ce..46251073 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -18,8 +18,6 @@ */ package github.daneren2005.dsub.fragments; -import android.content.DialogInterface; -import android.util.Log; import android.view.ContextMenu; import android.view.MenuInflater; import android.view.MenuItem; @@ -30,18 +28,12 @@ import github.daneren2005.dsub.R; import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.MusicService; -import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.service.OfflineException; -import github.daneren2005.dsub.service.ServerTooOldException; -import github.daneren2005.dsub.util.LoadingTask; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.BookmarkAdapter; -import github.daneren2005.dsub.view.SongView; import java.text.Format; import java.text.SimpleDateFormat; @@ -114,7 +106,7 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En @Override protected Void doInBackground() throws Throwable { downloadService.clear(); - downloadService.download(Arrays.asList(bookmark), false, true, false, false, 0, bookmark.getBookmark().getPosition()); + downloadService.download(Arrays.asList(bookmark), false, true, false, 0, bookmark.getBookmark().getPosition()); return null; } diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index d441267d..4d273f6c 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -771,7 +771,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
private void playNow(final boolean shuffle, final boolean append, final boolean playNext) {
if(getSelectedSongs().size() > 0) {
- download(append, false, !append, playNext, shuffle);
+ download(append, false, !append, playNext);
selectAll(false, false);
}
else {
@@ -795,7 +795,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter downloadRecursively(id, false, append, !append, shuffle, false);
} else {
selectAll(true, false);
- download(append, false, !append, false, shuffle);
+ download(append, false, !append, false);
selectAll(false, false);
}
}
@@ -848,7 +848,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter return indexes;
}
- private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext, final boolean shuffle) {
+ private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext) {
if (getDownloadService() == null) {
return;
}
@@ -857,7 +857,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter warnIfNetworkOrStorageUnavailable();
// Conditions for using play now button
- if(!append && !save && autoplay && !playNext && !shuffle) {
+ if(!append && !save && autoplay && !playNext) {
// Call playNow which goes through and tries to use bookmark information
playNow(songs, playlistName, playlistId);
return;
@@ -870,7 +870,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter getDownloadService().clear();
}
- getDownloadService().download(songs, save, autoplay, playNext, shuffle);
+ getDownloadService().download(songs, save, autoplay, playNext);
if (playlistName != null) {
getDownloadService().setSuggestedPlaylistName(playlistName, playlistId);
} else {
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index caf9079f..741ed8a5 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -98,17 +98,6 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { replaceFragment(fragment);
break;
- case R.id.playlist_menu_play_shuffled:
- fragment = new SelectDirectoryFragment();
- args = new Bundle();
- args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
- args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
- args.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
- args.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
- fragment.setArguments(args);
-
- replaceFragment(fragment);
- break;
case R.id.playlist_menu_delete:
deletePlaylist(playlist);
break;
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 5cab2497..1a5cd5a7 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -376,10 +376,6 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR artistOverride = true;
downloadRecursively(entry.getId(), false, false, true, false, false);
break;
- case R.id.album_menu_play_shuffled:
- artistOverride = true;
- downloadRecursively(entry.getId(), false, false, true, true, false);
- break;
case R.id.album_menu_play_next:
artistOverride = true;
downloadRecursively(entry.getId(), false, true, false, false, false, true);
@@ -415,10 +411,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR playNow(songs);
break;
case R.id.song_menu_play_next:
- getDownloadService().download(songs, false, false, true, false);
+ getDownloadService().download(songs, false, false, true);
break;
case R.id.song_menu_play_last:
- getDownloadService().download(songs, false, false, false, false);
+ getDownloadService().download(songs, false, false, false);
break;
case R.id.song_menu_download:
getDownloadService().downloadBackground(songs, false);
@@ -893,7 +889,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR downloadService.clear();
}
if(!background) {
- downloadService.download(songs, save, autoplay, playNext, false);
+ downloadService.download(songs, save, autoplay, playNext);
if(!append) {
transition = true;
}
@@ -1557,7 +1553,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
downloadService.clear();
- downloadService.download(entries, false, true, true, false, entries.indexOf(song), position);
+ downloadService.download(entries, false, true, true, entries.indexOf(song), position);
downloadService.setSuggestedPlaylistName(playlistName, playlistId);
return null;
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 8d9f6867..69ed7c7f 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -53,12 +53,11 @@ import github.daneren2005.dsub.view.UpdateView; import github.daneren2005.serverproxy.BufferProxy; import java.io.File; -import java.io.IOError; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Random; import java.util.Timer; import java.util.TimerTask; @@ -70,7 +69,6 @@ import android.content.SharedPreferences; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.audiofx.AudioEffect; -import android.media.audiofx.Equalizer; import android.os.Build; import android.os.Handler; import android.os.IBinder; @@ -231,6 +229,7 @@ public class DownloadService extends Service { instance = this; lifecycleSupport.onCreate(); shufflePlayBuffer = new ShufflePlayBuffer(this); + shuffleMode = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, false); } @Override @@ -303,10 +302,10 @@ public class DownloadService extends Service { return binder; } - public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) { - download(songs, save, autoplay, playNext, shuffle, 0, 0); + public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext) { + download(songs, save, autoplay, playNext, 0, 0); } - public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int start, int position) { + public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, int start, int position) { setShuffleRemote(false); int offset = 1; @@ -395,7 +394,7 @@ public class DownloadService extends Service { removePlayed = true; } boolean startShufflePlay = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_REMOTE, false); - download(songs, false, false, false, false); + download(songs, false, false, false); if(startShufflePlay) { shuffleRemote = true; SharedPreferences.Editor editor = prefs.edit(); @@ -742,7 +741,7 @@ public class DownloadService extends Service { // Add size condition to prevent infinite loop do { newIndex = random.nextInt(size()); - } while(index == newIndex && size() > 1) + } while(index == newIndex && size() > 1); } return newIndex; diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 0a1e2cdd..9cd2896b 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -198,7 +198,7 @@ public class DownloadServiceLifecycleSupport { } editor.commit(); - downloadService.setShufflePlayEnabled(true); + downloadService.setShuffleRemote(true); } else { downloadService.start(); } |