MonkeyedTextInputEditText: au revoir
Remember to go back to using com.google.android.material when 1.3.0-alpha03 comes out. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
a3726b07bf
commit
d79cdb0d41
@ -15,7 +15,7 @@ buildscript {
|
|||||||
jsr305Version = '3.0.2'
|
jsr305Version = '3.0.2'
|
||||||
junitVersion = '4.13'
|
junitVersion = '4.13'
|
||||||
kotlinVersion = '1.4.10'
|
kotlinVersion = '1.4.10'
|
||||||
materialComponentsVersion = '1.3.0-alpha02'
|
materialComponentsVersion = '22973ff10305397bfc72fed41684175fee8aeefb'
|
||||||
mavenPluginVersion = '2.1'
|
mavenPluginVersion = '2.1'
|
||||||
preferenceVersion = '1.1.1'
|
preferenceVersion = '1.1.1'
|
||||||
zxingEmbeddedVersion = '3.6.0'
|
zxingEmbeddedVersion = '3.6.0'
|
||||||
@ -39,6 +39,7 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ dependencies {
|
|||||||
implementation "androidx.databinding:databinding-runtime:$agpVersion"
|
implementation "androidx.databinding:databinding-runtime:$agpVersion"
|
||||||
implementation "androidx.fragment:fragment-ktx:$fragmentVersion"
|
implementation "androidx.fragment:fragment-ktx:$fragmentVersion"
|
||||||
implementation "androidx.preference:preference-ktx:$preferenceVersion"
|
implementation "androidx.preference:preference-ktx:$preferenceVersion"
|
||||||
implementation "com.google.android.material:material:$materialComponentsVersion"
|
implementation "com.github.material-components:material-components-android:$materialComponentsVersion"
|
||||||
implementation "com.journeyapps:zxing-android-embedded:$zxingEmbeddedVersion"
|
implementation "com.journeyapps:zxing-android-embedded:$zxingEmbeddedVersion"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
|
||||||
|
@ -1,36 +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
|
|
||||||
|
|
||||||
/* Is this no longer necessary?
|
|
||||||
* https://github.com/material-components/material-components-android/pull/1163 was merged via
|
|
||||||
* https://github.com/material-components/material-components-android/commit/22973ff10305397bfc72fed41684175fee8aeefb .
|
|
||||||
* It would seem like we can now set expandedHintEnabled=false
|
|
||||||
* TODO: when a new material-components library comes out, switch to expandedHintEnabled=false.
|
|
||||||
*/
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -111,11 +111,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/public_key"
|
android:hint="@string/public_key"
|
||||||
|
app:expandedHintEnabled="false"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/private_key_text_layout">
|
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:id="@+id/public_key_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -154,12 +155,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/listen_port"
|
android:hint="@string/listen_port"
|
||||||
|
app:expandedHintEnabled="false"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_weight="0.3"
|
app:layout_constraintHorizontal_weight="0.3"
|
||||||
app:layout_constraintStart_toEndOf="@id/addresses_label_layout"
|
app:layout_constraintStart_toEndOf="@id/addresses_label_layout"
|
||||||
app:layout_constraintTop_toBottomOf="@id/public_key_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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/hint_random"
|
android:hint="@string/hint_random"
|
||||||
@ -195,12 +197,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/mtu"
|
android:hint="@string/mtu"
|
||||||
|
app:expandedHintEnabled="false"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_weight="0.3"
|
app:layout_constraintHorizontal_weight="0.3"
|
||||||
app:layout_constraintStart_toEndOf="@id/dns_servers_label_layout"
|
app:layout_constraintStart_toEndOf="@id/dns_servers_label_layout"
|
||||||
app:layout_constraintTop_toBottomOf="@id/addresses_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:id="@+id/mtu_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -84,11 +84,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/pre_shared_key"
|
android:hint="@string/pre_shared_key"
|
||||||
|
app:expandedHintEnabled="false"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/public_key_label_layout">
|
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:id="@+id/pre_shared_key_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -106,18 +107,19 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:hint="@string/persistent_keepalive"
|
android:hint="@string/persistent_keepalive"
|
||||||
app:suffixText="@{@plurals/persistent_keepalive_seconds_suffix(BindingAdapters.tryParseInt(item.persistentKeepalive))}"
|
app:expandedHintEnabled="false"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/pre_shared_key_label_layout">
|
app:layout_constraintTop_toBottomOf="@id/pre_shared_key_label_layout"
|
||||||
|
app:suffixText="@{@plurals/persistent_keepalive_seconds_suffix(BindingAdapters.tryParseInt(item.persistentKeepalive))}">
|
||||||
|
|
||||||
<com.wireguard.android.widget.MonkeyedTextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/persistent_keepalive_text"
|
android:id="@+id/persistent_keepalive_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/hint_optional_discouraged"
|
android:hint="@string/hint_optional_discouraged"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:text="@={item.persistentKeepalive}"/>
|
android:text="@={item.persistentKeepalive}" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user