mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #5603 from Bnyro/master
refactor: settings reorganization to improve UX
This commit is contained in:
commit
85bd7a951e
@ -80,7 +80,6 @@ object PreferenceKeys {
|
||||
const val PLAYER_AUDIO_QUALITY_MOBILE = "player_audio_quality_mobile"
|
||||
const val DEFAULT_SUBTITLE = "default_subtitle"
|
||||
const val SKIP_BUTTONS = "skip_buttons"
|
||||
const val PICTURE_IN_PICTURE = "picture_in_picture"
|
||||
const val PLAYER_RESIZE_MODE = "player_resize_mode"
|
||||
const val DEARROW = "dearrow"
|
||||
const val USE_HLS_OVER_DASH = "use_hls"
|
||||
@ -90,7 +89,6 @@ object PreferenceKeys {
|
||||
const val PLAYER_PINCH_CONTROL = "player_pinch_control"
|
||||
const val CAPTIONS_SIZE = "captions_size"
|
||||
const val DOUBLE_TAP_TO_SEEK = "double_tap_seek"
|
||||
const val PAUSE_ON_QUIT = "pause_on_quit"
|
||||
const val ALTERNATIVE_PIP_CONTROLS = "alternative_pip_controls"
|
||||
const val SKIP_SILENCE = "skip_silence"
|
||||
const val ENABLED_VIDEO_CODECS = "video_codecs"
|
||||
@ -104,6 +102,7 @@ object PreferenceKeys {
|
||||
const val SHOW_TIME_LEFT = "show_time_left"
|
||||
const val FALLBACK_PIPED_PROXY = "fallback_piped_proxy"
|
||||
const val ALLOW_PLAYBACK_DURING_CALL = "playback_during_call"
|
||||
const val BEHAVIOR_WHEN_MINIMIZED = "behavior_when_minimized"
|
||||
|
||||
/**
|
||||
* Background mode
|
||||
|
@ -221,11 +221,16 @@ object PlayerHelper {
|
||||
false
|
||||
)
|
||||
|
||||
private val behaviorWhenMinimized = PreferenceHelper.getString(
|
||||
PreferenceKeys.BEHAVIOR_WHEN_MINIMIZED,
|
||||
"pip"
|
||||
)
|
||||
|
||||
val pipEnabled: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.PICTURE_IN_PICTURE,
|
||||
true
|
||||
)
|
||||
get() = behaviorWhenMinimized == "pip"
|
||||
|
||||
val pauseOnQuit: Boolean
|
||||
get() = behaviorWhenMinimized == "pause"
|
||||
|
||||
var autoPlayEnabled: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
@ -306,12 +311,6 @@ object PlayerHelper {
|
||||
true
|
||||
)
|
||||
|
||||
val pauseOnQuit: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.PAUSE_ON_QUIT,
|
||||
false
|
||||
)
|
||||
|
||||
private val alternativePiPControls: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.ALTERNATIVE_PIP_CONTROLS,
|
||||
|
@ -34,21 +34,22 @@ class PlayerSettings : BasePreferenceFragment() {
|
||||
true
|
||||
}
|
||||
|
||||
val pictureInPicture =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.PICTURE_IN_PICTURE)!!
|
||||
val behaviorWhenMinimized =
|
||||
findPreference<ListPreference>(PreferenceKeys.BEHAVIOR_WHEN_MINIMIZED)!!
|
||||
val alternativePipControls =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.ALTERNATIVE_PIP_CONTROLS)
|
||||
val pauseOnQuit = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PAUSE_ON_QUIT)
|
||||
|
||||
val pipAvailable = PictureInPictureCompat.isPictureInPictureAvailable(requireContext())
|
||||
pictureInPicture.isVisible = pipAvailable
|
||||
alternativePipControls?.isVisible = pipAvailable
|
||||
|
||||
pauseOnQuit?.isEnabled = !pictureInPicture.isChecked
|
||||
pictureInPicture.setOnPreferenceChangeListener { _, newValue ->
|
||||
pauseOnQuit?.isEnabled = !(newValue as Boolean)
|
||||
true
|
||||
if (!pipAvailable) {
|
||||
with(behaviorWhenMinimized) {
|
||||
// remove PiP option entry
|
||||
entries = entries.toList().subList(1, 3).toTypedArray()
|
||||
entryValues = entryValues.toList().subList(1, 3).toTypedArray()
|
||||
if (value !in entryValues) value = entryValues.first().toString()
|
||||
}
|
||||
}
|
||||
|
||||
alternativePipControls?.isVisible = pipAvailable
|
||||
}
|
||||
|
||||
private fun setupSubtitlePref(preference: ListPreference) {
|
||||
|
@ -517,4 +517,16 @@
|
||||
<item>@string/category_music_offtopic</item>
|
||||
<item>@string/category_preview</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="onMinimize">
|
||||
<item>@string/picture_in_picture</item>
|
||||
<item>@string/pause</item>
|
||||
<item>@string/none</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="onMinimizeValues">
|
||||
<item>pip</item>
|
||||
<item>pause</item>
|
||||
<item>none</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@ -469,6 +469,7 @@
|
||||
<string name="enqueueing_playlist_download">Enqueueing videos to download of playlist "%1$s"</string>
|
||||
<string name="audio_language">Audio language</string>
|
||||
<string name="default_language">Default</string>
|
||||
<string name="behavior_when_minimized">Behavior when minimized</string>
|
||||
|
||||
<!-- Backup & Restore Settings -->
|
||||
<string name="import_subscriptions_from">Import subscriptions from</string>
|
||||
@ -512,6 +513,7 @@
|
||||
<string name="add_to_group">Add to group</string>
|
||||
<string name="uptime">%.2f%% uptime</string>
|
||||
<string name="change">Change</string>
|
||||
<string name="gestures">Gestures</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory app:title="@string/behavior">
|
||||
<PreferenceCategory app:title="@string/gestures">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
@ -24,13 +24,6 @@
|
||||
app:key="player_pinch_control"
|
||||
app:title="@string/pinch_control" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_next"
|
||||
android:summary="@string/skip_buttons_summary"
|
||||
app:key="skip_buttons"
|
||||
app:title="@string/skip_buttons" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_skip"
|
||||
@ -38,11 +31,34 @@
|
||||
app:key="double_tap_seek"
|
||||
app:title="@string/double_tap_seek" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/behavior">
|
||||
|
||||
<com.github.libretube.ui.views.SliderPreference
|
||||
android:icon="@drawable/ic_skip"
|
||||
app:defValue="10.0"
|
||||
app:key="seek_increment"
|
||||
app:stepSize="5.0"
|
||||
app:title="@string/seek_increment"
|
||||
app:valueFrom="5.0"
|
||||
app:valueTo="60.0" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_next"
|
||||
android:summary="@string/skip_buttons_summary"
|
||||
app:key="skip_buttons"
|
||||
app:title="@string/skip_buttons" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_window"
|
||||
app:key="picture_in_picture"
|
||||
app:title="@string/picture_in_picture" />
|
||||
app:key="behavior_when_minimized"
|
||||
app:title="@string/behavior_when_minimized"
|
||||
app:entries="@array/onMinimize"
|
||||
app:entryValues="@array/onMinimizeValues"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:disableDependentsState="true"
|
||||
@ -62,15 +78,6 @@
|
||||
app:title="@string/fullscreen_orientation"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<com.github.libretube.ui.views.SliderPreference
|
||||
android:icon="@drawable/ic_skip"
|
||||
app:defValue="10.0"
|
||||
app:key="seek_increment"
|
||||
app:stepSize="5.0"
|
||||
app:title="@string/seek_increment"
|
||||
app:valueFrom="5.0"
|
||||
app:valueTo="60.0" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/captions">
|
||||
@ -196,12 +203,14 @@
|
||||
|
||||
<PreferenceCategory app:title="@string/misc">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_pause_filled"
|
||||
android:summary="@string/pauseOnScreenOff_summary"
|
||||
app:defaultValue="false"
|
||||
app:key="pause_screen_off"
|
||||
app:title="@string/pauseOnScreenOff" />
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_time"
|
||||
app:defaultValue="50"
|
||||
app:entries="@array/bufferingGoal"
|
||||
app:entryValues="@array/bufferingGoalValues"
|
||||
app:key="buffering_goal"
|
||||
app:summary="@string/buffering_goal_summary"
|
||||
app:title="@string/buffering_goal" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_call"
|
||||
@ -212,26 +221,17 @@
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:dependency="picture_in_picture"
|
||||
android:icon="@drawable/ic_headphones"
|
||||
android:summary="@string/alternative_pip_controls_summary"
|
||||
app:key="alternative_pip_controls"
|
||||
app:title="@string/alternative_pip_controls" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_pause_filled"
|
||||
app:key="pause_on_quit"
|
||||
app:title="@string/pause_on_quit" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_time"
|
||||
app:defaultValue="50"
|
||||
app:entries="@array/bufferingGoal"
|
||||
app:entryValues="@array/bufferingGoalValues"
|
||||
app:key="buffering_goal"
|
||||
app:summary="@string/buffering_goal_summary"
|
||||
app:title="@string/buffering_goal" />
|
||||
android:summary="@string/pauseOnScreenOff_summary"
|
||||
app:defaultValue="false"
|
||||
app:key="pause_screen_off"
|
||||
app:title="@string/pauseOnScreenOff" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user