Various Android TV homepage fixes

This commit is contained in:
Blatzar 2023-01-09 02:15:06 +01:00
parent 0ebc12e29b
commit 06c2cf86ec
4 changed files with 25 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package com.lagradost.cloudstream3
import android.content.ComponentName
import android.content.DialogInterface
import android.content.Intent
import android.content.res.ColorStateList
import android.content.res.Configuration
@ -102,6 +103,7 @@ import java.net.URI
import java.net.URLDecoder
import java.nio.charset.Charset
import kotlin.reflect.KClass
import kotlin.system.exitProcess
//https://github.com/videolan/vlc-android/blob/3706c4be2da6800b3d26344fc04fab03ffa4b860/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt#L1898
@ -505,10 +507,13 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
builder.setTitle(R.string.confirm_exit_dialog)
builder.apply {
setPositiveButton(R.string.yes) { _, _ -> super.onBackPressed() }
// Forceful exit since back button can actually go back to setup
setPositiveButton(R.string.yes) { _, _ -> exitProcess(0) }
setNegativeButton(R.string.no) { _, _ -> }
}
builder.show()
builder.show().also {
it.getButton(DialogInterface.BUTTON_NEGATIVE).requestFocus()
}
}
private fun backPressed() {

View file

@ -81,6 +81,8 @@ class APIRepository(val api: MainAPI) {
}
api.load(fixedUrl)?.also { response ->
// Remove all blank tags as early as possible
response.tags = response.tags?.filter { it.isNotBlank() }
val add = SavedLoadResponse(unixTime, response, lookingForHash)
synchronized(cache) {
@ -122,7 +124,6 @@ class APIRepository(val api: MainAPI) {
delay(delta)
}
@OptIn(DelicateCoroutinesApi::class)
suspend fun getMainPage(page: Int, nameIndex: Int? = null): Resource<List<HomePageResponse?>> {
return safeApiCall {
api.lastHomepageRequest = unixTimeMS

View file

@ -268,11 +268,23 @@ class HomeParentItemAdapterPreview(
)
)
}
// This makes the hidden next buttons only available when on the info button
// Otherwise you might be able to go to the next item without being at the info button
itemView.home_preview_info_btt?.setOnFocusChangeListener { _, hasFocus ->
itemView.home_preview_hidden_next_focus?.isFocusable = hasFocus
}
itemView.home_preview_play_btt?.setOnFocusChangeListener { _, hasFocus ->
itemView.home_preview_hidden_prev_focus?.isFocusable = hasFocus
}
itemView.home_preview_info_btt?.setOnClickListener { view ->
clickCallback?.invoke(
LoadClickCallback(0, view, position, this)
)
}
itemView.home_preview_hidden_next_focus?.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
previewViewpager?.apply {
@ -281,6 +293,7 @@ class HomeParentItemAdapterPreview(
itemView.home_preview_info_btt?.requestFocus()
}
}
itemView.home_preview_hidden_prev_focus?.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
previewViewpager?.apply {

View file

@ -20,6 +20,7 @@
android:layout_height="wrap_content">
<androidx.viewpager2.widget.ViewPager2
android:descendantFocusability="blocksDescendants"
android:id="@+id/home_preview_viewpager"
android:layout_width="match_parent"
android:layout_height="400dp"
@ -87,7 +88,7 @@
android:id="@+id/home_preview_hidden_prev_focus"
android:layout_width="1dp"
android:layout_height="1dp"
android:focusable="true" />
android:focusable="false" />
<com.google.android.material.button.MaterialButton
android:id="@+id/home_preview_play_btt"
@ -119,7 +120,7 @@
android:id="@+id/home_preview_hidden_next_focus"
android:layout_width="1dp"
android:layout_height="1dp"
android:focusable="true" />
android:focusable="false" />
</LinearLayout>
</LinearLayout>
</FrameLayout>