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:
Hans-Peter Lehmann 2025-09-22 22:45:16 +02:00 committed by GitHub
parent 6f7f9b2914
commit 198c151a22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 23 additions and 15 deletions

View File

@ -180,7 +180,7 @@ public class EspressoTestUtils {
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getInstrumentation().getTargetContext())
.edit()
.putString(UserPreferences.PREF_UPDATE_INTERVAL, "0")
.putString(UserPreferences.PREF_UPDATE_INTERVAL_MINUTES, "0")
.commit();
}

View File

@ -144,8 +144,9 @@ public class PreferenceUpgrader {
.apply();
}
UserPreferences.setAllowMobileSync(true);
if (prefs.getString(UserPreferences.PREF_UPDATE_INTERVAL, ":").contains(":")) { // Unset or "time of day"
prefs.edit().putString(UserPreferences.PREF_UPDATE_INTERVAL, "12").apply();
if (prefs.getString(UserPreferences.PREF_UPDATE_INTERVAL_MINUTES, ":").contains(":")) {
// Unset or "time of day"
prefs.edit().putString(UserPreferences.PREF_UPDATE_INTERVAL_MINUTES, "12").apply();
}
}
if (oldVersion < 3020000) {
@ -178,6 +179,8 @@ public class PreferenceUpgrader {
UserPreferences.setBottomNavigationEnabled(true);
}
if (oldVersion < 3100000) {
// Migrate refresh interval from hours to minutes
UserPreferences.setUpdateInterval(60L * UserPreferences.getUpdateInterval());
FeedUpdateManager.getInstance().restartUpdateAlarm(context, true);
}
}

View File

@ -78,7 +78,8 @@ public class DownloadsPreferencesFragment extends AnimatedPreferenceFragment
@Override
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);
}
}

View File

@ -81,7 +81,7 @@ public class FeedUpdateWorker extends Worker {
}
if (isAutomaticRefresh && isAutomaticRefreshEnabled
&& 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
itr.remove();
continue;

View File

@ -94,7 +94,7 @@ public abstract class UserPreferences {
// Network
private static final String PREF_ENQUEUE_DOWNLOADED = "prefEnqueueDownloaded";
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_EPISODE_CLEANUP = "prefEpisodeCleanup";
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
@ -456,7 +456,11 @@ public abstract class UserPreferences {
}
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() {

View File

@ -59,13 +59,13 @@
<string-array name="feed_refresh_interval_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>4</item>
<item>8</item>
<item>12</item>
<item>24</item>
<item>72</item>
<item>60</item>
<item>120</item>
<item>240</item>
<item>480</item>
<item>720</item>
<item>1440</item>
<item>4320</item>
</string-array>
<string-array name="globalNewEpisodesActionItems">

View File

@ -14,7 +14,7 @@
android:key="prefAutoUpdateIntervall"
android:title="@string/feed_refresh_title"
android:summary="@string/feed_refresh_sum"
android:defaultValue="12"/>
android:defaultValue="720"/>
<de.danoeh.antennapod.ui.preferences.preference.MaterialListPreference
android:entryValues="@array/globalNewEpisodesActionValues"
android:entries="@array/globalNewEpisodesActionItems"