aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-23 14:49:58 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-23 14:49:58 +0100
commite23b95303f731431ef079995375aabe9a06fa93f (patch)
tree24c90a0f2bafa41dfe05e01e2544efd0a1290c4c /src
parent1ece2e3350a5f11abf07269d7a609aa6d85f631c (diff)
attempt to work around bugs in Chinese ROMs
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/widget/TextInputEditText.java47
-rw-r--r--src/main/res/layout/activity_change_password.xml4
-rw-r--r--src/main/res/layout/activity_edit_account.xml2
3 files changed, 50 insertions, 3 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
diff --git a/src/main/res/layout/activity_change_password.xml b/src/main/res/layout/activity_change_password.xml
index 6bd7f2d0d..4ff57e22b 100644
--- a/src/main/res/layout/activity_change_password.xml
+++ b/src/main/res/layout/activity_change_password.xml
@@ -39,7 +39,7 @@
app:passwordToggleEnabled="true"
app:passwordToggleTint="?android:textColorSecondary">
- <android.support.design.widget.TextInputEditText
+ <de.pixart.messenger.ui.widget.TextInputEditText.widget.TextInputEditText
android:id="@+id/current_password"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"
@@ -59,7 +59,7 @@
app:passwordToggleEnabled="true"
app:passwordToggleTint="?android:textColorSecondary">
- <android.support.design.widget.TextInputEditText
+ <de.pixart.messenger.ui.widget.TextInputEditText
android:id="@+id/new_password"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"
diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml
index 73ae622be..011f89e5b 100644
--- a/src/main/res/layout/activity_edit_account.xml
+++ b/src/main/res/layout/activity_edit_account.xml
@@ -91,7 +91,7 @@
app:passwordToggleEnabled="true"
app:passwordToggleTint="?android:textColorSecondary">
- <android.support.design.widget.TextInputEditText
+ <de.pixart.messenger.ui.widget.TextInputEditText
android:id="@+id/account_password"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"