implement TextView.setCompoundDrawables()

This adds an additional GtkBox for every TextView
This commit is contained in:
Julian Winkler
2024-03-30 11:04:21 +01:00
parent 849701c5c4
commit ae58d2b319
7 changed files with 84 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ package android.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
public class Button extends TextView {
@@ -41,4 +42,7 @@ public class Button extends TextView {
native_setOnClickListener(widget, l);
}
@Override
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {}
}

View File

@@ -1,6 +1,7 @@
package android.widget;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.TextWatcher;
@@ -46,4 +47,7 @@ public class EditText extends TextView {
public void setOnEditorActionListener(OnEditorActionListener l) {
native_setOnEditorActionListener(widget, l);
}
@Override
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {}
}

View File

@@ -67,16 +67,12 @@ public class TextView extends View {
protected native long native_constructor(Context context, AttributeSet attrs);
public void setText(CharSequence text) {
if (text == null) {
native_setText("NULL");
return;
}
native_setText(text.toString());
native_setText(text != null ? text.toString() : null);
if (text instanceof android.text.Spanned)
native_set_markup(1);
requestLayout();
if (!isLayoutRequested())
requestLayout();
}
public void setText(int resId) {
@@ -158,7 +154,15 @@ public class TextView extends View {
public void setCompoundDrawablePadding(int pad) {}
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {}
protected native void native_setCompoundDrawables(long widget, long left, long top, long right, long bottom);
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {
native_setCompoundDrawables(widget,
left != null ? left.paintable : 0,
top != null ? top.paintable : 0,
right != null ? right.paintable : 0,
bottom != null ? bottom.paintable : 0);
}
public void setAllCaps(boolean allCaps) {}
@@ -178,7 +182,9 @@ public class TextView extends View {
public int getMaxLines() {return -1;}
public void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom) {}
public void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom) {
setCompoundDrawables(start, top, end, bottom);
}
public int getLineCount() {return 1;}