Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
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)
Expand Down Expand Up @@ -289,9 +292,8 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(

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()
Expand Down Expand Up @@ -739,11 +741,13 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
// 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)
Expand All @@ -753,9 +757,23 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
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)
Expand All @@ -765,16 +783,17 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
}
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
Expand Down Expand Up @@ -1152,6 +1171,10 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/lock_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M240,880q-33,0 -56.5,-23.5T160,800v-400q0,-33 23.5,-56.5T240,320h40v-80q0,-83 58.5,-141.5T480,40q83,0 141.5,58.5T680,240v80h40q33,0 56.5,23.5T800,400v400q0,33 -23.5,56.5T720,880L240,880ZM240,800h480v-400L240,400v400ZM480,680q33,0 56.5,-23.5T560,600q0,-33 -23.5,-56.5T480,520q-33,0 -56.5,23.5T400,600q0,33 23.5,56.5T480,680ZM360,320h240v-80q0,-50 -35,-85t-85,-35q-50,0 -85,35t-35,85v80Z"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/donottranslate-strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<string name="show_episode_text_key">show_episode_text_key</string>
<string name="hide_player_control_names_key">hide_player_control_names_key</string>
<string name="preview_seekbar_key">preview_seekbar_key</string>
<string name="show_info_when_locked_key">show_info_when_locked_key</string>
<string name="backup_path_key">backup_path_key</string>
<string name="backup_dir_key">backup_dir_key</string>
<string name="confirm_exit_key">confirm_exit_key</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@
<string name="hide_player_control_names">Hide names of the player\'s controls</string>
<string name="preview_seekbar">Seekbar preview</string>
<string name="preview_seekbar_desc">Enable preview thumbnail on seekbar</string>
<string name="show_info_when_locked">Show info when locked</string>
<string name="show_info_when_locked_desc">Show the title and playback progress when tapping the screen with the controls locked</string>
<string name="no_subtitles_loaded">No subtitles loaded yet</string>
<string name="backup_path_title">Backup folder location</string>
<string name="custom">Custom</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/settings_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/video_locked"
android:key="@string/show_info_when_locked_key"
android:summary="@string/show_info_when_locked_desc"
android:title="@string/show_info_when_locked" />
</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_category_subtitles">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading