diff options
author | orionlee <orionlee@yahoo.com> | 2018-11-14 14:14:15 -0800 |
---|---|---|
committer | orionlee <orionlee@yahoo.com> | 2019-01-04 10:33:26 -0800 |
commit | d1c73dda5b5e7d9346c24d323461810bac18499e (patch) | |
tree | 2e6dd62af5126cf65f6fb0031bdddb66b9c1331d /core/src/main/java/de | |
parent | 566a682122a8438a656b72ec603e6ddaae90727c (diff) | |
download | AntennaPod-d1c73dda5b5e7d9346c24d323461810bac18499e.zip |
episode cleanup 12 hour option - use hours internally part 2 (persisted shared preference)
requires data migartion: app versionCode increased to 1070196
Diffstat (limited to 'core/src/main/java/de')
4 files changed, 19 insertions, 9 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java b/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java index 8ad70c328..9b8806d5b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java +++ b/core/src/main/java/de/danoeh/antennapod/core/UpdateManager.java @@ -63,6 +63,14 @@ class UpdateManager { UserPreferences.enableSonic(); } } + + if(oldVersionCode < 1070196) { + // migrate episode cleanup value (unit changed from days to hours) + int oldValueInDays = UserPreferences.getEpisodeCleanupValue(); + if (oldValueInDays > 0) { + UserPreferences.setEpisodeCleanupValue(oldValueInDays * 24); + } // else 0 or special negative values, no change needed + } } } 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 a8d0b6ba1..95f206a63 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 @@ -674,7 +674,7 @@ public class UserPreferences { } public static EpisodeCleanupAlgorithm getEpisodeCleanupAlgorithm() { - float cleanupValue = Float.parseFloat(prefs.getString(PREF_EPISODE_CLEANUP, "-1")); + int cleanupValue = getEpisodeCleanupValue(); if (cleanupValue == EPISODE_CLEANUP_QUEUE) { return new APQueueCleanupAlgorithm(); } else if (cleanupValue == EPISODE_CLEANUP_NULL) { @@ -684,6 +684,16 @@ public class UserPreferences { } } + public static int getEpisodeCleanupValue() { + return Integer.parseInt(prefs.getString(PREF_EPISODE_CLEANUP, "-1")); + } + + public static void setEpisodeCleanupValue(int episodeCleanupValue) { + prefs.edit() + .putString(PREF_EPISODE_CLEANUP, Integer.toString(episodeCleanupValue)) + .apply(); + } + /** * 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. diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/APCleanupAlgorithm.java b/core/src/main/java/de/danoeh/antennapod/core/storage/APCleanupAlgorithm.java index 1b446dd6f..c63ac4416 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/APCleanupAlgorithm.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/APCleanupAlgorithm.java @@ -29,10 +29,6 @@ public class APCleanupAlgorithm extends EpisodeCleanupAlgorithm { this.numberOfHoursAfterPlayback = numberOfHoursAfterPlayback; } - public APCleanupAlgorithm(float numberOfDaysAfterPlayback) { // TODO: temporary, until callers are migrated - this.numberOfHoursAfterPlayback = (int)(24 * numberOfDaysAfterPlayback); - } - /** * @return the number of episodes that *could* be cleaned up, if needed */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java index 5915d216c..6966667bf 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java @@ -131,10 +131,6 @@ public final class Converter { } - public static int numberOfDaysFloatToNumberOfHours(float numberOfDays) { - return (int)Math.ceil(numberOfDays * 24); - } - /** * Converts the volume as read as the progress from a SeekBar scaled to 100 and as saved in * UserPreferences to the format taken by setVolume methods. |