1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 05:16:51 +01:00

Fix fitness goal and inactivity warning threshold preference migration

This commit is contained in:
José Rebelo 2022-05-07 20:45:33 +01:00
parent 1092e1b10a
commit 2aecb85015

View File

@ -115,7 +115,7 @@ public class GBApplication extends Application {
private static SharedPreferences sharedPrefs;
private static final String PREFS_VERSION = "shared_preferences_version";
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
private static final int CURRENT_PREFS_VERSION = 11;
private static final int CURRENT_PREFS_VERSION = 12;
private static LimitedQueue mIDSenderLookup = new LimitedQueue(16);
private static Prefs prefs;
@ -1075,6 +1075,11 @@ public class GBApplication extends Application {
Log.w(TAG, "error acquiring DB lock");
}
}
if (oldVersion < 12) {
// Convert preferences that were wrongly migrated to int, since Android saves them as Strings internally
editor.putString("inactivity_warnings_threshold", String.valueOf(prefs.getInt("inactivity_warnings_threshold", 60)));
editor.putString("fitness_goal", String.valueOf(prefs.getInt("fitness_goal", 8000)));
}
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
editor.apply();
}