Selaa lähdekoodia

TunnelList: Get focus to toggle button via remote for Fire TV

This removes a no-longer-needed workaround for the ListView
OnItemClickListener (it won't fire if a focusable view is inside the
item view). Since converting our ListView instances to RecyclerView
instances, we set the OnClick and OnLongClick listeners directly on the
item view, and this workaround no longer has any effect.

Unsurprisingly, the workaround breaks focusability of the Switch, which
is necessary to toggle tunnels on devices with keypad-based navigation,
such as the Fire TV.

This commit also adds explicit focusability hints for the Switch.

Related mail thread:
https://lists.zx2c4.com/pipermail/wireguard/2019-May/004112.html

Reported-by: Christophe-Marie Duquesne <chmd@chmd.fr>
Reported-by: Revath S Kumar <gmail@revathskumar.com>
[Samuel: sorted attributes; expanded commit message]
Signed-off-by: Samuel Holland <samuel@sholland.org>
master
Revath S Kumar 5 vuotta sitten
committed by Jason A. Donenfeld
vanhempi
commit
e9e4fd4e8b
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. +5
    -1
      app/src/main/res/layout/tunnel_list_item.xml

+ 5
- 1
app/src/main/res/layout/tunnel_list_item.xml Näytä tiedosto

@@ -26,10 +26,13 @@
</data>

<com.wireguard.android.widget.MultiselectableRelativeLayout
android:id="@+id/tunnel_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_item_background"
android:descendantFocusability="blocksDescendants"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:nextFocusRight="@+id/tunnel_switch"
android:padding="16dp">

<TextView
@@ -49,6 +52,7 @@
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tunnel_name"
android:layout_alignParentEnd="true"
android:nextFocusLeft="@+id/tunnel_list_item"
app:checked="@{item.state == State.UP}"
app:onBeforeCheckedChanged="@{fragment::setTunnelState}" />
</com.wireguard.android.widget.MultiselectableRelativeLayout>


Ladataan…
Peruuta
Tallenna