package com.shlb.comb.activity;
|
|
import android.widget.CompoundButton;
|
import android.widget.Toast;
|
|
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView;
|
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;
|
import com.shlb.comb.R;
|
import com.shlb.comb.base.BaseActivity;
|
import com.shlb.comb.event.UpdateEvent;
|
|
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.ThreadMode;
|
|
public class SystemSettingsActivity extends BaseActivity {
|
|
private QMUIGroupListView mGroupListView;
|
|
@Override
|
protected void contentView() {
|
setContentView(R.layout.activity_system_settings);
|
}
|
|
@Override
|
protected void initView() {
|
super.initHead();
|
setTitle("系统设置");
|
|
// Set left button to back icon
|
if (iv_left != null) {
|
iv_left.setImageResource(R.mipmap.icon_back);
|
iv_left.setOnClickListener(v -> finish());
|
}
|
|
// Hide right text (connection status)
|
android.view.View tvRightText = findViewById(R.id.tv_right_text);
|
if (tvRightText != null) {
|
tvRightText.setVisibility(android.view.View.GONE);
|
}
|
|
mGroupListView = findViewById(R.id.groupListView);
|
initGroupListView();
|
// Hide right button if not needed
|
if (iv_right != null) {
|
iv_right.setVisibility(android.view.View.GONE);
|
}
|
}
|
|
@Override
|
protected void initData() {
|
|
}
|
|
@Override
|
protected void initEvent() {
|
|
}
|
|
private void initGroupListView() {
|
QMUICommonListItemView itemCmdLog = mGroupListView.createItemView("CMD日志");
|
itemCmdLog.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
|
boolean isCmdLogEnabled = com.blankj.utilcode.util.SPUtils.getInstance().getBoolean("cmd_log_enabled", false);
|
itemCmdLog.getSwitch().setChecked(isCmdLogEnabled);
|
itemCmdLog.getSwitch().setOnCheckedChangeListener((buttonView, isChecked) -> {
|
com.blankj.utilcode.util.SPUtils.getInstance().put("cmd_log_enabled", isChecked);
|
Toast("CMD日志: " + (isChecked ? "开启" : "关闭"));
|
});
|
|
// QMUICommonListItemView itemTestPage = mGroupListView.createItemView("测试页面");
|
// itemTestPage.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
|
// itemTestPage.getSwitch().setOnCheckedChangeListener((buttonView, isChecked) -> {
|
// Toast("测试页面: " + (isChecked ? "开启" : "关闭"));
|
// });
|
|
QMUICommonListItemView itemKeepAdmin = mGroupListView.createItemView("保持管理员模式");
|
itemKeepAdmin.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
|
boolean isKeepAdmin = com.blankj.utilcode.util.SPUtils.getInstance().getBoolean("keep_admin_mode", false);
|
itemKeepAdmin.getSwitch().setChecked(isKeepAdmin);
|
itemKeepAdmin.getSwitch().setOnCheckedChangeListener((buttonView, isChecked) -> {
|
com.blankj.utilcode.util.SPUtils.getInstance().put("keep_admin_mode", isChecked);
|
Toast("管理员模式持久化: " + (isChecked ? "开启" : "关闭"));
|
});
|
|
QMUIGroupListView.newSection(this)
|
.setTitle("设置")
|
.addItemView(itemCmdLog, null)
|
.addItemView(itemKeepAdmin, null)
|
.addTo(mGroupListView);
|
}
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
public void onEvent(UpdateEvent event) {
|
// Placeholder to satisfy EventBus requirements in BaseActivity
|
}
|
}
|