use state to control RadioButtonItem and CheckBoxItem

This commit is contained in:
BinTianqi
2024-06-03 13:51:22 +08:00
parent f47a851be7
commit 45317e3975
7 changed files with 114 additions and 113 deletions

View File

@@ -567,21 +567,21 @@ private fun CredentialManagePolicy(pkgName: String) {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem( RadioButtonItem(
stringResource(R.string.none), stringResource(R.string.none),
{ policyType==-1 }, { policyType=-1 } policyType == -1, { policyType = -1 }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.blacklist), stringResource(R.string.blacklist),
{ policyType==PACKAGE_POLICY_BLOCKLIST }, policyType == PACKAGE_POLICY_BLOCKLIST,
{ policyType = PACKAGE_POLICY_BLOCKLIST } { policyType = PACKAGE_POLICY_BLOCKLIST }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.whitelist), stringResource(R.string.whitelist),
{ policyType==PACKAGE_POLICY_ALLOWLIST }, policyType == PACKAGE_POLICY_ALLOWLIST,
{ policyType = PACKAGE_POLICY_ALLOWLIST } { policyType = PACKAGE_POLICY_ALLOWLIST }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.whitelist_and_system_app), stringResource(R.string.whitelist_and_system_app),
{ policyType==PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM }, policyType == PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM,
{ policyType = PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM } { policyType = PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM }
) )
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))

View File

