diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index 0071ab49..4620b11f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -256,13 +256,14 @@ class HomeFragment : Fragment() { nsfw: MaterialButton?, others: MaterialButton?, ): List>> { + // This list should be same order as home screen to aid navigation return listOf( - Pair(anime, listOf(TvType.Anime, TvType.OVA, TvType.AnimeMovie)), - Pair(cartoons, listOf(TvType.Cartoon)), - Pair(tvs, listOf(TvType.TvSeries)), - Pair(docs, listOf(TvType.Documentary)), Pair(movies, listOf(TvType.Movie, TvType.Torrent)), + Pair(tvs, listOf(TvType.TvSeries)), + Pair(anime, listOf(TvType.Anime, TvType.OVA, TvType.AnimeMovie)), Pair(asian, listOf(TvType.AsianDrama)), + Pair(cartoons, listOf(TvType.Cartoon)), + Pair(docs, listOf(TvType.Documentary)), Pair(livestream, listOf(TvType.Live)), Pair(nsfw, listOf(TvType.NSFW)), Pair(others, listOf(TvType.Others)), @@ -352,11 +353,25 @@ class HomeFragment : Fragment() { arrayAdapter.notifyDataSetChanged() } + /** + * Since fire tv is fucked we need to manually define the focus layout. + * Since visible buttons are only known in runtime this is required. + **/ + var lastButton: MaterialButton? = null + for ((button, validTypes) in pairList) { val isValid = validAPIs.any { api -> validTypes.any { api.supportedTypes.contains(it) } } button?.isVisible = isValid if (isValid) { + + // Set focus navigation + button?.let { currentButton -> + lastButton?.nextFocusRightId = currentButton.id + lastButton?.id?.let { currentButton.nextFocusLeftId = it } + lastButton = currentButton + } + fun buttonContains(): Boolean { return preSelectedTypes.any { validTypes.contains(it) } } diff --git a/app/src/main/res/layout/home_select_mainpage.xml b/app/src/main/res/layout/home_select_mainpage.xml index 6f86d40c..ca9fa517 100644 --- a/app/src/main/res/layout/home_select_mainpage.xml +++ b/app/src/main/res/layout/home_select_mainpage.xml @@ -52,6 +52,11 @@ android:id="@+id/home_select_none" style="@style/RoundedSelectableButtonIcon"/>--> + +