Skip to content

Commit

Permalink
TV UX improvements (#538)
Browse files Browse the repository at this point in the history
* Update styles.xml
  • Loading branch information
self-similarity committed Aug 12, 2023
1 parent 2d65aef commit ecd529f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>) {
Expand All @@ -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
) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/color/button_selector_color.xml
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/result_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -839,4 +844,4 @@
@drawable/cast_ic_mini_controller_closed_caption
</item>
</style>
</resources>
</resources>

0 comments on commit ecd529f

Please sign in to comment.