aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-03-31 16:42:07 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-03-31 16:42:34 -0600
commited67cf5e6fff13dd68d3ba99903d0c8b707494bb (patch)
tree61a0fb68dd44f78e79ba4bda26088ad2af2e8d69
parentui: disable LongLogTag lint (diff)
downloadwireguard-android-jd/nomonkey.tar.xz
wireguard-android-jd/nomonkey.zip
TunnelEditor: get rid of monkeyed trick and use app:placeholderTextjd/nomonkey
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--build.gradle2
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/MonkeyedTextInputEditText.kt30
-rw-r--r--ui/src/main/res/layout/tunnel_editor_fragment.xml12
-rw-r--r--ui/src/main/res/layout/tunnel_editor_peer.xml8
4 files changed, 11 insertions, 41 deletions
diff --git a/build.gradle b/build.gradle
index e1bbdf79..17019864 100644
--- a/build.gradle
+++ b/build.gradle
@@ -23,7 +23,7 @@ buildscript {
jsr305Version = '3.0.2'
junitVersion = '4.13'
kotlinVersion = '1.3.71'
- materialComponentsVersion = '1.1.0'
+ materialComponentsVersion = '1.2.0-alpha05'
mavenPluginVersion = '2.1'
preferenceVersion = '1.1.0'
streamsupportVersion = '1.7.2'
diff --git a/ui/src/main/java/com/wireguard/android/widget/MonkeyedTextInputEditText.kt b/ui/src/main/java/com/wireguard/android/widget/MonkeyedTextInputEditText.kt
deleted file mode 100644
index 97746c09..00000000
--- a/ui/src/main/java/com/wireguard/android/widget/MonkeyedTextInputEditText.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright © 2020 WireGuard LLC. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.wireguard.android.widget
-
-import android.content.Context
-import android.text.Editable
-import android.text.SpannableStringBuilder
-import android.util.AttributeSet
-import com.google.android.material.R
-import com.google.android.material.textfield.TextInputEditText
-import com.google.android.material.textfield.TextInputLayout
-
-class MonkeyedTextInputEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = R.attr.editTextStyle) : TextInputEditText(context, attrs, defStyleAttr) {
- @Override
- override fun getText(): Editable? {
- val text = super.getText()
- if (!text.isNullOrEmpty())
- return text
- /* We want this expression in TextInputLayout.java to be true if there's a hint set:
- * final boolean hasText = editText != null && !TextUtils.isEmpty(editText.getText());
- * But for everyone else it should return the real value, so we check the caller.
- */
- if (!hint.isNullOrEmpty() && Thread.currentThread().stackTrace[3].className == TextInputLayout::class.qualifiedName)
- return SpannableStringBuilder(hint)
- return text
- }
-}
diff --git a/ui/src/main/res/layout/tunnel_editor_fragment.xml b/ui/src/main/res/layout/tunnel_editor_fragment.xml
index d5724c11..ed7e614d 100644
--- a/ui/src/main/res/layout/tunnel_editor_fragment.xml
+++ b/ui/src/main/res/layout/tunnel_editor_fragment.xml
@@ -115,18 +115,18 @@
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/public_key"
+ app:placeholderText="@string/hint_generated"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/private_key_text_layout">
- <com.wireguard.android.widget.MonkeyedTextInputEditText
+ <com.google.android.material.textfield.TextInputEditText
android:id="@+id/public_key_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:ellipsize="end"
android:focusable="false"
- android:hint="@string/hint_generated"
android:onClick="@{ClipboardUtils::copyTextView}"
android:singleLine="true"
android:text="@{config.interface.publicKey}" />
@@ -158,15 +158,15 @@
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/listen_port"
+ app:placeholderText="@string/hint_random"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="0.3"
app:layout_constraintStart_toEndOf="@id/addresses_label_layout"
app:layout_constraintTop_toBottomOf="@id/public_key_label_layout">
- <com.wireguard.android.widget.MonkeyedTextInputEditText
+ <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/hint_random"
android:inputType="number"
android:text="@={config.interface.listenPort}"
android:textAlignment="center" />
@@ -199,16 +199,16 @@
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/mtu"
+ app:placeholderText="@string/hint_automatic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="0.3"
app:layout_constraintStart_toEndOf="@id/dns_servers_label_layout"
app:layout_constraintTop_toBottomOf="@id/addresses_label_layout">
- <com.wireguard.android.widget.MonkeyedTextInputEditText
+ <com.google.android.material.textfield.TextInputEditText
android:id="@+id/mtu_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/hint_automatic"
android:inputType="number"
android:text="@={config.interface.mtu}"
android:textAlignment="center" />
diff --git a/ui/src/main/res/layout/tunnel_editor_peer.xml b/ui/src/main/res/layout/tunnel_editor_peer.xml
index f00a6d26..75e3b7e1 100644
--- a/ui/src/main/res/layout/tunnel_editor_peer.xml
+++ b/ui/src/main/res/layout/tunnel_editor_peer.xml
@@ -86,15 +86,15 @@
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/pre_shared_key"
+ app:placeholderText="@string/hint_optional"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/public_key_label_layout">
- <com.wireguard.android.widget.MonkeyedTextInputEditText
+ <com.google.android.material.textfield.TextInputEditText
android:id="@+id/pre_shared_key_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/hint_optional"
android:inputType="textNoSuggestions|textPassword"
android:onClick="@{fragment::onKeyClick}"
android:text="@={item.preSharedKey}"
@@ -108,15 +108,15 @@
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="@string/persistent_keepalive"
+ app:placeholderText="@string/hint_optional_discouraged"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/pre_shared_key_label_layout">
- <com.wireguard.android.widget.MonkeyedTextInputEditText
+ <com.google.android.material.textfield.TextInputEditText
android:id="@+id/persistent_keepalive_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hint="@string/hint_optional_discouraged"
android:inputType="number"
android:text="@={item.persistentKeepalive}" />
</com.google.android.material.textfield.TextInputLayout>