Fix settings migration

This commit is contained in:
Stypox 2023-04-04 10:27:43 +02:00
parent 704e9bd7b6
commit 4bb45c001d

View file

@ -111,31 +111,17 @@ public final class SettingMigrations {
public static final Migration MIGRATION_4_5 = new Migration(4, 5) { public static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override @Override
protected void migrate(final Context context) { protected void migrate(final Context context) {
final boolean brightnessGestureSwitch = sp.getBoolean( final boolean brightness = sp.getBoolean("brightness_gesture_control", true);
context.getString(R.string.left_gesture_control_key), true); final boolean volume = sp.getBoolean("volume_gesture_control", true);
final boolean volumeGestureSwitch = sp.getBoolean(
context.getString(R.string.right_gesture_control_key), true);
final SharedPreferences.Editor editor = sp.edit(); final SharedPreferences.Editor editor = sp.edit();
if (volumeGestureSwitch) { editor.putString(context.getString(R.string.right_gesture_control_key),
if (!brightnessGestureSwitch) { context.getString(volume
editor.putString(context.getString(R.string.left_gesture_control_key), ? R.string.volume_control_key : R.string.none_control_key));
context.getString(R.string.brightness)); editor.putString(context.getString(R.string.left_gesture_control_key),
} context.getString(brightness
editor.putString(context.getString(R.string.right_gesture_control_key), ? R.string.brightness_control_key : R.string.none_control_key));
context.getString(R.string.volume));
} else if (brightnessGestureSwitch) {
editor.putString(context.getString(R.string.right_gesture_control_key),
context.getString(R.string.brightness));
editor.putString(context.getString(R.string.left_gesture_control_key),
context.getString(R.string.volume));
} else {
editor.putString(context.getString(R.string.left_gesture_control_key),
context.getString(R.string.none));
editor.putString(context.getString(R.string.right_gesture_control_key),
context.getString(R.string.none));
}
editor.apply(); editor.apply();
} }