aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/res
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-22 16:41:08 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-22 23:53:27 +0200
commit0ad3781ae5956aa2dbf217edf48c5f8445a92db8 (patch)
tree7bbf4029e44a73b3a6efe209ed9d5f3b4484c159 /ui/src/main/res
parentStatistics: only do one hash lookup (diff)
downloadwireguard-android-0ad3781ae5956aa2dbf217edf48c5f8445a92db8.tar.xz
wireguard-android-0ad3781ae5956aa2dbf217edf48c5f8445a92db8.zip
tv: initial draft of Android TV support
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/res')
-rw-r--r--ui/src/main/res/layout/tv_activity.xml31
-rw-r--r--ui/src/main/res/layout/tv_tunnel_list_item.xml73
2 files changed, 104 insertions, 0 deletions
diff --git a/ui/src/main/res/layout/tv_activity.xml b/ui/src/main/res/layout/tv_activity.xml
new file mode 100644
index 00000000..03caa311
--- /dev/null
+++ b/ui/src/main/res/layout/tv_activity.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/tunnel_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="16dp"
+ android:orientation="horizontal"
+ app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
+ app:layout_constraintBottom_toTopOf="@id/import_button"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:itemCount="10"
+ tools:listitem="@layout/tv_tunnel_list_item" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/import_button"
+ style="?attr/textAppearanceButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:text="@string/create_from_file"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/ui/src/main/res/layout/tv_tunnel_list_item.xml b/ui/src/main/res/layout/tv_tunnel_list_item.xml
new file mode 100644
index 00000000..a48b977b
--- /dev/null
+++ b/ui/src/main/res/layout/tv_tunnel_list_item.xml
@@ -0,0 +1,73 @@
+<?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"
+ xmlns:tools="http://schemas.android.com/tools">
+
+ <data>
+
+ <import type="com.wireguard.android.model.ObservableTunnel" />
+
+ <import type="com.wireguard.android.backend.Tunnel.State" />
+
+ <variable
+ name="collection"
+ type="com.wireguard.android.databinding.ObservableKeyedArrayList&lt;String, ObservableTunnel&gt;" />
+
+ <variable
+ name="key"
+ type="String" />
+
+ <variable
+ name="item"
+ type="com.wireguard.android.model.ObservableTunnel" />
+
+ <!-- Unused on TV but we retain this so the existing Adapter and ViewHolder can be reused -->
+ <variable
+ name="fragment"
+ type="com.wireguard.android.fragment.TunnelListFragment" />
+ </data>
+
+ <com.google.android.material.card.MaterialCardView
+ android:layout_width="300dp"
+ android:layout_height="150dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ app:cardCornerRadius="12dp">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="16dp">
+
+ <com.google.android.material.textview.MaterialTextView
+ android:id="@+id/tunnel_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@{item.name}"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:text="@sample/interface_names.json/names/names/name" />
+
+ <com.wireguard.android.widget.ToggleSwitch
+ android:id="@+id/tunnel_toggle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:checked="@{item.state == State.UP}"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:checked="@sample/interface_names.json/names/checked/checked" />
+
+ <!-- TODO: wire in updates here -->
+ <com.google.android.material.textview.MaterialTextView
+ android:id="@+id/tunnel_transfer"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ tools:text="rx: 200 MB, tx: 100 MB" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </com.google.android.material.card.MaterialCardView>
+
+</layout>