@@ -129,7 +129,7 @@ private fun CreateWorkProfile() {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
var skipEncrypt by remember { mutableStateOf(false) } var skipEncrypt by remember { mutableStateOf(false) }
if(VERSION.SDK_INT>=24) { if(VERSION.SDK_INT>=24) {
CheckBoxItem(stringResource(R.string.skip_encryption), { skipEncrypt }, { skipEncrypt=!skipEncrypt }) CheckBoxItem(stringResource(R.string.skip_encryption), skipEncrypt, { skipEncrypt = it })
} }
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
Button( Button(

View File

@@ -212,29 +212,30 @@ private fun Switches() {
private fun WifiSecLevel() { private fun WifiSecLevel() {
val context = LocalContext.current val context = LocalContext.current
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
var selectedWifiSecLevel by remember { mutableIntStateOf(0) }
LaunchedEffect(Unit) { selectedWifiSecLevel = dpm.minimumRequiredWifiSecurityLevel }
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) { Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
var selectedWifiSecLevel by remember { mutableIntStateOf(dpm.minimumRequiredWifiSecurityLevel) }
Spacer(Modifier.padding(vertical = 10.dp)) Spacer(Modifier.padding(vertical = 10.dp))
Text(text = stringResource(R.string.min_wifi_security_level), style = typography.headlineLarge) Text(text = stringResource(R.string.min_wifi_security_level), style = typography.headlineLarge)
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem( RadioButtonItem(
stringResource(R.string.wifi_security_level_open), stringResource(R.string.wifi_security_level_open),
{ selectedWifiSecLevel == WIFI_SECURITY_OPEN }, selectedWifiSecLevel == WIFI_SECURITY_OPEN,
{ selectedWifiSecLevel = WIFI_SECURITY_OPEN } { selectedWifiSecLevel = WIFI_SECURITY_OPEN }
) )
RadioButtonItem( RadioButtonItem(
"WEP, WPA(2)-PSK", "WEP, WPA(2)-PSK",
{ selectedWifiSecLevel == WIFI_SECURITY_PERSONAL }, selectedWifiSecLevel == WIFI_SECURITY_PERSONAL,
{ selectedWifiSecLevel = WIFI_SECURITY_PERSONAL } { selectedWifiSecLevel = WIFI_SECURITY_PERSONAL }
) )
RadioButtonItem( RadioButtonItem(
"WPA-EAP", "WPA-EAP",
{ selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_EAP }, selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_EAP,
{ selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_EAP } { selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_EAP }
) )
RadioButtonItem( RadioButtonItem(
"WPA3-192bit", "WPA3-192bit",
{ selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_192 }, selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_192,
{ selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_192 } { selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_192 }
) )
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
@@ -272,17 +273,17 @@ private fun WifiSsidPolicy() {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem( RadioButtonItem(
stringResource(R.string.none), stringResource(R.string.none),
{ selectedPolicyType == -1 }, selectedPolicyType == -1,
{ selectedPolicyType = -1 } { selectedPolicyType = -1 }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.whitelist), stringResource(R.string.whitelist),
{ selectedPolicyType == WIFI_SSID_POLICY_TYPE_ALLOWLIST }, selectedPolicyType == WIFI_SSID_POLICY_TYPE_ALLOWLIST,
{ selectedPolicyType = WIFI_SSID_POLICY_TYPE_ALLOWLIST } { selectedPolicyType = WIFI_SSID_POLICY_TYPE_ALLOWLIST }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.blacklist), stringResource(R.string.blacklist),
{ selectedPolicyType == WIFI_SSID_POLICY_TYPE_DENYLIST }, selectedPolicyType == WIFI_SSID_POLICY_TYPE_DENYLIST,
{ selectedPolicyType = WIFI_SSID_POLICY_TYPE_DENYLIST } { selectedPolicyType = WIFI_SSID_POLICY_TYPE_DENYLIST }
) )
AnimatedVisibility(selectedPolicyType != -1) { AnimatedVisibility(selectedPolicyType != -1) {
@@ -641,10 +642,10 @@ private fun APN() {
} }
Text(text = stringResource(R.string.auth_type), style = typography.titleLarge) Text(text = stringResource(R.string.auth_type), style = typography.titleLarge)
RadioButtonItem(stringResource(R.string.none), { selectedAuthType==AUTH_TYPE_NONE }, { selectedAuthType=AUTH_TYPE_NONE }) RadioButtonItem(stringResource(R.string.none), selectedAuthType==AUTH_TYPE_NONE , { selectedAuthType=AUTH_TYPE_NONE })
RadioButtonItem("CHAP", { selectedAuthType==AUTH_TYPE_CHAP }, { selectedAuthType=AUTH_TYPE_CHAP }) RadioButtonItem("CHAP", selectedAuthType == AUTH_TYPE_CHAP , { selectedAuthType = AUTH_TYPE_CHAP })
RadioButtonItem("PAP", { selectedAuthType==AUTH_TYPE_PAP}, { selectedAuthType=AUTH_TYPE_PAP }) RadioButtonItem("PAP", selectedAuthType == AUTH_TYPE_PAP, { selectedAuthType = AUTH_TYPE_PAP })
RadioButtonItem("PAP/CHAP", { selectedAuthType==AUTH_TYPE_PAP_OR_CHAP}, { selectedAuthType=AUTH_TYPE_PAP_OR_CHAP }) RadioButtonItem("PAP/CHAP", selectedAuthType == AUTH_TYPE_PAP_OR_CHAP, { selectedAuthType = AUTH_TYPE_PAP_OR_CHAP })
if(VERSION.SDK_INT>=29) { if(VERSION.SDK_INT>=29) {
val ts = context.getSystemService(ComponentActivity.TELEPHONY_SERVICE) as TelephonyManager val ts = context.getSystemService(ComponentActivity.TELEPHONY_SERVICE) as TelephonyManager
@@ -751,10 +752,10 @@ private fun APN() {
} }
Text(text = "MVNO", style = typography.titleLarge) Text(text = "MVNO", style = typography.titleLarge)
RadioButtonItem("SPN", { mvnoType == MVNO_TYPE_SPN }, { mvnoType = MVNO_TYPE_SPN }) RadioButtonItem("SPN", mvnoType == MVNO_TYPE_SPN, { mvnoType = MVNO_TYPE_SPN })
RadioButtonItem("IMSI", { mvnoType == MVNO_TYPE_IMSI }, { mvnoType = MVNO_TYPE_IMSI }) RadioButtonItem("IMSI", mvnoType == MVNO_TYPE_IMSI, { mvnoType = MVNO_TYPE_IMSI })
RadioButtonItem("GID", { mvnoType == MVNO_TYPE_GID }, { mvnoType = MVNO_TYPE_GID }) RadioButtonItem("GID", mvnoType == MVNO_TYPE_GID, { mvnoType = MVNO_TYPE_GID })
RadioButtonItem("ICCID", { mvnoType == MVNO_TYPE_ICCID }, { mvnoType = MVNO_TYPE_ICCID }) RadioButtonItem("ICCID", mvnoType == MVNO_TYPE_ICCID, { mvnoType = MVNO_TYPE_ICCID })
Text(text = stringResource(R.string.network_type), style = typography.titleLarge) Text(text = stringResource(R.string.network_type), style = typography.titleLarge)
TextField( TextField(
@@ -798,23 +799,23 @@ private fun APN() {
} }
Text(text = stringResource(R.string.protocol), style = typography.titleLarge) Text(text = stringResource(R.string.protocol), style = typography.titleLarge)
RadioButtonItem("IPV4", { protocol == PROTOCOL_IP }, { protocol = PROTOCOL_IP }) RadioButtonItem("IPV4", protocol == PROTOCOL_IP, { protocol = PROTOCOL_IP })
RadioButtonItem("IPV6", { protocol == PROTOCOL_IPV6 }, { protocol = PROTOCOL_IPV6 }) RadioButtonItem("IPV6", protocol == PROTOCOL_IPV6, { protocol = PROTOCOL_IPV6 })
RadioButtonItem("IPV4/IPV6", { protocol == PROTOCOL_IPV4V6 }, { protocol = PROTOCOL_IPV4V6 }) RadioButtonItem("IPV4/IPV6", protocol == PROTOCOL_IPV4V6, { protocol = PROTOCOL_IPV4V6 })
RadioButtonItem("PPP", { protocol == PROTOCOL_PPP }, { protocol = PROTOCOL_PPP }) RadioButtonItem("PPP", protocol == PROTOCOL_PPP, { protocol = PROTOCOL_PPP })
if(VERSION.SDK_INT>=29) { if(VERSION.SDK_INT>=29) {
RadioButtonItem("non-IP", { protocol == PROTOCOL_NON_IP }, { protocol = PROTOCOL_NON_IP }) RadioButtonItem("non-IP", protocol == PROTOCOL_NON_IP, { protocol = PROTOCOL_NON_IP })
RadioButtonItem("Unstructured", { protocol == PROTOCOL_UNSTRUCTURED }, { protocol = PROTOCOL_UNSTRUCTURED }) RadioButtonItem("Unstructured", protocol == PROTOCOL_UNSTRUCTURED, { protocol = PROTOCOL_UNSTRUCTURED })
} }
Text(text = stringResource(R.string.roaming_protocol), style = typography.titleLarge) Text(text = stringResource(R.string.roaming_protocol), style = typography.titleLarge)
RadioButtonItem("IPV4", { roamingProtocol == PROTOCOL_IP }, { roamingProtocol = PROTOCOL_IP }) RadioButtonItem("IPV4", roamingProtocol == PROTOCOL_IP, { roamingProtocol = PROTOCOL_IP })
RadioButtonItem("IPV6", { roamingProtocol == PROTOCOL_IPV6 }, { roamingProtocol = PROTOCOL_IPV6 }) RadioButtonItem("IPV6", roamingProtocol == PROTOCOL_IPV6, { roamingProtocol = PROTOCOL_IPV6 })
RadioButtonItem("IPV4/IPV6", { roamingProtocol == PROTOCOL_IPV4V6 }, { roamingProtocol = PROTOCOL_IPV4V6 }) RadioButtonItem("IPV4/IPV6", roamingProtocol == PROTOCOL_IPV4V6, { roamingProtocol = PROTOCOL_IPV4V6 })
RadioButtonItem("PPP", { roamingProtocol == PROTOCOL_PPP }, { roamingProtocol = PROTOCOL_PPP}) RadioButtonItem("PPP", roamingProtocol == PROTOCOL_PPP, { roamingProtocol = PROTOCOL_PPP})
if(VERSION.SDK_INT>=29) { if(VERSION.SDK_INT>=29) {
RadioButtonItem("non-IP", { roamingProtocol == PROTOCOL_NON_IP }, { roamingProtocol = PROTOCOL_NON_IP }) RadioButtonItem("non-IP", roamingProtocol == PROTOCOL_NON_IP, { roamingProtocol = PROTOCOL_NON_IP })
RadioButtonItem("Unstructured", { roamingProtocol == PROTOCOL_UNSTRUCTURED }, { roamingProtocol = PROTOCOL_UNSTRUCTURED }) RadioButtonItem("Unstructured", roamingProtocol == PROTOCOL_UNSTRUCTURED, { roamingProtocol = PROTOCOL_UNSTRUCTURED })
} }
var finalStep by remember { mutableStateOf(false) } var finalStep by remember { mutableStateOf(false) }

View File

@@ -231,16 +231,16 @@ private fun ResetPassword() {
if(VERSION.SDK_INT >= 23) { if(VERSION.SDK_INT >= 23) {
RadioButtonItem( RadioButtonItem(
stringResource(R.string.do_not_ask_credentials_on_boot), stringResource(R.string.do_not_ask_credentials_on_boot),
{ resetPwdFlag == RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT }, resetPwdFlag == RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT,
{ resetPwdFlag = RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT } { resetPwdFlag = RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT }
) )
} }
RadioButtonItem( RadioButtonItem(
stringResource(R.string.reset_password_require_entry), stringResource(R.string.reset_password_require_entry),
{ resetPwdFlag==RESET_PASSWORD_REQUIRE_ENTRY }, resetPwdFlag == RESET_PASSWORD_REQUIRE_ENTRY,
{ resetPwdFlag = RESET_PASSWORD_REQUIRE_ENTRY } { resetPwdFlag = RESET_PASSWORD_REQUIRE_ENTRY }
) )
RadioButtonItem(stringResource(R.string.none), { resetPwdFlag==0 }, { resetPwdFlag=0 }) RadioButtonItem(stringResource(R.string.none), resetPwdFlag == 0, { resetPwdFlag = 0 })
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
Button( Button(
onClick = { onClick = {
@@ -310,22 +310,22 @@ private fun PasswordComplexity() {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem( RadioButtonItem(
passwordComplexity[0].second, passwordComplexity[0].second,
{ selectedItem == passwordComplexity[0].first }, selectedItem == passwordComplexity[0].first,
{ selectedItem = passwordComplexity[0].first } { selectedItem = passwordComplexity[0].first }
) )
RadioButtonItem( RadioButtonItem(
passwordComplexity[1].second, passwordComplexity[1].second,
{ selectedItem == passwordComplexity[1].first }, selectedItem == passwordComplexity[1].first,
{ selectedItem = passwordComplexity[1].first } { selectedItem = passwordComplexity[1].first }
) )
RadioButtonItem( RadioButtonItem(
passwordComplexity[2].second, passwordComplexity[2].second,
{ selectedItem == passwordComplexity[2].first }, selectedItem == passwordComplexity[2].first,
{ selectedItem = passwordComplexity[2].first } { selectedItem = passwordComplexity[2].first }
) )
RadioButtonItem( RadioButtonItem(
passwordComplexity[3].second, passwordComplexity[3].second,
{ selectedItem == passwordComplexity[3].first }, selectedItem == passwordComplexity[3].first,
{ selectedItem = passwordComplexity[3].first } { selectedItem = passwordComplexity[3].first }
) )
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
@@ -564,24 +564,24 @@ private fun KeyguardDisabledFeatures() {
Spacer(Modifier.padding(vertical = 10.dp)) Spacer(Modifier.padding(vertical = 10.dp))
Text(text = stringResource(R.string.keyguard_disabled_features), style = typography.headlineLarge) Text(text = stringResource(R.string.keyguard_disabled_features), style = typography.headlineLarge)
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem(stringResource(R.string.enable_all), { state==0 }, { state=0 }) RadioButtonItem(stringResource(R.string.enable_all), state == 0, { state = 0 })
RadioButtonItem(stringResource(R.string.disable_all), { state==1 }, { state=1 }) RadioButtonItem(stringResource(R.string.disable_all), state == 1, { state = 1 })
RadioButtonItem(stringResource(R.string.custom), { state==2 }, { state=2 }) RadioButtonItem(stringResource(R.string.custom), state == 2 , { state = 2 })
AnimatedVisibility(state==2) { AnimatedVisibility(state==2) {
Column { Column {
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_widgets), { widgets }, { widgets=!widgets }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_widgets), widgets, { widgets = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_camera), { camera }, { camera=!camera }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_camera), camera, { camera = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_notification), { notification }, { notification=!notification }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_notification), notification, { notification = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_unredacted_notification), { unredacted }, { unredacted=!unredacted }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_unredacted_notification), unredacted, { unredacted = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_trust_agents), { agents }, { agents=!agents }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_trust_agents), agents, { agents = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_fingerprint), { fingerprint }, { fingerprint=!fingerprint }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_fingerprint), fingerprint, { fingerprint = it })
if(VERSION.SDK_INT >= 24) { CheckBoxItem(stringResource(R.string.keyguard_disabled_features_remote_input), { remote} , { remote=!remote }) } if(VERSION.SDK_INT >= 24) { CheckBoxItem(stringResource(R.string.keyguard_disabled_features_remote_input), remote , { remote = it }) }
if(VERSION.SDK_INT >= 28) { if(VERSION.SDK_INT >= 28) {
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_face), { face }, { face=!face }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_face), face, { face = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_iris), { iris }, { iris=!iris }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_iris), iris, { iris = it })
CheckBoxItem(stringResource(R.string.keyguard_disabled_features_biometrics), { biometrics }, { biometrics=!biometrics }) CheckBoxItem(stringResource(R.string.keyguard_disabled_features_biometrics), biometrics, { biometrics = it })
} }
if(VERSION.SDK_INT >= 34) { CheckBoxItem(stringResource(R.string.keyguard_disabled_features_shortcuts), { shortcuts }, { shortcuts=!shortcuts }) } if(VERSION.SDK_INT >= 34) { CheckBoxItem(stringResource(R.string.keyguard_disabled_features_shortcuts), shortcuts, { shortcuts = it }) }
} }
} }
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
@@ -640,14 +640,14 @@ private fun PasswordQuality() {
Text(text = stringResource(R.string.password_complexity_instead_password_quality)) Text(text = stringResource(R.string.password_complexity_instead_password_quality))
if(VERSION.SDK_INT >= 31) { Text(text = stringResource(R.string.password_quality_deprecated_desc), color = colorScheme.error) } if(VERSION.SDK_INT >= 31) { Text(text = stringResource(R.string.password_quality_deprecated_desc), color = colorScheme.error) }
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem(passwordQuality[0].second, { selectedItem == passwordQuality[0].first }, { selectedItem = passwordQuality[0].first }) RadioButtonItem(passwordQuality[0].second, selectedItem == passwordQuality[0].first, { selectedItem = passwordQuality[0].first })
RadioButtonItem(passwordQuality[1].second, { selectedItem == passwordQuality[1].first }, { selectedItem = passwordQuality[1].first }) RadioButtonItem(passwordQuality[1].second, selectedItem == passwordQuality[1].first, { selectedItem = passwordQuality[1].first })
RadioButtonItem(passwordQuality[2].second, { selectedItem == passwordQuality[2].first }, { selectedItem = passwordQuality[2].first }) RadioButtonItem(passwordQuality[2].second, selectedItem == passwordQuality[2].first, { selectedItem = passwordQuality[2].first })
RadioButtonItem(passwordQuality[3].second, { selectedItem == passwordQuality[3].first }, { selectedItem = passwordQuality[3].first }) RadioButtonItem(passwordQuality[3].second, selectedItem == passwordQuality[3].first, { selectedItem = passwordQuality[3].first })
RadioButtonItem(passwordQuality[4].second, { selectedItem == passwordQuality[4].first }, { selectedItem = passwordQuality[4].first }) RadioButtonItem(passwordQuality[4].second, selectedItem == passwordQuality[4].first, { selectedItem = passwordQuality[4].first })
RadioButtonItem(passwordQuality[5].second, { selectedItem == passwordQuality[5].first }, { selectedItem = passwordQuality[5].first }) RadioButtonItem(passwordQuality[5].second, selectedItem == passwordQuality[5].first, { selectedItem = passwordQuality[5].first })
RadioButtonItem(passwordQuality[6].second, { selectedItem == passwordQuality[6].first }, { selectedItem = passwordQuality[6].first }) RadioButtonItem(passwordQuality[6].second, selectedItem == passwordQuality[6].first, { selectedItem = passwordQuality[6].first })
RadioButtonItem(passwordQuality[7].second, { selectedItem == passwordQuality[7].first }, { selectedItem = passwordQuality[7].first }) RadioButtonItem(passwordQuality[7].second, selectedItem == passwordQuality[7].first, { selectedItem = passwordQuality[7].first })
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
Button( Button(
onClick = { onClick = {

View File

@@ -337,7 +337,7 @@ private fun Keyguard() {
if(VERSION.SDK_INT >= 26) { if(VERSION.SDK_INT >= 26) {
CheckBoxItem( CheckBoxItem(
stringResource(R.string.require_enter_password_again), stringResource(R.string.require_enter_password_again),
{ flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY }, flag == FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY,
{ flag = if(flag==0) {1}else{0} } { flag = if(flag==0) {1}else{0} }
) )
} }
@@ -505,9 +505,9 @@ private fun PermissionPolicy() {
Spacer(Modifier.padding(vertical = 10.dp)) Spacer(Modifier.padding(vertical = 10.dp))
Text(text = stringResource(R.string.permission_policy), style = typography.headlineLarge) Text(text = stringResource(R.string.permission_policy), style = typography.headlineLarge)
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem(stringResource(R.string.default_stringres), { selectedPolicy==PERMISSION_POLICY_PROMPT }, { selectedPolicy= PERMISSION_POLICY_PROMPT }) RadioButtonItem(stringResource(R.string.default_stringres), selectedPolicy == PERMISSION_POLICY_PROMPT, { selectedPolicy = PERMISSION_POLICY_PROMPT })
RadioButtonItem(stringResource(R.string.auto_grant), { selectedPolicy==PERMISSION_POLICY_AUTO_GRANT }, { selectedPolicy= PERMISSION_POLICY_AUTO_GRANT }) RadioButtonItem(stringResource(R.string.auto_grant), selectedPolicy == PERMISSION_POLICY_AUTO_GRANT, { selectedPolicy = PERMISSION_POLICY_AUTO_GRANT })
RadioButtonItem(stringResource(R.string.auto_deny), { selectedPolicy==PERMISSION_POLICY_AUTO_DENY }, { selectedPolicy= PERMISSION_POLICY_AUTO_DENY }) RadioButtonItem(stringResource(R.string.auto_deny), selectedPolicy == PERMISSION_POLICY_AUTO_DENY, { selectedPolicy = PERMISSION_POLICY_AUTO_DENY })
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
Button( Button(
onClick = { onClick = {
@@ -533,17 +533,17 @@ private fun MTEPolicy() {
var selectedMtePolicy by remember { mutableIntStateOf(dpm.mtePolicy) } var selectedMtePolicy by remember { mutableIntStateOf(dpm.mtePolicy) }
RadioButtonItem( RadioButtonItem(
stringResource(R.string.decide_by_user), stringResource(R.string.decide_by_user),
{ selectedMtePolicy == MTE_NOT_CONTROLLED_BY_POLICY }, selectedMtePolicy == MTE_NOT_CONTROLLED_BY_POLICY,
{ selectedMtePolicy = MTE_NOT_CONTROLLED_BY_POLICY } { selectedMtePolicy = MTE_NOT_CONTROLLED_BY_POLICY }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.enabled), stringResource(R.string.enabled),
{ selectedMtePolicy == MTE_ENABLED }, selectedMtePolicy == MTE_ENABLED,
{ selectedMtePolicy = MTE_ENABLED } { selectedMtePolicy = MTE_ENABLED }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.disabled), stringResource(R.string.disabled),
{ selectedMtePolicy == MTE_DISABLED }, selectedMtePolicy == MTE_DISABLED,
{ selectedMtePolicy = MTE_DISABLED } { selectedMtePolicy = MTE_DISABLED }
) )
Button( Button(
@@ -578,22 +578,22 @@ private fun NearbyStreamingPolicy() {
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
RadioButtonItem( RadioButtonItem(
stringResource(R.string.decide_by_user), stringResource(R.string.decide_by_user),
{ appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }, appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY,
{ appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY } { appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.enabled), stringResource(R.string.enabled),
{ appPolicy == NEARBY_STREAMING_ENABLED }, appPolicy == NEARBY_STREAMING_ENABLED,
{ appPolicy = NEARBY_STREAMING_ENABLED } { appPolicy = NEARBY_STREAMING_ENABLED }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.disabled), stringResource(R.string.disabled),
{ appPolicy == NEARBY_STREAMING_DISABLED }, appPolicy == NEARBY_STREAMING_DISABLED,
{ appPolicy = NEARBY_STREAMING_DISABLED } { appPolicy = NEARBY_STREAMING_DISABLED }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.enable_if_secure_enough), stringResource(R.string.enable_if_secure_enough),
{ appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }, appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY,
{ appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY } { appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }
) )
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
@@ -612,22 +612,22 @@ private fun NearbyStreamingPolicy() {
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
RadioButtonItem( RadioButtonItem(
stringResource(R.string.decide_by_user), stringResource(R.string.decide_by_user),
{ notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }, notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY,
{ notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY } { notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.enabled), stringResource(R.string.enabled),
{ notificationPolicy == NEARBY_STREAMING_ENABLED }, notificationPolicy == NEARBY_STREAMING_ENABLED,
{ notificationPolicy = NEARBY_STREAMING_ENABLED } { notificationPolicy = NEARBY_STREAMING_ENABLED }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.disabled), stringResource(R.string.disabled),
{ notificationPolicy == NEARBY_STREAMING_DISABLED }, notificationPolicy == NEARBY_STREAMING_DISABLED,
{ notificationPolicy = NEARBY_STREAMING_DISABLED } { notificationPolicy = NEARBY_STREAMING_DISABLED }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.enable_if_secure_enough), stringResource(R.string.enable_if_secure_enough),
{ notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }, notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY,
{ notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY } { notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }
) )
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
@@ -689,17 +689,17 @@ private fun LockTaskFeatures() {
Text(text = stringResource(R.string.lock_task_feature), style = typography.headlineLarge) Text(text = stringResource(R.string.lock_task_feature), style = typography.headlineLarge)
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
if(!inited) { refreshFeature(); custom=dpm.getLockTaskFeatures(receiver)!=0; inited= true } if(!inited) { refreshFeature(); custom=dpm.getLockTaskFeatures(receiver)!=0; inited= true }
RadioButtonItem(stringResource(R.string.disable_all), { !custom }, { custom=false }) RadioButtonItem(stringResource(R.string.disable_all), !custom, { custom = false })
RadioButtonItem(stringResource(R.string.custom), { custom }, { custom= true }) RadioButtonItem(stringResource(R.string.custom), custom, { custom = true })
AnimatedVisibility(custom) { AnimatedVisibility(custom) {
Column { Column {
CheckBoxItem(stringResource(R.string.ltf_sys_info), { sysInfo }, { sysInfo = !sysInfo }) CheckBoxItem(stringResource(R.string.ltf_sys_info), sysInfo, { sysInfo = it })
CheckBoxItem(stringResource(R.string.ltf_notifications), { notifications }, { notifications = !notifications }) CheckBoxItem(stringResource(R.string.ltf_notifications), notifications, { notifications = it })
CheckBoxItem(stringResource(R.string.ltf_home), { home }, { home = !home }) CheckBoxItem(stringResource(R.string.ltf_home), home, { home = it })
CheckBoxItem(stringResource(R.string.ltf_overview), { overview }, { overview = !overview }) CheckBoxItem(stringResource(R.string.ltf_overview), overview, { overview = it })
CheckBoxItem(stringResource(R.string.ltf_global_actions), { globalAction}, {globalAction = !globalAction}) CheckBoxItem(stringResource(R.string.ltf_global_actions), globalAction, { globalAction = it })
CheckBoxItem(stringResource(R.string.ltf_keyguard), { keyGuard }, { keyGuard = !keyGuard }) CheckBoxItem(stringResource(R.string.ltf_keyguard), keyGuard, { keyGuard = it })
if(VERSION.SDK_INT >= 30) { CheckBoxItem(stringResource(R.string.ltf_block_activity_start_in_task), { blockAct }, { blockAct=!blockAct }) } if(VERSION.SDK_INT >= 30) { CheckBoxItem(stringResource(R.string.ltf_block_activity_start_in_task), blockAct, { blockAct = it }) }
} }
} }
Button( Button(
@@ -949,7 +949,7 @@ fun FactoryResetProtection() {
} }
AnimatedVisibility(usePolicy) { AnimatedVisibility(usePolicy) {
Column { Column {
CheckBoxItem(stringResource(R.string.enable_frp), { enabled }, { enabled = !enabled }) CheckBoxItem(stringResource(R.string.enable_frp), enabled, { enabled = it })
Text(stringResource(R.string.account_list_is)) Text(stringResource(R.string.account_list_is))
Text( Text(
text = if(accountList.isEmpty()) stringResource(R.string.none) else accountList.toText(), text = if(accountList.isEmpty()) stringResource(R.string.none) else accountList.toText(),
@@ -1032,15 +1032,15 @@ private fun WipeData() {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
CheckBoxItem( CheckBoxItem(
stringResource(R.string.wipe_external_storage), stringResource(R.string.wipe_external_storage),
{ externalStorage }, { externalStorage = !externalStorage; confirmed = false } externalStorage, { externalStorage = it; confirmed = false }
) )
if(VERSION.SDK_INT >= 22 && isDeviceOwner(dpm)) { if(VERSION.SDK_INT >= 22 && isDeviceOwner(dpm)) {
CheckBoxItem(stringResource(R.string.wipe_reset_protection_data), CheckBoxItem(stringResource(R.string.wipe_reset_protection_data),
{ protectionData }, { protectionData = !protectionData; confirmed = false} protectionData, { protectionData = it; confirmed = false}
) )
} }
if(VERSION.SDK_INT >= 28) { CheckBoxItem(stringResource(R.string.wipe_euicc), { euicc }, { euicc = !euicc; confirmed = false }) } if(VERSION.SDK_INT >= 28) { CheckBoxItem(stringResource(R.string.wipe_euicc), euicc, { euicc = it; confirmed = false }) }
if(VERSION.SDK_INT >= 29) { CheckBoxItem(stringResource(R.string.wipe_silently), { silent }, { silent = !silent; confirmed = false }) } if(VERSION.SDK_INT >= 29) { CheckBoxItem(stringResource(R.string.wipe_silently), silent, { silent = it; confirmed = false }) }
AnimatedVisibility(!silent && VERSION.SDK_INT >= 28) { AnimatedVisibility(!silent && VERSION.SDK_INT >= 28) {
OutlinedTextField( OutlinedTextField(
value = reason, onValueChange = { reason = it }, value = reason, onValueChange = { reason = it },
@@ -1120,17 +1120,17 @@ private fun SysUpdatePolicy() {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
RadioButtonItem( RadioButtonItem(
stringResource(R.string.system_update_policy_automatic), stringResource(R.string.system_update_policy_automatic),
{ selectedPolicy == TYPE_INSTALL_AUTOMATIC }, { selectedPolicy = TYPE_INSTALL_AUTOMATIC } selectedPolicy == TYPE_INSTALL_AUTOMATIC, { selectedPolicy = TYPE_INSTALL_AUTOMATIC }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.system_update_policy_install_windowed), stringResource(R.string.system_update_policy_install_windowed),
{ selectedPolicy == TYPE_INSTALL_WINDOWED }, { selectedPolicy = TYPE_INSTALL_WINDOWED } selectedPolicy == TYPE_INSTALL_WINDOWED, { selectedPolicy = TYPE_INSTALL_WINDOWED }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.system_update_policy_postpone), stringResource(R.string.system_update_policy_postpone),
{ selectedPolicy == TYPE_POSTPONE}, { selectedPolicy = TYPE_POSTPONE } selectedPolicy == TYPE_POSTPONE, { selectedPolicy = TYPE_POSTPONE }
) )
RadioButtonItem(stringResource(R.string.none), { selectedPolicy == null }, { selectedPolicy = null }) RadioButtonItem(stringResource(R.string.none), selectedPolicy == null, { selectedPolicy = null })
var windowedPolicyStart by remember { mutableStateOf("") } var windowedPolicyStart by remember { mutableStateOf("") }
var windowedPolicyEnd by remember { mutableStateOf("") } var windowedPolicyEnd by remember { mutableStateOf("") }
if(selectedPolicy == 2) { if(selectedPolicy == 2) {

View File

@@ -202,7 +202,7 @@ private fun UserOperation() {
) )
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
if(VERSION.SDK_INT >= 24) { if(VERSION.SDK_INT >= 24) {
CheckBoxItem(text = stringResource(R.string.use_uid), checked = { useUid }, operation = { idInput=""; useUid = !useUid}) CheckBoxItem(text = stringResource(R.string.use_uid), checked = useUid, operation = { idInput=""; useUid = it })
} }
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
if(VERSION.SDK_INT > 28) { if(VERSION.SDK_INT > 28) {
@@ -301,21 +301,21 @@ private fun CreateUser() {
) )
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
var selectedFlag by remember { mutableIntStateOf(0) } var selectedFlag by remember { mutableIntStateOf(0) }
RadioButtonItem(stringResource(R.string.none), { selectedFlag == 0 }, { selectedFlag = 0 }) RadioButtonItem(stringResource(R.string.none), selectedFlag == 0, { selectedFlag = 0 })
RadioButtonItem( RadioButtonItem(
stringResource(R.string.create_user_skip_wizard), stringResource(R.string.create_user_skip_wizard),
{ selectedFlag == DevicePolicyManager.SKIP_SETUP_WIZARD }, selectedFlag == DevicePolicyManager.SKIP_SETUP_WIZARD,
{ selectedFlag = DevicePolicyManager.SKIP_SETUP_WIZARD } { selectedFlag = DevicePolicyManager.SKIP_SETUP_WIZARD }
) )
if(VERSION.SDK_INT >= 28) { if(VERSION.SDK_INT >= 28) {
RadioButtonItem( RadioButtonItem(
stringResource(R.string.create_user_ephemeral_user), stringResource(R.string.create_user_ephemeral_user),
{ selectedFlag == DevicePolicyManager.MAKE_USER_EPHEMERAL }, selectedFlag == DevicePolicyManager.MAKE_USER_EPHEMERAL,
{ selectedFlag = DevicePolicyManager.MAKE_USER_EPHEMERAL } { selectedFlag = DevicePolicyManager.MAKE_USER_EPHEMERAL }
) )
RadioButtonItem( RadioButtonItem(
stringResource(R.string.create_user_enable_all_system_app), stringResource(R.string.create_user_enable_all_system_app),
{ selectedFlag == DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED }, selectedFlag == DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED,
{ selectedFlag = DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED } { selectedFlag = DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED }
) )
} }
@@ -521,7 +521,7 @@ private fun UserIcon() {
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
Text(text = stringResource(R.string.pick_a_square_image)) Text(text = stringResource(R.string.pick_a_square_image))
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
CheckBoxItem(stringResource(R.string.file_picker_instead_gallery), {getContent}, {getContent=!getContent}) CheckBoxItem(stringResource(R.string.file_picker_instead_gallery), getContent, { getContent = it })
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
Button( Button(
onClick = { onClick = {

View File

@@ -81,7 +81,7 @@ fun Information(content: @Composable ()->Unit) {
@Composable @Composable
fun RadioButtonItem( fun RadioButtonItem(
text: String, text: String,
selected: ()->Boolean, selected: Boolean,
operation: () -> Unit, operation: () -> Unit,
textColor: Color = colorScheme.onBackground textColor: Color = colorScheme.onBackground
) { ) {
@@ -90,7 +90,7 @@ fun RadioButtonItem(
.clip(RoundedCornerShape(25)) .clip(RoundedCornerShape(25))
.clickable(onClick = operation) .clickable(onClick = operation)
) { ) {
RadioButton(selected = selected(), onClick = operation) RadioButton(selected = selected, onClick = operation)
Text(text = text, color = textColor, modifier = Modifier.padding(bottom = if(zhCN) { 2 } else { 0 }.dp)) Text(text = text, color = textColor, modifier = Modifier.padding(bottom = if(zhCN) { 2 } else { 0 }.dp))
} }
} }
@@ -98,18 +98,18 @@ fun RadioButtonItem(
@Composable @Composable
fun CheckBoxItem( fun CheckBoxItem(
text: String, text: String,
checked: ()->Boolean, checked: Boolean,
operation: ()->Unit, operation: (Boolean) -> Unit,
textColor: Color = colorScheme.onBackground textColor: Color = colorScheme.onBackground
) { ) {
Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clip(RoundedCornerShape(25)) .clip(RoundedCornerShape(25))
.clickable(onClick = operation) .clickable { operation(!checked) }
) { ) {
Checkbox( Checkbox(
checked = checked(), checked = checked,
onCheckedChange = { operation() } onCheckedChange = operation
) )
Text(text = text, color = textColor, modifier = Modifier.padding(bottom = if(zhCN) { 2 } else { 0 }.dp)) Text(text = text, color = textColor, modifier = Modifier.padding(bottom = if(zhCN) { 2 } else { 0 }.dp))
} }