kopia lustrzana https://github.com/TeamNewPipe/NewPipe
Made two list options
rodzic
759a9080a8
commit
2ded8c7cc1
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
<string name="use_external_video_player_key">use_external_video_player</string>
|
||||
<string name="use_external_audio_player_key">use_external_audio_player</string>
|
||||
|
||||
<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>
|
||||
|
@ -193,6 +190,38 @@
|
|||
<item>@string/audio_webm_key</item>
|
||||
</string-array>
|
||||
|
||||
<string name="left_gesture_control_key">left_gesture_control</string>
|
||||
<string name="default_left_gesture_control_value">@string/left_brightness_control_key</string>
|
||||
<string name="left_brightness_control_key">left_brightness_control</string>
|
||||
<string name="left_volume_control_key">left_volume_control</string>
|
||||
<string name="left_none_control_key">left_none_control</string>
|
||||
<string-array name="left_gesture_control_description">
|
||||
<item>@string/brightness</item>
|
||||
<item>@string/volume</item>
|
||||
<item>@string/none</item>
|
||||
</string-array>
|
||||
<string-array name="left_gesture_control_values">
|
||||
<item>@string/left_brightness_control_key</item>
|
||||
<item>@string/left_volume_control_key</item>
|
||||
<item>@string/left_none_control_key</item>
|
||||
</string-array>
|
||||
|
||||
<string name="right_gesture_control_key">right_gesture_control</string>
|
||||
<string name="default_right_gesture_control_value">@string/right_volume_control_key</string>
|
||||
<string name="right_brightness_control_key">right_brightness_control</string>
|
||||
<string name="right_volume_control_key">right_volume_control</string>
|
||||
<string name="right_none_control_key">right_none_control</string>
|
||||
<string-array name="right_gesture_control_description">
|
||||
<item>@string/volume</item>
|
||||
<item>@string/brightness</item>
|
||||
<item>@string/none</item>
|
||||
</string-array>
|
||||
<string-array name="right_gesture_control_values">
|
||||
<item>@string/right_volume_control_key</item>
|
||||
<item>@string/right_brightness_control_key</item>
|
||||
<item>@string/right_none_control_key</item>
|
||||
</string-array>
|
||||
|
||||
<string name="last_resize_mode">last_resize_mode</string>
|
||||
|
||||
<!-- DEBUG ONLY -->
|
||||
|
|
|
@ -101,13 +101,13 @@
|
|||
<string name="auto_queue_title">Auto-enqueue next stream</string>
|
||||
<string name="auto_queue_summary">Continue ending (non-repeating) playback queue by appending a related stream</string>
|
||||
<string name="auto_queue_toggle">Auto-enqueuing</string>
|
||||
<string name="volume_gesture_control_title">Volume gesture control</string>
|
||||
<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="switch_gesture_sides_summary_disabled">Enable both brightness and volume gestures to use this feature</string>
|
||||
<string name="left_gesture_control_summary">Change the left gesture control</string>
|
||||
<string name="left_gesture_control_title">Left gesture control</string>
|
||||
<string name="right_gesture_control_summary">Change the right gesture control</string>
|
||||
<string name="right_gesture_control_title">Right gesture control</string>
|
||||
<string name="brightness">Brightness</string>
|
||||
<string name="volume">Volume</string>
|
||||
<string name="none">None</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>
|
||||
|
|
|
@ -174,27 +174,23 @@
|
|||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="@string/volume_gesture_control_key"
|
||||
android:summary="@string/volume_gesture_control_summary"
|
||||
android:title="@string/volume_gesture_control_title"
|
||||
<ListPreference
|
||||
android:defaultValue="@string/default_left_gesture_control_value"
|
||||
android:entries="@array/left_gesture_control_description"
|
||||
android:entryValues="@array/left_gesture_control_values"
|
||||
android:key="@string/left_gesture_control_key"
|
||||
android:summary="@string/left_gesture_control_summary"
|
||||
android:title="@string/left_gesture_control_title"
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="@string/brightness_gesture_control_key"
|
||||
android:summary="@string/brightness_gesture_control_summary"
|
||||
android:title="@string/brightness_gesture_control_title"
|
||||
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"
|
||||
<ListPreference
|
||||
android:defaultValue="@string/default_right_gesture_control_value"
|
||||
android:entries="@array/right_gesture_control_description"
|
||||
android:entryValues="@array/right_gesture_control_values"
|
||||
android:key="@string/right_gesture_control_key"
|
||||
android:summary="@string/right_gesture_control_summary"
|
||||
android:title="@string/right_gesture_control_title"
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue