diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:49:58 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-11-23 14:49:58 +0100 |
commit | e23b95303f731431ef079995375aabe9a06fa93f (patch) | |
tree | 24c90a0f2bafa41dfe05e01e2544efd0a1290c4c /src/main/java/de | |
parent | 1ece2e3350a5f11abf07269d7a609aa6d85f631c (diff) |
attempt to work around bugs in Chinese ROMs
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/widget/TextInputEditText.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/widget/TextInputEditText.java b/src/main/java/de/pixart/messenger/ui/widget/TextInputEditText.java new file mode 100644 index 000000000..51ad578df --- /dev/null +++ b/src/main/java/de/pixart/messenger/ui/widget/TextInputEditText.java @@ -0,0 +1,47 @@ +package de.pixart.messenger.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); + } +}
\ No newline at end of file |