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 ee8455a8c..91e89d7c5 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -31,6 +31,7 @@ import android.widget.Toast; import com.bumptech.glide.Glide; +import de.danoeh.antennapod.preferences.PreferenceUpgrader; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.Validate; @@ -54,7 +55,6 @@ import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.Flavors; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.StorageUtils; -import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.core.util.gui.NotificationUtils; import de.danoeh.antennapod.dialog.RatingDialog; import de.danoeh.antennapod.dialog.RenameFeedDialog; @@ -207,6 +207,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi transaction.commit(); checkFirstLaunch(); + PreferenceUpgrader.checkUpgrades(this); NotificationUtils.createChannels(this); } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java new file mode 100644 index 000000000..93b326698 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java @@ -0,0 +1,29 @@ +package de.danoeh.antennapod.preferences; + +import android.content.Context; +import android.content.SharedPreferences; +import de.danoeh.antennapod.BuildConfig; +import de.danoeh.antennapod.core.preferences.UserPreferences; + +public class PreferenceUpgrader { + private static final String PREF_CONFIGURED_VERSION = "configuredVersion"; + private static final String PREF_NAME = "PreferenceUpgrader"; + + + public static void checkUpgrades(Context context) { + SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + int oldVersion = prefs.getInt(PREF_CONFIGURED_VERSION, 1070200); + int newVersion = BuildConfig.VERSION_CODE; + + if (oldVersion != newVersion) { + prefs.edit().putInt(PREF_CONFIGURED_VERSION, newVersion).apply(); + upgrade(oldVersion); + } + } + + private static void upgrade(int oldVersion) { + if (oldVersion < 1070300) { + UserPreferences.restartUpdateAlarm(); + } + } +}