diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index d90b6043f28..c49d9dd21fc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -100,6 +100,9 @@ open class FullScreenPlayer : AbstractPlayerFragment( protected var playerRotateEnabled = false protected var rotatedManually = false private var hideControlsNames = false + + /** Show the title and the (read only) progress bar when tapping the screen while locked. */ + private var showInfoWhenLocked = true protected var subtitleDelay set(value) = try { player.setSubtitleOffset(-value) @@ -289,9 +292,8 @@ open class FullScreenPlayer : AbstractPlayerFragment( playerBinding?.apply { - if (isLayout(PHONE)) { // isEnabled also disables the onKeyDown - exoProgress.isEnabled = isShowing // Prevent accidental clicks/drags - } + // isEnabled also disables the onKeyDown + exoProgress.isEnabled = isProgressBarInteractive() if (isShowing) { updateUIVisibility() @@ -739,11 +741,13 @@ open class FullScreenPlayer : AbstractPlayerFragment( // video_bar.startAnimation(fadeAnimation) // TITLE - playerVideoTitleRez.startAnimation(fadeAnimation) - playerVideoInfo.startAnimation(fadeAnimation) playerEpisodeFiller.startAnimation(fadeAnimation) - playerVideoTitleHolder.startAnimation(fadeAnimation) - playerTopHolder.startAnimation(fadeAnimation) + if (!showInfoWhenLocked) { + playerVideoTitleRez.startAnimation(fadeAnimation) + playerVideoInfo.startAnimation(fadeAnimation) + playerVideoTitleHolder.startAnimation(fadeAnimation) + playerTopHolder.startAnimation(fadeAnimation) + } // BOTTOM playerLockHolder.startAnimation(fadeAnimation) // player_go_back_holder?.startAnimation(fadeAnimation) @@ -753,9 +757,23 @@ open class FullScreenPlayer : AbstractPlayerFragment( updateLockUI() } + /** + * Whether the seekbar may be scrubbed/focused. While locked it is only a read only + * position indicator, and on phones it is disabled when hidden to prevent + * accidental clicks/drags. + */ + private fun isProgressBarInteractive(): Boolean = + !isLocked && (isShowing || !isLayout(PHONE)) + + /** If the info (title + progress bar) should be kept when the controls are locked. */ + private val keepsInfoWhenLocked: Boolean get() = isLocked && showInfoWhenLocked + private fun updateUIVisibility() { val isGone = isLocked || !isShowing - var togglePlayerTitleGone = isGone + // The title and the progress bar may be kept while locked, so the playback position + // can be read without unlocking first, exoProgress is disabled to keep it read only. + val isInfoGone = if (keepsInfoWhenLocked) !isShowing else isGone + var togglePlayerTitleGone = isInfoGone context?.let { val settingsManager = PreferenceManager.getDefaultSharedPreferences(it) val limitTitle = settingsManager.getInt(getString(R.string.prefer_limit_title_key), 0) @@ -765,16 +783,17 @@ open class FullScreenPlayer : AbstractPlayerFragment( } playerBinding?.apply { playerLockHolder.isGone = isGone - playerVideoBar.isGone = isGone + playerVideoBar.isGone = isInfoGone + exoProgress.isEnabled = isProgressBarInteractive() playerPausePlayHolderHolder.isGone = isGone || currentPlayerStatus == CSPlayerLoading.IsBuffering - playerTopHolder.isGone = isGone + playerTopHolder.isGone = isInfoGone val showPlayerEpisodes = !isGone && isThereEpisodes() playerEpisodesButtonRoot.isVisible = showPlayerEpisodes playerEpisodesButton.isVisible = showPlayerEpisodes playerVideoTitleHolder.isGone = togglePlayerTitleGone || playerVideoTitle.text.isBlank() - playerVideoTitleRez.isGone = isGone || playerVideoTitleRez.text.isBlank() + playerVideoTitleRez.isGone = isInfoGone || playerVideoTitleRez.text.isBlank() playerEpisodeFiller.isGone = isGone playerCenterMenu.isGone = isGone playerLock.isGone = !isShowing @@ -1152,6 +1171,10 @@ open class FullScreenPlayer : AbstractPlayerFragment( ctx.getString(R.string.hide_player_control_names_key), false ) + showInfoWhenLocked = settingsManager.getBoolean( + ctx.getString(R.string.show_info_when_locked_key), + true + ) val profiles = QualityDataHelper.getProfiles() val type = if (ctx.isUsingMobileData()) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayerScreen.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayerScreen.kt index 176eb1202e5..dcfdcb45128 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayerScreen.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayerScreen.kt @@ -286,6 +286,12 @@ object SettingsPlayerScreen : SearchableSettings { title = stringResource(R.string.resolution), icon = painterResource(R.drawable.high_res_24px), ), + Preference.PreferenceItem.SwitchPreference( + preference = settings.player.showInfoWhenLocked, + title = stringResource(R.string.show_info_when_locked), + subtitle = stringResource(R.string.show_info_when_locked_desc), + icon = painterResource(R.drawable.lock_24px), + ), // Unsure if we want to have MultiSelectListPreference or boolean /*Preference.PreferenceItem.MultiSelectListPreference( diff --git a/app/src/main/res/drawable/lock_24px.xml b/app/src/main/res/drawable/lock_24px.xml new file mode 100644 index 00000000000..c907c52b0c9 --- /dev/null +++ b/app/src/main/res/drawable/lock_24px.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/donottranslate-strings.xml b/app/src/main/res/values/donottranslate-strings.xml index a1334f0b192..83c570d1cdd 100644 --- a/app/src/main/res/values/donottranslate-strings.xml +++ b/app/src/main/res/values/donottranslate-strings.xml @@ -87,6 +87,7 @@ show_episode_text_key hide_player_control_names_key preview_seekbar_key + show_info_when_locked_key backup_path_key backup_dir_key confirm_exit_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 66eb3533c4c..53da8336f3e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -717,6 +717,8 @@ Hide names of the player\'s controls Seekbar preview Enable preview thumbnail on seekbar + Show info when locked + Show the title and playback progress when tapping the screen with the controls locked No subtitles loaded yet Backup folder location Custom diff --git a/app/src/main/res/xml/settings_player.xml b/app/src/main/res/xml/settings_player.xml index 6e136747448..7f1e13d9ed5 100644 --- a/app/src/main/res/xml/settings_player.xml +++ b/app/src/main/res/xml/settings_player.xml @@ -40,6 +40,12 @@ android:icon="@drawable/ic_baseline_text_format_24" android:key="@string/hide_player_control_names_key" android:title="@string/hide_player_control_names" /> + diff --git a/shared/src/commonMain/kotlin/com/lagradost/cloudstream4/DevicePreferenceStore.kt b/shared/src/commonMain/kotlin/com/lagradost/cloudstream4/DevicePreferenceStore.kt index c0f784fc13f..401ec7649e4 100644 --- a/shared/src/commonMain/kotlin/com/lagradost/cloudstream4/DevicePreferenceStore.kt +++ b/shared/src/commonMain/kotlin/com/lagradost/cloudstream4/DevicePreferenceStore.kt @@ -157,6 +157,7 @@ class PlayerPreferences(preferences: PreferenceStore) { val defaultPlayer = preferences.getString("player_default_key", "") val limitPlayerTitle = preferences.getInt("prefer_limit_title_key", 0) val hidePlayerControlNames = preferences.getBoolean("hide_player_control_names_key", false) + val showInfoWhenLocked = preferences.getBoolean("show_info_when_locked_key", true) val showName = preferences.getBoolean("show_name", true) val showResolution = preferences.getBoolean("show_resolution", true) val showMediaInfo = preferences.getBoolean("show_media_info", false)