From 0beeeb435153f1fdb11ffe7f89899b76c10f3f3b Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Fri, 2 Oct 2015 07:56:34 -0400 Subject: [PATCH] resolved bug in how we were choosing the default cleanup parameter --- .../java/de/test/antennapod/storage/DBTasksTest.java | 1 + .../antennapod/preferences/PreferenceController.java | 4 ++-- .../antennapod/core/preferences/UserPreferences.java | 7 +++++-- .../danoeh/antennapod/core/storage/APCleanupAlgorithm.java | 2 +- .../antennapod/core/storage/APQueueCleanupAlgorithm.java | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java b/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java index 024b506d9..698d23406 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java @@ -65,6 +65,7 @@ public class DBTasksTest extends InstrumentationTestCase { SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit(); prefEdit.putString(UserPreferences.PREF_EPISODE_CACHE_SIZE, Integer.toString(EPISODE_CACHE_SIZE)); + prefEdit.putInt(UserPreferences.PREF_EPISODE_CLEANUP, UserPreferences.EPISODE_CLEANUP_DEFAULT); prefEdit.commit(); UserPreferences.init(context); diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index 0b3fda9b2..a8838dafa 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -442,9 +442,9 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc String[] entries = new String[values.length]; for (int x = 0; x < values.length; x++) { int v = Integer.parseInt(values[x]); - if (v == -1) { + if (v == UserPreferences.EPISODE_CLEANUP_QUEUE) { entries[x] = res.getString(R.string.episode_cleanup_queue_removal); - } else if (v == -2){ + } else if (v == UserPreferences.EPISODE_CLEANUP_NULL){ entries[x] = res.getString(R.string.episode_cleanup_never); } else if (v == 0) { entries[x] = res.getString(R.string.episode_cleanup_after_listening); 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 1d5bd5031..f706c83ee 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 @@ -98,6 +98,9 @@ public class UserPreferences { // Experimental public static final String PREF_SONIC = "prefSonic"; public static final String PREF_NORMALIZER = "prefNormalizer"; + public static final int EPISODE_CLEANUP_QUEUE = -1; + public static final int EPISODE_CLEANUP_NULL = -2; + public static final int EPISODE_CLEANUP_DEFAULT = 0; // Constants private static int EPISODE_CACHE_SIZE_UNLIMITED = -1; @@ -494,9 +497,9 @@ public class UserPreferences { public static EpisodeCleanupAlgorithm getEpisodeCleanupAlgorithm() { int cleanupValue = prefs.getInt(PREF_EPISODE_CLEANUP, -1); - if (cleanupValue == -1) { + if (cleanupValue == EPISODE_CLEANUP_QUEUE) { return new APQueueCleanupAlgorithm(); - } else if (cleanupValue == -2) { + } else if (cleanupValue == EPISODE_CLEANUP_NULL) { return new APNullCleanupAlgorithm(); } else { return new APCleanupAlgorithm(cleanupValue); 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 ef834921a..b4fbdaea1 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 @@ -90,6 +90,6 @@ public class APCleanupAlgorithm extends EpisodeCleanupAlgorithm { @Override public int getDefaultCleanupParameter() { - return 0; + return getNumEpisodesToCleanup(0); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/APQueueCleanupAlgorithm.java b/core/src/main/java/de/danoeh/antennapod/core/storage/APQueueCleanupAlgorithm.java index ebf8ca4cf..549b4e02c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/APQueueCleanupAlgorithm.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/APQueueCleanupAlgorithm.java @@ -74,6 +74,6 @@ public class APQueueCleanupAlgorithm extends EpisodeCleanupAlgorithm { @Override public int getDefaultCleanupParameter() { - return 0; + return getNumEpisodesToCleanup(0); } }