Skip to content

Commit

Permalink
Fix settings migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Apr 4, 2023
1 parent 704e9bd commit 4bb45c0
Showing 1 changed file with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,17 @@ protected void migrate(final Context context) {
public static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
protected void migrate(final Context context) {
final boolean brightnessGestureSwitch = sp.getBoolean(
context.getString(R.string.left_gesture_control_key), true);
final boolean volumeGestureSwitch = sp.getBoolean(
context.getString(R.string.right_gesture_control_key), true);
final boolean brightness = sp.getBoolean("brightness_gesture_control", true);
final boolean volume = sp.getBoolean("volume_gesture_control", true);

final SharedPreferences.Editor editor = sp.edit();

if (volumeGestureSwitch) {
if (!brightnessGestureSwitch) {
editor.putString(context.getString(R.string.left_gesture_control_key),
context.getString(R.string.brightness));
}
editor.putString(context.getString(R.string.right_gesture_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.putString(context.getString(R.string.right_gesture_control_key),
context.getString(volume
? R.string.volume_control_key : R.string.none_control_key));
editor.putString(context.getString(R.string.left_gesture_control_key),
context.getString(brightness
? R.string.brightness_control_key : R.string.none_control_key));

editor.apply();
}
Expand Down

0 comments on commit 4bb45c0

Please sign in to comment.