Fixed upgrading preferences

Needs to use the original storage location that `UpdateManager` used,
which was removed in e2cf363cc4
This commit is contained in:
ByteHamster 2019-08-28 20:22:10 +02:00
parent 2a24fa849e
commit 4a2feb3721
1 changed files with 5 additions and 6 deletions

View File

@ -8,22 +8,23 @@ import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.gui.NotificationUtils; import de.danoeh.antennapod.core.util.gui.NotificationUtils;
public class PreferenceUpgrader { public class PreferenceUpgrader {
private static final String PREF_CONFIGURED_VERSION = "configuredVersion"; private static final String PREF_CONFIGURED_VERSION = "version_code";
private static final String PREF_NAME = "PreferenceUpgrader"; private static final String PREF_NAME = "app_version";
private static SharedPreferences prefs; private static SharedPreferences prefs;
public static void checkUpgrades(Context context) { public static void checkUpgrades(Context context) {
prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences upgraderPrefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); SharedPreferences upgraderPrefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
int oldVersion = upgraderPrefs.getInt(PREF_CONFIGURED_VERSION, 1070200); int oldVersion = upgraderPrefs.getInt(PREF_CONFIGURED_VERSION, -1);
int newVersion = BuildConfig.VERSION_CODE; int newVersion = BuildConfig.VERSION_CODE;
if (oldVersion != newVersion) { if (oldVersion != newVersion) {
NotificationUtils.createChannels(context); NotificationUtils.createChannels(context);
UserPreferences.restartUpdateAlarm();
upgraderPrefs.edit().putInt(PREF_CONFIGURED_VERSION, newVersion).apply();
upgrade(oldVersion); upgrade(oldVersion);
upgraderPrefs.edit().putInt(PREF_CONFIGURED_VERSION, newVersion).apply();
} }
} }
@ -41,8 +42,6 @@ public class PreferenceUpgrader {
} }
} }
if (oldVersion < 1070300) { if (oldVersion < 1070300) {
UserPreferences.restartUpdateAlarm();
if (UserPreferences.getMediaPlayer().equals("builtin")) { if (UserPreferences.getMediaPlayer().equals("builtin")) {
prefs.edit().putString(UserPreferences.PREF_MEDIA_PLAYER, prefs.edit().putString(UserPreferences.PREF_MEDIA_PLAYER,
UserPreferences.PREF_MEDIA_PLAYER_EXOPLAYER).apply(); UserPreferences.PREF_MEDIA_PLAYER_EXOPLAYER).apply();