From d79cdb0d41f05f53c13a0b247f54c28f42609e2f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 15 Sep 2020 13:29:53 +0200 Subject: 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 --- ui/build.gradle | 2 +- .../android/widget/MonkeyedTextInputEditText.kt | 36 ---------------------- ui/src/main/res/layout/tunnel_editor_fragment.xml | 9 ++++-- ui/src/main/res/layout/tunnel_editor_peer.xml | 12 +++++--- 4 files changed, 14 insertions(+), 45 deletions(-) delete mode 100644 ui/src/main/java/com/wireguard/android/widget/MonkeyedTextInputEditText.kt (limited to 'ui') diff --git a/ui/build.gradle b/ui/build.gradle index 0f258dc6..936a95d8 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -66,7 +66,7 @@ dependencies { implementation "androidx.databinding:databinding-runtime:$agpVersion" implementation "androidx.fragment:fragment-ktx:$fragmentVersion" 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 "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" 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 f9b81bea..00000000 --- a/ui/src/main/java/com/wireguard/android/widget/MonkeyedTextInputEditText.kt +++ /dev/null @@ -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 - } -} diff --git a/ui/src/main/res/layout/tunnel_editor_fragment.xml b/ui/src/main/res/layout/tunnel_editor_fragment.xml index dffc9d97..8b2ff2ec 100644 --- a/ui/src/main/res/layout/tunnel_editor_fragment.xml +++ b/ui/src/main/res/layout/tunnel_editor_fragment.xml @@ -111,11 +111,12 @@ android:layout_height="wrap_content" android:layout_margin="4dp" android:hint="@string/public_key" + app:expandedHintEnabled="false" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/private_key_text_layout"> - - - - + app:layout_constraintTop_toBottomOf="@id/pre_shared_key_label_layout" + app:suffixText="@{@plurals/persistent_keepalive_seconds_suffix(BindingAdapters.tryParseInt(item.persistentKeepalive))}"> - + android:text="@={item.persistentKeepalive}" />