Materia3 buttons and WatchCredits button
This commit is contained in:
parent
91cccc55a7
commit
6095c97704
5 changed files with 75 additions and 43 deletions
|
@ -124,6 +124,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
val subtitleButton = binding.playerView.findViewById<ImageButton>(R.id.btn_subtitle)
|
||||
val speedButton = binding.playerView.findViewById<ImageButton>(R.id.btn_speed)
|
||||
val skipButton = binding.playerView.findViewById<Button>(R.id.btn_skip_intro)
|
||||
val watchCreditsButton = binding.playerView.findViewById<Button>(R.id.btn_watch_credits)
|
||||
val pipButton = binding.playerView.findViewById<ImageButton>(R.id.btn_pip)
|
||||
val lockButton = binding.playerView.findViewById<ImageButton>(R.id.btn_lockview)
|
||||
val unlockButton = binding.playerView.findViewById<ImageButton>(R.id.btn_unlock)
|
||||
|
@ -137,22 +138,15 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
// Title
|
||||
videoNameTextView.text = currentItemTitle
|
||||
|
||||
// Skip button
|
||||
// Button Visibility
|
||||
// Skip Button
|
||||
if (currentSegment != oldSegment) buttonPressed = false
|
||||
skipButton.isVisible =
|
||||
!isInPictureInPictureMode && !buttonPressed && (showSkip == true || (binding.playerView.isControllerFullyVisible && currentSegment?.skip == true))
|
||||
binding.playerView.setControllerVisibilityListener(
|
||||
PlayerView.ControllerVisibilityListener { visibility ->
|
||||
skipButton.isVisible =
|
||||
!isInPictureInPictureMode && !buttonPressed && (showSkip == true || visibility == View.VISIBLE && currentSegment?.skip == true)
|
||||
},
|
||||
)
|
||||
// Button Text
|
||||
// Button Visibility and Text
|
||||
when (currentSegment?.type) {
|
||||
"intro" -> {
|
||||
skipButton.text =
|
||||
getString(CoreR.string.skip_intro_button)
|
||||
skipButton.isVisible =
|
||||
!isInPictureInPictureMode && !buttonPressed && (showSkip == true || (binding.playerView.isControllerFullyVisible && currentSegment?.skip == true))
|
||||
}
|
||||
|
||||
"credit" -> {
|
||||
|
@ -162,9 +156,35 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
} else {
|
||||
getString(CoreR.string.skip_credit_button_last)
|
||||
}
|
||||
skipButton.isVisible =
|
||||
!isInPictureInPictureMode && !buttonPressed && currentSegment?.skip == true && !binding.playerView.isControllerFullyVisible
|
||||
watchCreditsButton.isVisible = skipButton.isVisible
|
||||
}
|
||||
}
|
||||
binding.playerView.setControllerVisibilityListener(
|
||||
PlayerView.ControllerVisibilityListener { visibility ->
|
||||
when (currentSegment?.type) {
|
||||
"intro" -> {
|
||||
skipButton.isVisible =
|
||||
!buttonPressed && (showSkip == true || (visibility == View.VISIBLE && currentSegment?.skip == true))
|
||||
}
|
||||
|
||||
"credit" -> {
|
||||
skipButton.isVisible =
|
||||
!buttonPressed && currentSegment?.skip == true && visibility == View.GONE
|
||||
watchCreditsButton.isVisible = skipButton.isVisible
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
// onClick
|
||||
if (currentSegment?.type == "credit") {
|
||||
watchCreditsButton.setOnClickListener {
|
||||
buttonPressed = true
|
||||
skipButton.isVisible = false
|
||||
watchCreditsButton.isVisible = false
|
||||
}
|
||||
}
|
||||
skipButton.setOnClickListener {
|
||||
when (currentSegment?.type) {
|
||||
"intro" -> {
|
||||
|
@ -183,6 +203,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
}
|
||||
buttonPressed = true
|
||||
skipButton.isVisible = false
|
||||
watchCreditsButton.isVisible = false
|
||||
}
|
||||
oldSegment = currentSegment
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_skip_intro"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/player_background"
|
||||
app:icon="@drawable/ic_skip_forward"
|
||||
app:iconGravity="end"
|
||||
app:iconTint="@android:color/white"
|
||||
app:strokeColor="@android:color/white"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
|
@ -71,10 +71,39 @@
|
|||
android:layout_height="match_parent"
|
||||
app:animation_enabled="false"/>
|
||||
|
||||
<include
|
||||
layout="@layout/exo_player_skip_control"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginBottom="64dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_watch_credits"
|
||||
style="@style/Widget.Material3.Button.TonalButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:text="@string/watch_credits"
|
||||
android:textColor="@color/material_dynamic_secondary10"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/material_dynamic_secondary90"
|
||||
app:strokeColor="#928E98"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_skip_intro"
|
||||
style="@style/Widget.Material3.Button.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/material_dynamic_primary100"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/material_dynamic_primary40"
|
||||
app:icon="@drawable/ic_skip_forward"
|
||||
app:iconTint="@color/material_dynamic_primary100"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</merge>
|
4
app/phone/src/main/res/values/strings.xml
Normal file
4
app/phone/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="watch_credits">Watch credits</string>
|
||||
</resources>
|
|
@ -251,8 +251,11 @@ constructor(
|
|||
_uiState.update { it.copy(currentSegment = currentSegment) }
|
||||
Timber.tag("SegmentInfo").d("currentSegment: %s", currentSegment)
|
||||
|
||||
val showSkip = currentSegment?.let { it.skip && seconds in it.showAt..<it.hideAt } ?: false
|
||||
_uiState.update { it.copy(showSkip = showSkip) }
|
||||
if (currentSegment?.type == "intro") {
|
||||
val showSkip =
|
||||
currentSegment.let { it.skip && seconds in it.showAt..<it.hideAt }
|
||||
_uiState.update { it.copy(showSkip = showSkip) }
|
||||
}
|
||||
}
|
||||
handler.postDelayed(this, 1000L)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue