From ad22cdd2ca25c20418e2a15f1a7a5fda990896d1 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 22 Jun 2022 09:39:15 -0500 Subject: [PATCH] Use more features of the TextInputLayout --- .../res/layout/command_checkbox_field.xml | 3 ++- .../res/layout/command_radio_edit_field.xml | 2 +- .../res/layout/command_result_field.xml | 2 +- .../res/layout/command_spinner_field.xml | 2 +- .../res/layout/command_text_field.xml | 22 +++++-------------- .../conversations/entities/Conversation.java | 15 ++++++++----- 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/cheogram/res/layout/command_checkbox_field.xml b/src/cheogram/res/layout/command_checkbox_field.xml index 520a05d1922894fe25befa2794faaf66011e6a29..d27b6af383d562764876b07584550a30b2b3cb45 100644 --- a/src/cheogram/res/layout/command_checkbox_field.xml +++ b/src/cheogram/res/layout/command_checkbox_field.xml @@ -31,7 +31,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="16dp" - android:textAppearance="@style/TextAppearance.Conversations.Status" /> + android:textAppearance="@style/TextAppearance.Conversations.Status" + android:textColor="?android:textColorSecondary" /> diff --git a/src/cheogram/res/layout/command_radio_edit_field.xml b/src/cheogram/res/layout/command_radio_edit_field.xml index 361528e081ee474335fa57965c2add5a0125531c..b1dd8ede886a2ff6a37c6b1d3748c391f35e08f1 100644 --- a/src/cheogram/res/layout/command_radio_edit_field.xml +++ b/src/cheogram/res/layout/command_radio_edit_field.xml @@ -47,7 +47,7 @@ android:paddingLeft="16dp" android:paddingRight="8dp" android:textAppearance="@style/TextAppearance.Conversations.Status" - android:textColor="?attr/edit_text_color" /> + android:textColor="?android:textColorSecondary" /> diff --git a/src/cheogram/res/layout/command_result_field.xml b/src/cheogram/res/layout/command_result_field.xml index b1ede046dc3372cac5f208a6b7822916058aa18b..be0d879f1756c2a3186adb1f78259cbfbebd2d3f 100644 --- a/src/cheogram/res/layout/command_result_field.xml +++ b/src/cheogram/res/layout/command_result_field.xml @@ -36,7 +36,7 @@ android:paddingLeft="8dp" android:paddingRight="8dp" android:textAppearance="@style/TextAppearance.Conversations.Status" - android:textColor="?attr/edit_text_color" /> + android:textColor="?android:textColorSecondary" /> diff --git a/src/cheogram/res/layout/command_spinner_field.xml b/src/cheogram/res/layout/command_spinner_field.xml index 4654307c254b9f79026e06ca16d7ac9ae838b6f4..1909173af4c2267f1cc34c6451197ed8c4669330 100644 --- a/src/cheogram/res/layout/command_spinner_field.xml +++ b/src/cheogram/res/layout/command_spinner_field.xml @@ -32,7 +32,7 @@ android:paddingLeft="16dp" android:paddingRight="8dp" android:textAppearance="@style/TextAppearance.Conversations.Status" - android:textColor="?attr/edit_text_color" /> + android:textColor="?android:textColorSecondary" /> diff --git a/src/cheogram/res/layout/command_text_field.xml b/src/cheogram/res/layout/command_text_field.xml index db02a5ad670eac98b08cf99aa96be1257285e739..13af8548deba73b68e50412e677027a4a91df801 100644 --- a/src/cheogram/res/layout/command_text_field.xml +++ b/src/cheogram/res/layout/command_text_field.xml @@ -1,11 +1,6 @@ - + app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint" + app:helperTextTextAppearance="@style/TextAppearance.Conversations.Status" + app:helperTextTextColor="?android:textColorSecondary"> - - - - diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index deeb93cc11f7a77b549374a44ca05b53be50ba54..8f6ad8306dd6581a42df745a39095411ca134b81 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -37,6 +37,7 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.viewpager.widget.ViewPager; import com.google.android.material.tabs.TabLayout; +import com.google.android.material.textfield.TextInputLayout; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Lists; @@ -1342,8 +1343,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl abstract public void bind(Element el); - protected void setupInputType(Element field, TextView textinput) { + protected void setupInputType(Element field, TextView textinput, TextInputLayout layout) { int flags = 0; + if (layout != null) layout.setEndIconMode(TextInputLayout.END_ICON_NONE); textinput.setInputType(flags | InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT); String type = field.getAttribute("type"); @@ -1360,6 +1362,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl if (type.equals("text-private")) { textinput.setInputType(flags | InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + if (layout != null) layout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE); } } @@ -1576,7 +1579,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl Element validate = field.findChild("validate", "http://jabber.org/protocol/xdata-validate"); binding.open.setVisibility((validate != null && validate.findChild("open", "http://jabber.org/protocol/xdata-validate") != null) ? View.VISIBLE : View.GONE); binding.open.setText(mValue.getContent()); - setupInputType(field, binding.open); + setupInputType(field, binding.open, null); options.clear(); List