diff options
author | ByteHamster <info@bytehamster.com> | 2022-04-25 22:45:47 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-04-26 17:57:42 +0200 |
commit | 069a2ca329a342ad0559a48719f49264d2610f00 (patch) | |
tree | 59cc8327dec62ddfd105d1ad2fdb59dcba12736e /app | |
parent | 20363ee41c814b14b16999505fa850a0943346dd (diff) | |
download | AntennaPod-069a2ca329a342ad0559a48719f49264d2610f00.zip |
Decouple preferences
Diffstat (limited to 'app')
5 files changed, 14 insertions, 8 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java index 902cad98c..ef5719d6f 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java @@ -10,6 +10,7 @@ import androidx.test.espresso.matcher.RootMatchers; import androidx.test.filters.LargeTest; import androidx.test.rule.ActivityTestRule; +import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithmFactory; import org.awaitility.Awaitility; import org.junit.Before; import org.junit.Rule; @@ -397,7 +398,7 @@ public class PreferencesTest { onView(withId(R.id.select_dialog_listview)).perform(swipeDown()); onView(withText(R.string.episode_cleanup_except_favorite_removal)).perform(click()); Awaitility.await().atMost(1000, MILLISECONDS) - .until(() -> UserPreferences.getEpisodeCleanupAlgorithm() instanceof ExceptFavoriteCleanupAlgorithm); + .until(() -> EpisodeCleanupAlgorithmFactory.build() instanceof ExceptFavoriteCleanupAlgorithm); } @Test @@ -408,7 +409,7 @@ public class PreferencesTest { onView(withId(R.id.select_dialog_listview)).perform(swipeDown()); onView(withText(R.string.episode_cleanup_queue_removal)).perform(click()); Awaitility.await().atMost(1000, MILLISECONDS) - .until(() -> UserPreferences.getEpisodeCleanupAlgorithm() instanceof APQueueCleanupAlgorithm); + .until(() -> EpisodeCleanupAlgorithmFactory.build() instanceof APQueueCleanupAlgorithm); } @Test @@ -419,7 +420,7 @@ public class PreferencesTest { onView(withId(R.id.select_dialog_listview)).perform(swipeUp()); onView(withText(R.string.episode_cleanup_never)).perform(click()); Awaitility.await().atMost(1000, MILLISECONDS) - .until(() -> UserPreferences.getEpisodeCleanupAlgorithm() instanceof APNullCleanupAlgorithm); + .until(() -> EpisodeCleanupAlgorithmFactory.build() instanceof APNullCleanupAlgorithm); } @Test @@ -431,7 +432,7 @@ public class PreferencesTest { onView(withText(R.string.episode_cleanup_after_listening)).perform(click()); Awaitility.await().atMost(1000, MILLISECONDS) .until(() -> { - EpisodeCleanupAlgorithm alg = UserPreferences.getEpisodeCleanupAlgorithm(); + EpisodeCleanupAlgorithm alg = EpisodeCleanupAlgorithmFactory.build(); if (alg instanceof APCleanupAlgorithm) { APCleanupAlgorithm cleanupAlg = (APCleanupAlgorithm) alg; return cleanupAlg.getNumberOfHoursAfterPlayback() == 0; @@ -450,7 +451,7 @@ public class PreferencesTest { onView(withText(search)).perform(click()); Awaitility.await().atMost(1000, MILLISECONDS) .until(() -> { - EpisodeCleanupAlgorithm alg = UserPreferences.getEpisodeCleanupAlgorithm(); + EpisodeCleanupAlgorithm alg = EpisodeCleanupAlgorithmFactory.build(); if (alg instanceof APCleanupAlgorithm) { APCleanupAlgorithm cleanupAlg = (APCleanupAlgorithm) alg; return cleanupAlg.getNumberOfHoursAfterPlayback() == 72; // 5 days diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 3f7a5db68..b23e22c9f 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -231,6 +231,7 @@ public class MainActivity extends CastEnabledActivity { // for backward compatibility, we only change defaults for fresh installs UserPreferences.setUpdateInterval(12); + AutoUpdateManager.restartUpdateAlarm(this); SharedPreferences.Editor edit = prefs.edit(); edit.putBoolean(PREF_IS_FIRST_LAUNCH, false); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FeedRefreshIntervalDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FeedRefreshIntervalDialog.java index 7e42302d1..f97940f8b 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FeedRefreshIntervalDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FeedRefreshIntervalDialog.java @@ -10,6 +10,7 @@ import android.widget.ArrayAdapter; import androidx.appcompat.app.AlertDialog; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.databinding.FeedRefreshDialogBinding; import org.apache.commons.lang3.ArrayUtils; @@ -70,6 +71,7 @@ public class FeedRefreshIntervalDialog { builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { if (viewBinding.intervalRadioButton.isChecked()) { UserPreferences.setUpdateInterval(INTERVAL_VALUES_HOURS[viewBinding.spinner.getSelectedItemPosition()]); + AutoUpdateManager.restartUpdateAlarm(context); } else if (viewBinding.timeRadioButton.isChecked()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { UserPreferences.setUpdateTimeOfDay(viewBinding.timePicker.getHour(), @@ -78,8 +80,10 @@ public class FeedRefreshIntervalDialog { UserPreferences.setUpdateTimeOfDay(viewBinding.timePicker.getCurrentHour(), viewBinding.timePicker.getCurrentMinute()); } + AutoUpdateManager.restartUpdateAlarm(context); } else if (viewBinding.disableRadioButton.isChecked()) { - UserPreferences.disableAutoUpdate(context); + UserPreferences.disableAutoUpdate(); + AutoUpdateManager.disableAutoUpdate(context); } else { throw new IllegalStateException("Unexpected error."); } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java index 2c3c44b1d..b24a26602 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.AntennapodHttpClient; -import de.danoeh.antennapod.core.service.download.ProxyConfig; +import de.danoeh.antennapod.model.download.ProxyConfig; import io.reactivex.Completable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java index 9e524188f..a468794cb 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java @@ -17,7 +17,7 @@ import java.util.Set; import de.danoeh.antennapod.R; import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; -import de.danoeh.antennapod.core.feed.SubscriptionsFilter; +import de.danoeh.antennapod.model.feed.SubscriptionsFilter; import de.danoeh.antennapod.core.feed.SubscriptionsFilterGroup; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.ui.common.RecursiveRadioGroup; |