attempt to work around bugs in Chinese ROMs

This commit is contained in:
Daniel Gultsch 2018-11-21 12:08:41 +01:00
parent 0381fe3c06
commit f8fbb36a98
3 changed files with 52 additions and 3 deletions

View file

@ -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);
}
}

View file

@ -38,7 +38,7 @@
app:passwordToggleEnabled="true" app:passwordToggleEnabled="true"
app:passwordToggleTint="?android:textColorSecondary"> app:passwordToggleTint="?android:textColorSecondary">
<android.support.design.widget.TextInputEditText <eu.siacs.conversations.ui.widget.TextInputEditText
android:id="@+id/current_password" android:id="@+id/current_password"
style="@style/Widget.Conversations.EditText" style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -58,7 +58,7 @@
app:passwordToggleEnabled="true" app:passwordToggleEnabled="true"
app:passwordToggleTint="?android:textColorSecondary"> app:passwordToggleTint="?android:textColorSecondary">
<android.support.design.widget.TextInputEditText <eu.siacs.conversations.ui.widget.TextInputEditText
android:id="@+id/new_password" android:id="@+id/new_password"
style="@style/Widget.Conversations.EditText" style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -82,7 +82,7 @@
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint" app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"> app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">
<android.support.design.widget.TextInputEditText <eu.siacs.conversations.ui.widget.TextInputEditText
android:id="@+id/account_password" android:id="@+id/account_password"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"