mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 11:02:35 +01:00
Merge pull request #9708 from Marius1501/switch_setting_brightness_volume
Created a setting to switch the sides of volume and brightness
This commit is contained in:
commit
445d364193
@ -2013,7 +2013,10 @@ public final class VideoDetailFragment
|
|||||||
restoreDefaultBrightness();
|
restoreDefaultBrightness();
|
||||||
} else {
|
} else {
|
||||||
// Do not restore if user has disabled brightness gesture
|
// Do not restore if user has disabled brightness gesture
|
||||||
if (!PlayerHelper.isBrightnessGestureEnabled(activity)) {
|
if (!PlayerHelper.getActionForRightGestureSide(activity)
|
||||||
|
.equals(getString(R.string.brightness_control_key))
|
||||||
|
&& !PlayerHelper.getActionForLeftGestureSide(activity)
|
||||||
|
.equals(getString(R.string.brightness_control_key))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Restore already saved brightness level
|
// Restore already saved brightness level
|
||||||
|
@ -193,18 +193,20 @@ class MainPlayerGestureListener(
|
|||||||
isMoving = true
|
isMoving = true
|
||||||
|
|
||||||
// -- Brightness and Volume control --
|
// -- Brightness and Volume control --
|
||||||
val isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(player.context)
|
if (getDisplayHalfPortion(initialEvent) == DisplayPortion.RIGHT_HALF) {
|
||||||
val isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(player.context)
|
when (PlayerHelper.getActionForRightGestureSide(player.context)) {
|
||||||
if (isBrightnessGestureEnabled && isVolumeGestureEnabled) {
|
player.context.getString(R.string.volume_control_key) ->
|
||||||
if (getDisplayHalfPortion(initialEvent) === DisplayPortion.LEFT_HALF) {
|
|
||||||
onScrollBrightness(distanceY)
|
|
||||||
} else /* DisplayPortion.RIGHT_HALF */ {
|
|
||||||
onScrollVolume(distanceY)
|
onScrollVolume(distanceY)
|
||||||
|
player.context.getString(R.string.brightness_control_key) ->
|
||||||
|
onScrollBrightness(distanceY)
|
||||||
}
|
}
|
||||||
} else if (isBrightnessGestureEnabled) {
|
} else {
|
||||||
onScrollBrightness(distanceY)
|
when (PlayerHelper.getActionForLeftGestureSide(player.context)) {
|
||||||
} else if (isVolumeGestureEnabled) {
|
player.context.getString(R.string.volume_control_key) ->
|
||||||
onScrollVolume(distanceY)
|
onScrollVolume(distanceY)
|
||||||
|
player.context.getString(R.string.brightness_control_key) ->
|
||||||
|
onScrollBrightness(distanceY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -228,14 +228,16 @@ public final class PlayerHelper {
|
|||||||
.getBoolean(context.getString(R.string.resume_on_audio_focus_gain_key), false);
|
.getBoolean(context.getString(R.string.resume_on_audio_focus_gain_key), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVolumeGestureEnabled(@NonNull final Context context) {
|
public static String getActionForRightGestureSide(@NonNull final Context context) {
|
||||||
return getPreferences(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 getActionForLeftGestureSide(@NonNull final Context context) {
|
||||||
return getPreferences(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) {
|
public static boolean isStartMainPlayerFullscreenEnabled(@NonNull final Context context) {
|
||||||
|
@ -108,6 +108,25 @@ public final class SettingMigrations {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final Migration MIGRATION_4_5 = new Migration(4, 5) {
|
||||||
|
@Override
|
||||||
|
protected void migrate(final Context context) {
|
||||||
|
final boolean brightness = sp.getBoolean("brightness_gesture_control", true);
|
||||||
|
final boolean volume = sp.getBoolean("volume_gesture_control", true);
|
||||||
|
|
||||||
|
final SharedPreferences.Editor editor = sp.edit();
|
||||||
|
|
||||||
|
editor.putString(context.getString(R.string.right_gesture_control_key),
|
||||||
|
context.getString(volume
|
||||||
|
? R.string.volume_control_key : R.string.none_control_key));
|
||||||
|
editor.putString(context.getString(R.string.left_gesture_control_key),
|
||||||
|
context.getString(brightness
|
||||||
|
? R.string.brightness_control_key : R.string.none_control_key));
|
||||||
|
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all implemented migrations.
|
* List of all implemented migrations.
|
||||||
* <p>
|
* <p>
|
||||||
@ -119,12 +138,13 @@ public final class SettingMigrations {
|
|||||||
MIGRATION_1_2,
|
MIGRATION_1_2,
|
||||||
MIGRATION_2_3,
|
MIGRATION_2_3,
|
||||||
MIGRATION_3_4,
|
MIGRATION_3_4,
|
||||||
|
MIGRATION_4_5,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version number for preferences. Must be incremented every time a migration is necessary.
|
* Version number for preferences. Must be incremented every time a migration is necessary.
|
||||||
*/
|
*/
|
||||||
public static final int VERSION = 4;
|
public static final int VERSION = 5;
|
||||||
|
|
||||||
|
|
||||||
public static void initMigrations(final Context context, final boolean isFirstRun) {
|
public static void initMigrations(final Context context, final boolean isFirstRun) {
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
<string name="use_external_video_player_key">use_external_video_player</string>
|
<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="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="resume_on_audio_focus_gain_key">resume_on_audio_focus_gain</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="popup_remember_size_pos_key">popup_remember_size_pos_key</string>
|
||||||
<string name="use_inexact_seek_key">use_inexact_seek_key</string>
|
<string name="use_inexact_seek_key">use_inexact_seek_key</string>
|
||||||
@ -192,6 +190,35 @@
|
|||||||
<item>@string/audio_webm_key</item>
|
<item>@string/audio_webm_key</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string name="left_gesture_control_key">left_gesture_control</string>
|
||||||
|
<string name="default_left_gesture_control_value">@string/brightness_control_key</string>
|
||||||
|
<string name="brightness_control_key">brightness_control</string>
|
||||||
|
<string name="volume_control_key">volume_control</string>
|
||||||
|
<string name="none_control_key">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/brightness_control_key</item>
|
||||||
|
<item>@string/volume_control_key</item>
|
||||||
|
<item>@string/none_control_key</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string name="right_gesture_control_key">right_gesture_control</string>
|
||||||
|
<string name="default_right_gesture_control_value">@string/volume_control_key</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/volume_control_key</item>
|
||||||
|
<item>@string/brightness_control_key</item>
|
||||||
|
<item>@string/none_control_key</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string name="last_resize_mode">last_resize_mode</string>
|
<string name="last_resize_mode">last_resize_mode</string>
|
||||||
|
|
||||||
<!-- DEBUG ONLY -->
|
<!-- DEBUG ONLY -->
|
||||||
|
@ -101,10 +101,13 @@
|
|||||||
<string name="auto_queue_title">Auto-enqueue next stream</string>
|
<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_summary">Continue ending (non-repeating) playback queue by appending a related stream</string>
|
||||||
<string name="auto_queue_toggle">Auto-enqueuing</string>
|
<string name="auto_queue_toggle">Auto-enqueuing</string>
|
||||||
<string name="volume_gesture_control_title">Volume gesture control</string>
|
<string name="left_gesture_control_summary">Choose gesture for left half of player screen</string>
|
||||||
<string name="volume_gesture_control_summary">Use gestures to control player volume</string>
|
<string name="left_gesture_control_title">Left gesture action</string>
|
||||||
<string name="brightness_gesture_control_title">Brightness gesture control</string>
|
<string name="right_gesture_control_summary">Choose gesture for right half of player screen</string>
|
||||||
<string name="brightness_gesture_control_summary">Use gestures to control player brightness</string>
|
<string name="right_gesture_control_title">Right gesture action</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_title">Search suggestions</string>
|
||||||
<string name="show_search_suggestions_summary">Choose the suggestions to show when searching</string>
|
<string name="show_search_suggestions_summary">Choose the suggestions to show when searching</string>
|
||||||
<string name="local_search_suggestions">Local search suggestions</string>
|
<string name="local_search_suggestions">Local search suggestions</string>
|
||||||
|
@ -174,19 +174,23 @@
|
|||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<ListPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="@string/default_left_gesture_control_value"
|
||||||
android:key="@string/volume_gesture_control_key"
|
android:entries="@array/left_gesture_control_description"
|
||||||
android:summary="@string/volume_gesture_control_summary"
|
android:entryValues="@array/left_gesture_control_values"
|
||||||
android:title="@string/volume_gesture_control_title"
|
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:singleLineTitle="false"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<ListPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="@string/default_right_gesture_control_value"
|
||||||
android:key="@string/brightness_gesture_control_key"
|
android:entries="@array/right_gesture_control_description"
|
||||||
android:summary="@string/brightness_gesture_control_summary"
|
android:entryValues="@array/right_gesture_control_values"
|
||||||
android:title="@string/brightness_gesture_control_title"
|
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:singleLineTitle="false"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user