aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Knepper <thknepper@gmx.de>2015-07-26 20:00:48 +0200
committerThomas Knepper <thknepper@gmx.de>2015-07-26 20:00:48 +0200
commit6cb7a1de67af90d1d13cd04ab64afee4d1e99b70 (patch)
tree67ff40d7e5bd6edb94b882fe16aa69df8dc211f0
parent04bf2e345beae36a512aa50b5b920a4af9345743 (diff)
downloaddsub-6cb7a1de67af90d1d13cd04ab64afee4d1e99b70.tar.gz
dsub-6cb7a1de67af90d1d13cd04ab64afee4d1e99b70.tar.bz2
dsub-6cb7a1de67af90d1d13cd04ab64afee4d1e99b70.zip
option, to keep 1, 2 or 3 played songs
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--app/src/main/res/values-de/strings.xml5
-rw-r--r--app/src/main/res/values/arrays.xml13
-rw-r--r--app/src/main/res/values/strings.xml5
-rw-r--r--app/src/main/res/xml/settings.xml7
7 files changed, 37 insertions, 1 deletions
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 3be21a67..52748e7b 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
@@ -71,6 +71,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
private EditTextPreference cacheLocation;
private ListPreference preloadCountWifi;
private ListPreference preloadCountMobile;
+ private ListPreference keepPlayedCount;
private ListPreference tempLoss;
private ListPreference pauseDisconnect;
private Preference addServerPreference;
@@ -177,6 +178,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
cacheLocation = (EditTextPreference) this.findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION);
preloadCountWifi = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT_WIFI);
preloadCountMobile = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT_MOBILE);
+ keepPlayedCount = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_KEEP_PLAYED_CNT);
tempLoss = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_TEMP_LOSS);
pauseDisconnect = (ListPreference) this.findPreference(Constants.PREFERENCES_KEY_PAUSE_DISCONNECT);
serversCategory = (PreferenceCategory) this.findPreference(Constants.PREFERENCES_KEY_SERVER_KEY);
@@ -316,6 +318,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
cacheLocation.setSummary(cacheLocation.getText());
preloadCountWifi.setSummary(preloadCountWifi.getEntry());
preloadCountMobile.setSummary(preloadCountMobile.getEntry());
+ keepPlayedCount.setSummary(keepPlayedCount.getEntry());
tempLoss.setSummary(tempLoss.getEntry());
pauseDisconnect.setSummary(pauseDisconnect.getEntry());
videoPlayer.setSummary(videoPlayer.getEntry());
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 9e57f5b0..ae2eb073 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1972,7 +1972,9 @@ public class DownloadService extends Service {
}
private synchronized void checkRemovePlayed() {
- while(currentPlayingIndex > 0) {
+ SharedPreferences prefs = Util.getPreferences(this);
+ int keepCount = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_KEEP_PLAYED_CNT, "0"));
+ while(currentPlayingIndex > keepCount) {
downloadList.remove(0);
currentPlayingIndex = downloadList.indexOf(currentPlaying);
revision++;
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 05481bf0..b3dd173b 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
@@ -113,6 +113,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_PERSISTENT_NOTIFICATION = "persistentNotification";
public static final String PREFERENCES_KEY_GAPLESS_PLAYBACK = "gaplessPlayback";
public static final String PREFERENCES_KEY_REMOVE_PLAYED = "removePlayed";
+ public static final String PREFERENCES_KEY_KEEP_PLAYED_CNT = "keepPlayedCount";
public static final String PREFERENCES_KEY_SHUFFLE_MODE = "shuffleMode2";
public static final String PREFERENCES_KEY_SHUFFLE_MODE_EXTRA = "shuffleModeExtra";
public static final String PREFERENCES_KEY_CHAT_REFRESH = "chatRefreshRate";
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 97ab596b..25f1b57c 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -577,5 +577,10 @@
<item quantity="one">Noch ein Tag bis zum Ablauf des Testzeitraums.</item>
<item quantity="other">%d Tage bis zum Ablauf des Testzeitraums.</item>
</plurals>
+ <string name="settings.keep_played_count_none">Alle abgespielten Lieder entfernen</string>
+ <string name="settings.keep_played_count_one">Das letzte abgespielte Lied behalten</string>
+ <string name="settings.keep_played_count_three">3 abgespielte Lieder behalten</string>
+ <string name="settings.keep_played_count_two">2 abgespielte Lieder behalten</string>
+ <string name="settings.keep_played_count_title">Abgespielte Lieder behalten</string>
</resources>
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 37b15d12..c103fb15 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -202,6 +202,19 @@
<item>@string/settings.temp_loss_nothing</item>
</string-array>
+ <string-array name="keepPlayedCountValues">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+ <string-array name="keepPlayedCountNames">
+ <item>@string/settings.keep_played_count_none</item>
+ <item>@string/settings.keep_played_count_one</item>
+ <item>@string/settings.keep_played_count_two</item>
+ <item>@string/settings.keep_played_count_three</item>
+ </string-array>
+
<string-array name="disconnectPauseValues">
<item>0</item>
<item>3</item>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8544c6e3..3d67ec37 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -379,6 +379,11 @@
<string name="settings.temp_loss_pause_lower">Pause, lower volume when requested</string>
<string name="settings.temp_loss_lower">Always lower volume</string>
<string name="settings.temp_loss_nothing">Do Nothing</string>
+ <string name="settings.keep_played_count_title">Keep played songs</string>
+ <string name="settings.keep_played_count_none">Remove all played songs</string>
+ <string name="settings.keep_played_count_one">Keep last played songs</string>
+ <string name="settings.keep_played_count_two">Keep 2 played songs</string>
+ <string name="settings.keep_played_count_three">Keep 3 played songs</string>
<string name="settings.disconnect_pause_title">Pause on Disconnect</string>
<string name="settings.disconnect_pause_both">Pause</string>
<string name="settings.disconnect_pause_neither">Do Nothing</string>
diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml
index b1cbdd8c..b23825bf 100644
--- a/app/src/main/res/xml/settings.xml
+++ b/app/src/main/res/xml/settings.xml
@@ -335,6 +335,13 @@
myns:max="100"/>
<ListPreference
+ android:title="@string/settings.keep_played_count_title"
+ android:key="keepPlayedCount"
+ android:defaultValue="0"
+ android:entryValues="@array/keepPlayedCountValues"
+ android:entries="@array/keepPlayedCountNames"/>
+
+ <ListPreference
android:title="@string/settings.temp_loss_title"
android:key="tempLoss"
android:defaultValue="1"