diff options
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 31688494..211cf0d7 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -2002,7 +2002,9 @@ public class DownloadService extends Service { private synchronized void checkRemovePlayed() { boolean changed = false; - 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); changed = true; 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 95fabc23..5c477ad9 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 327df3cb..45b89df9 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -636,5 +636,10 @@ <string name="details.year">Jahr</string> <string name="details.version">Version</string> <string name="playlist.mine">Meine Wiedergabelisten</string> + <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 d876ecdb..a7dd932d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -163,6 +163,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 ec6c45b4..1cb85711 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -371,6 +371,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" |