use of net.osmand.plus.mapmarkers.MarkersDb39HelperLegacy in project Osmand by osmandapp.
the class AppVersionUpgradeOnInit method upgradeVersion.
@SuppressLint("ApplySharedPref")
void upgradeVersion(SharedPreferences startPrefs, int lastVersion) {
if (!startPrefs.contains(NUMBER_OF_STARTS)) {
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
} else {
startPrefs.edit().putInt(NUMBER_OF_STARTS, startPrefs.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
}
if (!startPrefs.contains(FIRST_INSTALLED)) {
startPrefs.edit().putLong(FIRST_INSTALLED, System.currentTimeMillis()).commit();
}
if (!startPrefs.contains(FIRST_TIME_APP_RUN)) {
firstTime = true;
startPrefs.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, lastVersion).commit();
} else {
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
if (needsUpgrade(startPrefs, lastVersion)) {
OsmandSettings settings = app.getSettings();
if (prevAppVersion < VERSION_2_2) {
settings.SHOW_DASHBOARD_ON_START.set(true);
settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
settings.SHOW_CARD_TO_CHOOSE_DRAWER.set(true);
}
if (prevAppVersion < VERSION_3_2) {
settings.BILLING_PURCHASE_TOKENS_SENT.set("");
}
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3") || Version.getAppVersion(app).equals("3.5.4")) {
migratePreferences();
app.getAppInitializer().addListener(new AppInitializeListener() {
@Override
public void onStart(AppInitializer init) {
}
@Override
public void onProgress(AppInitializer init, InitEvents event) {
if (event.equals(InitEvents.FAVORITES_INITIALIZED)) {
migrateHomeWorkParkingToFavorites();
}
}
@Override
public void onFinish(AppInitializer init) {
}
});
}
if (prevAppVersion < VERSION_3_6) {
migratePreferences();
}
if (prevAppVersion < VERSION_3_7) {
migrateEnumPreferences();
}
if (prevAppVersion < VERSION_3_7_01) {
app.getAppInitializer().addListener(new AppInitializeListener() {
@Override
public void onStart(AppInitializer init) {
}
@Override
public void onProgress(AppInitializer init, InitEvents event) {
if (event.equals(InitEvents.FAVORITES_INITIALIZED)) {
app.getFavoritesHelper().fixBlackBackground();
}
}
@Override
public void onFinish(AppInitializer init) {
}
});
}
if (prevAppVersion < VERSION_3_8_00) {
migrateQuickActionStates();
}
if (prevAppVersion < VERSION_4_0_00) {
app.getAppInitializer().addListener(new AppInitializeListener() {
@Override
public void onStart(AppInitializer init) {
new MarkersDb39HelperLegacy(app).migrateMarkersGroups();
}
@Override
public void onProgress(AppInitializer init, InitEvents event) {
}
@Override
public void onFinish(AppInitializer init) {
}
});
}
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, lastVersion).commit();
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
appVersionChanged = true;
}
}
}
Aggregations