From 77b5937fbb8490b368acac85f434113a175f1bba Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 6 Apr 2020 18:09:03 -0600 Subject: ui: add missing fields to detail view Signed-off-by: Jason A. Donenfeld --- .../android/databinding/BindingAdapters.kt | 13 +++- ui/src/main/res/layout/tunnel_detail_fragment.xml | 80 +++++++++++++++++++++- ui/src/main/res/layout/tunnel_detail_peer.xml | 66 +++++++++++++++++- ui/src/main/res/values-de/strings.xml | 1 - ui/src/main/res/values-hi/strings.xml | 1 - ui/src/main/res/values-id/strings.xml | 1 - ui/src/main/res/values-it/strings.xml | 1 - ui/src/main/res/values-ja/strings.xml | 1 - ui/src/main/res/values-ru/strings.xml | 1 - ui/src/main/res/values-sl/strings.xml | 1 - ui/src/main/res/values-zh-rCN/strings.xml | 1 - ui/src/main/res/values/strings.xml | 6 +- 12 files changed, 157 insertions(+), 16 deletions(-) (limited to 'ui/src/main') diff --git a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt index 05d69aec..fe828004 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt +++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt @@ -26,6 +26,7 @@ import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener import com.wireguard.config.Attribute import com.wireguard.config.InetNetwork import java9.util.Optional +import java.net.InetAddress /** * Static methods for use by generated code in the Android data binding library. @@ -135,13 +136,19 @@ object BindingAdapters { @JvmStatic @BindingAdapter("android:text") - fun setText(view: TextView, text: Optional<*>) { - view.text = text.map { it.toString() }.orElse("") + fun setOptionalText(view: TextView, text: Optional<*>?) { + view.text = text?.map { it.toString() }?.orElse("") ?: "" } @JvmStatic @BindingAdapter("android:text") - fun setText(view: TextView, networks: Iterable?) { + fun setInetNetworkSetText(view: TextView, networks: Iterable?) { view.text = if (networks != null) Attribute.join(networks) else "" } + + @JvmStatic + @BindingAdapter("android:text") + fun setInetAddressSetText(view: TextView, addresses: Iterable?) { + view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else "" + } } diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index 0bb3558c..9fbd4722 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -28,6 +28,7 @@ android:background="?attr/colorBackground" android:clickable="true" android:focusable="true"> + @@ -81,6 +82,8 @@ style="@style/DetailText" android:layout_width="match_parent" android:layout_height="wrap_content" + android:contentDescription="@string/name" + android:onClick="@{ClipboardUtils::copyTextView}" android:text="@{tunnel.name}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/interface_name_label" @@ -101,7 +104,7 @@ style="@style/DetailText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:contentDescription="@string/public_key_description" + android:contentDescription="@string/public_key" android:ellipsize="end" android:maxLines="1" android:onClick="@{ClipboardUtils::copyTextView}" @@ -118,6 +121,7 @@ android:layout_marginTop="8dp" android:labelFor="@+id/addresses_text" android:text="@string/addresses" + android:visibility="@{config.interface.addresses.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/public_key_text" /> @@ -127,10 +131,84 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:contentDescription="@string/addresses" + android:onClick="@{ClipboardUtils::copyTextView}" android:text="@{config.interface.addresses}" + android:visibility="@{config.interface.addresses.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/addresses_label" tools:text="fc00:bbbb:bbbb:bb11::3:368b/128" /> + + + + + + + + + + + + diff --git a/ui/src/main/res/layout/tunnel_detail_peer.xml b/ui/src/main/res/layout/tunnel_detail_peer.xml index a73716d7..d0de329b 100644 --- a/ui/src/main/res/layout/tunnel_detail_peer.xml +++ b/ui/src/main/res/layout/tunnel_detail_peer.xml @@ -45,7 +45,7 @@ style="@style/DetailText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:contentDescription="@string/public_key_description" + android:contentDescription="@string/public_key" android:ellipsize="end" android:maxLines="1" android:onClick="@{ClipboardUtils::copyTextView}" @@ -55,6 +55,32 @@ app:layout_constraintTop_toBottomOf="@+id/public_key_label" tools:text="wOs2eguFEohqIZxlSJ1CAT9584tc6ejj9hfGFsoBVkA=" /> + + + + + app:layout_constraintTop_toBottomOf="@+id/pre_shared_key_text" /> @@ -82,6 +112,7 @@ android:layout_marginTop="8dp" android:labelFor="@+id/endpoint_text" android:text="@string/endpoint" + android:visibility="@{item.endpoint.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/allowed_ips_text" /> @@ -90,11 +121,38 @@ style="@style/DetailText" android:layout_width="match_parent" android:layout_height="wrap_content" + android:contentDescription="@string/endpoint" + android:onClick="@{ClipboardUtils::copyTextView}" android:text="@{item.endpoint}" + android:visibility="@{item.endpoint.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/endpoint_label" tools:text="192.168.0.1:51820" /> + + + + Vorab geteilter Schlüssel Privater Schlüssel Öffentlicher Schlüssel - Öffentlicher Schlüssel Tipp: Mit `qrencode -t ansiutf8 < tunnel.conf` generieren. Wird aktivierte Tunnel beim Systemstart nicht automatisch starten Wird aktivierte Tunnel beim Systemstart automatisch wieder starten diff --git a/ui/src/main/res/values-hi/strings.xml b/ui/src/main/res/values-hi/strings.xml index 19d970b8..fa65c119 100644 --- a/ui/src/main/res/values-hi/strings.xml +++ b/ui/src/main/res/values-hi/strings.xml @@ -120,7 +120,6 @@ प्री-शेयर्ड कीस निजी कीस सार्वजनिक कीस - सार्वजनिक कीस सुझाव: `qrencode -t ansiutf8 < tunnel.conf` के साथ उत्पन्न करो बूट पर सक्षम टनलस को लाएगा बूट पर सक्षम टनलस को नहीं लाएगा diff --git a/ui/src/main/res/values-id/strings.xml b/ui/src/main/res/values-id/strings.xml index ca3ba316..866e7ed4 100644 --- a/ui/src/main/res/values-id/strings.xml +++ b/ui/src/main/res/values-id/strings.xml @@ -128,7 +128,6 @@ Kunci Pra-bersama Kunci pribadi Kunci publik - Kunci publik Tips: generate dengan `qrencode -t ansiutf8 < tunnel.conf`. Tunel yang diaktifkan tidak akan ditampilkan saat boot Tunel yang diaktifkan akan dimunculkan saat boot diff --git a/ui/src/main/res/values-it/strings.xml b/ui/src/main/res/values-it/strings.xml index 0abd3c3a..61e6186a 100644 --- a/ui/src/main/res/values-it/strings.xml +++ b/ui/src/main/res/values-it/strings.xml @@ -134,7 +134,6 @@ Chiave condivisa (PSK) Chiave privata Chiave pubblica - La chiave pubblica Suggerimento: genera con `qrencode -t ansiutf8 < tunnel.conf`. Non attiverà i tunnel configurati all\'avvio Attiverà i tunnel configurati all\'avvio diff --git a/ui/src/main/res/values-ja/strings.xml b/ui/src/main/res/values-ja/strings.xml index f8054ab2..fff388f7 100644 --- a/ui/src/main/res/values-ja/strings.xml +++ b/ui/src/main/res/values-ja/strings.xml @@ -128,7 +128,6 @@ 事前共有鍵 秘密鍵 公開鍵 - 公開鍵 Tip: `qrencode -t ansiutf8 < tunnel.conf` で生成できます 起動時にトンネルを有効化しない 起動時に、前回有効だったトンネルを有効化する diff --git a/ui/src/main/res/values-ru/strings.xml b/ui/src/main/res/values-ru/strings.xml index 5f9927a0..dfa0904e 100644 --- a/ui/src/main/res/values-ru/strings.xml +++ b/ui/src/main/res/values-ru/strings.xml @@ -146,7 +146,6 @@ Общий ключ Приватный ключ Публичный ключ - Публичный ключ Совет: генерировать с `qrencode -t ansiutf8 < tunnel.conf`. Не поднимать ранее выбранные туннели при загрузке Поднимать ранее выбранные туннели при загрузке diff --git a/ui/src/main/res/values-sl/strings.xml b/ui/src/main/res/values-sl/strings.xml index 4aa1dce6..7befe6ba 100644 --- a/ui/src/main/res/values-sl/strings.xml +++ b/ui/src/main/res/values-sl/strings.xml @@ -146,7 +146,6 @@ Vnaprej deljen ključ Privatni ključ Javni ključ - Javni ključ Namig: Generirajte z `qrencode -t ansiutf8 < tunnel.conf`. Pri vklopu telefona, aktivirani tuneli ne bodo avtimatično vzpostavljeni Pri vklopu telefona bodo aktivirani tuneli avtimatično vzpostavljeni diff --git a/ui/src/main/res/values-zh-rCN/strings.xml b/ui/src/main/res/values-zh-rCN/strings.xml index ca4e8fcd..91753ce4 100644 --- a/ui/src/main/res/values-zh-rCN/strings.xml +++ b/ui/src/main/res/values-zh-rCN/strings.xml @@ -128,7 +128,6 @@ 预共享密钥 私钥 公钥 - 公钥 提示:使用命令 `qrencode -t ansiutf8 < tunnel.conf` 生成二维码 未启用 设备启动时自动开启上次使用的隧道 diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml index e47bd9b8..41bb31ac 100644 --- a/ui/src/main/res/values/strings.xml +++ b/ui/src/main/res/values/strings.xml @@ -39,6 +39,10 @@ Exclude %d app Exclude %d apps + + every second + every %d seconds + Use all apps Add peer Addresses @@ -148,9 +152,9 @@ control WireGuard tunnels Persistent keepalive Pre-shared key + enabled Private key Public key - Public key Tip: generate with `qrencode -t ansiutf8 < tunnel.conf`. Will not bring up enabled tunnels at boot Will bring up enabled tunnels at boot -- cgit v1.2.3