Quicksy: fix drawables not being styled in enter phone number screen

This commit is contained in:
Daniel Gultsch 2021-09-29 10:42:26 +02:00
parent e791e19265
commit ea9b73c1fe
3 changed files with 15 additions and 9 deletions

View file

@ -14,6 +14,8 @@ import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
@ -126,7 +128,7 @@ public class EnterPhoneNumberActivity extends XmppActivity implements QuickConve
} }
@Override @Override
public void onSaveInstanceState(Bundle savedInstanceState) { public void onSaveInstanceState(@NotNull Bundle savedInstanceState) {
if (this.region != null) { if (this.region != null) {
savedInstanceState.putString("region", this.region); savedInstanceState.putString("region", this.region);
} }

View file

@ -26,6 +26,8 @@ import android.widget.TextView;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import eu.siacs.conversations.ui.util.StyledAttributes;
public class TextDrawable extends Drawable implements TextWatcher { public class TextDrawable extends Drawable implements TextWatcher {
private WeakReference<TextView> ref; private WeakReference<TextView> ref;
private String mText; private String mText;
@ -62,6 +64,7 @@ public class TextDrawable extends Drawable implements TextWatcher {
*/ */
public TextDrawable(TextView tv, String initialText, boolean bindToViewsText, boolean bindToViewsPaint) { public TextDrawable(TextView tv, String initialText, boolean bindToViewsText, boolean bindToViewsPaint) {
this(tv.getPaint(), initialText); this(tv.getPaint(), initialText);
mPaint.setColor(StyledAttributes.getColor(tv.getContext(), android.R.attr.textColorPrimary));
ref = new WeakReference<>(tv); ref = new WeakReference<>(tv);
if (bindToViewsText || bindToViewsPaint) { if (bindToViewsText || bindToViewsPaint) {
if (bindToViewsText) { if (bindToViewsText) {
@ -157,6 +160,10 @@ public class TextDrawable extends Drawable implements TextWatcher {
setBounds(bounds); setBounds(bounds);
} }
public Paint getPaint() {
return mPaint;
}
public void setPaint(Paint paint) { public void setPaint(Paint paint) {
mPaint = new Paint(paint); mPaint = new Paint(paint);
//Since this can change the font used, we need to recalculate bounds. //Since this can change the font used, we need to recalculate bounds.
@ -168,8 +175,8 @@ public class TextDrawable extends Drawable implements TextWatcher {
invalidateSelf(); invalidateSelf();
} }
public Paint getPaint() { public String getText() {
return mPaint; return mText;
} }
public void setText(String text) { public void setText(String text) {
@ -183,10 +190,6 @@ public class TextDrawable extends Drawable implements TextWatcher {
invalidateSelf(); invalidateSelf();
} }
public String getText() {
return mText;
}
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -49,7 +50,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:cursorVisible="false" android:cursorVisible="false"
android:drawableEnd="@drawable/ic_arrow_drop_down_black_18dp" android:drawableEnd="@drawable/ic_arrow_drop_down_black_18dp"
android:drawableRight="@drawable/ic_arrow_drop_down_black_18dp" app:drawableTint="?android:attr/textColorPrimary"
android:focusable="false" android:focusable="false"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:imeOptions="flagNoExtractUi" android:imeOptions="flagNoExtractUi"