Under Button text

This commit is contained in:
KingLucius 2024-07-18 16:33:44 +03:00
parent 244a4e003e
commit a6d7d93527
3 changed files with 235 additions and 101 deletions

View file

@ -77,7 +77,8 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
protected open var isFullScreenPlayer = true protected open var isFullScreenPlayer = true
protected var playerBinding: PlayerCustomLayoutBinding? = null protected var playerBinding: PlayerCustomLayoutBinding? = null
private var durationMode : Boolean by UserPreferenceDelegate("duration_mode", false) private var durationMode: Boolean by UserPreferenceDelegate("duration_mode", false)
// state of player UI // state of player UI
protected var isShowing = false protected var isShowing = false
protected var isLocked = false protected var isLocked = false
@ -283,7 +284,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
player.getCurrentPreferredSubtitle() == null player.getCurrentPreferredSubtitle() == null
} }
private fun restoreOrientationWithSensor(activity: Activity){ private fun restoreOrientationWithSensor(activity: Activity) {
val currentOrientation = activity.resources.configuration.orientation val currentOrientation = activity.resources.configuration.orientation
var orientation = 0 var orientation = 0
when (currentOrientation) { when (currentOrientation) {
@ -299,7 +300,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
activity.requestedOrientation = orientation activity.requestedOrientation = orientation
} }
private fun toggleOrientationWithSensor(activity: Activity){ private fun toggleOrientationWithSensor(activity: Activity) {
val currentOrientation = activity.resources.configuration.orientation val currentOrientation = activity.resources.configuration.orientation
var orientation = 0 var orientation = 0
when (currentOrientation) { when (currentOrientation) {
@ -344,12 +345,11 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
private fun updateOrientation(ignoreDynamicOrientation: Boolean = false) { private fun updateOrientation(ignoreDynamicOrientation: Boolean = false) {
activity?.apply { activity?.apply {
if(lockRotation) { if (lockRotation) {
if(isLocked) { if (isLocked) {
lockOrientation(this) lockOrientation(this)
} } else {
else { if (ignoreDynamicOrientation) {
if(ignoreDynamicOrientation){
// restore when lock is disabled // restore when lock is disabled
restoreOrientationWithSensor(this) restoreOrientationWithSensor(this)
} else { } else {
@ -948,7 +948,10 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
} }
else -> { else -> {
player.handleEvent(CSPlayerEvent.PlayPauseToggle, PlayerEventSource.UI) player.handleEvent(
CSPlayerEvent.PlayPauseToggle,
PlayerEventSource.UI
)
} }
} }
} else if (doubleTapEnabled && isFullScreenPlayer) { } else if (doubleTapEnabled && isFullScreenPlayer) {
@ -1423,6 +1426,25 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
} }
playerBinding?.apply { playerBinding?.apply {
if (isLayout(TV or EMULATOR)) {
mapOf(
playerGoBack to playerGoBackText,
playerRestart to playerRestartText,
playerGoForward to playerGoForwardText
).forEach { (button, text) ->
button.setOnFocusChangeListener { _, hasFocus ->
if (!hasFocus) {
text.isSelected = false
text.isVisible = false
return@setOnFocusChangeListener
}
text.isSelected = true
text.isVisible = true
}
}
}
playerPausePlay.setOnClickListener { playerPausePlay.setOnClickListener {
autoHide() autoHide()
player.handleEvent(CSPlayerEvent.PlayPauseToggle) player.handleEvent(CSPlayerEvent.PlayPauseToggle)
@ -1569,7 +1591,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
private fun setRemainingTimeCounter(showRemaining: Boolean) { private fun setRemainingTimeCounter(showRemaining: Boolean) {
durationMode = showRemaining durationMode = showRemaining
playerBinding?.exoDuration?.isInvisible= showRemaining playerBinding?.exoDuration?.isInvisible = showRemaining
playerBinding?.timeLeft?.isVisible = showRemaining playerBinding?.timeLeft?.isVisible = showRemaining
} }

View file

@ -176,47 +176,104 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<ImageView <LinearLayout
android:id="@+id/player_go_back" android:layout_width="wrap_content"
android:layout_width="30dp" android:layout_height="wrap_content"
android:layout_height="30dp" android:layout_marginEnd="10dp"
android:src="@drawable/ic_baseline_arrow_back_24" android:id="@+id/player_go_back_root"
app:tint="@android:color/white" android:orientation="vertical">
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:contentDescription="@string/go_back_img_des"
android:focusable="true"
android:tag="@string/tv_no_focus_tag" />
<ImageView <ImageView
android:id="@+id/player_restart" android:id="@+id/player_go_back"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_arrow_back_24"
app:tint="@android:color/white"
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:contentDescription="@string/go_back_img_des"
android:focusable="true"
android:nextFocusRight="@id/player_restart"
android:nextFocusLeft="@id/player_go_back"
android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_go_back"
android:tag="@string/tv_no_focus_tag" />
<TextView
android:id="@+id/player_go_back_text"
style="@style/ResultMarqueeButtonText"
android:text="@string/go_back_img_des"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp" android:layout_marginStart="40dp"
android:src="@drawable/ic_baseline_replay_24" android:layout_marginEnd="10dp"
app:tint="@android:color/white" android:id="@+id/player_restart_root"
android:background="@drawable/video_tap_button_always_white" android:orientation="vertical">
android:clickable="true"
android:contentDescription="@string/go_back_img_des"
android:focusable="true"
android:visibility="gone"
tools:visibility="visible"
android:tag="@string/tv_no_focus_tag" />
<ImageView <ImageView
android:id="@+id/player_go_forward" android:id="@+id/player_restart"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_replay_24"
app:tint="@android:color/white"
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:contentDescription="@string/restart"
android:focusable="true"
android:nextFocusRight="@id/player_go_forward"
android:nextFocusLeft="@id/player_go_back"
android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_restart"
android:tag="@string/tv_no_focus_tag" />
<TextView
android:id="@+id/player_restart_text"
style="@style/ResultMarqueeButtonText"
android:text="@string/restart"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="80dp" android:layout_marginStart="80dp"
android:src="@drawable/ic_baseline_skip_next_rounded_24" android:layout_marginEnd="10dp"
app:tint="@android:color/white" android:id="@+id/player_go_forward_root"
android:background="@drawable/video_tap_button_always_white" android:orientation="vertical">
android:clickable="true"
android:contentDescription="@string/go_back_img_des" <ImageView
android:focusable="true" android:id="@+id/player_go_forward"
android:visibility="gone" android:layout_width="30dp"
tools:visibility="visible" android:layout_height="30dp"
android:tag="@string/tv_no_focus_tag" /> android:layout_gravity="center"
android:src="@drawable/ic_baseline_skip_next_rounded_24"
app:tint="@android:color/white"
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:nextFocusRight="@id/player_go_forward"
android:nextFocusLeft="@id/player_restart"
android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_go_forward"
android:contentDescription="@string/next_episode"
android:focusable="true"
android:tag="@string/tv_no_focus_tag" />
<TextView
android:id="@+id/player_go_forward_text"
style="@style/ResultMarqueeButtonText"
android:text="@string/next_episode"
android:visibility="gone"/>
</LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -287,61 +287,115 @@
android:id="@+id/player_go_back_holder" android:id="@+id/player_go_back_holder"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_marginStart="17dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginEnd="32dp" android:layout_marginEnd="17dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<ImageView <LinearLayout
android:id="@+id/player_go_back" android:layout_width="60dp"
android:layout_width="30dp" android:layout_height="wrap_content"
android:layout_height="30dp" android:layout_marginEnd="10dp"
android:src="@drawable/ic_baseline_arrow_back_24" android:id="@+id/player_go_back_root"
app:tint="@android:color/white" android:orientation="vertical">
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:contentDescription="@string/go_back_img_des"
android:focusable="true"
android:nextFocusRight="@id/player_restart"
android:nextFocusLeft="@id/player_go_back"
android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_go_back"
android:tag="@string/tv_no_focus_tag" />
<ImageView <ImageView
android:id="@+id/player_restart" android:id="@+id/player_go_back"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_marginStart="40dp" android:layout_gravity="center"
android:src="@drawable/ic_baseline_replay_24" android:src="@drawable/ic_baseline_arrow_back_24"
app:tint="@android:color/white" app:tint="@android:color/white"
android:background="@drawable/video_tap_button_always_white" android:background="@drawable/video_tap_button_always_white"
android:clickable="true" android:clickable="true"
android:contentDescription="@string/go_back_img_des" android:contentDescription="@string/go_back_img_des"
android:focusable="true" android:focusable="true"
android:nextFocusRight="@id/player_go_forward" android:nextFocusRight="@id/player_restart"
android:nextFocusLeft="@id/player_go_back" android:nextFocusLeft="@id/player_go_back"
android:nextFocusDown="@id/player_pause_play" android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_restart" android:nextFocusUp="@id/player_go_back"
android:tag="@string/tv_no_focus_tag" /> android:tag="@string/tv_no_focus_tag" />
<ImageView <TextView
android:id="@+id/player_go_forward" android:id="@+id/player_go_back_text"
android:layout_width="30dp" android:layout_marginTop="5dp"
android:layout_height="30dp" style="@style/ResultMarqueeButtonText"
android:layout_marginStart="80dp" android:text="@string/go_back_img_des"
android:src="@drawable/ic_baseline_skip_next_rounded_24" android:visibility="invisible"
app:tint="@android:color/white" tools:visibility="visible"/>
android:background="@drawable/video_tap_button_always_white"
android:clickable="true" </LinearLayout>
android:nextFocusRight="@id/player_go_forward"
android:nextFocusLeft="@id/player_restart" <LinearLayout
android:nextFocusDown="@id/player_pause_play" android:layout_width="60dp"
android:nextFocusUp="@id/player_go_forward" android:layout_height="wrap_content"
android:contentDescription="@string/go_back_img_des" android:layout_marginStart="50dp"
android:focusable="true" android:layout_marginEnd="10dp"
android:tag="@string/tv_no_focus_tag" /> android:id="@+id/player_restart_root"
android:orientation="vertical">
<ImageView
android:id="@+id/player_restart"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_replay_24"
app:tint="@android:color/white"
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:contentDescription="@string/restart"
android:focusable="true"
android:nextFocusRight="@id/player_go_forward"
android:nextFocusLeft="@id/player_go_back"
android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_restart"
android:tag="@string/tv_no_focus_tag" />
<TextView
android:id="@+id/player_restart_text"
android:layout_marginTop="5dp"
style="@style/ResultMarqueeButtonText"
android:text="@string/restart"
android:visibility="invisible"
tools:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_marginEnd="10dp"
android:id="@+id/player_go_forward_root"
android:orientation="vertical">
<ImageView
android:id="@+id/player_go_forward"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_skip_next_rounded_24"
app:tint="@android:color/white"
android:background="@drawable/video_tap_button_always_white"
android:clickable="true"
android:nextFocusRight="@id/player_go_forward"
android:nextFocusLeft="@id/player_restart"
android:nextFocusDown="@id/player_pause_play"
android:nextFocusUp="@id/player_go_forward"
android:contentDescription="@string/next_episode"
android:focusable="true"
android:tag="@string/tv_no_focus_tag" />
<TextView
android:id="@+id/player_go_forward_text"
android:layout_marginTop="5dp"
style="@style/ResultMarqueeButtonText"
android:text="@string/next_episode"
android:visibility="invisible"
tools:visibility="visible"/>
</LinearLayout>
</FrameLayout> </FrameLayout>
</FrameLayout> </FrameLayout>
@ -545,6 +599,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layoutDirection="ltr" android:layoutDirection="ltr"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/player_pause_play" android:id="@+id/player_pause_play"
@ -560,10 +615,10 @@
android:src="@drawable/netflix_pause" android:src="@drawable/netflix_pause"
android:tag="@string/tv_no_focus_tag" android:tag="@string/tv_no_focus_tag"
app:tint="@color/player_button_tv"
tools:ignore="ContentDescription"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:tint="@color/player_button_tv"
tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@id/exo_position" android:id="@id/exo_position"
@ -654,10 +709,10 @@
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="normal" android:textStyle="normal"
android:visibility="gone"
app:layout_constraintBaseline_toBaselineOf="@id/exo_position" app:layout_constraintBaseline_toBaselineOf="@id/exo_position"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
tools:text="-23:20" tools:text="-23:20" />
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>