diff --git a/app/src/main/java/org/schabi/newpipe/player/gesture/MainPlayerGestureListener.kt b/app/src/main/java/org/schabi/newpipe/player/gesture/MainPlayerGestureListener.kt
index a6dba0dd5..75a27896d 100644
--- a/app/src/main/java/org/schabi/newpipe/player/gesture/MainPlayerGestureListener.kt
+++ b/app/src/main/java/org/schabi/newpipe/player/gesture/MainPlayerGestureListener.kt
@@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.math.MathUtils
import androidx.core.view.isVisible
+import androidx.preference.PreferenceManager
import org.schabi.newpipe.MainActivity
import org.schabi.newpipe.R
import org.schabi.newpipe.ktx.AnimationType
@@ -193,10 +194,16 @@ class MainPlayerGestureListener(
isMoving = true
// -- Brightness and Volume control --
- val isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(player.context)
- val isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(player.context)
+ var isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(player.context)
+ var isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(player.context)
+ var displaySide = DisplayPortion.LEFT_HALF
+ val sidesSwitched = PreferenceManager.getDefaultSharedPreferences(player.context)
+ .getBoolean(R.string.switch_gesture_sides_key.toString(), false)
+ if (sidesSwitched) {
+ displaySide = DisplayPortion.RIGHT_HALF
+ }
if (isBrightnessGestureEnabled && isVolumeGestureEnabled) {
- if (getDisplayHalfPortion(initialEvent) === DisplayPortion.LEFT_HALF) {
+ if (getDisplayHalfPortion(initialEvent) === displaySide) {
onScrollBrightness(distanceY)
} else /* DisplayPortion.RIGHT_HALF */ {
onScrollVolume(distanceY)
diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java
index aae9cfca5..4936f979b 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java
@@ -6,8 +6,11 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.format.DateUtils;
+import android.view.View;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.preference.ListPreference;
import com.google.android.material.snackbar.Snackbar;
@@ -21,6 +24,17 @@ import java.util.List;
public class VideoAudioSettingsFragment extends BasePreferenceFragment {
private SharedPreferences.OnSharedPreferenceChangeListener listener;
+ @Override
+ public void onViewCreated(@NonNull final View rootView,
+ @Nullable final Bundle savedInstanceState) {
+ super.onViewCreated(rootView, savedInstanceState);
+ findPreference(getString(R.string.switch_gesture_sides_key))
+ .setEnabled(getPreferenceManager().getSharedPreferences()
+ .getBoolean(getString(R.string.volume_gesture_control_key), true)
+ && getPreferenceManager().getSharedPreferences()
+ .getBoolean(getString(R.string.brightness_gesture_control_key), true));
+ }
+
@Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
addPreferencesFromResourceRegistry();
@@ -29,6 +43,12 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
listener = (sharedPreferences, key) -> {
+ findPreference(getString(R.string.switch_gesture_sides_key))
+ .setEnabled(sharedPreferences.getBoolean(
+ getString(R.string.volume_gesture_control_key), true)
+ && sharedPreferences.getBoolean(
+ getString(R.string.brightness_gesture_control_key), true));
+
// on M and above, if user chooses to minimise to popup player on exit
// and the app doesn't have display over other apps permission,
// show a snackbar to let the user give permission
diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml
index 6a1d5cd45..dae8cc113 100644
--- a/app/src/main/res/values/settings_keys.xml
+++ b/app/src/main/res/values/settings_keys.xml
@@ -18,6 +18,7 @@
volume_gesture_control
brightness_gesture_control
+ switch_gesture_sides
resume_on_audio_focus_gain
popup_remember_size_pos_key
use_inexact_seek_key
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index dd8b8a58d..67acdcf0c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -105,6 +105,8 @@
Use gestures to control player volume
Brightness gesture control
Use gestures to control player brightness
+ Switch gesture sides
+ Switches the sides of the volume and brightness gesture controls
Search suggestions
Choose the suggestions to show when searching
Local search suggestions
diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml
index 117ee8703..da932bb38 100644
--- a/app/src/main/res/xml/video_audio_settings.xml
+++ b/app/src/main/res/xml/video_audio_settings.xml
@@ -190,6 +190,14 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
+
+