diff options
-rw-r--r-- | res/drawable-hdpi/ic_menu_shuffle_selected.png | bin | 0 -> 1138 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_menu_shuffle_selected.png | bin | 0 -> 733 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_menu_shuffle_selected.png | bin | 0 -> 1670 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/ic_menu_shuffle_selected.png | bin | 0 -> 2573 bytes | |||
-rw-r--r-- | res/layout/download_media_buttons.xml | 4 | ||||
-rw-r--r-- | res/menu/nowplaying.xml | 12 | ||||
-rw-r--r-- | res/menu/nowplaying_offline.xml | 12 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/fragments/NowPlayingFragment.java | 90 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 4 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 2 |
11 files changed, 71 insertions, 55 deletions
diff --git a/res/drawable-hdpi/ic_menu_shuffle_selected.png b/res/drawable-hdpi/ic_menu_shuffle_selected.png Binary files differnew file mode 100644 index 00000000..e2ace634 --- /dev/null +++ b/res/drawable-hdpi/ic_menu_shuffle_selected.png diff --git a/res/drawable-mdpi/ic_menu_shuffle_selected.png b/res/drawable-mdpi/ic_menu_shuffle_selected.png Binary files differnew file mode 100644 index 00000000..c8c01fff --- /dev/null +++ b/res/drawable-mdpi/ic_menu_shuffle_selected.png diff --git a/res/drawable-xhdpi/ic_menu_shuffle_selected.png b/res/drawable-xhdpi/ic_menu_shuffle_selected.png Binary files differnew file mode 100644 index 00000000..03719061 --- /dev/null +++ b/res/drawable-xhdpi/ic_menu_shuffle_selected.png diff --git a/res/drawable-xxhdpi/ic_menu_shuffle_selected.png b/res/drawable-xxhdpi/ic_menu_shuffle_selected.png Binary files differnew file mode 100644 index 00000000..16cfea54 --- /dev/null +++ b/res/drawable-xxhdpi/ic_menu_shuffle_selected.png diff --git a/res/layout/download_media_buttons.xml b/res/layout/download_media_buttons.xml index 1affb164..1e694662 100644 --- a/res/layout/download_media_buttons.xml +++ b/res/layout/download_media_buttons.xml @@ -55,8 +55,8 @@ <ImageButton style="@style/PlaybackControl.Small" - android:id="@+id/download_toggle_list" - android:src="?attr/toggle_list" + android:id="@+id/download_shuffle" + android:src="?attr/shuffle" android:layout_alignParentRight="true" android:layout_centerVertical="true" /> diff --git a/res/menu/nowplaying.xml b/res/menu/nowplaying.xml index 60255692..3f49ae19 100644 --- a/res/menu/nowplaying.xml +++ b/res/menu/nowplaying.xml @@ -3,18 +3,18 @@ xmlns:compat="http://schemas.android.com/apk/res-auto" android:checkableBehavior="all"> - <item - android:id="@+id/menu_shuffle" - android:icon="?attr/shuffle" - android:title="@string/download.menu_shuffle" - compat:showAsAction="ifRoom|withText"/> - <item android:id="@+id/menu_mediaroute" compat:actionProviderClass="android.support.v7.app.MediaRouteActionProvider" compat:actionViewClass="android.support.v7.app.MediaRouteButton" compat:showAsAction="always" android:title="@string/menu.cast"/> + + <item + android:id="@+id/menu_toggle_list" + android:icon="?attr/toggle_list" + android:title="@string/download.menu_toggle" + compat:showAsAction="ifRoom|withText"/> <item android:id="@+id/menu_remove_all" diff --git a/res/menu/nowplaying_offline.xml b/res/menu/nowplaying_offline.xml index bba5ba00..105b375c 100644 --- a/res/menu/nowplaying_offline.xml +++ b/res/menu/nowplaying_offline.xml @@ -2,18 +2,18 @@ <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:icon="?attr/shuffle" - android:title="@string/download.menu_shuffle" - compat:showAsAction="always|withText"/> - <item android:id="@+id/menu_mediaroute" compat:actionProviderClass="android.support.v7.app.MediaRouteActionProvider" compat:actionViewClass="android.support.v7.app.MediaRouteButton" compat:showAsAction="always" android:title="@string/menu.cast"/> + + <item + android:id="@+id/menu_toggle_list" + android:icon="?attr/toggle_list" + android:title="@string/download.menu_toggle" + compat:showAsAction="always|withText"/> <item android:id="@+id/menu_remove_all" diff --git a/res/values/strings.xml b/res/values/strings.xml index 33a40981..71b6e08e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -212,6 +212,8 @@ <string name="download.downloading_summary_expanded">Current: %1$s
\nEstimated Size: %2$s</string>
<string name="download.failed_to_load">Failed to load</string>
+ <string name="download.shuffle_on">Shuffle on</string>
+ <string name="download.shuffle_off">Shuffle off</string>
<string name="sync.new_podcasts">New podcasts available</string>
<string name="sync.new_playlists">New songs in playlists</string>
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index eb4ce5ab..f3a1cd4c 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/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 81289f86..2b727dfb 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -59,6 +59,7 @@ 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; @@ -231,6 +232,7 @@ public class DownloadService extends Service { instance = this; lifecycleSupport.onCreate(); shufflePlayBuffer = new ShufflePlayBuffer(this); + shuffleMode = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, false); } @Override @@ -742,7 +744,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(); } |