mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Many fixes
This commit is contained in:
parent
45ecc903a2
commit
6e89ed9d81
6 changed files with 184 additions and 120 deletions
|
@ -539,6 +539,10 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
val isTrueTv = isTrueTvSettings()
|
||||
navView.menu.findItem(R.id.navigation_library)?.isVisible = !isTrueTv
|
||||
navRailView.menu.findItem(R.id.navigation_library)?.isVisible = !isTrueTv
|
||||
|
||||
// Hide downloads on TV
|
||||
navView.menu.findItem(R.id.navigation_downloads)?.isVisible = !isTrueTv
|
||||
navRailView.menu.findItem(R.id.navigation_downloads)?.isVisible = !isTrueTv
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1112,16 +1116,17 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
newLocalBinding.root.viewTreeObserver.addOnGlobalFocusChangeListener { _, newFocus ->
|
||||
// println("refocus $oldFocus -> $newFocus")
|
||||
try {
|
||||
val r = Rect(0,0,0,0)
|
||||
val r = Rect(0, 0, 0, 0)
|
||||
newFocus.getDrawingRect(r)
|
||||
val x = r.centerX()
|
||||
val y = r.centerY()
|
||||
val dx = 0 //screenWidth / 2
|
||||
val dy = screenHeight / 2
|
||||
val r2 = Rect(x-dx,y-dy,x+dx,y+dy)
|
||||
val r2 = Rect(x - dx, y - dy, x + dx, y + dy)
|
||||
newFocus.requestRectangleOnScreen(r2, false)
|
||||
// TvFocus.current =TvFocus.current.copy(y=y.toFloat())
|
||||
} catch (_ : Throwable) { }
|
||||
// TvFocus.current =TvFocus.current.copy(y=y.toFloat())
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
TvFocus.updateFocusView(newFocus)
|
||||
/*var focus = newFocus
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.ui
|
|||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.core.view.children
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlin.math.abs
|
||||
|
@ -70,8 +71,8 @@ class GrdLayoutManager(val context: Context, _spanCount: Int) :
|
|||
val orientation = this.orientation
|
||||
|
||||
// fixes arabic by inverting left and right layout focus
|
||||
val correctDirection = if(this.isLayoutRTL) {
|
||||
when(direction) {
|
||||
val correctDirection = if (this.isLayoutRTL) {
|
||||
when (direction) {
|
||||
View.FOCUS_RIGHT -> View.FOCUS_LEFT
|
||||
View.FOCUS_LEFT -> View.FOCUS_RIGHT
|
||||
else -> direction
|
||||
|
@ -83,12 +84,15 @@ class GrdLayoutManager(val context: Context, _spanCount: Int) :
|
|||
View.FOCUS_DOWN -> {
|
||||
return spanCount
|
||||
}
|
||||
|
||||
View.FOCUS_UP -> {
|
||||
return -spanCount
|
||||
}
|
||||
|
||||
View.FOCUS_RIGHT -> {
|
||||
return 1
|
||||
}
|
||||
|
||||
View.FOCUS_LEFT -> {
|
||||
return -1
|
||||
}
|
||||
|
@ -98,12 +102,15 @@ class GrdLayoutManager(val context: Context, _spanCount: Int) :
|
|||
View.FOCUS_DOWN -> {
|
||||
return 1
|
||||
}
|
||||
|
||||
View.FOCUS_UP -> {
|
||||
return -1
|
||||
}
|
||||
|
||||
View.FOCUS_RIGHT -> {
|
||||
return spanCount
|
||||
}
|
||||
|
||||
View.FOCUS_LEFT -> {
|
||||
return -spanCount
|
||||
}
|
||||
|
@ -155,4 +162,32 @@ class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
|
||||
layoutManager = manager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recyclerview wherein the max item width or height is set by the biggest view to prevent inconsistent view sizes.
|
||||
*/
|
||||
class MaxRecyclerView(ctx: Context, attrs: AttributeSet) : RecyclerView(ctx, attrs) {
|
||||
private var biggestObserved: Int = 0
|
||||
private val orientation = LayoutManager.getProperties(context, attrs, 0, 0).orientation
|
||||
private val isHorizontal = orientation == HORIZONTAL
|
||||
private fun View.updateMaxSize() {
|
||||
if (isHorizontal) {
|
||||
this.minimumHeight = biggestObserved
|
||||
} else {
|
||||
this.minimumWidth = biggestObserved
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChildAttachedToWindow(child: View) {
|
||||
child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)
|
||||
val observed = if (isHorizontal) child.measuredHeight else child.measuredWidth
|
||||
if (observed > biggestObserved) {
|
||||
biggestObserved = observed
|
||||
children.forEach { it.updateMaxSize() }
|
||||
} else {
|
||||
child.updateMaxSize()
|
||||
}
|
||||
super.onChildAttachedToWindow(child)
|
||||
}
|
||||
}
|
|
@ -177,7 +177,7 @@ class ResultFragmentTv : Fragment() {
|
|||
isVisible = true
|
||||
}
|
||||
|
||||
this.animate().alpha(if (turnVisible) 1.0f else 0.0f).apply {
|
||||
this.animate().alpha(if (turnVisible) 0.97f else 0.0f).apply {
|
||||
duration = 200
|
||||
interpolator = DecelerateInterpolator()
|
||||
setListener(object : Animator.AnimatorListener {
|
||||
|
@ -294,9 +294,9 @@ class ResultFragmentTv : Fragment() {
|
|||
toggleEpisodes(true)
|
||||
binding?.apply {
|
||||
val views = listOf(
|
||||
resultDubSelection,
|
||||
resultSeasonSelection,
|
||||
resultRangeSelection,
|
||||
resultDubSelection,
|
||||
resultEpisodes,
|
||||
resultPlayTrailer,
|
||||
)
|
||||
|
|
|
@ -518,7 +518,8 @@ class ResultViewModel2 : ViewModel() {
|
|||
val episodeNumber = episodes[currentIndex].episode
|
||||
if (episodeNumber < currentMin) {
|
||||
currentMin = episodeNumber
|
||||
} else if (episodeNumber > currentMax) {
|
||||
}
|
||||
if (episodeNumber > currentMax) {
|
||||
currentMax = episodeNumber
|
||||
}
|
||||
++currentIndex
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:startColor="@color/transparent"
|
||||
android:endColor="?attr/primaryBlackBackground"/>
|
||||
android:centerColor="?attr/primaryBlackBackground"
|
||||
android:centerX="0.2"
|
||||
android:endColor="?attr/primaryBlackBackground"
|
||||
android:startColor="@color/transparent" />
|
||||
</shape>
|
|
@ -535,129 +535,150 @@ https://developer.android.com/design/ui/tv/samples/jet-fit
|
|||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<FrameLayout
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/episodes_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/episodes_shadow"/>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/episodes_shadow"/>
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/episode_holder_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/result_padding"
|
||||
android:paddingEnd="@dimen/result_padding"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:visibility="gone">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/result_season_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_episodes_show"
|
||||
android:nextFocusRight="@id/result_range_selection"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_selection" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/result_range_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
|
||||
android:nextFocusLeft="@id/result_season_selection"
|
||||
android:nextFocusRight="@id/result_dub_selection"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_selection"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/result_dub_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_range_selection"
|
||||
android:nextFocusRight="@id/result_episodes"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_selection" />
|
||||
tools:visibility="visible">
|
||||
|
||||
|
||||
<!--<androidx.core.widget.ContentLoadingProgressBar
|
||||
android:id="@+id/result_episode_loading"
|
||||
<!--
|
||||
These two shadow spaces are used to create a view which always x% bigger
|
||||
than the episode_holder_tv. This is required for creating a consistent shadow.
|
||||
-->
|
||||
<Space
|
||||
android:id="@+id/shadow_space_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="@+id/episode_holder_tv"
|
||||
app:layout_constraintStart_toStartOf="@+id/episode_holder_tv" />
|
||||
|
||||
style="@style/Widget.AppCompat.ProgressBar"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp" />-->
|
||||
<!--
|
||||
The dimension ratio should and episodes_shadow centerX should add up to
|
||||
100% for the best results. For example (100:80 + 0.2) or (100:70 + 0.3).
|
||||
Bigger centerX => Larger fade distance.
|
||||
-->
|
||||
<Space
|
||||
android:id="@+id/shadow_space_2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="100:80"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/shadow_space_1" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/result_episodes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_dub_selection"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_episode" />
|
||||
|
||||
<View
|
||||
android:id="@+id/temporary_no_focus"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="1dp"
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:nextFocusLeft="@id/temporary_no_focus"
|
||||
android:nextFocusRight="@id/temporary_no_focus"
|
||||
android:nextFocusUp="@id/temporary_no_focus"
|
||||
android:nextFocusDown="@id/temporary_no_focus" />
|
||||
</LinearLayout>
|
||||
android:focusableInTouchMode="false"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/episodes_shadow"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/shadow_space_2"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/episode_holder_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/result_padding"
|
||||
android:paddingEnd="@dimen/result_padding"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.lagradost.cloudstream3.ui.MaxRecyclerView
|
||||
android:id="@+id/result_dub_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_episodes_show"
|
||||
android:nextFocusRight="@id/result_season_selection"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_selection"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<com.lagradost.cloudstream3.ui.MaxRecyclerView
|
||||
android:id="@+id/result_season_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_dub_selection"
|
||||
android:nextFocusRight="@id/result_range_selection"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_selection"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<com.lagradost.cloudstream3.ui.MaxRecyclerView
|
||||
android:id="@+id/result_range_selection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_season_selection"
|
||||
android:nextFocusRight="@id/result_episodes"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_selection"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<!--<androidx.core.widget.ContentLoadingProgressBar
|
||||
android:id="@+id/result_episode_loading"
|
||||
|
||||
style="@style/Widget.AppCompat.ProgressBar"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp" />-->
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/result_episodes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
android:nextFocusLeft="@id/result_range_selection"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="@dimen/result_padding"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/result_episode" />
|
||||
|
||||
<View
|
||||
android:id="@+id/temporary_no_focus"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="1dp"
|
||||
android:focusable="false"
|
||||
android:nextFocusLeft="@id/temporary_no_focus"
|
||||
android:nextFocusRight="@id/temporary_no_focus"
|
||||
android:nextFocusUp="@id/temporary_no_focus"
|
||||
android:nextFocusDown="@id/temporary_no_focus" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue