Made two list options

This commit is contained in:
ge78fug 2023-01-29 19:23:39 +01:00 committed by Stypox
parent f62884f0a1
commit 1908a477d3
7 changed files with 79 additions and 70 deletions

View file

@ -9,7 +9,6 @@ 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
@ -194,23 +193,23 @@ class MainPlayerGestureListener(
isMoving = true
// -- Brightness and Volume control --
val isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(player.context)
val isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(player.context)
val brightnessSide = if (PreferenceManager.getDefaultSharedPreferences(player.context)
.getBoolean(
player.context.getString(R.string.switch_gesture_sides_key), false))
DisplayPortion.RIGHT_HALF
else DisplayPortion.LEFT_HALF
if (isBrightnessGestureEnabled && isVolumeGestureEnabled) {
if (getDisplayHalfPortion(initialEvent) == brightnessSide) {
onScrollBrightness(distanceY)
} else /* DisplayPortion.RIGHT_HALF */ {
onScrollVolume(distanceY)
val rightSide = PlayerHelper.getRightSideGesture(player.context)
val leftSide = PlayerHelper.getLeftSideGesture(player.context)
if (getDisplayHalfPortion(initialEvent) == DisplayPortion.RIGHT_HALF) {
when (rightSide) {
player.context.getString(R.string.right_volume_control_key) ->
onScrollVolume(distanceY)
player.context.getString(R.string.right_brightness_control_key) ->
onScrollBrightness(distanceY)
}
} else {
when (leftSide) {
player.context.getString(R.string.left_volume_control_key) ->
onScrollVolume(distanceY)
player.context.getString(R.string.left_brightness_control_key) ->
onScrollBrightness(distanceY)
}
} else if (isBrightnessGestureEnabled) {
onScrollBrightness(distanceY)
} else if (isVolumeGestureEnabled) {
onScrollVolume(distanceY)
}
return true

View file

@ -228,14 +228,16 @@ public final class PlayerHelper {
.getBoolean(context.getString(R.string.resume_on_audio_focus_gain_key), false);
}
public static boolean isVolumeGestureEnabled(@NonNull final Context context) {
public static String getRightSideGesture(@NonNull final Context context) {
return getPreferences(context)
.getBoolean(context.getString(R.string.volume_gesture_control_key), true);
.getString(context.getString(R.string.right_gesture_control_key),
context.getString(R.string.default_right_gesture_control_value));
}
public static boolean isBrightnessGestureEnabled(@NonNull final Context context) {
public static String getLeftSideGesture(@NonNull final Context context) {
return getPreferences(context)
.getBoolean(context.getString(R.string.brightness_gesture_control_key), true);
.getString(context.getString(R.string.left_gesture_control_key),
context.getString(R.string.default_left_gesture_control_value));
}
public static boolean isStartMainPlayerFullscreenEnabled(@NonNull final Context context) {