summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/res
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-23 12:04:36 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-23 17:56:37 +0200
commitb3c43e428f98a3b9b32e404ca7ff958d2f05b03b (patch)
treeeff9e367258a4f6c9f23afcac5d593561855513f /ui/src/main/res
parent7bec539722b670f8e101c65914e0a8e59be90dd7 (diff)
tv: use our own file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/res')
-rw-r--r--ui/src/main/res/layout/tv_activity.xml58
-rw-r--r--ui/src/main/res/layout/tv_file_list_item.xml46
-rw-r--r--ui/src/main/res/values/strings.xml2
3 files changed, 99 insertions, 7 deletions
diff --git a/ui/src/main/res/layout/tv_activity.xml b/ui/src/main/res/layout/tv_activity.xml
index 5e29ed5f..16207b15 100644
--- a/ui/src/main/res/layout/tv_activity.xml
+++ b/ui/src/main/res/layout/tv_activity.xml
@@ -9,16 +9,30 @@
<import type="com.wireguard.android.model.ObservableTunnel" />
+ <import type="com.wireguard.android.activity.TvMainActivity.KeyedFile" />
+
<variable
name="isDeleting"
type="androidx.databinding.ObservableBoolean" />
<variable
+ name="files"
+ type="com.wireguard.android.databinding.ObservableKeyedArrayList&lt;String, KeyedFile&gt;" />
+
+ <variable
+ name="filesRoot"
+ type="androidx.databinding.ObservableField&lt;String&gt;" />
+
+ <variable
name="tunnels"
type="com.wireguard.android.databinding.ObservableKeyedArrayList&lt;String, ObservableTunnel&gt;" />
<variable
- name="rowConfigurationHandler"
+ name="tunnelRowConfigurationHandler"
+ type="com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler" />
+
+ <variable
+ name="filesRowConfigurationHandler"
type="com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler" />
</data>
@@ -54,8 +68,8 @@
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
- android:visibility="@{tunnels.isEmpty() ? View.GONE : View.VISIBLE}"
- app:configurationHandler="@{rowConfigurationHandler}"
+ android:visibility="@{(tunnels.isEmpty || !filesRoot.isEmpty) ? View.GONE : View.VISIBLE}"
+ app:configurationHandler="@{tunnelRowConfigurationHandler}"
app:items="@{tunnels}"
app:layout="@{@layout/tv_tunnel_list_item}"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
@@ -67,12 +81,44 @@
tools:listitem="@layout/tv_tunnel_list_item" />
<TextView
+ android:id="@+id/files_root_label"
+ style="@style/TextAppearance.MaterialComponents.Headline5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginStart="8dp"
+ android:text="@{filesRoot}"
+ android:visibility="@{filesRoot.isEmpty ? View.GONE : View.VISIBLE}"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/banner_logo"
+ tools:visibility="gone" />
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/files_list"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_marginTop="16dp"
+ android:orientation="horizontal"
+ android:visibility="@{filesRoot.isEmpty ? View.GONE : View.VISIBLE}"
+ app:configurationHandler="@{filesRowConfigurationHandler}"
+ app:items="@{files}"
+ app:layout="@{@layout/tv_file_list_item}"
+ app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
+ app:layout_constraintBottom_toTopOf="@id/import_button"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/files_root_label"
+ app:spanCount="5"
+ tools:itemCount="10"
+ tools:listitem="@layout/tv_file_list_item"
+ tools:visibility="gone" />
+
+ <TextView
style="@style/TextAppearance.MaterialComponents.Headline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/tv_add_tunnel_get_started"
- android:visibility="@{tunnels.isEmpty() ? View.VISIBLE : View.GONE}"
+ android:visibility="@{(filesRoot.isEmpty &amp;&amp; tunnels.isEmpty) ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toTopOf="@id/delete_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -87,7 +133,7 @@
android:layout_margin="16dp"
android:minWidth="0dp"
android:visibility="@{isDeleting ? View.GONE : View.VISIBLE}"
- app:icon="@drawable/ic_action_add_white"
+ app:icon="@{filesRoot.isEmpty ? @drawable/ic_action_add_white : @drawable/ic_arrow_back}"
app:iconPadding="0dp"
app:iconTint="?attr/colorOnPrimary"
app:layout_constraintBottom_toBottomOf="parent"
@@ -100,7 +146,7 @@
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:minWidth="0dp"
- android:visibility="@{tunnels.isEmpty &amp;&amp; !isDeleting ? View.GONE : View.VISIBLE}"
+ android:visibility="@{((tunnels.isEmpty &amp;&amp; !isDeleting) || !filesRoot.isEmpty) ? View.GONE : View.VISIBLE}"
app:icon="@{isDeleting ? @drawable/ic_arrow_back : @drawable/ic_action_delete}"
app:iconPadding="0dp"
app:iconTint="?attr/colorOnPrimary"
diff --git a/ui/src/main/res/layout/tv_file_list_item.xml b/ui/src/main/res/layout/tv_file_list_item.xml
new file mode 100644
index 00000000..270a2531
--- /dev/null
+++ b/ui/src/main/res/layout/tv_file_list_item.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <data>
+
+ <import type="com.wireguard.android.activity.TvMainActivity.KeyedFile" />
+
+ <variable
+ name="key"
+ type="String" />
+
+ <variable
+ name="item"
+ type="KeyedFile" />
+ </data>
+
+ <com.google.android.material.card.MaterialCardView
+ android:layout_width="320dp"
+ android:layout_height="50dp"
+ android:layout_margin="8dp"
+ android:layout_marginTop="4dp"
+ android:layout_marginBottom="0dp"
+ android:backgroundTint="@color/tv_card_background"
+ android:checkable="true"
+ android:focusable="true"
+ app:contentPadding="8dp">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <com.google.android.material.textview.MaterialTextView
+ style="@style/TextAppearance.MaterialComponents.Headline5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@{key}"
+ android:textColor="?attr/colorOnPrimary"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </com.google.android.material.card.MaterialCardView>
+
+</layout>
diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml
index f539b0ba..000b993c 100644
--- a/ui/src/main/res/values/strings.xml
+++ b/ui/src/main/res/values/strings.xml
@@ -102,7 +102,7 @@
<string name="dark_theme_title">Use dark theme</string>
<string name="delete">Delete</string>
<string name="tv_delete">Select tunnel to delete</string>
- <string name="tv_error">Your TV does not have a file picker</string>
+ <string name="tv_select_a_storage_drive">Select a storage drive</string>
<string name="tv_add_tunnel_get_started">Add a tunnel to get started</string>
<string name="disable_config_export_title">Disable config exporting</string>
<string name="disable_config_export_description">Disabling config exporting makes private keys less accessible</string>