summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/preferences
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-02-24 12:30:23 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2013-02-24 12:30:23 +0100
commitf9e00f72a0dfeea3e5b9db8a522f7251e158dc7d (patch)
tree86396c75b933e10fe4adad579ade3bafa329b0f2 /src/de/danoeh/antennapod/preferences
parent56f199dc8c69d7e24d0e05613f9911c323cb46a6 (diff)
downloadAntennaPod-f9e00f72a0dfeea3e5b9db8a522f7251e158dc7d.zip
limited access to feed items, feeds, playback history and download log
Diffstat (limited to 'src/de/danoeh/antennapod/preferences')
-rw-r--r--src/de/danoeh/antennapod/preferences/UserPreferences.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java
index 7625f88e4..c0f0f9353 100644
--- a/src/de/danoeh/antennapod/preferences/UserPreferences.java
+++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java
@@ -45,7 +45,7 @@ public class UserPreferences implements
private boolean pauseOnHeadsetDisconnect;
private boolean followQueue;
private boolean downloadMediaOnWifiOnly;
- private int updateInterval;
+ private long updateInterval;
private boolean allowMobileUpdate;
private boolean autoQueue;
private boolean displayOnlyEpisodes;
@@ -55,10 +55,6 @@ public class UserPreferences implements
private UserPreferences(Context context) {
this.context = context;
loadPreferences();
- createImportDirectory();
- createNoMediaFile();
- PreferenceManager.getDefaultSharedPreferences(context)
- .registerOnSharedPreferenceChangeListener(this);
}
/**
@@ -73,6 +69,11 @@ public class UserPreferences implements
if (context == null)
throw new IllegalArgumentException("Context must not be null");
instance = new UserPreferences(context);
+
+ createImportDirectory();
+ createNoMediaFile();
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .registerOnSharedPreferenceChangeListener(instance);
}
private void loadPreferences() {
@@ -83,7 +84,8 @@ public class UserPreferences implements
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
downloadMediaOnWifiOnly = sp.getBoolean(
PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY, true);
- updateInterval = sp.getInt(PREF_UPDATE_INTERVAL, 0);
+ 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);
@@ -102,6 +104,11 @@ public class UserPreferences implements
}
}
+ private long readUpdateInterval(String valueFromPrefs) {
+ int hours = Integer.parseInt(valueFromPrefs);
+ return TimeUnit.HOURS.toMillis(hours);
+ }
+
private static void instanceAvailable() {
if (instance == null) {
throw new IllegalStateException(
@@ -124,7 +131,7 @@ public class UserPreferences implements
return instance.downloadMediaOnWifiOnly;
}
- public static int getUpdateInterval() {
+ public static long getUpdateInterval() {
instanceAvailable();
return instance.updateInterval;
}
@@ -170,18 +177,16 @@ public class UserPreferences implements
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
} else if (key.equals(PREF_UPDATE_INTERVAL)) {
- updateInterval = sp.getInt(PREF_UPDATE_INTERVAL, 0);
AlarmManager alarmManager = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
- int hours = Integer.parseInt(sp
- .getString(PREF_UPDATE_INTERVAL, "0"));
+ updateInterval = readUpdateInterval(sp.getString(
+ PREF_UPDATE_INTERVAL, "0"));
PendingIntent updateIntent = PendingIntent.getBroadcast(context, 0,
new Intent(FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
alarmManager.cancel(updateIntent);
- if (hours != 0) {
- long newIntervall = TimeUnit.HOURS.toMillis(hours);
+ if (updateInterval != 0) {
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
- newIntervall, newIntervall, updateIntent);
+ updateInterval, updateInterval, updateIntent);
if (AppConfig.DEBUG)
Log.d(TAG, "Changed alarm to new intervall");
} else {