TV UX improvements (#538)

* Update styles.xml
This commit is contained in:
self-similarity 2023-08-12 15:44:35 +00:00 committed by GitHub
parent 2d65aefc76
commit ecd529f73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 20 deletions

View File

@ -1273,7 +1273,18 @@ class GeneratorPlayer : FullScreenPlayer() {
from, to
).apply {
addListener(onEnd = {
if (!show) playerBinding?.skipChapterButton?.isVisible = false
if (show) {
if (!isShowing) {
// Automatically request focus if the menu is not opened
playerBinding?.skipChapterButton?.requestFocus()
}
} else {
playerBinding?.skipChapterButton?.isVisible = false
if (!isShowing) {
// Automatically return focus to play pause
playerBinding?.playerPausePlay?.requestFocus()
}
}
})
addUpdateListener { valueAnimator ->
val value = valueAnimator.animatedValue as Int

View File

@ -45,19 +45,9 @@ class SelectAdaptor(val callback: (Any) -> Unit) : RecyclerView.Adapter<Recycler
if(newIndex == selectedIndex) return
val oldIndex = selectedIndex
selectedIndex = newIndex
recyclerView.apply {
for (i in 0 until itemCount) {
val viewHolder = getChildViewHolder( getChildAt(i) ?: continue) ?: continue
val pos = viewHolder.absoluteAdapterPosition
if (viewHolder is SelectViewHolder) {
if (pos == oldIndex) {
viewHolder.update(false)
} else if (pos == newIndex) {
viewHolder.update(true)
}
}
}
}
notifyItemChanged(selectedIndex)
notifyItemChanged(oldIndex)
}
fun updateSelectionList(newList: List<SelectData>) {
@ -79,10 +69,6 @@ class SelectAdaptor(val callback: (Any) -> Unit) : RecyclerView.Adapter<Recycler
RecyclerView.ViewHolder(binding.root) {
private val item: MaterialButton = binding.root
fun update(isSelected: Boolean) {
item.isSelected = isSelected
}
fun bind(
data: SelectData, isSelected: Boolean, callback: (Any) -> Unit
) {

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:state_focused="true" android:color="@color/black"/>
<item android:state_selected="true" android:state_focused="false" android:color="@color/white"/>
<item android:color="@color/transparent"/>
</selector>

View File

@ -2,7 +2,7 @@
<com.google.android.material.button.MaterialButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/RegularButtonTV"
style="@style/SelectableButtonTV"
android:layout_gravity="start"
android:layout_margin="2dp"
android:minWidth="115dp"

View File

@ -737,6 +737,11 @@
<item name="android:layout_marginEnd">0dp</item>
</style>
<style name="SelectableButtonTV" parent="RegularButtonTV">
<item name="icon">@drawable/ic_baseline_check_24_listview</item>
<item name="iconTint">@color/button_selector_color</item>
</style>
<style name="RegularButtonTV">
<item name="android:tag">@string/tv_no_focus_tag</item>
<item name="android:stateListAnimator">@null</item>
@ -839,4 +844,4 @@
@drawable/cast_ic_mini_controller_closed_caption
</item>
</style>
</resources>
</resources>