mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
reformat code
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -60,4 +60,4 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: OwnDroid-CI-${{ env.SHORT_SHA }}-release-signed.apk
|
||||
path: app/build/outputs/apk/debug/app-debug.apk
|
||||
path: app/build/outputs/apk/debug/app-release.apk
|
||||
|
||||
@@ -148,9 +148,9 @@ private fun HomePage(navCtrl:NavHostController, pkgName: MutableState<String>){
|
||||
val activateType = stringResource(
|
||||
if(isDeviceOwner(dpm)) { R.string.device_owner }
|
||||
else if(isProfileOwner(dpm)) {
|
||||
if(VERSION.SDK_INT>=24&&dpm.isManagedProfile(receiver)){R.string.work_profile_owner}else{R.string.profile_owner}
|
||||
if(VERSION.SDK_INT >= 24 && dpm.isManagedProfile(receiver)) R.string.work_profile_owner else R.string.profile_owner
|
||||
}
|
||||
else if(dpm.isAdminActive(receiver)){R.string.device_admin}else{R.string.click_to_activate}
|
||||
else if(dpm.isAdminActive(receiver)) R.string.device_admin else R.string.click_to_activate
|
||||
)
|
||||
LaunchedEffect(Unit) { pkgName.value = "" }
|
||||
Column(modifier = Modifier.background(colorScheme.background).statusBarsPadding().verticalScroll(rememberScrollState())) {
|
||||
@@ -172,14 +172,14 @@ private fun HomePage(navCtrl:NavHostController, pkgName: MutableState<String>){
|
||||
) {
|
||||
Spacer(modifier = Modifier.padding(start = 22.dp))
|
||||
Icon(
|
||||
painter = painterResource(if(dpm.isAdminActive(receiver)){ R.drawable.check_circle_fill1 }else{ R.drawable.block_fill0 }),
|
||||
painter = painterResource(if(dpm.isAdminActive(receiver)) R.drawable.check_circle_fill1 else R.drawable.block_fill0),
|
||||
contentDescription = null,
|
||||
tint = colorScheme.onPrimary
|
||||
)
|
||||
Spacer(modifier = Modifier.padding(start = 10.dp))
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(if(dpm.isAdminActive(receiver)){R.string.activated}else{R.string.deactivated}),
|
||||
text = stringResource(if(dpm.isAdminActive(receiver)) R.string.activated else R.string.deactivated),
|
||||
style = typography.headlineSmall,
|
||||
color = colorScheme.onPrimary,
|
||||
modifier = Modifier.padding(bottom = 2.dp)
|
||||
|
||||
@@ -27,16 +27,8 @@ import com.bintianqi.owndroid.ui.*
|
||||
fun AppSetting(navCtrl:NavHostController, materialYou: MutableState<Boolean>, blackTheme: MutableState<Boolean>) {
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
/*val titleMap = mapOf(
|
||||
"About" to R.string.about
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.setting))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry, navCtrl, localNavCtrl)
|
||||
}
|
||||
) {
|
||||
|
||||
@@ -88,12 +88,9 @@ fun ApplicationManage(navCtrl:NavHostController, pkgName: MutableState<String>,
|
||||
)
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.app_manage))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry, navCtrl, localNavCtrl){Text(text = stringResource(titleMap[backStackEntry?.destination?.route] ?: R.string.app_manager))}
|
||||
TopBar(backStackEntry, navCtrl, localNavCtrl) {
|
||||
Text(text = stringResource(titleMap[backStackEntry?.destination?.route] ?: R.string.app_manager))
|
||||
}
|
||||
}
|
||||
) { paddingValues->
|
||||
Column(
|
||||
@@ -429,13 +426,12 @@ private fun CrossProfilePkg(pkgName: String){
|
||||
LaunchedEffect(Unit) { refresh() }
|
||||
Text(text = stringResource(R.string.app_list_is))
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize()) {
|
||||
Text(text = if(list==""){stringResource(R.string.none)}else{list})
|
||||
Text(text = if(list=="") stringResource(R.string.none) else list)
|
||||
}
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
Button(
|
||||
onClick = {
|
||||
if(pkgName!=""){
|
||||
crossProfilePkg.add(pkgName)}
|
||||
if(pkgName!="") { crossProfilePkg.add(pkgName) }
|
||||
dpm.setCrossProfilePackages(receiver, crossProfilePkg)
|
||||
refresh()
|
||||
},
|
||||
@@ -445,8 +441,7 @@ private fun CrossProfilePkg(pkgName: String){
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
if(pkgName!=""){
|
||||
crossProfilePkg.remove(pkgName)}
|
||||
if(pkgName!="") { crossProfilePkg.remove(pkgName) }
|
||||
dpm.setCrossProfilePackages(receiver, crossProfilePkg)
|
||||
refresh()
|
||||
},
|
||||
@@ -477,7 +472,7 @@ private fun CrossProfileWidget(pkgName: String){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Text(text = stringResource(R.string.app_list_is))
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize()) {
|
||||
Text(text = if(list==""){stringResource(R.string.none)}else{list})
|
||||
Text(text = if(list=="") stringResource(R.string.none) else list)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
@@ -524,23 +519,37 @@ private fun CredentialManagePolicy(pkgName: String){
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.credential_manage_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(stringResource(R.string.none),{policyType==-1},{policyType=-1})
|
||||
RadioButtonItem(stringResource(R.string.blacklist),{policyType==PACKAGE_POLICY_BLOCKLIST},{policyType=PACKAGE_POLICY_BLOCKLIST})
|
||||
RadioButtonItem(stringResource(R.string.whitelist),{policyType==PACKAGE_POLICY_ALLOWLIST},{policyType=PACKAGE_POLICY_ALLOWLIST})
|
||||
RadioButtonItem(stringResource(R.string.whitelist_and_system_app),{policyType==PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM},{policyType=PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.none),
|
||||
{ policyType==-1 }, { policyType=-1 }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.blacklist),
|
||||
{ policyType==PACKAGE_POLICY_BLOCKLIST },
|
||||
{ policyType=PACKAGE_POLICY_BLOCKLIST }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.whitelist),
|
||||
{policyType==PACKAGE_POLICY_ALLOWLIST},
|
||||
{policyType=PACKAGE_POLICY_ALLOWLIST}
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.whitelist_and_system_app),
|
||||
{ policyType==PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM },
|
||||
{ policyType=PACKAGE_POLICY_ALLOWLIST_AND_SYSTEM }
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
AnimatedVisibility(policyType!=-1) {
|
||||
Column {
|
||||
Text(stringResource(R.string.app_list_is))
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())) {
|
||||
Text(text = if(credentialListText!=""){ credentialListText }else{ stringResource(R.string.none) })
|
||||
Text(text = if(credentialListText!="") credentialListText else stringResource(R.string.none))
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
Button(
|
||||
onClick = {
|
||||
if(pkgName!=""){
|
||||
credentialList.add(pkgName)}
|
||||
if(pkgName!="") { credentialList.add(pkgName) }
|
||||
credentialListText = credentialList.toText()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
@@ -549,8 +558,7 @@ private fun CredentialManagePolicy(pkgName: String){
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
if(pkgName!=""){
|
||||
credentialList.remove(pkgName)}
|
||||
if(pkgName!="") { credentialList.remove(pkgName) }
|
||||
credentialListText = credentialList.toText()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
@@ -603,7 +611,7 @@ private fun PermittedAccessibility(pkgName: String){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Text(text = stringResource(R.string.app_list_is))
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize()) {
|
||||
Text(text = if(listText==""){stringResource(R.string.none)}else{listText})
|
||||
Text(text = if(listText=="") stringResource(R.string.none) else listText)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
@@ -625,7 +633,7 @@ private fun PermittedAccessibility(pkgName: String){
|
||||
focusMgr.clearFocus()
|
||||
Toast.makeText(
|
||||
context,
|
||||
if(dpm.setPermittedAccessibilityServices(receiver, permittedAccessibility)){R.string.success}else{R.string.fail},
|
||||
if(dpm.setPermittedAccessibilityServices(receiver, permittedAccessibility)) R.string.success else R.string.fail ,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
val getList = dpm.getPermittedAccessibilityServices(receiver)
|
||||
@@ -658,7 +666,7 @@ private fun PermittedIME(pkgName: String){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Text(text = stringResource(R.string.app_list_is))
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())) {
|
||||
Text(text = if(imeListText==""){stringResource(R.string.none)}else{imeListText})
|
||||
Text(text = if(imeListText=="") stringResource(R.string.none) else imeListText)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
@@ -680,7 +688,7 @@ private fun PermittedIME(pkgName: String){
|
||||
focusMgr.clearFocus()
|
||||
Toast.makeText(
|
||||
context,
|
||||
if(dpm.setPermittedInputMethods(receiver, permittedIme)){R.string.success}else{R.string.fail},
|
||||
if(dpm.setPermittedInputMethods(receiver, permittedIme)) R.string.success else R.string.fail,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
val getList = dpm.getPermittedInputMethods(receiver)
|
||||
@@ -714,7 +722,7 @@ private fun KeepUninstalledApp(pkgName: String){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Text(text = stringResource(R.string.app_list_is))
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState()).animateContentSize(scrollAnim())) {
|
||||
Text(text = if(listText==""){stringResource(R.string.none)}else{listText})
|
||||
Text(text = if(listText=="") stringResource(R.string.none) else listText)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
@@ -848,7 +856,10 @@ private fun ClearAppData(pkgName: String){
|
||||
val onClear = DevicePolicyManager.OnClearApplicationUserDataListener { pkg: String, succeed: Boolean ->
|
||||
Looper.prepare()
|
||||
focusMgr.clearFocus()
|
||||
val toastText = if(pkg!=""){"$pkg\n"}else{""} + context.getString(R.string.clear_data) + context.getString(if(succeed){R.string.success}else{R.string.fail})
|
||||
val toastText =
|
||||
if(pkg!="") { "$pkg\n" }else{ "" } +
|
||||
context.getString(R.string.clear_data) +
|
||||
context.getString(if(succeed) { R.string.success } else { R.string.fail })
|
||||
Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show()
|
||||
Looper.loop()
|
||||
}
|
||||
@@ -912,7 +923,7 @@ fun AppControlDialog(status: MutableIntState){
|
||||
modifier = Modifier.padding(start = 5.dp)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.current_status_is) + stringResource(if(enabled){R.string.enabled}else{R.string.disabled}),
|
||||
text = stringResource(R.string.current_status_is) + stringResource(if(enabled) R.string.enabled else R.string.disabled),
|
||||
modifier = Modifier.padding(start = 5.dp, top = 5.dp, bottom = 5.dp)
|
||||
)
|
||||
Row(
|
||||
|
||||
@@ -43,20 +43,8 @@ import com.bintianqi.owndroid.ui.*
|
||||
fun ManagedProfile(navCtrl: NavHostController) {
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
/*val titleMap = mapOf(
|
||||
"OrgOwnedWorkProfile" to R.string.org_owned_work_profile,
|
||||
"CreateWorkProfile" to R.string.create_work_profile,
|
||||
"SuspendPersonalApp" to R.string.suspend_personal_app,
|
||||
"IntentFilter" to R.string.intent_filter,
|
||||
"OrgID" to R.string.org_id
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.work_profile))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry, navCtrl, localNavCtrl)
|
||||
}
|
||||
) {
|
||||
@@ -83,8 +71,14 @@ private fun Home(navCtrl: NavHostController){
|
||||
val context = LocalContext.current
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context, Receiver::class.java)
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
Text(text = stringResource(R.string.work_profile), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp))
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.work_profile),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
||||
)
|
||||
if(VERSION.SDK_INT >= 30&&isProfileOwner(dpm) && dpm.isManagedProfile(receiver)) {
|
||||
SubPageItem(R.string.org_owned_work_profile, "", R.drawable.corporate_fare_fill0) { navCtrl.navigate("OrgOwnedWorkProfile") }
|
||||
}
|
||||
@@ -211,7 +205,8 @@ private fun SuspendPersonalApp(){
|
||||
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
SwitchItem(
|
||||
R.string.suspend_personal_app,"",null,{dpm.getPersonalAppsSuspendedReasons(receiver)!=PERSONAL_APPS_NOT_SUSPENDED},
|
||||
R.string.suspend_personal_app, "", null,
|
||||
{ dpm.getPersonalAppsSuspendedReasons(receiver)!=PERSONAL_APPS_NOT_SUSPENDED },
|
||||
{ dpm.setPersonalAppsSuspended(receiver,it) }
|
||||
)
|
||||
var time by remember { mutableStateOf("") }
|
||||
@@ -219,7 +214,12 @@ private fun SuspendPersonalApp(){
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.profile_max_time_off), style = typography.titleLarge)
|
||||
Text(text = stringResource(R.string.profile_max_time_out_desc))
|
||||
Text(text = stringResource(R.string.personal_app_suspended_because_timeout, dpm.getPersonalAppsSuspendedReasons(receiver)==PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT))
|
||||
Text(
|
||||
text = stringResource(
|
||||
R.string.personal_app_suspended_because_timeout,
|
||||
dpm.getPersonalAppsSuspendedReasons(receiver) == PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT
|
||||
)
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = time, onValueChange = { time=it }, modifier = Modifier.focusable().fillMaxWidth().padding(vertical = 2.dp),
|
||||
label = { Text(stringResource(R.string.time_unit_ms)) },
|
||||
|
||||
@@ -52,22 +52,8 @@ fun Network(navCtrl: NavHostController){
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
val scrollState = rememberScrollState()
|
||||
/*val titleMap = mapOf(
|
||||
"Home" to R.string.network,
|
||||
"MinWifiSecurityLevel" to R.string.min_wifi_security_level,
|
||||
"WifiSsidPolicy" to R.string.wifi_ssid_policy,
|
||||
"PrivateDNS" to R.string.private_dns,
|
||||
"NetLog" to R.string.retrieve_net_logs,
|
||||
"WifiKeypair" to R.string.wifi_keypair,
|
||||
"APN" to R.string.apn_settings
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.network))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry,navCtrl,localNavCtrl) {
|
||||
if(backStackEntry?.destination?.route == "Home" && scrollState.maxValue > 80) {
|
||||
Text(
|
||||
@@ -104,7 +90,11 @@ private fun Home(navCtrl:NavHostController,scrollState: ScrollState){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context, Receiver::class.java)
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {
|
||||
Text(text = stringResource(R.string.network), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.network),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
||||
)
|
||||
if(VERSION.SDK_INT>=24&&isDeviceOwner(dpm)) {
|
||||
val wifimac = dpm.getWifiMacAddress(receiver)
|
||||
Text(text = "WiFi MAC: $wifimac", modifier = Modifier.padding(start = 15.dp))
|
||||
@@ -166,10 +156,26 @@ private fun WifiSecLevel(){
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
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), {selectedWifiSecLevel==WIFI_SECURITY_OPEN}, {selectedWifiSecLevel= WIFI_SECURITY_OPEN})
|
||||
RadioButtonItem("WEP, WPA(2)-PSK", {selectedWifiSecLevel==WIFI_SECURITY_PERSONAL}, {selectedWifiSecLevel= WIFI_SECURITY_PERSONAL})
|
||||
RadioButtonItem("WPA-EAP", {selectedWifiSecLevel==WIFI_SECURITY_ENTERPRISE_EAP}, {selectedWifiSecLevel= WIFI_SECURITY_ENTERPRISE_EAP})
|
||||
RadioButtonItem("WPA3-192bit", {selectedWifiSecLevel==WIFI_SECURITY_ENTERPRISE_192}, {selectedWifiSecLevel= WIFI_SECURITY_ENTERPRISE_192})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.wifi_security_level_open),
|
||||
{ selectedWifiSecLevel == WIFI_SECURITY_OPEN },
|
||||
{ selectedWifiSecLevel = WIFI_SECURITY_OPEN }
|
||||
)
|
||||
RadioButtonItem(
|
||||
"WEP, WPA(2)-PSK",
|
||||
{ selectedWifiSecLevel == WIFI_SECURITY_PERSONAL },
|
||||
{ selectedWifiSecLevel = WIFI_SECURITY_PERSONAL }
|
||||
)
|
||||
RadioButtonItem(
|
||||
"WPA-EAP",
|
||||
{ selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_EAP },
|
||||
{ selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_EAP }
|
||||
)
|
||||
RadioButtonItem(
|
||||
"WPA3-192bit",
|
||||
{ selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_192 },
|
||||
{ selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_192 }
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
enabled = isDeviceOwner(dpm) || (isProfileOwner(dpm) && dpm.isOrganizationOwnedDeviceWithManagedProfile),
|
||||
@@ -204,9 +210,21 @@ private fun WifiSsidPolicy(){
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.wifi_ssid_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
RadioButtonItem(stringResource(R.string.none),{selectedPolicyType==-1},{selectedPolicyType=-1})
|
||||
RadioButtonItem(stringResource(R.string.whitelist),{selectedPolicyType==WIFI_SSID_POLICY_TYPE_ALLOWLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_ALLOWLIST})
|
||||
RadioButtonItem(stringResource(R.string.blacklist),{selectedPolicyType==WIFI_SSID_POLICY_TYPE_DENYLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_DENYLIST})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.none),
|
||||
{ selectedPolicyType == -1 },
|
||||
{ selectedPolicyType = -1 }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.whitelist),
|
||||
{ selectedPolicyType == WIFI_SSID_POLICY_TYPE_ALLOWLIST },
|
||||
{ selectedPolicyType = WIFI_SSID_POLICY_TYPE_ALLOWLIST }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.blacklist),
|
||||
{ selectedPolicyType == WIFI_SSID_POLICY_TYPE_DENYLIST },
|
||||
{ selectedPolicyType = WIFI_SSID_POLICY_TYPE_DENYLIST }
|
||||
)
|
||||
Column(modifier = Modifier.animateContentSize(scrollAnim()).horizontalScroll(rememberScrollState())) {
|
||||
if(ssidList!="") {
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
@@ -414,7 +432,7 @@ private fun WifiKeypair(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = dpm.grantKeyPairToWifiAuth(keyPair)
|
||||
Toast.makeText(context, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(result) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
) {
|
||||
@@ -423,7 +441,7 @@ private fun WifiKeypair(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = dpm.revokeKeyPairFromWifiAuth(keyPair)
|
||||
Toast.makeText(context, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(result) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
) {
|
||||
@@ -471,7 +489,7 @@ private fun APN(){
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = inputNum != "" && (nextStep || inputNum=="0" || setting[inputNum.toInt()-1] != null)
|
||||
) {
|
||||
Text(stringResource(if(nextStep){R.string.previous_step}else{R.string.next_step}))
|
||||
Text(stringResource(if(nextStep) R.string.previous_step else R.string.next_step))
|
||||
}
|
||||
var result = Builder().build()
|
||||
AnimatedVisibility(nextStep) {
|
||||
@@ -535,7 +553,11 @@ private fun APN(){
|
||||
keyboardActions = KeyboardActions(onDone = { focusMgr.clearFocus() }),
|
||||
modifier = Modifier.focusable().fillMaxWidth().padding(top = 2.dp, bottom = 4.dp)
|
||||
)
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(text = stringResource(R.string.enable), style = typography.titleLarge)
|
||||
Switch(checked = carrierEnabled, onCheckedChange = {carrierEnabled=it })
|
||||
}
|
||||
@@ -563,7 +585,7 @@ private fun APN(){
|
||||
}
|
||||
|
||||
Text(text = stringResource(R.string.auth_type), style = typography.titleLarge)
|
||||
RadioButtonItem("无",{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("PAP", { selectedAuthType==AUTH_TYPE_PAP}, { selectedAuthType=AUTH_TYPE_PAP })
|
||||
RadioButtonItem("PAP/CHAP", { selectedAuthType==AUTH_TYPE_PAP_OR_CHAP}, { selectedAuthType=AUTH_TYPE_PAP_OR_CHAP })
|
||||
@@ -709,7 +731,11 @@ private fun APN(){
|
||||
)
|
||||
|
||||
if(VERSION.SDK_INT>=33) {
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(text = stringResource(R.string.persistent), style = typography.titleLarge)
|
||||
Switch(checked = persistent, onCheckedChange = { persistent=it })
|
||||
}
|
||||
@@ -762,12 +788,11 @@ private fun APN(){
|
||||
builder.setRoamingProtocol(roamingProtocol)
|
||||
result = builder.build()
|
||||
}
|
||||
|
||||
finalStep=!finalStep
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(stringResource(if(finalStep){R.string.previous_step}else{R.string.next_step}))
|
||||
Text(stringResource(if(finalStep) R.string.previous_step else R.string.next_step))
|
||||
}
|
||||
AnimatedVisibility(finalStep) {
|
||||
if(inputNum=="0") {
|
||||
@@ -782,7 +807,7 @@ private fun APN(){
|
||||
Button(
|
||||
onClick = {
|
||||
val success = dpm.updateOverrideApn(receiver,id,result)
|
||||
Toast.makeText(context, if(success){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(success) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
Modifier.fillMaxWidth(0.49F)
|
||||
) {
|
||||
@@ -791,7 +816,7 @@ private fun APN(){
|
||||
Button(
|
||||
onClick = {
|
||||
val success = dpm.removeOverrideApn(receiver,id)
|
||||
Toast.makeText(context, if(success){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(success) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
Modifier.fillMaxWidth(0.96F)
|
||||
) {
|
||||
|
||||
@@ -42,25 +42,8 @@ fun Password(navCtrl: NavHostController){
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
val scrollState = rememberScrollState()
|
||||
/*val titleMap = mapOf(
|
||||
"ResetPasswordToken" to R.string.reset_password_token,
|
||||
"PasswordInfo" to R.string.password_info,
|
||||
"ResetPassword" to R.string.reset_password,
|
||||
"RequirePasswordComplexity" to R.string.required_password_complexity,
|
||||
"KeyguardDisabledFeatures" to R.string.keyguard_disabled_features,
|
||||
"MaxTimeToLock" to R.string.max_time_to_lock,
|
||||
"PasswordTimeout" to R.string.pwd_timeout,
|
||||
"MaxPasswordFail" to R.string.max_pwd_fail,
|
||||
"PasswordHistoryLength" to R.string.pwd_history,
|
||||
"RequirePasswordQuality" to R.string.required_password_quality,
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.password_and_keyguard))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry,navCtrl,localNavCtrl) {
|
||||
if(backStackEntry?.destination?.route == "Home" && scrollState.maxValue > 80) {
|
||||
Text(
|
||||
@@ -97,7 +80,11 @@ fun Password(navCtrl: NavHostController){
|
||||
@Composable
|
||||
private fun Home(navCtrl:NavHostController,scrollState: ScrollState) {
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {
|
||||
Text(text = stringResource(R.string.password_and_keyguard), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.password_and_keyguard),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
||||
)
|
||||
SubPageItem(R.string.password_info, "", R.drawable.info_fill0) { navCtrl.navigate("PasswordInfo") }
|
||||
if(VERSION.SDK_INT >= 26) {
|
||||
SubPageItem(R.string.reset_password_token, "", R.drawable.key_vertical_fill0) { navCtrl.navigate("ResetPasswordToken") }
|
||||
@@ -162,8 +149,11 @@ private fun ResetPasswordToken(){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
if(dpm.clearResetPasswordToken(receiver)){ Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{ Toast.makeText(context, R.string.fail, Toast.LENGTH_SHORT).show() }
|
||||
Toast.makeText(
|
||||
context,
|
||||
if(dpm.clearResetPasswordToken(receiver)) R.string.success else R.string.fail,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = isDeviceOwner(dpm) || isProfileOwner(dpm)
|
||||
@@ -173,11 +163,11 @@ private fun ResetPasswordToken(){
|
||||
Button(
|
||||
onClick = {
|
||||
try {
|
||||
if(dpm.setResetPasswordToken(receiver, tokenByteArray)){
|
||||
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Toast.makeText(context, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
Toast.makeText(
|
||||
context,
|
||||
if(dpm.setResetPasswordToken(receiver, tokenByteArray)) R.string.success else R.string.fail,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}catch(e:SecurityException) {
|
||||
Toast.makeText(context, R.string.security_exception, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
@@ -233,25 +223,30 @@ private fun ResetPassword(){
|
||||
if(VERSION.SDK_INT >= 23) {
|
||||
RadioButtonItem(
|
||||
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(stringResource(R.string.reset_password_require_entry),{resetPwdFlag==RESET_PASSWORD_REQUIRE_ENTRY}, {resetPwdFlag=RESET_PASSWORD_REQUIRE_ENTRY})
|
||||
RadioButtonItem(
|
||||
stringResource(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 })
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
if(newPwd.length>=4||newPwd.isEmpty()){ confirmed=!confirmed
|
||||
}else{ Toast.makeText(context, R.string.require_4_digit_password, Toast.LENGTH_SHORT).show() }
|
||||
if(newPwd.length>=4 || newPwd.isEmpty()) { confirmed=!confirmed }
|
||||
else { Toast.makeText(context, R.string.require_4_digit_password, Toast.LENGTH_SHORT).show() }
|
||||
},
|
||||
enabled = isDeviceOwner(dpm) || isProfileOwner(dpm) || dpm.isAdminActive(receiver),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = if(confirmed){ colorScheme.primary }else{ colorScheme.error },
|
||||
contentColor = if(confirmed){ colorScheme.onPrimary }else{ colorScheme.onError }
|
||||
containerColor = if(confirmed) colorScheme.primary else colorScheme.error,
|
||||
contentColor = if(confirmed) colorScheme.onPrimary else colorScheme.onError
|
||||
)
|
||||
) {
|
||||
Text(text = stringResource(if(confirmed){R.string.cancel}else{R.string.confirm}))
|
||||
Text(text = stringResource(if(confirmed) R.string.cancel else R.string.confirm))
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
if(VERSION.SDK_INT >= 26) {
|
||||
@@ -305,10 +300,26 @@ 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})
|
||||
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 }
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
|
||||
Button(
|
||||
@@ -338,7 +349,7 @@ private fun ScreenTimeout(){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context,Receiver::class.java)
|
||||
val focusMgr = LocalFocusManager.current
|
||||
var inputContent by remember{ mutableStateOf(if(isDeviceOwner(dpm)){dpm.getMaximumTimeToLock(receiver).toString()}else{""}) }
|
||||
var inputContent by remember { mutableStateOf(if(isDeviceOwner(dpm)) dpm.getMaximumTimeToLock(receiver).toString() else "") }
|
||||
var ableToApply by remember { mutableStateOf(inputContent!="") }
|
||||
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
@@ -374,7 +385,7 @@ private fun MaxFailedPasswordForWipe(){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context,Receiver::class.java)
|
||||
val focusMgr = LocalFocusManager.current
|
||||
var inputContent by remember{ mutableStateOf(if(isDeviceOwner(dpm)){dpm.getMaximumFailedPasswordsForWipe(receiver).toString()}else{""}) }
|
||||
var inputContent by remember { mutableStateOf(if(isDeviceOwner(dpm)) dpm.getMaximumFailedPasswordsForWipe(receiver).toString() else "") }
|
||||
var ableToApply by remember { mutableStateOf(inputContent != "" && inputContent != "0") }
|
||||
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
@@ -410,7 +421,7 @@ private fun PasswordExpiration(){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context,Receiver::class.java)
|
||||
val focusMgr = LocalFocusManager.current
|
||||
var inputContent by remember{ mutableStateOf(if(isDeviceOwner(dpm)){dpm.getPasswordExpirationTimeout(receiver).toString()}else{""}) }
|
||||
var inputContent by remember { mutableStateOf(if(isDeviceOwner(dpm)) dpm.getPasswordExpirationTimeout(receiver).toString() else "") }
|
||||
var ableToApply by remember { mutableStateOf(inputContent != "") }
|
||||
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
@@ -446,7 +457,7 @@ private fun PasswordHistoryLength(){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context,Receiver::class.java)
|
||||
val focusMgr = LocalFocusManager.current
|
||||
var inputContent by remember{ mutableStateOf(if(isDeviceOwner(dpm)){dpm.getPasswordHistoryLength(receiver).toString()}else{""}) }
|
||||
var inputContent by remember { mutableStateOf(if(isDeviceOwner(dpm)) dpm.getPasswordHistoryLength(receiver).toString() else "") }
|
||||
var ableToApply by remember { mutableStateOf(inputContent!="") }
|
||||
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
|
||||
@@ -44,27 +44,8 @@ fun DpmPermissions(navCtrl:NavHostController){
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
val scrollState = rememberScrollState()
|
||||
/*val titleMap = mapOf(
|
||||
"Home" to R.string.permission,
|
||||
"Shizuku" to R.string.shizuku,
|
||||
"DeviceAdmin" to R.string.device_admin,
|
||||
"ProfileOwner" to R.string.profile_owner,
|
||||
"DeviceOwner" to R.string.device_owner,
|
||||
"DeviceInfo" to R.string.device_info,
|
||||
"SpecificID" to R.string.enrollment_specific_id,
|
||||
"OrgName" to R.string.org_name,
|
||||
"NoManagementAccount" to R.string.account_types_management_disabled,
|
||||
"LockScreenInfo" to R.string.owner_lockscr_info,
|
||||
"SupportMsg" to R.string.support_msg,
|
||||
"TransformOwnership" to R.string.transform_ownership
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.permission))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry,navCtrl,localNavCtrl) {
|
||||
if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80) {
|
||||
Text(
|
||||
@@ -105,20 +86,24 @@ private fun Home(localNavCtrl:NavHostController,listScrollState:ScrollState){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context, Receiver::class.java)
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(listScrollState)) {
|
||||
Text(text = stringResource(R.string.permission), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.permission),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
||||
)
|
||||
SubPageItem(
|
||||
R.string.device_admin, stringResource(if(dpm.isAdminActive(receiver)){R.string.activated}else{R.string.deactivated}),
|
||||
R.string.device_admin, stringResource(if(dpm.isAdminActive(receiver)) R.string.activated else R.string.deactivated),
|
||||
operation = { localNavCtrl.navigate("DeviceAdmin") }
|
||||
)
|
||||
if(!isDeviceOwner(dpm)) {
|
||||
SubPageItem(
|
||||
R.string.profile_owner, stringResource(if(isProfileOwner(dpm)){R.string.activated}else{R.string.deactivated}),
|
||||
R.string.profile_owner, stringResource(if(isProfileOwner(dpm)) R.string.activated else R.string.deactivated),
|
||||
operation = { localNavCtrl.navigate("ProfileOwner") }
|
||||
)
|
||||
}
|
||||
if(!isProfileOwner(dpm)) {
|
||||
SubPageItem(
|
||||
R.string.device_owner, stringResource(if(isDeviceOwner(dpm)){R.string.activated}else{R.string.deactivated}),
|
||||
R.string.device_owner, stringResource(if(isDeviceOwner(dpm)) R.string.activated else R.string.deactivated),
|
||||
operation = { localNavCtrl.navigate("DeviceOwner") }
|
||||
)
|
||||
}
|
||||
@@ -195,7 +180,7 @@ private fun DeviceAdmin(){
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 8.dp)) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.device_admin), style = typography.headlineLarge)
|
||||
Text(text = stringResource(if(dpm.isAdminActive(receiver)) { R.string.activated } else { R.string.deactivated }), style = typography.titleLarge)
|
||||
Text(text = stringResource(if(dpm.isAdminActive(receiver)) R.string.activated else R.string.deactivated), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
AnimatedVisibility(showDeactivateButton) {
|
||||
Button(
|
||||
@@ -233,7 +218,7 @@ private fun ProfileOwner(){
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 8.dp)) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.profile_owner), style = typography.headlineLarge)
|
||||
Text(stringResource(if(isProfileOwner(dpm)){R.string.activated}else{R.string.deactivated}), style = typography.titleLarge)
|
||||
Text(stringResource(if(isProfileOwner(dpm)) R.string.activated else R.string.deactivated), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
if(VERSION.SDK_INT>=24) {
|
||||
AnimatedVisibility(showDeactivateButton) {
|
||||
@@ -270,7 +255,7 @@ private fun DeviceOwner(){
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 8.dp)) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.device_owner), style = typography.headlineLarge)
|
||||
Text(text = stringResource(if(isDeviceOwner(dpm)){R.string.activated}else{R.string.deactivated}), style = typography.titleLarge)
|
||||
Text(text = stringResource(if(isDeviceOwner(dpm)) R.string.activated else R.string.deactivated), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
AnimatedVisibility(showDeactivateButton) {
|
||||
Button(
|
||||
@@ -309,7 +294,7 @@ fun DeviceInfo(){
|
||||
Spacer(Modifier.padding(vertical = 2.dp))
|
||||
if(VERSION.SDK_INT >= 33) {
|
||||
val dpmRole = dpm.devicePolicyManagementRoleHolderPackage
|
||||
Text(stringResource(R.string.dpmrh, if(dpmRole==null) { stringResource(R.string.none) } else { "" }))
|
||||
Text(stringResource(R.string.dpmrh, if(dpmRole == null) stringResource(R.string.none) else ""))
|
||||
if(dpmRole!=null) {
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState())) {
|
||||
Text(text = dpmRole)
|
||||
@@ -476,7 +461,7 @@ private fun NoManageAccount(){
|
||||
var inited by remember { mutableStateOf(false) }
|
||||
if(!inited) { refreshList(); inited=true }
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Text(text = if(accountList==""){stringResource(R.string.none)}else{accountList})
|
||||
Text(text = if(accountList=="") stringResource(R.string.none) else accountList)
|
||||
var inputText by remember{ mutableStateOf("") }
|
||||
OutlinedTextField(
|
||||
value = inputText,
|
||||
|
||||
@@ -55,28 +55,8 @@ fun SystemManage(navCtrl:NavHostController){
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
val scrollState = rememberScrollState()
|
||||
/*val titleMap = mapOf(
|
||||
"Switches" to R.string.options,
|
||||
"Keyguard" to R.string.keyguard,
|
||||
"BugReport" to R.string.request_bug_report,
|
||||
"Reboot" to R.string.reboot,
|
||||
"EditTime" to R.string.edit_time,
|
||||
"PermissionPolicy" to R.string.permission_policy,
|
||||
"MTEPolicy" to R.string.mte_policy,
|
||||
"NearbyStreamingPolicy" to R.string.nearby_streaming_policy,
|
||||
"LockTaskFeatures" to R.string.lock_task_feature,
|
||||
"CaCert" to R.string.ca_cert,
|
||||
"SecurityLogs" to R.string.security_logs,
|
||||
"SystemUpdatePolicy" to R.string.system_update_policy,
|
||||
"WipeData" to R.string.wipe_data
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.device_ctrl))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry,navCtrl,localNavCtrl) {
|
||||
if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80) {
|
||||
Text(
|
||||
@@ -118,7 +98,11 @@ private fun Home(navCtrl: NavHostController,scrollState: ScrollState){
|
||||
val context = LocalContext.current
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {
|
||||
Text(text = stringResource(R.string.system_manage), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.system_manage),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
||||
)
|
||||
if(isDeviceOwner(dpm) || isProfileOwner(dpm)) {
|
||||
SubPageItem(R.string.options, "", R.drawable.tune_fill0) { navCtrl.navigate("Switches") }
|
||||
}
|
||||
@@ -239,7 +223,7 @@ private fun Keyguard(){
|
||||
if(VERSION.SDK_INT >= 23) {
|
||||
Button(
|
||||
onClick = {
|
||||
Toast.makeText(context, if(dpm.setKeyguardDisabled(receiver,true)){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(dpm.setKeyguardDisabled(receiver,true)) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(dpm) || (VERSION.SDK_INT >= 28 && isProfileOwner(dpm) && dpm.isAffiliatedUser),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -248,7 +232,7 @@ private fun Keyguard(){
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
Toast.makeText(context, if(dpm.setKeyguardDisabled(receiver,false)){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(dpm.setKeyguardDisabled(receiver,false)) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(dpm) || (VERSION.SDK_INT >= 28 && isProfileOwner(dpm) && dpm.isAffiliatedUser),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -267,7 +251,13 @@ private fun Keyguard(){
|
||||
) {
|
||||
Text(stringResource(R.string.lock_now))
|
||||
}
|
||||
if(VERSION.SDK_INT>=26){ CheckBoxItem(stringResource(R.string.require_enter_password_again),{flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY},{flag = if(flag==0){1}else{0} }) }
|
||||
if(VERSION.SDK_INT >= 26) {
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.require_enter_password_again),
|
||||
{ flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY },
|
||||
{ flag = if(flag==0) {1}else{0} }
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
}
|
||||
}
|
||||
@@ -283,7 +273,7 @@ private fun BugReport(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = dpm.requestBugreport(receiver)
|
||||
Toast.makeText(context, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(result) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = isDeviceOwner(dpm)
|
||||
@@ -340,7 +330,7 @@ private fun EditTime(){
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = inputTime!="" && (isDeviceOwner(dpm) || (VERSION.SDK_INT >= 30 && isProfileOwner(dpm) && dpm.isOrganizationOwnedDeviceWithManagedProfile))
|
||||
) {
|
||||
Text("应用")
|
||||
Text(stringResource(R.string.apply))
|
||||
}
|
||||
Button(
|
||||
onClick = { inputTime = System.currentTimeMillis().toString() },
|
||||
@@ -388,9 +378,21 @@ private fun MTEPolicy(){
|
||||
Text(text = stringResource(R.string.mte_policy), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
var selectedMtePolicy by remember { mutableIntStateOf(dpm.mtePolicy) }
|
||||
RadioButtonItem(stringResource(R.string.decide_by_user), {selectedMtePolicy==MTE_NOT_CONTROLLED_BY_POLICY}, {selectedMtePolicy= MTE_NOT_CONTROLLED_BY_POLICY})
|
||||
RadioButtonItem(stringResource(R.string.enabled), {selectedMtePolicy==MTE_ENABLED}, {selectedMtePolicy=MTE_ENABLED})
|
||||
RadioButtonItem(stringResource(R.string.disabled), {selectedMtePolicy==MTE_DISABLED}, {selectedMtePolicy=MTE_DISABLED})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.decide_by_user),
|
||||
{ selectedMtePolicy == MTE_NOT_CONTROLLED_BY_POLICY },
|
||||
{ selectedMtePolicy = MTE_NOT_CONTROLLED_BY_POLICY }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enabled),
|
||||
{ selectedMtePolicy == MTE_ENABLED },
|
||||
{ selectedMtePolicy = MTE_ENABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.disabled),
|
||||
{ selectedMtePolicy == MTE_DISABLED },
|
||||
{ selectedMtePolicy = MTE_DISABLED }
|
||||
)
|
||||
Button(
|
||||
onClick = {
|
||||
try {
|
||||
@@ -421,10 +423,26 @@ private fun NearbyStreamingPolicy(){
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.nearby_app_streaming), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
RadioButtonItem(stringResource(R.string.decide_by_user),{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
|
||||
RadioButtonItem(stringResource(R.string.enabled),{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED})
|
||||
RadioButtonItem(stringResource(R.string.disabled),{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED})
|
||||
RadioButtonItem(stringResource(R.string.enable_if_secure_enough),{appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.decide_by_user),
|
||||
{ appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY },
|
||||
{ appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enabled),
|
||||
{ appPolicy == NEARBY_STREAMING_ENABLED },
|
||||
{ appPolicy = NEARBY_STREAMING_ENABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.disabled),
|
||||
{ appPolicy == NEARBY_STREAMING_DISABLED },
|
||||
{ appPolicy = NEARBY_STREAMING_DISABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enable_if_secure_enough),
|
||||
{ appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY },
|
||||
{ appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -433,16 +451,32 @@ private fun NearbyStreamingPolicy(){
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text("应用")
|
||||
Text(stringResource(R.string.apply))
|
||||
}
|
||||
var notificationPolicy by remember { mutableIntStateOf(dpm.nearbyNotificationStreamingPolicy) }
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.nearby_notification_streaming), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
RadioButtonItem(stringResource(R.string.decide_by_user),{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
|
||||
RadioButtonItem(stringResource(R.string.enabled),{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED})
|
||||
RadioButtonItem(stringResource(R.string.disabled),{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED})
|
||||
RadioButtonItem(stringResource(R.string.enable_if_secure_enough),{notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.decide_by_user),
|
||||
{ notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY },
|
||||
{ notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enabled),
|
||||
{ notificationPolicy == NEARBY_STREAMING_ENABLED },
|
||||
{ notificationPolicy = NEARBY_STREAMING_ENABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.disabled),
|
||||
{ notificationPolicy == NEARBY_STREAMING_DISABLED },
|
||||
{ notificationPolicy = NEARBY_STREAMING_DISABLED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.enable_if_secure_enough),
|
||||
{ notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY },
|
||||
{ notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY }
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -547,7 +581,7 @@ private fun LockTaskFeatures(){
|
||||
LaunchedEffect(Unit) { refreshWhitelist() }
|
||||
Text(text = stringResource(R.string.whitelist_app), style = typography.titleLarge)
|
||||
SelectionContainer(modifier = Modifier.animateContentSize()) {
|
||||
Text(text = if(listText==""){ stringResource(R.string.none) }else{listText})
|
||||
Text(text = if(listText == "") stringResource(R.string.none) else listText)
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = inputPkg,
|
||||
@@ -641,7 +675,7 @@ private fun CaCert(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = dpm.installCaCert(receiver, caCertByteArray)
|
||||
Toast.makeText(context, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(result) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
exist = dpm.hasCaCertInstalled(receiver, caCertByteArray)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
@@ -653,7 +687,7 @@ private fun CaCert(){
|
||||
if(exist) {
|
||||
dpm.uninstallCaCert(receiver, caCertByteArray)
|
||||
exist = dpm.hasCaCertInstalled(receiver, caCertByteArray)
|
||||
Toast.makeText(context, if(exist){R.string.fail}else{R.string.success}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(exist) R.string.fail else R.string.success, Toast.LENGTH_SHORT).show()
|
||||
} else { Toast.makeText(context, R.string.not_exist, Toast.LENGTH_SHORT).show() }
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
@@ -735,11 +769,20 @@ private fun WipeData(){
|
||||
var silent by remember { mutableStateOf(false) }
|
||||
var reason by remember { mutableStateOf("") }
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.wipe_data),style = typography.headlineLarge,modifier = Modifier.padding(6.dp),color = colorScheme.error)
|
||||
Text(
|
||||
text = stringResource(R.string.wipe_data),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(6.dp),color = colorScheme.error
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
CheckBoxItem(stringResource(R.string.wipe_external_storage),{externalStorage},{externalStorage=!externalStorage;confirmed=false})
|
||||
CheckBoxItem(
|
||||
stringResource(R.string.wipe_external_storage),
|
||||
{ externalStorage }, { externalStorage = !externalStorage; confirmed = false }
|
||||
)
|
||||
if(VERSION.SDK_INT >= 22 && isDeviceOwner(dpm)) {
|
||||
CheckBoxItem(stringResource(R.string.wipe_reset_protection_data),{protectionData},{protectionData=!protectionData;confirmed=false})
|
||||
CheckBoxItem(stringResource(R.string.wipe_reset_protection_data),
|
||||
{ protectionData }, { protectionData = !protectionData; confirmed = false}
|
||||
)
|
||||
}
|
||||
if(VERSION.SDK_INT >= 28) { CheckBoxItem(stringResource(R.string.wipe_euicc), { euicc }, { euicc = !euicc; confirmed = false }) }
|
||||
if(VERSION.SDK_INT >= 29) { CheckBoxItem(stringResource(R.string.wipe_silently), { silent }, { silent = !silent; confirmed = false }) }
|
||||
@@ -764,13 +807,13 @@ private fun WipeData(){
|
||||
confirmed = !confirmed
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = if(confirmed){ colorScheme.primary }else{ colorScheme.error },
|
||||
contentColor = if(confirmed){ colorScheme.onPrimary }else{ colorScheme.onError }
|
||||
containerColor = if(confirmed) colorScheme.primary else colorScheme.error ,
|
||||
contentColor = if(confirmed) colorScheme.onPrimary else colorScheme.onError
|
||||
),
|
||||
enabled = dpm.isAdminActive(receiver),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(text = stringResource(if(confirmed){ R.string.cancel }else{ R.string.confirm }))
|
||||
Text(text = stringResource(if(confirmed) R.string.cancel else R.string.confirm))
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -813,9 +856,6 @@ private fun SysUpdatePolicy(){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context,Receiver::class.java)
|
||||
val focusMgr = LocalFocusManager.current
|
||||
val sharedPref = context.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||
val isWear = sharedPref.getBoolean("isWear",false)
|
||||
val bodyTextStyle = if(isWear){ typography.bodyMedium}else{typography.bodyLarge}
|
||||
Column(modifier = Modifier.fillMaxSize().padding(horizontal = 8.dp).verticalScroll(rememberScrollState())) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
if(VERSION.SDK_INT >= 23) {
|
||||
@@ -823,9 +863,18 @@ private fun SysUpdatePolicy(){
|
||||
var selectedPolicy by remember { mutableStateOf(dpm.systemUpdatePolicy?.policyType) }
|
||||
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),{selectedPolicy==TYPE_INSTALL_AUTOMATIC},{selectedPolicy= TYPE_INSTALL_AUTOMATIC})
|
||||
RadioButtonItem(stringResource(R.string.system_update_policy_install_windowed),{selectedPolicy==TYPE_INSTALL_WINDOWED},{selectedPolicy= TYPE_INSTALL_WINDOWED})
|
||||
RadioButtonItem(stringResource(R.string.system_update_policy_postpone),{selectedPolicy==TYPE_POSTPONE},{selectedPolicy= TYPE_POSTPONE})
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.system_update_policy_automatic),
|
||||
{ selectedPolicy == TYPE_INSTALL_AUTOMATIC }, { selectedPolicy = TYPE_INSTALL_AUTOMATIC }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.system_update_policy_install_windowed),
|
||||
{ selectedPolicy == TYPE_INSTALL_WINDOWED }, { selectedPolicy = TYPE_INSTALL_WINDOWED }
|
||||
)
|
||||
RadioButtonItem(
|
||||
stringResource(R.string.system_update_policy_postpone),
|
||||
{ selectedPolicy == TYPE_POSTPONE}, { selectedPolicy = TYPE_POSTPONE }
|
||||
)
|
||||
RadioButtonItem(stringResource(R.string.none), { selectedPolicy == null }, { selectedPolicy = null })
|
||||
var windowedPolicyStart by remember { mutableStateOf("") }
|
||||
var windowedPolicyEnd by remember { mutableStateOf("") }
|
||||
@@ -849,7 +898,7 @@ private fun SysUpdatePolicy(){
|
||||
modifier = Modifier.focusable().fillMaxWidth()
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 3.dp))
|
||||
Text(text = stringResource(R.string.minutes_in_one_day), style = bodyTextStyle)
|
||||
Text(text = stringResource(R.string.minutes_in_one_day))
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -875,56 +924,18 @@ private fun SysUpdatePolicy(){
|
||||
val sysUpdateInfo = dpm.getPendingSystemUpdate(receiver)
|
||||
Column {
|
||||
if(sysUpdateInfo != null) {
|
||||
Text(text = stringResource(R.string.update_received_time, Date(sysUpdateInfo.receivedTime)), style = bodyTextStyle)
|
||||
Text(text = stringResource(R.string.update_received_time, Date(sysUpdateInfo.receivedTime)))
|
||||
val securityStateDesc = when(sysUpdateInfo.securityPatchState) {
|
||||
SystemUpdateInfo.SECURITY_PATCH_STATE_UNKNOWN -> stringResource(R.string.unknown)
|
||||
SystemUpdateInfo.SECURITY_PATCH_STATE_TRUE -> "true"
|
||||
else->"false"
|
||||
}
|
||||
Text(text = stringResource(R.string.is_security_patch, securityStateDesc), style = bodyTextStyle)
|
||||
Text(text = stringResource(R.string.is_security_patch, securityStateDesc))
|
||||
}else{
|
||||
Text(text = stringResource(R.string.no_system_update), style = bodyTextStyle)
|
||||
Text(text = stringResource(R.string.no_system_update))
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
/*if(VERSION.SDK_INT>=29){
|
||||
Column(modifier = sections()){
|
||||
var resultUri by remember{mutableStateOf(otaUri)}
|
||||
Text(text = "安装系统更新", style = typography.titleLarge)
|
||||
Button(
|
||||
onClick = {
|
||||
val getUri = Intent(Intent.ACTION_GET_CONTENT)
|
||||
getUri.setType("application/zip")
|
||||
getUri.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
getOtaPackage.launch(getUri)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = isDeviceOwner(dpm)||isProfileOwner(dpm)
|
||||
) {
|
||||
Text("选择OTA包")
|
||||
}
|
||||
Button(
|
||||
onClick = {resultUri = otaUri},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = isDeviceOwner(dpm)||isProfileOwner(dpm)
|
||||
) {
|
||||
Text("查看OTA包详情")
|
||||
}
|
||||
Text("URI: $resultUri")
|
||||
if(installOta){
|
||||
Button(
|
||||
onClick = {
|
||||
val sysUpdateExecutor = Executors.newCachedThreadPool()
|
||||
val sysUpdateCallback:InstallSystemUpdateCallback = InstallSystemUpdateCallback
|
||||
dpm.installSystemUpdate(receiver,resultUri,sysUpdateExecutor,sysUpdateCallback)
|
||||
},
|
||||
enabled = isDeviceOwner(dpm)||isProfileOwner(dpm)
|
||||
){
|
||||
Text("安装")
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@ import android.provider.MediaStore
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.focusable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme.typography
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
@@ -44,7 +47,6 @@ import androidx.navigation.compose.rememberNavController
|
||||
import com.bintianqi.owndroid.*
|
||||
import com.bintianqi.owndroid.R
|
||||
import com.bintianqi.owndroid.ui.*
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
var affiliationID = mutableSetOf<String>()
|
||||
@Composable
|
||||
@@ -52,22 +54,8 @@ fun UserManage(navCtrl:NavHostController) {
|
||||
val localNavCtrl = rememberNavController()
|
||||
val backStackEntry by localNavCtrl.currentBackStackEntryAsState()
|
||||
val scrollState = rememberScrollState()
|
||||
/*val titleMap = mapOf(
|
||||
"UserInfo" to R.string.user_info,
|
||||
"UserOperation" to R.string.user_operation,
|
||||
"CreateUser" to R.string.create_user,
|
||||
"EditUsername" to R.string.edit_username,
|
||||
"ChangeUserIcon" to R.string.change_user_icon,
|
||||
"UserSessionMessage" to R.string.user_session_msg,
|
||||
"AffiliationID" to R.string.affiliation_id,
|
||||
)*/
|
||||
Scaffold(
|
||||
topBar = {
|
||||
/*TopAppBar(
|
||||
title = {Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.user_manage))},
|
||||
navigationIcon = {NavIcon{if(backStackEntry?.destination?.route=="Home"){navCtrl.navigateUp()}else{localNavCtrl.navigateUp()}}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
|
||||
)*/
|
||||
TopBar(backStackEntry, navCtrl, localNavCtrl) {
|
||||
if(backStackEntry?.destination?.route == "Home" && scrollState.maxValue > 80) {
|
||||
Text(
|
||||
@@ -103,7 +91,11 @@ private fun Home(navCtrl: NavHostController,scrollState: ScrollState){
|
||||
val context = LocalContext.current
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {
|
||||
Text(text = stringResource(R.string.user_manager), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.user_manager),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp)
|
||||
)
|
||||
SubPageItem(R.string.user_info, "", R.drawable.person_fill0) { navCtrl.navigate("UserInfo") }
|
||||
SubPageItem(R.string.user_operation, "", R.drawable.sync_alt_fill0) { navCtrl.navigate("UserOperation") }
|
||||
if(VERSION.SDK_INT >= 24 && isDeviceOwner(dpm)) {
|
||||
@@ -182,7 +174,7 @@ private fun UserOperation(){
|
||||
userHandleById = userHandleBySerial ?: Process.myUserHandle()
|
||||
}
|
||||
},
|
||||
label = {Text(if(useUid){"UID"}else{ stringResource(R.string.serial_number) })},
|
||||
label = { Text(if(useUid) "UID" else stringResource(R.string.serial_number)) },
|
||||
enabled = isDeviceOwner(dpm),
|
||||
modifier = Modifier.focusable().fillMaxWidth(),
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done),
|
||||
@@ -223,7 +215,7 @@ private fun UserOperation(){
|
||||
Button(
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
Toast.makeText(context, if(dpm.switchUser(receiver,userHandleById)) { R.string.success }else{ R.string.fail }, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(dpm.switchUser(receiver,userHandleById)) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(dpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -290,10 +282,22 @@ 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(stringResource(R.string.create_user_skip_wizard),{selectedFlag==DevicePolicyManager.SKIP_SETUP_WIZARD},{selectedFlag=DevicePolicyManager.SKIP_SETUP_WIZARD})
|
||||
RadioButtonItem(
|
||||
stringResource(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),{selectedFlag==DevicePolicyManager.MAKE_USER_EPHEMERAL},{selectedFlag=DevicePolicyManager.MAKE_USER_EPHEMERAL})
|
||||
RadioButtonItem(stringResource(R.string.create_user_enable_all_system_app),{selectedFlag==DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED},{selectedFlag=DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED})
|
||||
RadioButtonItem(
|
||||
stringResource(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),
|
||||
{ selectedFlag == DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED },
|
||||
{ selectedFlag = DevicePolicyManager.LEAVE_ALL_SYSTEM_APPS_ENABLED }
|
||||
)
|
||||
}
|
||||
var newUserHandle: UserHandle? by remember { mutableStateOf(null) }
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
@@ -301,7 +305,7 @@ private fun CreateUser(){
|
||||
onClick = {
|
||||
newUserHandle = dpm.createAndManageUser(receiver, userName, receiver, null, selectedFlag)
|
||||
focusMgr.clearFocus()
|
||||
Toast.makeText(context, if(newUserHandle!=null){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, if(newUserHandle!=null) R.string.success else R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(dpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -332,9 +336,7 @@ private fun AffiliationID(){
|
||||
Text(text = stringResource(R.string.affiliation_id), style = typography.headlineLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
if(list != "") {
|
||||
SelectionContainer {
|
||||
Text(text = list)
|
||||
}
|
||||
SelectionContainer { Text(text = list) }
|
||||
}else{
|
||||
Text(text = stringResource(R.string.none))
|
||||
}
|
||||
@@ -415,9 +417,7 @@ private fun Username(){
|
||||
Text(stringResource(R.string.apply))
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
dpm.setProfileName(receiver,null)
|
||||
},
|
||||
onClick = { dpm.setProfileName(receiver,null) },
|
||||
enabled = isDeviceOwner(dpm) || isProfileOwner(dpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -505,8 +505,8 @@ private fun UserIcon(){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
val intent = Intent(if(getContent){Intent.ACTION_GET_CONTENT}else{Intent.ACTION_PICK})
|
||||
if(getContent){intent.addCategory(Intent.CATEGORY_OPENABLE)}
|
||||
val intent = Intent(if(getContent) Intent.ACTION_GET_CONTENT else Intent.ACTION_PICK)
|
||||
if(getContent) intent.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*")
|
||||
getFile.launch(intent)
|
||||
},
|
||||
@@ -537,6 +537,6 @@ private fun userOperationResultCode(result:Int, context: Context): String {
|
||||
UserManager.USER_OPERATION_ERROR_UNKNOWN-> context.getString(R.string.unknown_result)
|
||||
UserManager.USER_OPERATION_ERROR_MANAGED_PROFILE-> context.getString(R.string.fail_managed_profile)
|
||||
UserManager.USER_OPERATION_ERROR_CURRENT_USER-> context.getString(R.string.fail_current_user)
|
||||
else->"未知"
|
||||
else->context.getString(R.string.unknown)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,11 @@ private fun Home(navCtrl:NavHostController,scrollState: ScrollState){
|
||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val receiver = ComponentName(context, Receiver::class.java)
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {
|
||||
Text(text = stringResource(R.string.user_restrict), style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 7.dp, start = 15.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.user_restrict),
|
||||
style = typography.headlineLarge,
|
||||
modifier = Modifier.padding(top = 8.dp, bottom = 7.dp, start = 15.dp)
|
||||
)
|
||||
Text(text = stringResource(R.string.switch_to_disable_feature), modifier = Modifier.padding(start = 15.dp))
|
||||
if(isProfileOwner(dpm)) { Text(text = stringResource(R.string.profile_owner_is_restricted), modifier = Modifier.padding(start = 15.dp)) }
|
||||
if(isProfileOwner(dpm) && (VERSION.SDK_INT < 24 || (VERSION.SDK_INT >= 24 && dpm.isManagedProfile(receiver)))) {
|
||||
|
||||
@@ -66,7 +66,11 @@ fun NavIcon(operation: () -> Unit){
|
||||
@Composable
|
||||
fun Information(content: @Composable ()->Unit) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(start = 5.dp)) {
|
||||
Icon(painter = painterResource(R.drawable.info_fill0),contentDescription = "info", tint = colorScheme.onBackground.copy(alpha = 0.8F))
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.info_fill0),
|
||||
contentDescription = "info",
|
||||
tint = colorScheme.onBackground.copy(alpha = 0.8F)
|
||||
)
|
||||
Spacer(Modifier.padding(vertical = 1.dp))
|
||||
Row {
|
||||
Spacer(Modifier.padding(horizontal = 1.dp))
|
||||
@@ -163,7 +167,6 @@ fun TopBar(
|
||||
title: @Composable ()->Unit = {}
|
||||
) {
|
||||
TopAppBar(
|
||||
//Text(text = stringResource(titleMap[backStackEntry?.destination?.route]?:R.string.user_restrict))
|
||||
title = title,
|
||||
navigationIcon = {
|
||||
NavIcon{
|
||||
@@ -192,9 +195,9 @@ fun CopyTextButton(@StringRes label: Int, content: String){
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, modifier = Modifier.animateContentSize()
|
||||
) {
|
||||
Icon(painter = painterResource(if(ok){R.drawable.check_fill0}else{R.drawable.content_copy_fill0}),contentDescription = null)
|
||||
Icon(painter = painterResource(if(ok) R.drawable.check_fill0 else R.drawable.content_copy_fill0), contentDescription = null)
|
||||
Spacer(modifier = Modifier.padding(horizontal = 2.dp))
|
||||
Text(text = stringResource(if(ok){R.string.success}else{label}))
|
||||
Text(text = stringResource(if(ok) R.string.success else label))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ fun OwnDroidTheme(
|
||||
}
|
||||
var colorScheme = when {
|
||||
materialYou && VERSION.SDK_INT>=31 -> {
|
||||
if(darkTheme){ dynamicDarkColorScheme(context) }else{ dynamicLightColorScheme(context) }
|
||||
if(darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
|
||||
Reference in New Issue
Block a user