From e72b4fc144e642eb99328d637549d805c14d9033 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 22 Sep 2020 23:50:26 +0200 Subject: tv: hook up isFocused as observable property This is kind of ridiculous, since the items own state should clearly be queryable, but it doesn't appear to be the case here, so just shuffle it around into kotlin and back. Signed-off-by: Jason A. Donenfeld --- .../main/java/com/wireguard/android/activity/TvMainActivity.kt | 4 ++++ ui/src/main/res/layout/tv_tunnel_list_item.xml | 10 ++++++---- ui/src/main/res/values/tv_colors.xml | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'ui/src/main') diff --git a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt index 2b12d545..1528ac95 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt @@ -79,6 +79,10 @@ class TvMainActivity : AppCompatActivity() { binding.rowConfigurationHandler = object : ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler { override fun onConfigureRow(binding: TvTunnelListItemBinding, item: ObservableTunnel, position: Int) { binding.isDeleting = isDeleting + binding.isFocused = ObservableBoolean() + binding.root.setOnFocusChangeListener { _, focused -> + binding.isFocused?.set(focused) + } binding.root.setOnClickListener { lifecycleScope.launch { if (isDeleting.get()) { diff --git a/ui/src/main/res/layout/tv_tunnel_list_item.xml b/ui/src/main/res/layout/tv_tunnel_list_item.xml index 0eedd87c..c45abd08 100644 --- a/ui/src/main/res/layout/tv_tunnel_list_item.xml +++ b/ui/src/main/res/layout/tv_tunnel_list_item.xml @@ -15,6 +15,10 @@ name="isDeleting" type="androidx.databinding.ObservableBoolean" /> + + @@ -24,16 +28,15 @@ type="com.wireguard.android.model.ObservableTunnel" /> - - diff --git a/ui/src/main/res/values/tv_colors.xml b/ui/src/main/res/values/tv_colors.xml index b202d2a2..f330bedc 100644 --- a/ui/src/main/res/values/tv_colors.xml +++ b/ui/src/main/res/values/tv_colors.xml @@ -2,4 +2,5 @@ #ff212121 @color/tv_primary_color + #b00020 -- cgit v1.2.3