forked from recloudstream/cloudstream
Fixed some focus and layout stuff for android TV
This commit is contained in:
parent
63b313395a
commit
d581c4b627
5 changed files with 31 additions and 14 deletions
|
@ -876,6 +876,10 @@ class CS3IPlayer : IPlayer {
|
|||
return Pair(subSources, activeSubtitles)
|
||||
}
|
||||
|
||||
override fun isActive(): Boolean {
|
||||
return exoPlayer != null
|
||||
}
|
||||
|
||||
private fun loadOnlinePlayer(context: Context, link: ExtractorLink) {
|
||||
Log.i(TAG, "loadOnlinePlayer $link")
|
||||
try {
|
||||
|
|
|
@ -1143,10 +1143,13 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
|||
|
||||
// handle tv controls directly based on player state
|
||||
keyEventListener = { eventNav ->
|
||||
val (event, hasNavigated) = eventNav
|
||||
if (event != null)
|
||||
handleKeyEvent(event, hasNavigated)
|
||||
else false
|
||||
// Don't hook player keys if player isn't active
|
||||
if (player.isActive()) {
|
||||
val (event, hasNavigated) = eventNav
|
||||
if (event != null)
|
||||
handleKeyEvent(event, hasNavigated)
|
||||
else false
|
||||
} else false
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -116,4 +116,7 @@ interface IPlayer {
|
|||
fun onResume(context: Context)
|
||||
|
||||
fun release()
|
||||
|
||||
/** Get if player is actually used */
|
||||
fun isActive() : Boolean
|
||||
}
|
|
@ -24,7 +24,6 @@ import android.widget.*
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.NestedScrollView
|
||||
|
@ -98,10 +97,7 @@ import kotlinx.android.synthetic.main.fragment_trailer.*
|
|||
import kotlinx.android.synthetic.main.result_recommendations.*
|
||||
import kotlinx.android.synthetic.main.result_sync.*
|
||||
import kotlinx.android.synthetic.main.trailer_custom_layout.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
@ -646,6 +642,13 @@ class ResultFragment : ResultTrailerPlayer() {
|
|||
}
|
||||
result_trailer_loading?.isVisible = isSuccess
|
||||
result_smallscreen_holder?.isVisible = !isSuccess && !isFullScreenPlayer
|
||||
|
||||
// We don't want the trailer to be focusable if it's not visible
|
||||
result_smallscreen_holder?.descendantFocusability = if (isSuccess) {
|
||||
ViewGroup.FOCUS_AFTER_DESCENDANTS
|
||||
} else {
|
||||
ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
}
|
||||
result_fullscreen_holder?.isVisible = !isSuccess && isFullScreenPlayer
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@
|
|||
</com.facebook.shimmer.ShimmerFrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:id="@+id/result_smallscreen_holder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -307,10 +308,10 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:id="@+id/result_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -322,6 +323,7 @@
|
|||
tools:text="The Perfect Run The Perfect Run" />
|
||||
|
||||
<com.lagradost.cloudstream3.widget.FlowLayout
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:itemSpacing="10dp">
|
||||
|
@ -358,11 +360,16 @@
|
|||
tools:text="121min" />
|
||||
</com.lagradost.cloudstream3.widget.FlowLayout>
|
||||
|
||||
<!--
|
||||
This has half margin and half padding to make TV focus on description look better.
|
||||
The focus outline now settles between the poster and text.
|
||||
-->
|
||||
<FrameLayout
|
||||
android:layout_marginHorizontal="5dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:padding="5dp"
|
||||
android:maxLength="1000"
|
||||
android:ellipsize="end"
|
||||
android:id="@+id/result_description"
|
||||
|
@ -371,9 +378,6 @@
|
|||
android:foreground="@drawable/outline_drawable"
|
||||
android:nextFocusUp="@id/result_back"
|
||||
android:nextFocusDown="@id/result_bookmark_button"
|
||||
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="0dp"
|
||||
android:textColor="?attr/textColor"
|
||||
android:textSize="15sp"
|
||||
tools:text="Ryan Quicksave Romano is an eccentric adventurer with a strange power: he can create a save-point in time and redo his life whenever he dies. Arriving in New Rome, the glitzy capital of sin of a rebuilding Europe, he finds the city torn between mega-corporations, sponsored heroes, superpowered criminals, and true monsters. It's a time of chaos, where potions can grant the power to rule the world and dangers lurk everywhere. " />
|
||||
|
|
Loading…
Reference in a new issue