Episode cache size can now be set to 'unlimited'
This commit is contained in:
parent
6eb0c58a08
commit
d086579e09
@ -21,7 +21,7 @@
|
||||
<item>24</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="episode_cache_size">
|
||||
<string-array name="episode_cache_size_entries">
|
||||
<item>@string/pref_episode_cache_unlimited</item>
|
||||
<item>10</item>
|
||||
<item>20</item>
|
||||
@ -31,6 +31,16 @@
|
||||
<item>100</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="episode_cache_size_values">
|
||||
<item>-1</item>
|
||||
<item>10</item>
|
||||
<item>20</item>
|
||||
<item>40</item>
|
||||
<item>60</item>
|
||||
<item>80</item>
|
||||
<item>100</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="autodl_select_networks_default_entries">
|
||||
<item>N/A</item>
|
||||
</string-array>
|
||||
|
@ -1,3 +1,4 @@
|
||||
<resources>
|
||||
<integer name="undobar_hide_delay">5000</integer>
|
||||
<integer name="episode_cache_size_unlimited">-1</integer>
|
||||
</resources>
|
||||
|
@ -34,7 +34,7 @@
|
||||
android:key="prefMobileUpdate"
|
||||
android:summary="@string/pref_mobileUpdate_sum"
|
||||
android:title="@string/pref_mobileUpdate_title" />
|
||||
<ListPreference android:defaultValue="20" android:entries="@array/episode_cache_size" android:key="prefEpisodeCacheSize" android:title="@string/pref_episode_cache_title" android:entryValues="@array/episode_cache_size"/><PreferenceScreen android:summary="@string/pref_automatic_download_sum" android:key="prefAutoDownloadSettings" android:title="@string/pref_automatic_download_title">
|
||||
<ListPreference android:defaultValue="20" android:entries="@array/episode_cache_size_entries" android:key="prefEpisodeCacheSize" android:title="@string/pref_episode_cache_title" android:entryValues="@array/episode_cache_size_values"/><PreferenceScreen android:summary="@string/pref_automatic_download_sum" android:key="prefAutoDownloadSettings" android:title="@string/pref_automatic_download_title">
|
||||
<CheckBoxPreference android:key="prefEnableAutoDl" android:title="@string/pref_automatic_download_title" android:defaultValue="false"/><CheckBoxPreference android:key="prefEnableAutoDownloadWifiFilter" android:title="@string/pref_autodl_wifi_filter_title" android:summary="@string/pref_autodl_wifi_filter_sum"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -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() {
|
||||
|
@ -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()) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user