2023-08-17 10:46:24 +02:00
|
|
|
package android.widget;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2024-05-27 19:02:31 +02:00
|
|
|
import android.content.res.ColorStateList;
|
2024-04-12 18:32:30 +02:00
|
|
|
import android.graphics.drawable.Drawable;
|
2023-08-17 10:46:24 +02:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
|
|
2024-02-15 21:08:13 +01:00
|
|
|
public abstract class CompoundButton extends Button implements Checkable {
|
2024-04-12 18:32:30 +02:00
|
|
|
Drawable button_drawable = null;
|
2024-06-24 18:44:31 +02:00
|
|
|
public Drawable mButtonDrawable; // directly accessed by androidx
|
2023-09-19 23:22:21 +02:00
|
|
|
|
2023-09-01 12:55:04 +02:00
|
|
|
public CompoundButton(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
}
|
2024-04-12 18:32:30 +02:00
|
|
|
|
2023-09-01 12:55:04 +02:00
|
|
|
public CompoundButton(Context context, AttributeSet attributeSet) {
|
|
|
|
|
super(context, attributeSet);
|
|
|
|
|
}
|
2023-08-17 10:46:24 +02:00
|
|
|
|
2024-02-15 21:08:13 +01:00
|
|
|
@Override
|
|
|
|
|
protected native long native_constructor(Context context, AttributeSet attrs);
|
|
|
|
|
|
2024-03-16 12:49:28 +01:00
|
|
|
public static interface OnCheckedChangeListener {
|
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked);
|
|
|
|
|
}
|
2023-09-01 12:55:04 +02:00
|
|
|
|
2024-02-15 21:08:13 +01:00
|
|
|
public native void setOnCheckedChangeListener(OnCheckedChangeListener listener);
|
2023-09-19 23:22:21 +02:00
|
|
|
|
2024-03-16 12:49:28 +01:00
|
|
|
@Override
|
2024-02-15 21:08:13 +01:00
|
|
|
public native void setChecked(boolean checked);
|
2023-09-19 23:22:21 +02:00
|
|
|
|
2024-03-16 12:49:28 +01:00
|
|
|
@Override
|
2024-02-15 21:08:13 +01:00
|
|
|
public native boolean isChecked();
|
|
|
|
|
|
2024-03-16 12:49:28 +01:00
|
|
|
public void toggle() {
|
|
|
|
|
setChecked(!isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-15 21:08:13 +01:00
|
|
|
// 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) {}
|
2024-04-12 18:32:30 +02:00
|
|
|
|
2024-05-27 19:02:31 +02:00
|
|
|
public void setButtonTintList(ColorStateList list) {
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-12 18:32:30 +02:00
|
|
|
public void setButtonDrawable(Drawable drawable) {
|
|
|
|
|
button_drawable = drawable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Drawable getButtonDrawable() {
|
|
|
|
|
return button_drawable;
|
|
|
|
|
}
|
2023-08-17 10:46:24 +02:00
|
|
|
}
|