2022-10-02 23:06:56 +02:00
|
|
|
package android.widget;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.ColorStateList;
|
|
|
|
import android.content.res.TypedArray;
|
2023-06-22 11:45:46 +02:00
|
|
|
import android.graphics.Typeface;
|
2023-09-01 12:55:04 +02:00
|
|
|
import android.graphics.drawable.Drawable;
|
2023-09-12 23:18:47 +02:00
|
|
|
import android.text.Editable;
|
2022-10-02 23:06:56 +02:00
|
|
|
import android.text.InputFilter;
|
2023-12-29 11:09:37 +01:00
|
|
|
import android.text.Layout;
|
2023-06-22 11:45:46 +02:00
|
|
|
import android.text.TextPaint;
|
2023-08-17 10:46:24 +02:00
|
|
|
import android.text.TextUtils;
|
2022-10-02 23:06:56 +02:00
|
|
|
import android.text.TextWatcher;
|
2023-09-12 23:18:47 +02:00
|
|
|
import android.text.method.KeyListener;
|
2023-09-19 23:22:21 +02:00
|
|
|
import android.text.method.MovementMethod;
|
2023-08-17 10:46:24 +02:00
|
|
|
import android.text.method.TransformationMethod;
|
2023-09-19 23:22:21 +02:00
|
|
|
import android.text.style.URLSpan;
|
2023-06-22 11:45:46 +02:00
|
|
|
import android.util.AttributeSet;
|
2023-08-22 14:41:01 +02:00
|
|
|
import android.view.Gravity;
|
2023-11-08 18:00:31 +01:00
|
|
|
import android.view.KeyEvent;
|
2022-10-02 23:06:56 +02:00
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
public class TextView extends View {
|
|
|
|
public String text;
|
|
|
|
|
2023-07-14 18:02:04 +02:00
|
|
|
public TextView(Context context, AttributeSet attrs) {
|
2023-08-22 14:41:01 +02:00
|
|
|
this(context, attrs, 0);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public TextView(Context context) {
|
2023-08-22 14:41:01 +02:00
|
|
|
this(context, null);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
2023-08-17 10:46:24 +02:00
|
|
|
public TextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
2023-08-22 14:41:01 +02:00
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
|
|
|
|
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.TextView, defStyleAttr, 0);
|
|
|
|
if (a.hasValue(com.android.internal.R.styleable.TextView_text)) {
|
|
|
|
setText(a.getText(com.android.internal.R.styleable.TextView_text));
|
|
|
|
}
|
2023-08-22 18:50:08 +02:00
|
|
|
int ap = a.getResourceId(com.android.internal.R.styleable.TextView_textAppearance, -1);
|
2023-08-22 14:41:01 +02:00
|
|
|
a.recycle();
|
2023-08-22 18:50:08 +02:00
|
|
|
if (ap != -1) {
|
|
|
|
a = context.obtainStyledAttributes(ap, com.android.internal.R.styleable.TextAppearance);
|
|
|
|
if (a.hasValue(com.android.internal.R.styleable.TextAppearance_textSize)) {
|
|
|
|
setTextSize(a.getDimensionPixelSize(com.android.internal.R.styleable.TextAppearance_textSize, 10));
|
|
|
|
}
|
|
|
|
a.recycle();
|
|
|
|
}
|
2023-12-29 11:05:05 +01:00
|
|
|
haveComplexMeasure = true;
|
2023-08-17 10:46:24 +02:00
|
|
|
}
|
|
|
|
|
2023-08-17 12:59:37 +02:00
|
|
|
@Override
|
|
|
|
protected native long native_constructor(Context context, AttributeSet attrs);
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2023-08-22 13:55:56 +02:00
|
|
|
public void setText(CharSequence text) {
|
2023-06-22 11:45:46 +02:00
|
|
|
if (text == null) {
|
2022-10-02 23:06:56 +02:00
|
|
|
native_setText("NULL");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
native_setText(text.toString());
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
if (text instanceof android.text.Spanned)
|
2022-10-02 23:06:56 +02:00
|
|
|
native_set_markup(1);
|
|
|
|
}
|
|
|
|
|
2023-07-14 18:02:04 +02:00
|
|
|
public void setText(int resId) {
|
|
|
|
setText(getContext().getResources().getText(resId));
|
|
|
|
}
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
private native final void native_set_markup(int bool);
|
|
|
|
|
|
|
|
public native final void native_setText(String text);
|
2023-06-22 11:45:46 +02:00
|
|
|
public native void setTextSize(float size);
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2023-09-03 12:57:13 +02:00
|
|
|
public native final void native_setTextColor(int color);
|
|
|
|
public void setTextColor(int color) {
|
|
|
|
native_setTextColor(color);
|
|
|
|
}
|
|
|
|
public void setTextColor(ColorStateList colors) {
|
2023-10-14 11:13:10 +02:00
|
|
|
if (colors != null)
|
|
|
|
setTextColor(colors.getDefaultColor()); // TODO: do this properly
|
2023-09-03 12:57:13 +02:00
|
|
|
}
|
2023-06-22 11:45:46 +02:00
|
|
|
public void setTextSize(int unit, float size) {}
|
|
|
|
public void setTypeface(Typeface tf, int style) {}
|
|
|
|
public void setTypeface(Typeface tf) {}
|
|
|
|
public void setLineSpacing(float add, float mult) {}
|
2022-10-02 23:06:56 +02:00
|
|
|
public final void setLinksClickable(boolean whether) {}
|
|
|
|
|
|
|
|
public void setInputType(int type) {}
|
|
|
|
public void setFilters(InputFilter[] filters) {}
|
|
|
|
public void setCursorVisible(boolean visible) {}
|
|
|
|
public void setImeOptions(int imeOptions) {}
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public final ColorStateList getTextColors() { return new ColorStateList(new int[][] {new int[0]}, new int[1]); }
|
|
|
|
public static ColorStateList getTextColors(Context context, TypedArray attrs) { return new ColorStateList(new int[][] {new int[0]}, new int[1]); }
|
2022-10-02 23:06:56 +02:00
|
|
|
|
|
|
|
public TextPaint getPaint() {
|
|
|
|
return new TextPaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addTextChangedListener(TextWatcher watcher) {}
|
2023-09-01 12:55:04 +02:00
|
|
|
public void removeTextChangedListener(TextWatcher watcher) {}
|
2023-06-22 11:45:46 +02:00
|
|
|
public void setOnEditorActionListener(TextView.OnEditorActionListener l) {}
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2023-08-17 10:46:24 +02:00
|
|
|
public TransformationMethod getTransformationMethod() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHintTextColor(ColorStateList colorStateList) {}
|
|
|
|
public void setLinkTextColor(ColorStateList colorStateList) {}
|
|
|
|
|
|
|
|
public void setSingleLine() {}
|
|
|
|
|
|
|
|
public void setEllipsize(TextUtils.TruncateAt truncateAt) {}
|
|
|
|
|
|
|
|
public void setTextAppearance(Context context, int appearance) {}
|
|
|
|
|
|
|
|
public void setMaxLines(int maxLines) {}
|
|
|
|
|
|
|
|
public void setMinWidth(int minWidth) {}
|
|
|
|
public void setMaxWidth(int maxWidth) {}
|
|
|
|
|
2023-08-22 14:41:01 +02:00
|
|
|
public Typeface getTypeface() {return null;}
|
|
|
|
|
|
|
|
public float getTextSize() {return 10;}
|
|
|
|
|
|
|
|
public int getGravity() {
|
|
|
|
return Gravity.CENTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCompoundPaddingTop() {return 0;}
|
|
|
|
public int getCompoundPaddingBottom() {return 0;}
|
|
|
|
|
2023-09-01 12:55:04 +02:00
|
|
|
public CharSequence getText() {
|
|
|
|
return "FIXME";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCompoundDrawablePadding(int pad) {}
|
|
|
|
|
|
|
|
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {}
|
|
|
|
|
|
|
|
public void setAllCaps(boolean allCaps) {}
|
|
|
|
|
|
|
|
public void setSaveEnabled(boolean enabled) {}
|
|
|
|
|
|
|
|
public final void setAutoLinkMask(int mask) {}
|
|
|
|
|
2023-09-12 23:18:47 +02:00
|
|
|
public void setEditableFactory(Editable.Factory factory) {}
|
|
|
|
|
|
|
|
public KeyListener getKeyListener() {return null;}
|
|
|
|
|
|
|
|
public int getInputType() {return 0;}
|
|
|
|
|
|
|
|
public final void setTransformationMethod(TransformationMethod method) {}
|
|
|
|
|
|
|
|
public InputFilter[] getFilters() {return new InputFilter[0];}
|
|
|
|
|
|
|
|
public int getMaxLines() {return -1;}
|
|
|
|
|
|
|
|
public void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom) {}
|
|
|
|
|
2023-09-19 23:22:21 +02:00
|
|
|
public int getLineCount() {return 1;}
|
|
|
|
|
|
|
|
public URLSpan[] getUrls() {return new URLSpan[0];}
|
|
|
|
|
|
|
|
public void setMovementMethod(MovementMethod method) {}
|
|
|
|
|
|
|
|
public void setTextIsSelectable(boolean selectable) {}
|
|
|
|
|
2023-09-21 22:49:36 +02:00
|
|
|
public void setText(CharSequence text, BufferType type) {
|
|
|
|
setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MovementMethod getMovementMethod() {
|
|
|
|
return new MovementMethod();
|
|
|
|
}
|
|
|
|
|
2023-10-08 17:51:41 +02:00
|
|
|
public CharSequence getHint() {return "HINT";}
|
|
|
|
|
2023-11-08 21:40:39 +01:00
|
|
|
public int getMinHeight() {return 0;}
|
|
|
|
public int getMinWidth() {return 0;}
|
|
|
|
public void setMinHeight(int minHeight) {}
|
|
|
|
|
|
|
|
public void setHorizontallyScrolling(boolean whether) {}
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
public static interface OnEditorActionListener {
|
2023-11-08 18:00:31 +01:00
|
|
|
public abstract boolean onEditorAction(TextView v, int actionId, KeyEvent event);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
2023-09-19 23:22:21 +02:00
|
|
|
|
|
|
|
public static enum BufferType {
|
|
|
|
EDITABLE,
|
|
|
|
NORMAL,
|
|
|
|
SPANNABLE,
|
|
|
|
}
|
2023-12-29 11:09:37 +01:00
|
|
|
|
|
|
|
public Layout getLayout() {
|
|
|
|
return new Layout();
|
|
|
|
}
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|