Vectras-VM-Android/app/src/main/java/com/vectras/vm/view/CheckBoxView.java
An Bui ca9cb3b25d 4.0.6
- Fixed the crash issue when dragging and dropping files.
- Added the Use default BIOS/UEFI option in the virtual machine editing and creation settings.
- Added a restriction when selecting the output save directory as the virtual machine's own directory.
- Fixed the issue of the virtual machine control panel dialog freezing.
- Fixed the issue of creating unused virtual machine directories.
- Added automatic cleanup of empty directories and files in the virtual machine directory.
- Removed the Hard drive interface, Boot from, Custom params, and Use default BIOS/UEFI options in the general Qemu settings.
2026-04-28 16:01:49 +07:00

76 lines
2.2 KiB
Java

package com.vectras.vm.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.vectras.vm.R;
public class CheckBoxView extends LinearLayout {
private TextView tvTitle;
private CheckBox checkBox;
public interface OnCheckedChangeListener {
void onCheckedChanged(CheckBoxView view, boolean isChecked);
}
private OnCheckedChangeListener listener;
public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {
this.listener = listener;
}
public CheckBoxView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
LayoutInflater.from(context).inflate(R.layout.checkbox_view, this, true);
tvTitle = findViewById(R.id.tv_title);
checkBox = findViewById(R.id.checkbox);
if (attrs != null) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CheckBoxView);
String title = typedArray.getString(R.styleable.CheckBoxView_setText);
boolean isChecked = typedArray.getBoolean(R.styleable.CheckBoxView_setChecked, false);
if (title != null) tvTitle.setText(title);
checkBox.setChecked(isChecked);
typedArray.recycle();
}
findViewById(R.id.root).setOnClickListener(v -> checkBox.setChecked(!checkBox.isChecked()));
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (listener != null) {
listener.onCheckedChanged(this, isChecked);
}
});
}
public void setText(String title) {
tvTitle.setText(title);
}
public void setChecked(boolean isCheck) {
checkBox.setChecked(isCheck);
}
public boolean isChecked() {
return checkBox.isChecked();
}
public void setEnabled(boolean isEnabled) {
findViewById(R.id.root).setEnabled(isEnabled);
findViewById(R.id.root).setAlpha(isEnabled ? 1f : 0.5f);
checkBox.setEnabled(isEnabled);
}
}