summaryrefslogtreecommitdiff
path: root/core/src/main/java/de/danoeh/antennapod
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/de/danoeh/antennapod')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java504
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java3
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java31
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/gui/UndoBarController.java3
4 files changed, 297 insertions, 244 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index d196a91b9..594241573 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -22,7 +22,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.receiver.FeedUpdateReceiver;
@@ -35,37 +34,51 @@ import de.danoeh.antennapod.core.receiver.FeedUpdateReceiver;
*/
public class UserPreferences implements
SharedPreferences.OnSharedPreferenceChangeListener {
+
public static final String IMPORT_DIR = "import/";
+
private static final String TAG = "UserPreferences";
+ // User Infercasce
+ public static final String PREF_THEME = "prefTheme";
+ public static final String PREF_HIDDEN_DRAWER_ITEMS = "prefHiddenDrawerItems";
+ public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
+ public static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
+
+ // Queue
+ public static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront";
+
+ // Playback
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";
public static final String PREF_UNPAUSE_ON_HEADSET_RECONNECT = "prefUnpauseOnHeadsetReconnect";
public static final String PREF_FOLLOW_QUEUE = "prefFollowQueue";
- public static final String PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY = "prefDownloadMediaOnWifiOnly";
- public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
- public static final String PREF_PARALLEL_DOWNLOADS = "prefParallelDownloads";
- public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate";
public static final String PREF_AUTO_DELETE = "prefAutoDelete";
public static final String PREF_SMART_MARK_AS_PLAYED_SECS = "prefSmartMarkAsPlayedSecs";
- public static final String PREF_AUTO_FLATTR = "pref_auto_flattr";
- public static final String PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD = "prefAutoFlattrPlayedDurationThreshold";
- public static final String PREF_THEME = "prefTheme";
- public static final String PREF_DATA_FOLDER = "prefDataFolder";
- public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl";
- public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
- public static final String PREF_ENABLE_AUTODL_ON_BATTERY = "prefEnableAutoDownloadOnBattery";
- private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
- public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
- private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss";
public static final String PREF_RESUME_AFTER_CALL = "prefResumeAfterCall";
+
+ // Network
+ public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
+ public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate";
+ public static final String PREF_PARALLEL_DOWNLOADS = "prefParallelDownloads";
+ public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
+ public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl";
+ public static final String PREF_ENABLE_AUTODL_ON_BATTERY = "prefEnableAutoDownloadOnBattery";
+ public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
+ public static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
+
+ // Services
+ public static final String PREF_AUTO_FLATTR = "pref_auto_flattr";
+ public static final String PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD = "prefAutoFlattrPlayedDurationThreshold";
+
+ // Other
+ public static final String PREF_DATA_FOLDER = "prefDataFolder";
+
+ // Mediaplayer
+ public static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs";
private static final String PREF_REWIND_SECS = "prefRewindSecs";
- private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
- private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
- public static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront";
- public static final String PREF_HIDDEN_DRAWER_ITEMS = "prefHiddenDrawerItems";
public static final String PREF_QUEUE_LOCKED = "prefQueueLocked";
// TODO: Make this value configurable
@@ -76,36 +89,46 @@ public class UserPreferences implements
private static UserPreferences instance;
private final Context context;
- // Preferences
+ // User Interface
+ private int theme;
+ private List<String> hiddenDrawerItems;
+ private int notifyPriority;
+ private boolean persistNotify;
+
+ // Queue
+ private boolean enqueueAtFront;
+
+ // Playback
private boolean pauseOnHeadsetDisconnect;
private boolean unpauseOnHeadsetReconnect;
private boolean followQueue;
- private boolean downloadMediaOnWifiOnly;
- private long updateInterval;
- private boolean allowMobileUpdate;
private boolean autoDelete;
private int smartMarkAsPlayedSecs;
- private boolean autoFlattr;
- private float autoFlattrPlayedDurationThreshold;
- private int theme;
+ private String[] playbackSpeedArray;
+ private boolean pauseForFocusLoss;
+ private boolean resumeAfterCall;
+
+ // Network
+ private long updateInterval;
+ private boolean allowMobileUpdate;
+ private int parallelDownloads;
+ private int episodeCacheSize;
private boolean enableAutodownload;
- private boolean enableAutodownloadWifiFilter;
private boolean enableAutodownloadOnBattery;
+ private boolean enableAutodownloadWifiFilter;
private String[] autodownloadSelectedNetworks;
- private int parallelDownloads;
- private int episodeCacheSize;
+
+ // Services
+ private boolean autoFlattr;
+ private float autoFlattrPlayedDurationThreshold;
+
+ // Settings somewhere in the GUI
private String playbackSpeed;
- private String[] playbackSpeedArray;
- private boolean pauseForFocusLoss;
- private boolean resumeAfterCall;
private int fastForwardSecs;
private int rewindSecs;
- private boolean isFreshInstall;
- private int notifyPriority;
- private boolean persistNotify;
- private List<String> hiddenDrawerItems;
private boolean queueLocked;
+
private UserPreferences(Context context) {
this.context = context;
loadPreferences();
@@ -130,50 +153,53 @@ 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);
- unpauseOnHeadsetReconnect = sp.getBoolean(
- PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
+
+ // User Interface
+ theme = readThemeValue(sp.getString(PREF_THEME, "0"));
+ if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
+ notifyPriority = NotificationCompat.PRIORITY_MAX;
+ } else {
+ notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
+ }
+ hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
+ persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
+
+ // Queue
+ enqueueAtFront = sp.getBoolean(PREF_QUEUE_ADD_TO_FRONT, false);
+
+ // Playback
+ pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
+ unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
- downloadMediaOnWifiOnly = sp.getBoolean(
- PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY, true);
- updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL,
- "0"));
- allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
smartMarkAsPlayedSecs = Integer.valueOf(sp.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
- autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
- autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
- PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
- 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, ""), ',');
+ playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
+ PREF_PLAYBACK_SPEED_ARRAY, null));
+ pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
+
+ // Network
+ updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL, "0"));
+ allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
- episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(
- PREF_EPISODE_CACHE_SIZE, "20"));
+ EPISODE_CACHE_SIZE_UNLIMITED = context.getResources().getInteger(
+ R.integer.episode_cache_size_unlimited);
+ episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(PREF_EPISODE_CACHE_SIZE, "20"));
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
+ enableAutodownloadWifiFilter = sp.getBoolean(PREF_ENABLE_AUTODL_WIFI_FILTER, false);
+ autodownloadSelectedNetworks = StringUtils.split(
+ sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
+
+ // Services
+ autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
+ autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
+ PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
+
+ // MediaPlayer
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
- playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
- PREF_PLAYBACK_SPEED_ARRAY, null));
- pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
- resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true);
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
- if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
- notifyPriority = NotificationCompat.PRIORITY_MAX;
- }
- else {
- notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
- }
- persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
- hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
queueLocked = sp.getBoolean(PREF_QUEUE_LOCKED, false);
}
@@ -224,8 +250,7 @@ public class UserPreferences implements
selectedSpeeds[i] = jsonArray.getString(i);
}
} catch (JSONException e) {
- Log.e(TAG,
- "Got JSON error when trying to get speeds from JSONArray");
+ Log.e(TAG, "Got JSON error when trying to get speeds from JSONArray");
e.printStackTrace();
}
}
@@ -234,107 +259,93 @@ public class UserPreferences implements
private static void instanceAvailable() {
if (instance == null) {
- throw new IllegalStateException(
- "UserPreferences was used before being set up");
+ throw new IllegalStateException("UserPreferences was used before being set up");
}
}
- public static boolean isPauseOnHeadsetDisconnect() {
- instanceAvailable();
- return instance.pauseOnHeadsetDisconnect;
- }
-
- public static boolean isUnpauseOnHeadsetReconnect() {
- instanceAvailable();
- return instance.unpauseOnHeadsetReconnect;
- }
-
- public static boolean isFollowQueue() {
- instanceAvailable();
- return instance.followQueue;
- }
-
- public static boolean isDownloadMediaOnWifiOnly() {
- instanceAvailable();
- return instance.downloadMediaOnWifiOnly;
- }
-
- public static long getUpdateInterval() {
- instanceAvailable();
- return instance.updateInterval;
- }
-
- public static boolean isAllowMobileUpdate() {
- instanceAvailable();
- return instance.allowMobileUpdate;
- }
-
- public static boolean isAutoDelete() {
+ /**
+ * Returns theme as R.style value
+ *
+ * @return R.style.Theme_AntennaPod_Light or R.style.Theme_AntennaPod_Dark
+ */
+ public static int getTheme() {
instanceAvailable();
- return instance.autoDelete;
+ return instance.theme;
}
- public static int getSmartMarkAsPlayedSecs() {
- instanceAvailable();;
- return instance.smartMarkAsPlayedSecs;
+ public static int getNoTitleTheme() {
+ int theme = getTheme();
+ if (theme == R.style.Theme_AntennaPod_Dark) {
+ return R.style.Theme_AntennaPod_Dark_NoTitle;
+ } else {
+ return R.style.Theme_AntennaPod_Light_NoTitle;
+ }
}
- public static boolean isAutoFlattr() {
+ public static List<String> getHiddenDrawerItems() {
instanceAvailable();
- return instance.autoFlattr;
+ return new ArrayList<String>(instance.hiddenDrawerItems);
}
+ /**
+ * Returns notification priority.
+ *
+ * @return NotificationCompat.PRIORITY_MAX or NotificationCompat.PRIORITY_DEFAULT
+ */
public static int getNotifyPriority() {
instanceAvailable();
return instance.notifyPriority;
}
+ /**
+ * Returns true if notifications are persistent
+ *
+ * @return {@code true} if notifications are persistent, {@code false} otherwise
+ */
public static boolean isPersistNotify() {
instanceAvailable();
return instance.persistNotify;
}
-
/**
- * Returns the time after which an episode should be auto-flattr'd in percent of the episode's
- * duration.
+ * Returns {@code true} if new queue elements are added to the front
+ *
+ * @return {@code true} if new queue elements are added to the front; {@code false} otherwise
*/
- public static float getAutoFlattrPlayedDurationThreshold() {
+ public static boolean enqueueAtFront() {
instanceAvailable();
- return instance.autoFlattrPlayedDurationThreshold;
+ return instance.enqueueAtFront;
}
- public static int getTheme() {
+ public static boolean isPauseOnHeadsetDisconnect() {
instanceAvailable();
- return instance.theme;
+ return instance.pauseOnHeadsetDisconnect;
}
- public static int getNoTitleTheme() {
- int theme = getTheme();
- if (theme == R.style.Theme_AntennaPod_Dark) {
- return R.style.Theme_AntennaPod_Dark_NoTitle;
- } else {
- return R.style.Theme_AntennaPod_Light_NoTitle;
- }
+ public static boolean isUnpauseOnHeadsetReconnect() {
+ instanceAvailable();
+ return instance.unpauseOnHeadsetReconnect;
}
- public static boolean isEnableAutodownloadWifiFilter() {
+
+ public static boolean isFollowQueue() {
instanceAvailable();
- return instance.enableAutodownloadWifiFilter;
+ return instance.followQueue;
}
- public static String[] getAutodownloadSelectedNetworks() {
+ public static boolean isAutoDelete() {
instanceAvailable();
- return instance.autodownloadSelectedNetworks;
+ return instance.autoDelete;
}
- public static int getParallelDownloads() {
+ public static int getSmartMarkAsPlayedSecs() {
instanceAvailable();
- return instance.parallelDownloads;
+ return instance.smartMarkAsPlayedSecs;
}
- public static int getEpisodeCacheSizeUnlimited() {
- return EPISODE_CACHE_SIZE_UNLIMITED;
+ public static boolean isAutoFlattr() {
+ instanceAvailable();
+ return instance.autoFlattr;
}
public static String getPlaybackSpeed() {
@@ -347,19 +358,28 @@ public class UserPreferences implements
return instance.playbackSpeedArray;
}
- public static int getFastFowardSecs() {
+ public static boolean shouldPauseForFocusLoss() {
instanceAvailable();
- return instance.fastForwardSecs;
+ return instance.pauseForFocusLoss;
}
- public static int getRewindSecs() {
+ public static long getUpdateInterval() {
instanceAvailable();
- return instance.rewindSecs;
+ return instance.updateInterval;
}
- public static List<String> getHiddenDrawerItems() {
+ public static boolean isAllowMobileUpdate() {
instanceAvailable();
- return new ArrayList<String>(instance.hiddenDrawerItems);
+ return instance.allowMobileUpdate;
+ }
+
+ public static int getParallelDownloads() {
+ instanceAvailable();
+ return instance.parallelDownloads;
+ }
+
+ public static int getEpisodeCacheSizeUnlimited() {
+ return EPISODE_CACHE_SIZE_UNLIMITED;
}
/**
@@ -382,19 +402,39 @@ public class UserPreferences implements
return instance.enableAutodownloadOnBattery;
}
- public static boolean shouldPauseForFocusLoss() {
+ public static boolean isEnableAutodownloadWifiFilter() {
instanceAvailable();
- return instance.pauseForFocusLoss;
+ return instance.enableAutodownloadWifiFilter;
}
- public static boolean shouldResumeAfterCall() {
+ public static int getFastFowardSecs() {
instanceAvailable();
- return instance.resumeAfterCall;
+ return instance.fastForwardSecs;
+ }
+
+ public static int getRewindSecs() {
+ instanceAvailable();
+ return instance.rewindSecs;
+ }
+
+
+ /**
+ * Returns the time after which an episode should be auto-flattr'd in percent of the episode's
+ * duration.
+ */
+ public static float getAutoFlattrPlayedDurationThreshold() {
+ instanceAvailable();
+ return instance.autoFlattrPlayedDurationThreshold;
+ }
+
+ public static String[] getAutodownloadSelectedNetworks() {
+ instanceAvailable();
+ return instance.autodownloadSelectedNetworks;
}
- public static boolean isFreshInstall() {
+ public static boolean shouldResumeAfterCall() {
instanceAvailable();
- return instance.isFreshInstall;
+ return instance.resumeAfterCall;
}
public static boolean isQueueLocked() {
@@ -405,77 +445,103 @@ public class UserPreferences implements
@Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
Log.d(TAG, "Registered change of user preferences. Key: " + key);
-
- if (key.equals(PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY)) {
- downloadMediaOnWifiOnly = sp.getBoolean(
- PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY, true);
-
- } else if (key.equals(PREF_MOBILE_UPDATE)) {
- allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
-
- } else if (key.equals(PREF_FOLLOW_QUEUE)) {
- followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
-
- } else if (key.equals(PREF_UPDATE_INTERVAL)) {
- updateInterval = readUpdateInterval(sp.getString(
- PREF_UPDATE_INTERVAL, "0"));
- ClientConfig.applicationCallbacks.setUpdateInterval(updateInterval);
- } else if (key.equals(PREF_AUTO_DELETE)) {
- autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
- } else if (key.equals(PREF_SMART_MARK_AS_PLAYED_SECS)) {
- smartMarkAsPlayedSecs = Integer.valueOf(sp.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
- } else if (key.equals(PREF_AUTO_FLATTR)) {
- autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, 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_PARALLEL_DOWNLOADS)) {
- parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
- } else if (key.equals(PREF_EPISODE_CACHE_SIZE)) {
- episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(
- PREF_EPISODE_CACHE_SIZE, "20"));
- } else if (key.equals(PREF_ENABLE_AUTODL)) {
- enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
- } else if (key.equals(PREF_ENABLE_AUTODL_ON_BATTERY)) {
- enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
- } else if (key.equals(PREF_PLAYBACK_SPEED)) {
- playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
- } else if (key.equals(PREF_PLAYBACK_SPEED_ARRAY)) {
- playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
- PREF_PLAYBACK_SPEED_ARRAY, null));
- } else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) {
- pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
- } else if (key.equals(PREF_RESUME_AFTER_CALL)) {
- resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true);
- } else if (key.equals(PREF_FAST_FORWARD_SECS)) {
- fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
- } else if (key.equals(PREF_REWIND_SECS)) {
- rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
- } else if (key.equals(PREF_PAUSE_ON_HEADSET_DISCONNECT)) {
- pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
- } else if (key.equals(PREF_UNPAUSE_ON_HEADSET_RECONNECT)) {
- unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
- } else if (key.equals(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD)) {
- autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
- PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
- } else if (key.equals(PREF_EXPANDED_NOTIFICATION)) {
- if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
- notifyPriority = NotificationCompat.PRIORITY_MAX;
- }
- else {
- notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
- }
- } else if (key.equals(PREF_PERSISTENT_NOTIFICATION)) {
- persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
- } else if (key.equals(PREF_HIDDEN_DRAWER_ITEMS)) {
- hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
- } else if(key.equals(PREF_QUEUE_LOCKED)) {
- queueLocked = sp.getBoolean(PREF_QUEUE_LOCKED, false);
+ switch(key) {
+ // User Interface
+ case PREF_THEME:
+ theme = readThemeValue(sp.getString(PREF_THEME, ""));
+ break;
+ case PREF_HIDDEN_DRAWER_ITEMS:
+ hiddenDrawerItems = Arrays.asList(StringUtils.split(sp.getString(PREF_HIDDEN_DRAWER_ITEMS, ""), ','));
+ break;
+ case PREF_EXPANDED_NOTIFICATION:
+ if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
+ notifyPriority = NotificationCompat.PRIORITY_MAX;
+ } else {
+ notifyPriority = NotificationCompat.PRIORITY_DEFAULT;
+ }
+ break;
+ case PREF_PERSISTENT_NOTIFICATION:
+ persistNotify = sp.getBoolean(PREF_PERSISTENT_NOTIFICATION, false);
+ break;
+ // Queue
+ case PREF_QUEUE_ADD_TO_FRONT:
+ enqueueAtFront = sp.getBoolean(PREF_QUEUE_ADD_TO_FRONT, false);
+ break;
+ // Playback
+ case PREF_PAUSE_ON_HEADSET_DISCONNECT:
+ pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
+ break;
+ case PREF_UNPAUSE_ON_HEADSET_RECONNECT:
+ unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
+ break;
+ case PREF_FOLLOW_QUEUE:
+ followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
+ break;
+ case PREF_AUTO_DELETE:
+ autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
+ break;
+ case PREF_SMART_MARK_AS_PLAYED_SECS:
+ smartMarkAsPlayedSecs = Integer.valueOf(sp.getString(PREF_SMART_MARK_AS_PLAYED_SECS, "30"));
+ break;
+ case PREF_PLAYBACK_SPEED_ARRAY:
+ playbackSpeedArray = readPlaybackSpeedArray(sp.getString(PREF_PLAYBACK_SPEED_ARRAY, null));
+ break;
+ case PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS:
+ pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
+ break;
+ case PREF_RESUME_AFTER_CALL:
+ resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true);
+ break;
+ // Network
+ case PREF_UPDATE_INTERVAL:
+ updateInterval = readUpdateInterval(sp.getString(PREF_UPDATE_INTERVAL, "0"));
+ ClientConfig.applicationCallbacks.setUpdateInterval(updateInterval);
+ break;
+ case PREF_MOBILE_UPDATE:
+ allowMobileUpdate = sp.getBoolean(PREF_MOBILE_UPDATE, false);
+ break;
+ case PREF_PARALLEL_DOWNLOADS:
+ parallelDownloads = Integer.valueOf(sp.getString(PREF_PARALLEL_DOWNLOADS, "6"));
+ break;
+ case PREF_EPISODE_CACHE_SIZE:
+ episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(PREF_EPISODE_CACHE_SIZE, "20"));
+ break;
+ case PREF_ENABLE_AUTODL:
+ enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
+ break;
+ case PREF_ENABLE_AUTODL_ON_BATTERY:
+ enableAutodownloadOnBattery = sp.getBoolean(PREF_ENABLE_AUTODL_ON_BATTERY, true);
+ break;
+ case PREF_ENABLE_AUTODL_WIFI_FILTER:
+ enableAutodownloadWifiFilter = sp.getBoolean(PREF_ENABLE_AUTODL_WIFI_FILTER, false);
+ break;
+ case PREF_AUTODL_SELECTED_NETWORKS:
+ autodownloadSelectedNetworks = StringUtils.split(
+ sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
+ break;
+ // Services
+ case PREF_AUTO_FLATTR:
+ autoFlattr = sp.getBoolean(PREF_AUTO_FLATTR, false);
+ break;
+ case PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD:
+ autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
+ PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
+ break;
+ // Mediaplayer
+ case PREF_PLAYBACK_SPEED:
+ playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
+ break;
+ case PREF_FAST_FORWARD_SECS:
+ fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
+ break;
+ case PREF_REWIND_SECS:
+ rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
+ break;
+ case PREF_QUEUE_LOCKED:
+ queueLocked = sp.getBoolean(PREF_QUEUE_LOCKED, false);
+ break;
+ default:
+ Log.w(TAG, "Unhandled key: " + key);
}
}
@@ -625,7 +691,6 @@ public class UserPreferences implements
}
return typeDir;
}
-
}
}
@@ -653,8 +718,7 @@ public class UserPreferences implements
Log.e(TAG, "Could not create .nomedia file");
e.printStackTrace();
}
- if (BuildConfig.DEBUG)
- Log.d(TAG, ".nomedia file created");
+ Log.d(TAG, ".nomedia file created");
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java
index 7a631a62b..b9a61e62b 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java
@@ -418,8 +418,7 @@ public class DBWriter {
if (item != null) {
// add item to either front ot back of queue
- boolean addToFront = PreferenceManager.getDefaultSharedPreferences(context)
- .getBoolean(UserPreferences.PREF_QUEUE_ADD_TO_FRONT, false);
+ boolean addToFront = UserPreferences.enqueueAtFront();
if(addToFront){
queue.add(0, item);
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
index 90caad946..50792ae26 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/flattr/FlattrUtils.java
@@ -26,7 +26,6 @@ import java.util.EnumSet;
import java.util.List;
import java.util.TimeZone;
-import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.asynctask.FlattrTokenFetcher;
@@ -65,18 +64,15 @@ public class FlattrUtils {
private static AccessToken retrieveToken() {
if (cachedToken == null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Retrieving access token");
+ Log.d(TAG, "Retrieving access token");
String token = PreferenceManager.getDefaultSharedPreferences(
ClientConfig.applicationCallbacks.getApplicationInstance())
.getString(PREF_ACCESS_TOKEN, null);
if (token != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Found access token. Caching.");
+ Log.d(TAG, "Found access token. Caching.");
cachedToken = new AccessToken(token);
} else {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "No access token found");
+ Log.d(TAG, "No access token found");
return null;
}
}
@@ -97,8 +93,7 @@ public class FlattrUtils {
}
public static void storeToken(AccessToken token) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Storing token");
+ Log.d(TAG, "Storing token");
SharedPreferences.Editor editor = PreferenceManager
.getDefaultSharedPreferences(ClientConfig.applicationCallbacks.getApplicationInstance()).edit();
if (token != null) {
@@ -111,8 +106,7 @@ public class FlattrUtils {
}
public static void deleteToken() {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Deleting flattr token");
+ Log.d(TAG, "Deleting flattr token");
storeToken(null);
}
@@ -169,15 +163,11 @@ public class FlattrUtils {
}
}
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "Got my flattrs list of length " + Integer.toString(myFlattrs.size()) + " comparison date" + firstOfMonthDate);
-
- for (Flattr fl : myFlattrs) {
- Thing thing = fl.getThing();
- Log.d(TAG, "Flattr thing: " + fl.getThingId() + " name: " + thing.getTitle() + " url: " + thing.getUrl() + " on: " + fl.getCreated());
- }
+ Log.d(TAG, "Got my flattrs list of length " + Integer.toString(myFlattrs.size()) + " comparison date" + firstOfMonthDate);
+ for (Flattr fl : myFlattrs) {
+ Thing thing = fl.getThing();
+ Log.d(TAG, "Flattr thing: " + fl.getThingId() + " name: " + thing.getTitle() + " url: " + thing.getUrl() + " on: " + fl.getCreated());
}
-
} else {
Log.e(TAG, "retrieveFlattrdThings was called with null access token");
}
@@ -191,8 +181,7 @@ public class FlattrUtils {
}
public static void revokeAccessToken(Context context) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Revoking access token");
+ Log.d(TAG, "Revoking access token");
deleteToken();
FlattrServiceCreator.deleteFlattrService();
showRevokeDialog(context);
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/gui/UndoBarController.java b/core/src/main/java/de/danoeh/antennapod/core/util/gui/UndoBarController.java
index 23d8cf7c7..26c712af3 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/gui/UndoBarController.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/gui/UndoBarController.java
@@ -88,7 +88,8 @@ public class UndoBarController<T> {
}
public void close() {
- mHideHandler.post(mHideRunnable);
+ hideUndoBar(true);
+ mUndoListener.onHide(mUndoToken);
}
public void hideUndoBar(boolean immediate) {