Made two list options
This commit is contained in:
parent
759a9080a8
commit
2ded8c7cc1
7 changed files with 79 additions and 70 deletions
|
|
@ -2013,7 +2013,10 @@ public final class VideoDetailFragment
|
|||
restoreDefaultBrightness();
|
||||
} else {
|
||||
// Do not restore if user has disabled brightness gesture
|
||||
if (!PlayerHelper.isBrightnessGestureEnabled(activity)) {
|
||||
if (!(PlayerHelper.getRightSideGesture(activity)
|
||||
.equals(getString(R.string.right_brightness_control_key))
|
||||
&& PlayerHelper.getLeftSideGesture(activity)
|
||||
.equals(getString(R.string.left_brightness_control_key)))) {
|
||||
return;
|
||||
}
|
||||
// Restore already saved brightness level
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.text.format.DateUtils;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
|
|
@ -27,7 +26,6 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
addPreferencesFromResourceRegistry();
|
||||
|
||||
updateSeekOptions();
|
||||
updateGestureSwitch();
|
||||
|
||||
listener = (sharedPreferences, key) -> {
|
||||
|
||||
|
|
@ -50,9 +48,6 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
}
|
||||
} else if (getString(R.string.use_inexact_seek_key).equals(key)) {
|
||||
updateSeekOptions();
|
||||
} else if (getString(R.string.volume_gesture_control_key).equals(key)
|
||||
|| getString(R.string.brightness_gesture_control_key).equals(key)) {
|
||||
updateGestureSwitch();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -122,19 +117,4 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
getPreferenceManager().getSharedPreferences()
|
||||
.unregisterOnSharedPreferenceChangeListener(listener);
|
||||
}
|
||||
|
||||
private void updateGestureSwitch() {
|
||||
final SwitchPreferenceCompat gestureSwitch = (SwitchPreferenceCompat)
|
||||
findPreference(getString(R.string.switch_gesture_sides_key));
|
||||
if (getPreferenceManager().getSharedPreferences()
|
||||
.getBoolean(getString(R.string.volume_gesture_control_key), true)
|
||||
&& getPreferenceManager().getSharedPreferences()
|
||||
.getBoolean(getString(R.string.brightness_gesture_control_key), true)) {
|
||||
gestureSwitch.setEnabled(true);
|
||||
gestureSwitch.setSummary(getString(R.string.switch_gesture_sides_summary));
|
||||
} else {
|
||||
gestureSwitch.setEnabled(false);
|
||||
gestureSwitch.setSummary(getString(R.string.switch_gesture_sides_summary_disabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue