summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/danoeh/antennapod')
-rw-r--r--src/de/danoeh/antennapod/activity/PreferenceActivity.java12
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java2
-rw-r--r--src/de/danoeh/antennapod/preferences/UserPreferences.java26
3 files changed, 34 insertions, 6 deletions
diff --git a/src/de/danoeh/antennapod/activity/PreferenceActivity.java b/src/de/danoeh/antennapod/activity/PreferenceActivity.java
index 994cd2df6..c59b14c03 100644
--- a/src/de/danoeh/antennapod/activity/PreferenceActivity.java
+++ b/src/de/danoeh/antennapod/activity/PreferenceActivity.java
@@ -205,9 +205,15 @@ public class PreferenceActivity extends SherlockPreferenceActivity {
}
private void setEpisodeCacheSizeText(int cacheSize) {
- findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setSummary(
- Integer.toString(cacheSize)
- + getString(R.string.episodes_suffix));
+ String s;
+ if (cacheSize == getResources().getInteger(
+ R.integer.episode_cache_size_unlimited)) {
+ s = getString(R.string.pref_episode_cache_unlimited);
+ } else {
+ s = Integer.toString(cacheSize)
+ + getString(R.string.episodes_suffix);
+ }
+ findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setSummary(s);
}
private void setDataFolderText() {
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index 38ef3921f..b2d97a311 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -733,7 +733,7 @@ public class FeedManager {
* that the number of episodes fits into the episode cache.
* */
private int getPerformAutoCleanupArgs(final int episodeNumber) {
- if (episodeNumber >= 0) {
+ if (episodeNumber >= 0 && UserPreferences.getEpisodeCacheSize() != UserPreferences.getEpisodeCacheSizeUnlimited()) {
int downloadedEpisodes = getNumberOfDownloadedEpisodes();
if (downloadedEpisodes + episodeNumber >= UserPreferences
.getEpisodeCacheSize()) {
diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java
index bd491a5cf..f2f35f41d 100644
--- a/src/de/danoeh/antennapod/preferences/UserPreferences.java
+++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java
@@ -42,6 +42,8 @@ public class UserPreferences implements
private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
+ private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
+
private static UserPreferences instance;
private Context context;
@@ -86,6 +88,8 @@ public class UserPreferences implements
private void loadPreferences() {
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(context);
+ EPISODE_CACHE_SIZE_UNLIMITED = context.getResources().getInteger(
+ R.integer.episode_cache_size_unlimited);
pauseOnHeadsetDisconnect = sp.getBoolean(
PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
@@ -101,7 +105,7 @@ public class UserPreferences implements
PREF_ENABLE_AUTODL_WIFI_FILTER, false);
autodownloadSelectedNetworks = StringUtils.split(
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
- episodeCacheSize = Integer.valueOf(sp.getString(
+ episodeCacheSize = readEpisodeCacheSize(sp.getString(
PREF_EPISODE_CACHE_SIZE, "20"));
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
}
@@ -122,6 +126,15 @@ public class UserPreferences implements
return TimeUnit.HOURS.toMillis(hours);
}
+ private int readEpisodeCacheSize(String valueFromPrefs) {
+ if (valueFromPrefs.equals(context
+ .getString(R.string.pref_episode_cache_unlimited))) {
+ return EPISODE_CACHE_SIZE_UNLIMITED;
+ } else {
+ return Integer.valueOf(valueFromPrefs);
+ }
+ }
+
private static void instanceAvailable() {
if (instance == null) {
throw new IllegalStateException(
@@ -179,6 +192,15 @@ public class UserPreferences implements
return instance.autodownloadSelectedNetworks;
}
+ public static int getEpisodeCacheSizeUnlimited() {
+ return EPISODE_CACHE_SIZE_UNLIMITED;
+ }
+
+ /**
+ * Returns the capacity of the episode cache. This method will return the
+ * negative integer EPISODE_CACHE_SIZE_UNLIMITED if the cache size is set to
+ * 'unlimited'.
+ */
public static int getEpisodeCacheSize() {
instanceAvailable();
return instance.episodeCacheSize;
@@ -224,7 +246,7 @@ public class UserPreferences implements
autodownloadSelectedNetworks = StringUtils.split(
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
} else if (key.equals(PREF_EPISODE_CACHE_SIZE)) {
- episodeCacheSize = Integer.valueOf(sp.getString(
+ episodeCacheSize = readEpisodeCacheSize(sp.getString(
PREF_EPISODE_CACHE_SIZE, "20"));
} else if (key.equals(PREF_ENABLE_AUTODL)) {
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);