From 7689d1d15cb26ef31193aef4cf0b02f59db13374 Mon Sep 17 00:00:00 2001 From: ge78fug Date: Wed, 1 Mar 2023 23:22:30 +0100 Subject: [PATCH] Added the migration --- .../newpipe/settings/SettingMigrations.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java b/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java index b1e2c04eb..21c0e1be4 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java @@ -108,6 +108,39 @@ public final class SettingMigrations { } }; + public static final Migration MIGRATION_4_5 = new Migration(4, 5) { + @Override + protected void migrate(final Context context) { + boolean brightnessGestureSwitch = sp.getBoolean( + context.getString(R.string.left_gesture_control_key), false); + boolean volumeGestureSwitch = sp.getBoolean( + context.getString(R.string.right_gesture_control_key), false); + + 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.apply(); + } + }; + /** * List of all implemented migrations. *

@@ -119,12 +152,13 @@ public final class SettingMigrations { MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, + MIGRATION_4_5, }; /** * Version number for preferences. Must be incremented every time a migration is necessary. */ - public static final int VERSION = 4; + public static final int VERSION = 5; public static void initMigrations(final Context context, final boolean isFirstRun) {