mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-22 16:10:31 +00:00
Created a setting to switch the sides of volume and brightness
This commit is contained in:
parent
07111d86d4
commit
3c74cb3439
@ -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)
|
||||
|
@ -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
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
<string name="volume_gesture_control_key">volume_gesture_control</string>
|
||||
<string name="brightness_gesture_control_key">brightness_gesture_control</string>
|
||||
<string name="switch_gesture_sides_key">switch_gesture_sides</string>
|
||||
<string name="resume_on_audio_focus_gain_key">resume_on_audio_focus_gain</string>
|
||||
<string name="popup_remember_size_pos_key">popup_remember_size_pos_key</string>
|
||||
<string name="use_inexact_seek_key">use_inexact_seek_key</string>
|
||||
|
@ -105,6 +105,8 @@
|
||||
<string name="volume_gesture_control_summary">Use gestures to control player volume</string>
|
||||
<string name="brightness_gesture_control_title">Brightness gesture control</string>
|
||||
<string name="brightness_gesture_control_summary">Use gestures to control player brightness</string>
|
||||
<string name="switch_gesture_sides_title">Switch gesture sides</string>
|
||||
<string name="switch_gesture_sides_summary">Switches the sides of the volume and brightness gesture controls</string>
|
||||
<string name="show_search_suggestions_title">Search suggestions</string>
|
||||
<string name="show_search_suggestions_summary">Choose the suggestions to show when searching</string>
|
||||
<string name="local_search_suggestions">Local search suggestions</string>
|
||||
|
@ -190,6 +190,14 @@
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="@string/switch_gesture_sides_key"
|
||||
android:summary="@string/switch_gesture_sides_summary"
|
||||
android:title="@string/switch_gesture_sides_title"
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="@string/popup_remember_size_pos_key"
|
||||
|
Loading…
Reference in New Issue
Block a user