mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 19:15:58 +00:00
clean code
This commit is contained in:
@@ -235,7 +235,7 @@ private fun HomePage(navCtrl:NavHostController, pkgName: MutableState<String>) {
|
||||
HomePageItem(R.string.work_profile, R.drawable.work_fill0, "ManagedProfile", navCtrl)
|
||||
}
|
||||
HomePageItem(R.string.app_manager, R.drawable.apps_fill0, "ApplicationManage", navCtrl)
|
||||
if(VERSION.SDK_INT>=24) {
|
||||
if(VERSION.SDK_INT >= 24 && (context.isProfileOwner || context.isDeviceOwner)) {
|
||||
HomePageItem(R.string.user_restrict, R.drawable.person_off, "UserRestriction", navCtrl)
|
||||
}
|
||||
HomePageItem(R.string.user_manager,R.drawable.manage_accounts_fill0,"UserManage", navCtrl)
|
||||
|
||||
@@ -640,21 +640,21 @@ private fun CredentialManagePolicy(pkgName: String) {
|
||||
Text(text = stringResource(R.string.credential_manage_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.none),
|
||||
R.string.none,
|
||||
policyType == -1, { policyType = -1 }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.blacklist),
|
||||
R.string.blacklist,
|
||||
policyType == PACKAGE_POLICY_BLOCKLIST,
|
||||
{ policyType = PACKAGE_POLICY_BLOCKLIST }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.whitelist),
|
||||
R.string.whitelist,
|
||||
policyType == PACKAGE_POLICY_ALLOWLIST,
|
||||
{ policyType = PACKAGE_POLICY_ALLOWLIST }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.whitelist_and_system_app),
|
||||
R.string.whitelist_and_system_app,
|
||||
policyType == PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM,
|
||||
{ policyType = PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM }
|
||||
)
|
||||
|
||||
@@ -132,7 +132,7 @@ private fun CreateWorkProfile() {
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
var skipEncrypt by remember { mutableStateOf(false) }
|
||||
if(VERSION.SDK_INT>=24) {
|
||||
CheckBoxItem(stringResource(R.string.skip_encryption), skipEncrypt, { skipEncrypt = it })
|
||||
CheckBoxItem(R.string.skip_encryption, skipEncrypt, { skipEncrypt = it })
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
@@ -293,9 +293,9 @@ private fun DeleteWorkProfile() {
|
||||
modifier = Modifier.padding(6.dp),color = colorScheme.error
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
CheckBoxItem(stringResource(R.string.wipe_external_storage), externalStorage, { externalStorage = it })
|
||||
if(VERSION.SDK_INT >= 28) { CheckBoxItem(stringResource(R.string.wipe_euicc), euicc, { euicc = it }) }
|
||||
if(VERSION.SDK_INT >= 29) { CheckBoxItem(stringResource(R.string.wipe_silently), silent, { silent = it }) }
|
||||
CheckBoxItem(R.string.wipe_external_storage, externalStorage, { externalStorage = it })
|
||||
if(VERSION.SDK_INT >= 28) { CheckBoxItem(R.string.wipe_euicc, euicc, { euicc = it }) }
|
||||
if(VERSION.SDK_INT >= 29) { CheckBoxItem(R.string.wipe_silently, silent, { silent = it }) }
|
||||
AnimatedVisibility(!silent && VERSION.SDK_INT >= 28) {
|
||||
OutlinedTextField(
|
||||
value = reason, onValueChange = { reason = it },
|
||||
|
||||
@@ -225,7 +225,7 @@ private fun WifiSecLevel() {
|
||||
Text(text = stringResource(R.string.min_wifi_security_level), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.wifi_security_level_open),
|
||||
R.string.wifi_security_open,
|
||||
selectedWifiSecLevel == WIFI_SECURITY_OPEN,
|
||||
{ selectedWifiSecLevel = WIFI_SECURITY_OPEN }
|
||||
)
|
||||
@@ -277,17 +277,17 @@ private fun WifiSsidPolicy() {
|
||||
Text(text = stringResource(R.string.wifi_ssid_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.none),
|
||||
R.string.none,
|
||||
selectedPolicyType == -1,
|
||||
{ selectedPolicyType = -1 }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.whitelist),
|
||||
R.string.whitelist,
|
||||
selectedPolicyType == WIFI_SSID_POLICY_TYPE_ALLOWLIST,
|
||||
{ selectedPolicyType = WIFI_SSID_POLICY_TYPE_ALLOWLIST }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.blacklist),
|
||||
R.string.blacklist,
|
||||
selectedPolicyType == WIFI_SSID_POLICY_TYPE_DENYLIST,
|
||||
{ selectedPolicyType = WIFI_SSID_POLICY_TYPE_DENYLIST }
|
||||
)
|
||||
@@ -450,9 +450,9 @@ private fun RecommendedGlobalProxy() {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.recommended_global_proxy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(stringResource(R.string.proxy_type_off), proxyType == 0, { proxyType = 0 })
|
||||
RadioButtonItem(stringResource(R.string.proxy_type_pac), proxyType == 1, { proxyType = 1 })
|
||||
RadioButtonItem(stringResource(R.string.proxy_type_direct), proxyType == 2, { proxyType = 2 })
|
||||
RadioButtonItem(R.string.proxy_type_off, proxyType == 0, { proxyType = 0 })
|
||||
RadioButtonItem(R.string.proxy_type_pac, proxyType == 1, { proxyType = 1 })
|
||||
RadioButtonItem(R.string.proxy_type_direct, proxyType == 2, { proxyType = 2 })
|
||||
AnimatedVisibility(proxyType != 0) {
|
||||
OutlinedTextField(
|
||||
value = proxyUri,
|
||||
@@ -465,7 +465,7 @@ private fun RecommendedGlobalProxy() {
|
||||
}
|
||||
AnimatedVisibility(proxyType == 1 && VERSION.SDK_INT >= 30) {
|
||||
Box(modifier = Modifier.padding(top = 2.dp)) {
|
||||
CheckBoxItem(stringResource(R.string.specify_port), specifyPort, { specifyPort = it })
|
||||
CheckBoxItem(R.string.specify_port, specifyPort, { specifyPort = it })
|
||||
}
|
||||
}
|
||||
AnimatedVisibility((proxyType == 1 && specifyPort && VERSION.SDK_INT >= 30) || proxyType == 2) {
|
||||
@@ -744,7 +744,7 @@ private fun APN() {
|
||||
}
|
||||
|
||||
Text(text = stringResource(R.string.auth_type), style = typography.titleLarge)
|
||||
RadioButtonItem(stringResource(R.string.none), selectedAuthType==AUTH_TYPE_NONE , { selectedAuthType=AUTH_TYPE_NONE })
|
||||
RadioButtonItem(R.string.none, selectedAuthType==AUTH_TYPE_NONE , { selectedAuthType=AUTH_TYPE_NONE })
|
||||
RadioButtonItem("CHAP", selectedAuthType == AUTH_TYPE_CHAP , { selectedAuthType = AUTH_TYPE_CHAP })
|
||||
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 })
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX
|
||||
import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
|
||||
@@ -278,17 +277,17 @@ private fun ResetPassword() {
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
if(VERSION.SDK_INT >= 23) {
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.do_not_ask_credentials_on_boot),
|
||||
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 }
|
||||
)
|
||||
}
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.reset_password_require_entry),
|
||||
R.string.reset_password_require_entry,
|
||||
resetPwdFlag == RESET_PASSWORD_REQUIRE_ENTRY,
|
||||
{ resetPwdFlag = RESET_PASSWORD_REQUIRE_ENTRY }
|
||||
)
|
||||
RadioButtonItem(stringResource(R.string.none), resetPwdFlag == 0, { resetPwdFlag = 0 })
|
||||
RadioButtonItem(R.string.none, resetPwdFlag == 0, { resetPwdFlag = 0 })
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -342,10 +341,10 @@ private fun PasswordComplexity() {
|
||||
val context = LocalContext.current
|
||||
val dpm = context.getDPM()
|
||||
val passwordComplexity = mapOf(
|
||||
PASSWORD_COMPLEXITY_NONE to stringResource(R.string.password_complexity_none),
|
||||
PASSWORD_COMPLEXITY_LOW to stringResource(R.string.password_complexity_low),
|
||||
PASSWORD_COMPLEXITY_MEDIUM to stringResource(R.string.password_complexity_medium),
|
||||
PASSWORD_COMPLEXITY_HIGH to stringResource(R.string.password_complexity_high)
|
||||
PASSWORD_COMPLEXITY_NONE to R.string.password_complexity_none,
|
||||
PASSWORD_COMPLEXITY_LOW to R.string.password_complexity_low,
|
||||
PASSWORD_COMPLEXITY_MEDIUM to R.string.password_complexity_medium,
|
||||
PASSWORD_COMPLEXITY_HIGH to R.string.password_complexity_high
|
||||
).toList()
|
||||
var selectedItem by remember { mutableIntStateOf(passwordComplexity[0].first) }
|
||||
LaunchedEffect(Unit) { selectedItem = dpm.requiredPasswordComplexity }
|
||||
@@ -353,28 +352,14 @@ private fun PasswordComplexity() {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.required_password_complexity), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(
|
||||
passwordComplexity[0].second,
|
||||
selectedItem == passwordComplexity[0].first,
|
||||
{ selectedItem = passwordComplexity[0].first }
|
||||
)
|
||||
RadioButtonItem(
|
||||
passwordComplexity[1].second,
|
||||
selectedItem == passwordComplexity[1].first,
|
||||
{ selectedItem = passwordComplexity[1].first }
|
||||
)
|
||||
RadioButtonItem(
|
||||
passwordComplexity[2].second,
|
||||
selectedItem == passwordComplexity[2].first,
|
||||
{ selectedItem = passwordComplexity[2].first }
|
||||
)
|
||||
RadioButtonItem(
|
||||
passwordComplexity[3].second,
|
||||
selectedItem == passwordComplexity[3].first,
|
||||
{ selectedItem = passwordComplexity[3].first }
|
||||
)
|
||||
for(index in 0..3) {
|
||||
RadioButtonItem(
|
||||
passwordComplexity[index].second,
|
||||
selectedItem == passwordComplexity[index].first,
|
||||
{ selectedItem = passwordComplexity[index].first }
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
dpm.requiredPasswordComplexity = selectedItem
|
||||
@@ -606,24 +591,24 @@ private fun DisableKeyguardFeatures() {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.disable_keyguard_features), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(stringResource(R.string.enable_all), state == 0, { state = 0 })
|
||||
RadioButtonItem(stringResource(R.string.disable_all), state == 1, { state = 1 })
|
||||
RadioButtonItem(stringResource(R.string.custom), state == 2 , { state = 2 })
|
||||
RadioButtonItem(R.string.enable_all, state == 0, { state = 0 })
|
||||
RadioButtonItem(R.string.disable_all, state == 1, { state = 1 })
|
||||
RadioButtonItem(R.string.custom, state == 2 , { state = 2 })
|
||||
AnimatedVisibility(state==2) {
|
||||
Column {
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_widgets), widgets, { widgets = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_camera), camera, { camera = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_notification), notification, { notification = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_unredacted_notification), unredacted, { unredacted = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_trust_agents), agents, { agents = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_fingerprint), fingerprint, { fingerprint = it })
|
||||
if(VERSION.SDK_INT >= 24) { CheckBoxItem(stringResource(R.string.disable_keyguard_features_remote_input), remote , { remote = it }) }
|
||||
CheckBoxItem(R.string.disable_keyguard_features_widgets, widgets, { widgets = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_camera, camera, { camera = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_notification, notification, { notification = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_unredacted_notification, unredacted, { unredacted = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_trust_agents, agents, { agents = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_fingerprint, fingerprint, { fingerprint = it })
|
||||
if(VERSION.SDK_INT >= 24) { CheckBoxItem(R.string.disable_keyguard_features_remote_input, remote , { remote = it }) }
|
||||
if(VERSION.SDK_INT >= 28) {
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_face), face, { face = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_iris), iris, { iris = it })
|
||||
CheckBoxItem(stringResource(R.string.disable_keyguard_features_biometrics), biometrics, { biometrics = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_face, face, { face = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_iris, iris, { iris = it })
|
||||
CheckBoxItem(R.string.disable_keyguard_features_biometrics, biometrics, { biometrics = it })
|
||||
}
|
||||
if(VERSION.SDK_INT >= 34) { CheckBoxItem(stringResource(R.string.disable_keyguard_features_shortcuts), shortcuts, { shortcuts = it }) }
|
||||
if(VERSION.SDK_INT >= 34) { CheckBoxItem(R.string.disable_keyguard_features_shortcuts, shortcuts, { shortcuts = it }) }
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
@@ -663,14 +648,13 @@ private fun PasswordQuality() {
|
||||
val dpm = context.getDPM()
|
||||
val receiver = context.getReceiver()
|
||||
val passwordQuality = mapOf(
|
||||
PASSWORD_QUALITY_UNSPECIFIED to stringResource(R.string.password_quality_unspecified),
|
||||
PASSWORD_QUALITY_SOMETHING to stringResource(R.string.password_quality_something),
|
||||
PASSWORD_QUALITY_ALPHABETIC to stringResource(R.string.password_quality_alphabetic),
|
||||
PASSWORD_QUALITY_NUMERIC to stringResource(R.string.password_quality_numeric),
|
||||
PASSWORD_QUALITY_ALPHANUMERIC to stringResource(R.string.password_quality_alphanumeric),
|
||||
PASSWORD_QUALITY_BIOMETRIC_WEAK to stringResource(R.string.password_quality_biometrics_weak),
|
||||
PASSWORD_QUALITY_NUMERIC_COMPLEX to stringResource(R.string.password_quality_numeric_complex),
|
||||
PASSWORD_QUALITY_COMPLEX to stringResource(R.string.custom) + "(${stringResource(R.string.unsupported) })",
|
||||
PASSWORD_QUALITY_UNSPECIFIED to R.string.password_quality_unspecified,
|
||||
PASSWORD_QUALITY_SOMETHING to R.string.password_quality_something,
|
||||
PASSWORD_QUALITY_ALPHABETIC to R.string.password_quality_alphabetic,
|
||||
PASSWORD_QUALITY_NUMERIC to R.string.password_quality_numeric,
|
||||
PASSWORD_QUALITY_ALPHANUMERIC to R.string.password_quality_alphanumeric,
|
||||
PASSWORD_QUALITY_BIOMETRIC_WEAK to R.string.password_quality_biometrics_weak,
|
||||
PASSWORD_QUALITY_NUMERIC_COMPLEX to R.string.password_quality_numeric_complex
|
||||
).toList()
|
||||
var selectedItem by remember { mutableIntStateOf(passwordQuality[0].first) }
|
||||
LaunchedEffect(Unit) { selectedItem=dpm.getPasswordQuality(receiver) }
|
||||
@@ -681,14 +665,9 @@ private fun PasswordQuality() {
|
||||
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) }
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
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[2].second, selectedItem == passwordQuality[2].first, { selectedItem = passwordQuality[2].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[5].second, selectedItem == passwordQuality[5].first, { selectedItem = passwordQuality[5].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 })
|
||||
for(index in 1..6) {
|
||||
RadioButtonItem(passwordQuality[index].second, selectedItem == passwordQuality[index].first, { selectedItem = passwordQuality[index].first })
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
|
||||
@@ -40,9 +40,7 @@ import com.bintianqi.owndroid.backToHomeStateFlow
|
||||
import com.bintianqi.owndroid.ui.*
|
||||
import com.rosan.dhizuku.api.Dhizuku
|
||||
import com.rosan.dhizuku.api.DhizukuRequestPermissionListener
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@Composable
|
||||
fun DpmPermissions(navCtrl:NavHostController) {
|
||||
|
||||
@@ -343,7 +343,7 @@ private fun Keyguard() {
|
||||
}
|
||||
if(VERSION.SDK_INT >= 26) {
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.evict_credential_encryptoon_key),
|
||||
R.string.evict_credential_encryptoon_key,
|
||||
flag == FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY,
|
||||
{ flag = if(flag==0) {1}else{0} }
|
||||
)
|
||||
@@ -511,9 +511,9 @@ private fun PermissionPolicy() {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.permission_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
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_deny), selectedPolicy == PERMISSION_POLICY_AUTO_DENY, { selectedPolicy = PERMISSION_POLICY_AUTO_DENY })
|
||||
RadioButtonItem(R.string.default_stringres, selectedPolicy == PERMISSION_POLICY_PROMPT, { selectedPolicy = PERMISSION_POLICY_PROMPT })
|
||||
RadioButtonItem(R.string.auto_grant, selectedPolicy == PERMISSION_POLICY_AUTO_GRANT, { selectedPolicy = PERMISSION_POLICY_AUTO_GRANT })
|
||||
RadioButtonItem(R.string.auto_deny, selectedPolicy == PERMISSION_POLICY_AUTO_DENY, { selectedPolicy = PERMISSION_POLICY_AUTO_DENY })
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -538,17 +538,17 @@ private fun MTEPolicy() {
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
var selectedMtePolicy by remember { mutableIntStateOf(dpm.mtePolicy) }
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.decide_by_user),
|
||||
R.string.decide_by_user,
|
||||
selectedMtePolicy == MTE_NOT_CONTROLLED_BY_POLICY,
|
||||
{ selectedMtePolicy = MTE_NOT_CONTROLLED_BY_POLICY }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enabled),
|
||||
R.string.enabled,
|
||||
selectedMtePolicy == MTE_ENABLED,
|
||||
{ selectedMtePolicy = MTE_ENABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.disabled),
|
||||
R.string.disabled,
|
||||
selectedMtePolicy == MTE_DISABLED,
|
||||
{ selectedMtePolicy = MTE_DISABLED }
|
||||
)
|
||||
@@ -557,7 +557,7 @@ private fun MTEPolicy() {
|
||||
try {
|
||||
dpm.mtePolicy = selectedMtePolicy
|
||||
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}catch(e:java.lang.UnsupportedOperationException) {
|
||||
} catch(e:java.lang.UnsupportedOperationException) {
|
||||
Toast.makeText(context, R.string.unsupported, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
selectedMtePolicy = dpm.mtePolicy
|
||||
@@ -583,22 +583,22 @@ private fun NearbyStreamingPolicy() {
|
||||
Text(text = stringResource(R.string.nearby_app_streaming), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.decide_by_user),
|
||||
R.string.decide_by_user,
|
||||
appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY,
|
||||
{ appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enabled),
|
||||
R.string.enabled,
|
||||
appPolicy == NEARBY_STREAMING_ENABLED,
|
||||
{ appPolicy = NEARBY_STREAMING_ENABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.disabled),
|
||||
R.string.disabled,
|
||||
appPolicy == NEARBY_STREAMING_DISABLED,
|
||||
{ appPolicy = NEARBY_STREAMING_DISABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enable_if_secure_enough),
|
||||
R.string.enable_if_secure_enough,
|
||||
appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY,
|
||||
{ appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }
|
||||
)
|
||||
@@ -617,22 +617,22 @@ private fun NearbyStreamingPolicy() {
|
||||
Text(text = stringResource(R.string.nearby_notification_streaming), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.decide_by_user),
|
||||
R.string.decide_by_user,
|
||||
notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY,
|
||||
{ notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enabled),
|
||||
R.string.enabled,
|
||||
notificationPolicy == NEARBY_STREAMING_ENABLED,
|
||||
{ notificationPolicy = NEARBY_STREAMING_ENABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.disabled),
|
||||
R.string.disabled,
|
||||
notificationPolicy == NEARBY_STREAMING_DISABLED,
|
||||
{ notificationPolicy = NEARBY_STREAMING_DISABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enable_if_secure_enough),
|
||||
R.string.enable_if_secure_enough,
|
||||
notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY,
|
||||
{ notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }
|
||||
)
|
||||
@@ -684,43 +684,43 @@ private fun LockTaskMode() {
|
||||
Text(text = stringResource(R.string.lock_task_feature), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
LaunchedEffect(Unit) { refreshFeature() }
|
||||
RadioButtonItem(stringResource(R.string.disable_all), !custom, { custom = false })
|
||||
RadioButtonItem(stringResource(R.string.custom), custom, { custom = true })
|
||||
RadioButtonItem(R.string.disable_all, !custom, { custom = false })
|
||||
RadioButtonItem(R.string.custom, custom, { custom = true })
|
||||
AnimatedVisibility(custom) {
|
||||
Column {
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_sys_info),
|
||||
R.string.ltf_sys_info,
|
||||
LOCK_TASK_FEATURE_SYSTEM_INFO in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_SYSTEM_INFO) }
|
||||
)
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_notifications),
|
||||
R.string.ltf_notifications,
|
||||
LOCK_TASK_FEATURE_NOTIFICATIONS in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_NOTIFICATIONS) }
|
||||
)
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_home),
|
||||
R.string.ltf_home,
|
||||
LOCK_TASK_FEATURE_HOME in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_HOME) }
|
||||
)
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_overview),
|
||||
R.string.ltf_overview,
|
||||
LOCK_TASK_FEATURE_OVERVIEW in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_OVERVIEW) }
|
||||
)
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_global_actions),
|
||||
R.string.ltf_global_actions,
|
||||
LOCK_TASK_FEATURE_GLOBAL_ACTIONS in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_GLOBAL_ACTIONS) }
|
||||
)
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_keyguard),
|
||||
R.string.ltf_keyguard,
|
||||
LOCK_TASK_FEATURE_KEYGUARD in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_KEYGUARD) }
|
||||
)
|
||||
if(VERSION.SDK_INT >= 30) {
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.ltf_block_activity_start_in_task),
|
||||
R.string.ltf_block_activity_start_in_task,
|
||||
LOCK_TASK_FEATURE_BLOCK_ACTIVITY_START_IN_TASK in lockTaskFeatures,
|
||||
{ lockTaskFeatures.toggle(it, LOCK_TASK_FEATURE_BLOCK_ACTIVITY_START_IN_TASK) }
|
||||
)
|
||||
@@ -1004,7 +1004,7 @@ fun FactoryResetProtection() {
|
||||
}
|
||||
AnimatedVisibility(usePolicy) {
|
||||
Column {
|
||||
CheckBoxItem(stringResource(R.string.enable_frp), enabled, { enabled = it })
|
||||
CheckBoxItem(R.string.enable_frp, enabled, { enabled = it })
|
||||
Text(stringResource(R.string.account_list_is))
|
||||
Text(
|
||||
text = if(accountList.isEmpty()) stringResource(R.string.none) else accountList.toText(),
|
||||
@@ -1087,16 +1087,16 @@ private fun WipeData() {
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.wipe_external_storage),
|
||||
R.string.wipe_external_storage,
|
||||
externalStorage, { externalStorage = it }
|
||||
)
|
||||
if(VERSION.SDK_INT >= 22 && context.isDeviceOwner) {
|
||||
CheckBoxItem(stringResource(R.string.wipe_reset_protection_data),
|
||||
CheckBoxItem(R.string.wipe_reset_protection_data,
|
||||
protectionData, { protectionData = it }
|
||||
)
|
||||
}
|
||||
if(VERSION.SDK_INT >= 28) { CheckBoxItem(stringResource(R.string.wipe_euicc), euicc, { euicc = it }) }
|
||||
if(VERSION.SDK_INT >= 29) { CheckBoxItem(stringResource(R.string.wipe_silently), silent, { silent = it }) }
|
||||
if(VERSION.SDK_INT >= 28) { CheckBoxItem(R.string.wipe_euicc, euicc, { euicc = it }) }
|
||||
if(VERSION.SDK_INT >= 29) { CheckBoxItem(R.string.wipe_silently, silent, { silent = it }) }
|
||||
AnimatedVisibility(!silent && VERSION.SDK_INT >= 28) {
|
||||
OutlinedTextField(
|
||||
value = reason, onValueChange = { reason = it },
|
||||
@@ -1189,18 +1189,18 @@ private fun SysUpdatePolicy() {
|
||||
Text(text = stringResource(R.string.system_update_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.system_update_policy_automatic),
|
||||
R.string.system_update_policy_automatic,
|
||||
selectedPolicy == TYPE_INSTALL_AUTOMATIC, { selectedPolicy = TYPE_INSTALL_AUTOMATIC }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.system_update_policy_install_windowed),
|
||||
R.string.system_update_policy_install_windowed,
|
||||
selectedPolicy == TYPE_INSTALL_WINDOWED, { selectedPolicy = TYPE_INSTALL_WINDOWED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.system_update_policy_postpone),
|
||||
R.string.system_update_policy_postpone,
|
||||
selectedPolicy == TYPE_POSTPONE, { selectedPolicy = TYPE_POSTPONE }
|
||||
)
|
||||
RadioButtonItem(stringResource(R.string.none), selectedPolicy == null, { selectedPolicy = null })
|
||||
RadioButtonItem(R.string.none, selectedPolicy == null, { selectedPolicy = null })
|
||||
var windowedPolicyStart by remember { mutableStateOf("") }
|
||||
var windowedPolicyEnd by remember { mutableStateOf("") }
|
||||
if(selectedPolicy == 2) {
|
||||
|
||||
@@ -201,7 +201,7 @@ private fun UserOperation() {
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
if(VERSION.SDK_INT >= 24) {
|
||||
CheckBoxItem(text = stringResource(R.string.use_uid), checked = useUid, operation = { idInput=""; useUid = it })
|
||||
CheckBoxItem(text = R.string.use_uid, checked = useUid, operation = { idInput=""; useUid = it })
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
if(VERSION.SDK_INT > 28) {
|
||||
@@ -295,20 +295,20 @@ private fun CreateUser() {
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
var selectedFlag by remember { mutableIntStateOf(0) }
|
||||
RadioButtonItem(stringResource(R.string.none), selectedFlag == 0, { selectedFlag = 0 })
|
||||
RadioButtonItem(R.string.none, selectedFlag == 0, { selectedFlag = 0 })
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.create_user_skip_wizard),
|
||||
R.string.create_user_skip_wizard,
|
||||
selectedFlag == DevicePolicyManager.SKIP_SETUP_WIZARD,
|
||||
{ selectedFlag = DevicePolicyManager.SKIP_SETUP_WIZARD }
|
||||
)
|
||||
if(VERSION.SDK_INT >= 28) {
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.create_user_ephemeral_user),
|
||||
R.string.create_user_ephemeral_user,
|
||||
selectedFlag == DevicePolicyManager.MAKE_USER_EPHEMERAL,
|
||||
{ selectedFlag = DevicePolicyManager.MAKE_USER_EPHEMERAL }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.create_user_enable_all_system_app),
|
||||
R.string.create_user_enable_all_system_app,
|
||||
selectedFlag == DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED,
|
||||
{ selectedFlag = DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED }
|
||||
)
|
||||
@@ -507,7 +507,7 @@ private fun UserIcon() {
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Text(text = stringResource(R.string.pick_a_square_image))
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
CheckBoxItem(stringResource(R.string.file_picker_instead_gallery), getContent, { getContent = it })
|
||||
CheckBoxItem(R.string.file_picker_instead_gallery, getContent, { getContent = it })
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
|
||||
@@ -77,6 +77,16 @@ fun Information(content: @Composable ()->Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RadioButtonItem(
|
||||
@StringRes text: Int,
|
||||
selected: Boolean,
|
||||
operation: () -> Unit,
|
||||
textColor: Color = colorScheme.onBackground
|
||||
) {
|
||||
RadioButtonItem(stringResource(text), selected, operation, textColor)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RadioButtonItem(
|
||||
text: String,
|
||||
@@ -96,7 +106,7 @@ fun RadioButtonItem(
|
||||
|
||||
@Composable
|
||||
fun CheckBoxItem(
|
||||
text: String,
|
||||
@StringRes text: Int,
|
||||
checked: Boolean,
|
||||
operation: (Boolean) -> Unit,
|
||||
textColor: Color = colorScheme.onBackground
|
||||
@@ -110,7 +120,7 @@ fun CheckBoxItem(
|
||||
checked = checked,
|
||||
onCheckedChange = operation
|
||||
)
|
||||
Text(text = text, color = textColor, modifier = Modifier.padding(bottom = if(zhCN) { 2 } else { 0 }.dp))
|
||||
Text(text = stringResource(text), color = textColor, modifier = Modifier.padding(bottom = if(zhCN) { 2 } else { 0 }.dp))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user