Upgrade preferences independently from database
This commit is contained in:
parent
5630bf756d
commit
8dc4c9ff56
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue