implement CompoundButton using GtkSwitch

This commit is contained in:
Julian Winkler
2024-02-15 21:08:13 +01:00
parent d2725a73c9
commit 2d6694d695
8 changed files with 306 additions and 13 deletions

View File

@@ -383,6 +383,8 @@ public class Canvas {
return false;
}
public void restoreToCount(int count) {}
private static native void native_drawText(long skia_canvas, CharSequence text, int start, int end, float x, float y, long skia_font, long skia_paint);
private static native void native_drawRect(long skia_canvas, float left, float top, float right, float bottom, long skia_paint);
private static native void native_drawLine(long skia_canvas, long widget, float startX, float startY, float stopX, float stopY, long skia_paint);

View File

@@ -26,7 +26,7 @@ public class Button extends TextView {
protected native void native_setOnClickListener(long widget, OnClickListener l);
@Override
public final void setText(CharSequence text) {
public void setText(CharSequence text) {
native_setText(widget, String.valueOf(text));
}

View File

@@ -1,4 +1,6 @@
package android.widget;
public interface Checkable {
public void setChecked(boolean checked);
}

View File

@@ -3,10 +3,8 @@ package android.widget;
import android.content.Context;
import android.util.AttributeSet;
public abstract class CompoundButton extends Button {
public abstract class CompoundButton extends Button implements Checkable {
private boolean checked;
public CompoundButton(Context context) {
super(context);
}
@@ -15,15 +13,24 @@ public abstract class CompoundButton extends Button {
super(context, attributeSet);
}
@Override
protected native long native_constructor(Context context, AttributeSet attrs);
public static interface OnCheckedChangeListener {}
public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {}
public native void setOnCheckedChangeListener(OnCheckedChangeListener listener);
public void setChecked(boolean checked) {
this.checked = checked;
}
public native void setChecked(boolean checked);
public boolean isChecked() {
return checked;
}
public native boolean isChecked();
// following methods are overridden to prevent calling incompatible methods from superclasses
@Override
public void setOnClickListener(final OnClickListener l) {}
@Override
public void setText(CharSequence text) {}
@Override
public void setTextColor(int color) {}
@Override
public void setTextSize(float size) {}
}

View File

@@ -13,6 +13,4 @@ public class Switch extends CompoundButton {
super(context, attributeSet);
}
public void setChecked(boolean checked) {}
}