From f8fbb36a9894f0e9cddbb2a8532c4a718a9b7196 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 21 Nov 2018 12:08:41 +0100 Subject: [PATCH] attempt to work around bugs in Chinese ROMs --- .../ui/widget/TextInputEditText.java | 49 +++++++++++++++++++ .../res/layout/activity_change_password.xml | 4 +- src/main/res/layout/activity_edit_account.xml | 2 +- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/main/java/eu/siacs/conversations/ui/widget/TextInputEditText.java diff --git a/src/main/java/eu/siacs/conversations/ui/widget/TextInputEditText.java b/src/main/java/eu/siacs/conversations/ui/widget/TextInputEditText.java new file mode 100644 index 000000000..747e59916 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/ui/widget/TextInputEditText.java @@ -0,0 +1,49 @@ +package eu.siacs.conversations.ui.widget; + + +import android.content.Context; +import android.os.Build; +import android.util.AttributeSet; +import android.widget.TextView; + +import java.lang.reflect.Field; + +/** + * A wrapper class to fix some weird fuck ups on Meizu devices + * credit goes to the people in this thread https://github.com/android-in-china/Compatibility/issues/11 + */ +public class TextInputEditText extends android.support.design.widget.TextInputEditText { + + public TextInputEditText(Context context) { + super(context); + } + + public TextInputEditText(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public TextInputEditText(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + public CharSequence getHint() { + String manufacturer = Build.MANUFACTURER.toUpperCase(); + if (!manufacturer.contains("MEIZU") || Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + return super.getHint(); + }else{ + try { + return getSuperHintHack(); + }catch (Exception e){ + return super.getHint(); + } + } + } + + private CharSequence getSuperHintHack() throws NoSuchFieldException, IllegalAccessException { + Field hintField = TextView.class.getDeclaredField("mHint"); + hintField.setAccessible(true); + return (CharSequence) hintField.get(this); + } +} + diff --git a/src/main/res/layout/activity_change_password.xml b/src/main/res/layout/activity_change_password.xml index b0e3462bf..03d575f98 100644 --- a/src/main/res/layout/activity_change_password.xml +++ b/src/main/res/layout/activity_change_password.xml @@ -38,7 +38,7 @@ app:passwordToggleEnabled="true" app:passwordToggleTint="?android:textColorSecondary"> - - -