mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-10-29 03:36:21 +00:00
Migrate update interval from hours to minutes (#8005)
This is a bit of a hack so that we have "1" available for "global" (instead of 1 hour) because we cannot change sql default values.
This commit is contained in:
parent
6f7f9b2914
commit
198c151a22
@ -180,7 +180,7 @@ public class EspressoTestUtils {
|
|||||||
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getInstrumentation().getTargetContext())
|
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getInstrumentation().getTargetContext())
|
||||||
.edit()
|
.edit()
|
||||||
.putString(UserPreferences.PREF_UPDATE_INTERVAL, "0")
|
.putString(UserPreferences.PREF_UPDATE_INTERVAL_MINUTES, "0")
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,8 +144,9 @@ public class PreferenceUpgrader {
|
|||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
UserPreferences.setAllowMobileSync(true);
|
UserPreferences.setAllowMobileSync(true);
|
||||||
if (prefs.getString(UserPreferences.PREF_UPDATE_INTERVAL, ":").contains(":")) { // Unset or "time of day"
|
if (prefs.getString(UserPreferences.PREF_UPDATE_INTERVAL_MINUTES, ":").contains(":")) {
|
||||||
prefs.edit().putString(UserPreferences.PREF_UPDATE_INTERVAL, "12").apply();
|
// Unset or "time of day"
|
||||||
|
prefs.edit().putString(UserPreferences.PREF_UPDATE_INTERVAL_MINUTES, "12").apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldVersion < 3020000) {
|
if (oldVersion < 3020000) {
|
||||||
@ -178,6 +179,8 @@ public class PreferenceUpgrader {
|
|||||||
UserPreferences.setBottomNavigationEnabled(true);
|
UserPreferences.setBottomNavigationEnabled(true);
|
||||||
}
|
}
|
||||||
if (oldVersion < 3100000) {
|
if (oldVersion < 3100000) {
|
||||||
|
// Migrate refresh interval from hours to minutes
|
||||||
|
UserPreferences.setUpdateInterval(60L * UserPreferences.getUpdateInterval());
|
||||||
FeedUpdateManager.getInstance().restartUpdateAlarm(context, true);
|
FeedUpdateManager.getInstance().restartUpdateAlarm(context, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,7 +78,8 @@ public class DownloadsPreferencesFragment extends AnimatedPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (UserPreferences.PREF_UPDATE_INTERVAL.equals(key) || UserPreferences.PREF_MOBILE_UPDATE.equals(key)) {
|
if (UserPreferences.PREF_UPDATE_INTERVAL_MINUTES.equals(key)
|
||||||
|
|| UserPreferences.PREF_MOBILE_UPDATE.equals(key)) {
|
||||||
FeedUpdateManager.getInstance().restartUpdateAlarm(getContext(), true);
|
FeedUpdateManager.getInstance().restartUpdateAlarm(getContext(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,7 +81,7 @@ public class FeedUpdateWorker extends Worker {
|
|||||||
}
|
}
|
||||||
if (isAutomaticRefresh && isAutomaticRefreshEnabled
|
if (isAutomaticRefresh && isAutomaticRefreshEnabled
|
||||||
&& feed.getLastRefreshAttempt() > System.currentTimeMillis() - JOB_SCHEDULE_TIME_VARIATION
|
&& feed.getLastRefreshAttempt() > System.currentTimeMillis() - JOB_SCHEDULE_TIME_VARIATION
|
||||||
- TimeUnit.HOURS.toMillis(UserPreferences.getUpdateInterval())) {
|
- TimeUnit.MINUTES.toMillis(UserPreferences.getUpdateInterval())) {
|
||||||
// Recently updated, no need to automatically check again
|
// Recently updated, no need to automatically check again
|
||||||
itr.remove();
|
itr.remove();
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -94,7 +94,7 @@ public abstract class UserPreferences {
|
|||||||
// Network
|
// Network
|
||||||
private static final String PREF_ENQUEUE_DOWNLOADED = "prefEnqueueDownloaded";
|
private static final String PREF_ENQUEUE_DOWNLOADED = "prefEnqueueDownloaded";
|
||||||
public static final String PREF_ENQUEUE_LOCATION = "prefEnqueueLocation";
|
public static final String PREF_ENQUEUE_LOCATION = "prefEnqueueLocation";
|
||||||
public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
|
public static final String PREF_UPDATE_INTERVAL_MINUTES = "prefAutoUpdateIntervall";
|
||||||
public static final String PREF_MOBILE_UPDATE = "prefMobileUpdateTypes";
|
public static final String PREF_MOBILE_UPDATE = "prefMobileUpdateTypes";
|
||||||
public static final String PREF_EPISODE_CLEANUP = "prefEpisodeCleanup";
|
public static final String PREF_EPISODE_CLEANUP = "prefEpisodeCleanup";
|
||||||
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
|
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
|
||||||
@ -456,7 +456,11 @@ public abstract class UserPreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getUpdateInterval() {
|
public static long getUpdateInterval() {
|
||||||
return Integer.parseInt(prefs.getString(PREF_UPDATE_INTERVAL, "12"));
|
return Integer.parseInt(prefs.getString(PREF_UPDATE_INTERVAL_MINUTES, "720"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUpdateInterval(long interval) {
|
||||||
|
prefs.edit().putString(PREF_UPDATE_INTERVAL_MINUTES, String.valueOf(interval)).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAutoUpdateDisabled() {
|
public static boolean isAutoUpdateDisabled() {
|
||||||
|
|||||||
@ -59,13 +59,13 @@
|
|||||||
|
|
||||||
<string-array name="feed_refresh_interval_values">
|
<string-array name="feed_refresh_interval_values">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>1</item>
|
<item>60</item>
|
||||||
<item>2</item>
|
<item>120</item>
|
||||||
<item>4</item>
|
<item>240</item>
|
||||||
<item>8</item>
|
<item>480</item>
|
||||||
<item>12</item>
|
<item>720</item>
|
||||||
<item>24</item>
|
<item>1440</item>
|
||||||
<item>72</item>
|
<item>4320</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="globalNewEpisodesActionItems">
|
<string-array name="globalNewEpisodesActionItems">
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
android:key="prefAutoUpdateIntervall"
|
android:key="prefAutoUpdateIntervall"
|
||||||
android:title="@string/feed_refresh_title"
|
android:title="@string/feed_refresh_title"
|
||||||
android:summary="@string/feed_refresh_sum"
|
android:summary="@string/feed_refresh_sum"
|
||||||
android:defaultValue="12"/>
|
android:defaultValue="720"/>
|
||||||
<de.danoeh.antennapod.ui.preferences.preference.MaterialListPreference
|
<de.danoeh.antennapod.ui.preferences.preference.MaterialListPreference
|
||||||
android:entryValues="@array/globalNewEpisodesActionValues"
|
android:entryValues="@array/globalNewEpisodesActionValues"
|
||||||
android:entries="@array/globalNewEpisodesActionItems"
|
android:entries="@array/globalNewEpisodesActionItems"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user