From 8006545a86a0158ff9ede9c8cf7b547ab2d1686a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 28 Mar 2016 17:24:48 -0700 Subject: Fixes #667: Add optional caching while casting --- .../java/github/daneren2005/dsub/service/DownloadService.java | 9 ++++----- app/src/main/java/github/daneren2005/dsub/util/Constants.java | 1 + app/src/main/java/github/daneren2005/dsub/util/Util.java | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/settings_cast.xml | 6 ++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index ae6e46ee..10ef0e0d 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1042,6 +1042,8 @@ public class DownloadService extends Service { bufferAndPlay(position, start); checkDownloads(); setNextPlaying(); + } else { + checkDownloads(); } } } @@ -1716,10 +1718,7 @@ public class DownloadService extends Service { setNextPlayerState(IDLE); } } - - if(remoteState == LOCAL) { - checkDownloads(); - } + checkDownloads(); if(routeId != null) { final Runnable delayedReconnect = new Runnable() { @@ -2154,7 +2153,7 @@ public class DownloadService extends Service { int preloaded = 0; - if(n != 0 && remoteState == LOCAL) { + if(n != 0 && (remoteState == LOCAL || Util.shouldCacheDuringCasting(this))) { int start = currentPlaying == null ? 0 : getCurrentPlayingIndex(); if(start == -1) { start = 0; 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 541f342e..ec3489ab 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java @@ -173,6 +173,7 @@ public final class Constants { public static final String PREFERENCES_KEY_CAST_GAPLESS_PLAYBACK = "castingGaplessPlayback"; public static final String PREFERENCES_KEY_CAST_STREAM_ORIGINAL = "castStreamOriginal"; public static final String PREFERENCES_KEY_HEADS_UP_NOTIFICATION = "headsUpNotification"; + public static final String PREFERENCES_KEY_CAST_CACHE = "castCache"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; 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 435c33c0..7efb020d 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -694,6 +694,10 @@ public final class Util { editor.commit(); } + public static boolean shouldCacheDuringCasting(Context context) { + return Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CAST_CACHE, false); + } + public static boolean shouldStartOnHeadphones(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.PREFERENCES_KEY_START_ON_HEADPHONES, false); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee4af53c..b201b4cb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -472,6 +472,8 @@ Stream original files where supported by cast device Heads Up Notifications (5.0+) Show playing notifications as Heads Up notifications (Android Lollipop+ only) + Cache While Casting + Cache currently playing songs while casting Shuffle By Start Year: diff --git a/app/src/main/res/xml/settings_cast.xml b/app/src/main/res/xml/settings_cast.xml index 45766162..c23ae04d 100644 --- a/app/src/main/res/xml/settings_cast.xml +++ b/app/src/main/res/xml/settings_cast.xml @@ -21,5 +21,11 @@ android:summary="@string/settings.casting_stream_original_summary" android:key="castStreamOriginal" android:defaultValue="true"/> + + \ No newline at end of file -- cgit v1.2.3