summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/preferences/UserPreferences.java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-03-10 19:40:50 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2013-03-10 19:40:50 +0100
commitfc156782f4ea98c014f117e77a959fc3d5bf2e10 (patch)
treea52253ecce4de5b3f71eff66b32782b76fecdf65 /src/de/danoeh/antennapod/preferences/UserPreferences.java
parentcbb3d4691796e41d4afa70211038a66c5ce155f2 (diff)
parentd4b7acd5df4e6a6ecc04923dd629978244d21b13 (diff)
downloadAntennaPod-fc156782f4ea98c014f117e77a959fc3d5bf2e10.zip
Merge branch 'queue_update' into develop
Diffstat (limited to 'src/de/danoeh/antennapod/preferences/UserPreferences.java')
-rw-r--r--src/de/danoeh/antennapod/preferences/UserPreferences.java60
1 files changed, 49 insertions, 11 deletions
diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java
index f4c0b94b0..09fb49623 100644
--- a/src/de/danoeh/antennapod/preferences/UserPreferences.java
+++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java
@@ -2,8 +2,11 @@ package de.danoeh.antennapod.preferences;
import java.io.File;
import java.io.IOException;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang3.StringUtils;
+
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
@@ -31,11 +34,13 @@ public class UserPreferences implements
public static final String PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY = "prefDownloadMediaOnWifiOnly";
public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate";
- public static final String PREF_AUTO_QUEUE = "prefAutoQueue";
public static final String PREF_DISPLAY_ONLY_EPISODES = "prefDisplayOnlyEpisodes";
public static final String PREF_AUTO_DELETE = "prefAutoDelete";
public static final String PREF_THEME = "prefTheme";
public static final String PREF_DATA_FOLDER = "prefDataFolder";
+ public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
+ private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
+ public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
private static UserPreferences instance;
private Context context;
@@ -46,10 +51,12 @@ public class UserPreferences implements
private boolean downloadMediaOnWifiOnly;
private long updateInterval;
private boolean allowMobileUpdate;
- private boolean autoQueue;
private boolean displayOnlyEpisodes;
private boolean autoDelete;
private int theme;
+ private boolean enableAutodownloadWifiFilter;
+ private String[] autodownloadSelectedNetworks;
+ private int episodeCacheSize;
private UserPreferences(Context context) {
this.context = context;
@@ -86,10 +93,15 @@ public class UserPreferences implements
updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL,
"0"));
allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
- autoQueue = sp.getBoolean(PREF_AUTO_QUEUE, true);
displayOnlyEpisodes = sp.getBoolean(PREF_DISPLAY_ONLY_EPISODES, false);
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
theme = readThemeValue(sp.getString(PREF_THEME, "0"));
+ enableAutodownloadWifiFilter = sp.getBoolean(
+ PREF_ENABLE_AUTODL_WIFI_FILTER, false);
+ autodownloadSelectedNetworks = StringUtils.split(
+ sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
+ episodeCacheSize = Integer.valueOf(sp.getString(
+ PREF_EPISODE_CACHE_SIZE, "20"));
}
private int readThemeValue(String valueFromPrefs) {
@@ -140,11 +152,6 @@ public class UserPreferences implements
return instance.allowMobileUpdate;
}
- public static boolean isAutoQueue() {
- instanceAvailable();
- return instance.autoQueue;
- }
-
public static boolean isDisplayOnlyEpisodes() {
instanceAvailable();
return instance.displayOnlyEpisodes;
@@ -160,6 +167,21 @@ public class UserPreferences implements
return instance.theme;
}
+ public static boolean isEnableAutodownloadWifiFilter() {
+ instanceAvailable();
+ return instance.enableAutodownloadWifiFilter;
+ }
+
+ public static String[] getAutodownloadSelectedNetworks() {
+ instanceAvailable();
+ return instance.autodownloadSelectedNetworks;
+ }
+
+ public static int getEpisodeCacheSize() {
+ instanceAvailable();
+ return instance.episodeCacheSize;
+ }
+
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
if (AppConfig.DEBUG)
@@ -196,17 +218,33 @@ public class UserPreferences implements
} else if (key.equals(PREF_AUTO_DELETE)) {
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
- } else if (key.equals(PREF_AUTO_QUEUE)) {
- autoQueue = sp.getBoolean(PREF_AUTO_QUEUE, true);
-
} else if (key.equals(PREF_DISPLAY_ONLY_EPISODES)) {
displayOnlyEpisodes = sp.getBoolean(PREF_DISPLAY_ONLY_EPISODES,
false);
} else if (key.equals(PREF_THEME)) {
theme = readThemeValue(sp.getString(PREF_THEME, ""));
+ } else if (key.equals(PREF_ENABLE_AUTODL_WIFI_FILTER)) {
+ enableAutodownloadWifiFilter = sp.getBoolean(
+ PREF_ENABLE_AUTODL_WIFI_FILTER, false);
+ } else if (key.equals(PREF_AUTODL_SELECTED_NETWORKS)) {
+ autodownloadSelectedNetworks = StringUtils.split(
+ sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
+ } else if (key.equals(PREF_EPISODE_CACHE_SIZE)) {
+ episodeCacheSize = Integer.valueOf(sp.getString(
+ PREF_EPISODE_CACHE_SIZE, "20"));
}
}
+ public static void setAutodownloadSelectedNetworks(Context context,
+ String[] value) {
+ SharedPreferences.Editor editor = PreferenceManager
+ .getDefaultSharedPreferences(context.getApplicationContext())
+ .edit();
+ editor.putString(PREF_AUTODL_SELECTED_NETWORKS,
+ StringUtils.join(value, ','));
+ editor.commit();
+ }
+
/**
* Return the folder where the app stores all of its data. This method will
* return the standard data folder if none has been set by the user.