better color scheme

This commit is contained in:
BinTianqi
2024-02-14 21:51:56 +08:00
parent 9042fa2472
commit 9325480b35
13 changed files with 98 additions and 108 deletions

View File

@@ -60,6 +60,7 @@ fun ApplicationManage(){
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
val isWear = sharedPref.getBoolean("isWear",false) val isWear = sharedPref.getBoolean("isWear",false)
val bodyTextStyle = if(isWear){ typography.bodyMedium }else{ typography.bodyLarge } val bodyTextStyle = if(isWear){ typography.bodyMedium }else{ typography.bodyLarge }
val titleColor = colorScheme.onPrimaryContainer
Column{ Column{
if(!isWear){ if(!isWear){
TextField( TextField(
@@ -81,7 +82,7 @@ fun ApplicationManage(){
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}) keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()})
) )
} }else{Spacer(Modifier.padding(vertical = 2.dp))}
if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){
Text(text = "作用域: 工作资料", style = bodyTextStyle, textAlign = TextAlign.Center,modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp)) Text(text = "作用域: 工作资料", style = bodyTextStyle, textAlign = TextAlign.Center,modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp))
} }
@@ -124,7 +125,7 @@ fun ApplicationManage(){
if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){ if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
var state by remember{mutableStateOf(myDpm.isUninstallBlocked(myComponent,pkgName))} var state by remember{mutableStateOf(myDpm.isUninstallBlocked(myComponent,pkgName))}
Text(text = "防卸载", style = typography.titleLarge) Text(text = "防卸载", style = typography.titleLarge, color = titleColor)
Text("当前状态:${if(state){"打开"}else{"关闭"}}") Text("当前状态:${if(state){"打开"}else{"关闭"}}")
Text(text = "有时候无法正确获取防卸载状态", style = bodyTextStyle) Text(text = "有时候无法正确获取防卸载状态", style = bodyTextStyle)
Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth()) { Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth()) {
@@ -166,7 +167,7 @@ fun ApplicationManage(){
} }
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refresh();inited=true} if(!inited){refresh();inited=true}
Text(text = "禁止用户控制", style = typography.titleLarge) Text(text = "禁止用户控制", style = typography.titleLarge, color = titleColor)
Text(text = "用户将无法清除应用的存储空间和缓存", style = bodyTextStyle) Text(text = "用户将无法清除应用的存储空间和缓存", style = bodyTextStyle)
Text(text = "应用列表:") Text(text = "应用列表:")
if(listText!=""){ if(listText!=""){
@@ -220,7 +221,7 @@ fun ApplicationManage(){
Column(modifier = sections()){ Column(modifier = sections()){
var inputPermission by remember{mutableStateOf("android.permission.")} var inputPermission by remember{mutableStateOf("android.permission.")}
var currentState by remember{mutableStateOf(grantState[myDpm.getPermissionGrantState(myComponent,pkgName,inputPermission)])} var currentState by remember{mutableStateOf(grantState[myDpm.getPermissionGrantState(myComponent,pkgName,inputPermission)])}
Text(text = "权限管理", style = typography.titleLarge) Text(text = "权限管理", style = typography.titleLarge, color = titleColor)
OutlinedTextField( OutlinedTextField(
value = inputPermission, value = inputPermission,
label = { Text("权限")}, label = { Text("权限")},
@@ -266,7 +267,7 @@ fun ApplicationManage(){
if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "跨资料应用", style = typography.titleLarge) Text(text = "跨资料应用", style = typography.titleLarge, color = titleColor)
var list by remember{mutableStateOf("")} var list by remember{mutableStateOf("")}
val refresh = { val refresh = {
crossProfilePkg = myDpm.getCrossProfilePackages(myComponent) crossProfilePkg = myDpm.getCrossProfilePackages(myComponent)
@@ -314,7 +315,7 @@ fun ApplicationManage(){
} }
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refresh();inited=true} if(!inited){refresh();inited=true}
Text(text = "跨资料微件", style = typography.titleLarge) Text(text = "跨资料微件", style = typography.titleLarge, color = titleColor)
Text(text = "(跨资料桌面小部件提供者)", style = bodyTextStyle) Text(text = "(跨资料桌面小部件提供者)", style = bodyTextStyle)
Text(text = if(list!=""){list}else{""}, style = bodyTextStyle) Text(text = if(list!=""){list}else{""}, style = bodyTextStyle)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
@@ -358,7 +359,7 @@ fun ApplicationManage(){
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refreshPolicy(); refreshText(); inited = true} if(!inited){refreshPolicy(); refreshText(); inited = true}
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "凭据管理策略", style = typography.titleLarge) Text(text = "凭据管理策略", style = typography.titleLarge, color = titleColor)
RadioButtonItem("",{policyType==-1},{policyType=-1}) RadioButtonItem("",{policyType==-1},{policyType=-1})
RadioButtonItem("黑名单",{policyType==PACKAGE_POLICY_BLOCKLIST},{policyType=PACKAGE_POLICY_BLOCKLIST}) RadioButtonItem("黑名单",{policyType==PACKAGE_POLICY_BLOCKLIST},{policyType=PACKAGE_POLICY_BLOCKLIST})
RadioButtonItem("白名单",{policyType==PACKAGE_POLICY_ALLOWLIST},{policyType=PACKAGE_POLICY_ALLOWLIST}) RadioButtonItem("白名单",{policyType==PACKAGE_POLICY_ALLOWLIST},{policyType=PACKAGE_POLICY_ALLOWLIST})
@@ -415,7 +416,7 @@ fun ApplicationManage(){
if(isProfileOwner(myDpm)||isDeviceOwner(myDpm)){ if(isProfileOwner(myDpm)||isDeviceOwner(myDpm)){
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "许可的无障碍应用", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) Text(text = "许可的无障碍应用", style = typography.titleLarge, color = titleColor)
var listText by remember{ mutableStateOf("") } var listText by remember{ mutableStateOf("") }
val refreshList = { val refreshList = {
listText = "" listText = ""
@@ -460,7 +461,7 @@ fun ApplicationManage(){
if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){ if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "许可的输入法", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) Text(text = "许可的输入法", style = typography.titleLarge, color = titleColor)
var imeListText by remember{ mutableStateOf("") } var imeListText by remember{ mutableStateOf("") }
val refreshList = { val refreshList = {
imeListText = "" imeListText = ""
@@ -503,7 +504,7 @@ fun ApplicationManage(){
if(VERSION.SDK_INT>=28&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=28&&isDeviceOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "保持卸载的应用", style = typography.titleLarge) Text(text = "保持卸载的应用", style = typography.titleLarge, color = titleColor)
Text(text = "作用未知", style = bodyTextStyle) Text(text = "作用未知", style = bodyTextStyle)
var listText by remember{mutableStateOf("")} var listText by remember{mutableStateOf("")}
val refresh = { val refresh = {
@@ -591,7 +592,7 @@ fun ApplicationManage(){
} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "卸载应用", style = typography.titleLarge) Text(text = "卸载应用", style = typography.titleLarge, color = titleColor)
Text(text = "静默卸载需Device owner", style = bodyTextStyle) Text(text = "静默卸载需Device owner", style = bodyTextStyle)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
@@ -619,7 +620,7 @@ fun ApplicationManage(){
} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "安装应用", style = typography.titleLarge) Text(text = "安装应用", style = typography.titleLarge, color = titleColor)
Text(text = "静默安装需Device owner", style = bodyTextStyle) Text(text = "静默安装需Device owner", style = bodyTextStyle)
Button( Button(
onClick = { onClick = {

View File

@@ -42,6 +42,7 @@ fun DeviceControl(){
val myComponent = ComponentName(myContext,MyDeviceAdminReceiver::class.java) val myComponent = ComponentName(myContext,MyDeviceAdminReceiver::class.java)
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
val isWear = sharedPref.getBoolean("isWear",false) val isWear = sharedPref.getBoolean("isWear",false)
val titleColor = colorScheme.onPrimaryContainer
val userManager = myContext.getSystemService(Context.USER_SERVICE) as UserManager val userManager = myContext.getSystemService(Context.USER_SERVICE) as UserManager
val bodyTextStyle = if(isWear){typography.bodyMedium}else{typography.bodyLarge} val bodyTextStyle = if(isWear){typography.bodyMedium}else{typography.bodyLarge}
val focusMgr = LocalFocusManager.current val focusMgr = LocalFocusManager.current
@@ -126,7 +127,7 @@ fun DeviceControl(){
} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "锁屏", style = typography.titleLarge) Text(text = "锁屏", style = typography.titleLarge, color = titleColor)
var flag by remember{mutableIntStateOf(0)} var flag by remember{mutableIntStateOf(0)}
if(VERSION.SDK_INT>=26){ CheckBoxItem("需要重新输入密码",{flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY},{flag = if(flag==0){1}else{0} }) } if(VERSION.SDK_INT>=26){ CheckBoxItem("需要重新输入密码",{flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY},{flag = if(flag==0){1}else{0} }) }
Button( Button(
@@ -162,10 +163,10 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=28){ if(VERSION.SDK_INT>=28){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "修改时间", style = typography.titleLarge) Text(text = "修改时间", style = typography.titleLarge, color = titleColor)
var inputTime by remember{mutableStateOf("")} var inputTime by remember{mutableStateOf("")}
Text(text = "从Epoch(1970/1/1 00:00:00 UTC)到你想设置的时间(毫秒)", style = bodyTextStyle) Text(text = "从Epoch(1970/1/1 00:00:00 UTC)到你想设置的时间(毫秒)", style = bodyTextStyle)
TextField( OutlinedTextField(
value = inputTime, value = inputTime,
label = { Text("时间(ms)")}, label = { Text("时间(ms)")},
onValueChange = {inputTime = it}, onValueChange = {inputTime = it},
@@ -205,7 +206,7 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var selectedPolicy by remember{mutableIntStateOf(myDpm.getPermissionPolicy(myComponent))} var selectedPolicy by remember{mutableIntStateOf(myDpm.getPermissionPolicy(myComponent))}
Text(text = "权限策略", style = typography.titleLarge) Text(text = "权限策略", style = typography.titleLarge, color = titleColor)
RadioButtonItem("默认", {selectedPolicy==PERMISSION_POLICY_PROMPT}, {selectedPolicy= PERMISSION_POLICY_PROMPT}) RadioButtonItem("默认", {selectedPolicy==PERMISSION_POLICY_PROMPT}, {selectedPolicy= PERMISSION_POLICY_PROMPT})
RadioButtonItem("自动允许", {selectedPolicy==PERMISSION_POLICY_AUTO_GRANT}, {selectedPolicy= PERMISSION_POLICY_AUTO_GRANT}) RadioButtonItem("自动允许", {selectedPolicy==PERMISSION_POLICY_AUTO_GRANT}, {selectedPolicy= PERMISSION_POLICY_AUTO_GRANT})
RadioButtonItem("自动拒绝", {selectedPolicy==PERMISSION_POLICY_AUTO_DENY}, {selectedPolicy= PERMISSION_POLICY_AUTO_DENY}) RadioButtonItem("自动拒绝", {selectedPolicy==PERMISSION_POLICY_AUTO_DENY}, {selectedPolicy= PERMISSION_POLICY_AUTO_DENY})
@@ -223,7 +224,7 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=34&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=34&&isDeviceOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "MTE策略", style = typography.titleLarge, color = colorScheme.onPrimaryContainer) Text(text = "MTE策略", style = typography.titleLarge, color = titleColor)
Text("MTE内存标记拓展安卓14和ARMv9的高端功能") Text("MTE内存标记拓展安卓14和ARMv9的高端功能")
var selectedMtePolicy by remember{mutableIntStateOf(myDpm.mtePolicy)} var selectedMtePolicy by remember{mutableIntStateOf(myDpm.mtePolicy)}
RadioButtonItem("由用户决定", {selectedMtePolicy==MTE_NOT_CONTROLLED_BY_POLICY}, {selectedMtePolicy= MTE_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem("由用户决定", {selectedMtePolicy==MTE_NOT_CONTROLLED_BY_POLICY}, {selectedMtePolicy= MTE_NOT_CONTROLLED_BY_POLICY})
@@ -249,7 +250,7 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var appPolicy by remember{mutableIntStateOf(myDpm.nearbyAppStreamingPolicy)} var appPolicy by remember{mutableIntStateOf(myDpm.nearbyAppStreamingPolicy)}
Text(text = "附近App共享", style = typography.titleLarge) Text(text = "附近App共享", style = typography.titleLarge, color = titleColor)
RadioButtonItem("由用户决定",{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem("由用户决定",{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("启用",{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem("启用",{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED})
RadioButtonItem("禁用",{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED}) RadioButtonItem("禁用",{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED})
@@ -265,7 +266,7 @@ fun DeviceControl(){
} }
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
var notificationPolicy by remember{mutableIntStateOf(myDpm.nearbyNotificationStreamingPolicy)} var notificationPolicy by remember{mutableIntStateOf(myDpm.nearbyNotificationStreamingPolicy)}
Text(text = "附近通知共享", style = typography.titleLarge) Text(text = "附近通知共享", style = typography.titleLarge, color = titleColor)
RadioButtonItem("由用户决定",{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem("由用户决定",{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("启用",{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem("启用",{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED})
RadioButtonItem("禁用",{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED}) RadioButtonItem("禁用",{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED})
@@ -317,7 +318,7 @@ fun DeviceControl(){
custom = false custom = false
} }
} }
Text(text = "锁定任务模式", style = typography.titleLarge, color = colorScheme.onPrimaryContainer) Text(text = "锁定任务模式", style = typography.titleLarge, color = titleColor)
if(!inited){ refreshFeature();custom=myDpm.getLockTaskFeatures(myComponent)!=0;inited=true } if(!inited){ refreshFeature();custom=myDpm.getLockTaskFeatures(myComponent)!=0;inited=true }
Text(text = "在锁定任务模式下:", style = bodyTextStyle) Text(text = "在锁定任务模式下:", style = bodyTextStyle)
RadioButtonItem("禁用全部",{!custom},{custom=false}) RadioButtonItem("禁用全部",{!custom},{custom=false})
@@ -368,9 +369,9 @@ fun DeviceControl(){
} }
} }
refreshWhitelist() refreshWhitelist()
Text(text = "白名单应用", style = typography.titleLarge) Text(text = "白名单应用", style = typography.titleLarge, color = titleColor)
if(listText!=""){ Text(listText) }else{ Text(("")) } if(listText!=""){ Text(listText) }else{ Text(("")) }
TextField( OutlinedTextField(
value = inputPkg, value = inputPkg,
onValueChange = {inputPkg=it}, onValueChange = {inputPkg=it},
label = {Text("包名")}, label = {Text("包名")},
@@ -420,7 +421,7 @@ fun DeviceControl(){
} }
LaunchedEffect(exist){ launch{isCaCertSelected(600){refresh()}} } LaunchedEffect(exist){ launch{isCaCertSelected(600){refresh()}} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "Ca证书", style = typography.titleLarge) Text(text = "Ca证书", style = typography.titleLarge, color = titleColor)
if(isEmpty){ Text(text = "请选择Ca证书(.0)") }else{ Text(text = "证书已安装:$exist") } if(isEmpty){ Text(text = "请选择Ca证书(.0)") }else{ Text(text = "证书已安装:$exist") }
Button( Button(
onClick = { onClick = {
@@ -471,7 +472,7 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isOrganizationOwnedDeviceWithManagedProfile))){ if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isOrganizationOwnedDeviceWithManagedProfile))){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "收集安全日志", style = typography.titleLarge) Text(text = "收集安全日志", style = typography.titleLarge, color = titleColor)
Text(text = "功能开发中", style = bodyTextStyle) Text(text = "功能开发中", style = bodyTextStyle)
Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){ Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){
var checked by remember{mutableStateOf(myDpm.isSecurityLoggingEnabled(myComponent))} var checked by remember{mutableStateOf(myDpm.isSecurityLoggingEnabled(myComponent))}
@@ -534,7 +535,7 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=28){ CheckBoxItem("清除eUICC",{euicc},{euicc=!euicc}, colorScheme.onErrorContainer) } if(VERSION.SDK_INT>=28){ CheckBoxItem("清除eUICC",{euicc},{euicc=!euicc}, colorScheme.onErrorContainer) }
if(VERSION.SDK_INT>=29){ CheckBoxItem("静默清除",{silent},{silent=!silent}, colorScheme.onErrorContainer) } if(VERSION.SDK_INT>=29){ CheckBoxItem("静默清除",{silent},{silent=!silent}, colorScheme.onErrorContainer) }
AnimatedVisibility(!silent&&VERSION.SDK_INT>=28) { AnimatedVisibility(!silent&&VERSION.SDK_INT>=28) {
TextField( OutlinedTextField(
value = reason, onValueChange = {reason=it}, value = reason, onValueChange = {reason=it},
label = {Text("原因")}, label = {Text("原因")},
enabled = !confirmed, enabled = !confirmed,

View File

@@ -200,7 +200,7 @@ fun HomePage(navCtrl:NavHostController){
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = if (!isWear) { 5.dp } else { 2.dp }, horizontal = if (!isWear) { 8.dp } else { 4.dp }) .padding(vertical = if (!isWear) { 5.dp } else { 2.dp }, horizontal = if (!isWear) { 8.dp } else { 4.dp })
.clip(RoundedCornerShape(15)) .clip(RoundedCornerShape(15))
.background(color = MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.8F)) .background(color = MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.7F))
.clickable(onClick = { navCtrl.navigate("Permissions") }) .clickable(onClick = { navCtrl.navigate("Permissions") })
.padding( .padding(
horizontal = 5.dp, horizontal = 5.dp,
@@ -244,7 +244,7 @@ fun HomePageItem(name:Int, imgVector:Int, navTo:String, myNav:NavHostController)
.fillMaxWidth() .fillMaxWidth()
.padding(vertical = if (!isWear) { 4.dp } else { 2.dp }, horizontal = if (!isWear) { 7.dp } else { 4.dp }) .padding(vertical = if (!isWear) { 4.dp } else { 2.dp }, horizontal = if (!isWear) { 7.dp } else { 4.dp })
.clip(RoundedCornerShape(15)) .clip(RoundedCornerShape(15))
.background(color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.8F)) .background(color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.7F))
.clickable(onClick = { myNav.navigate(navTo) }) .clickable(onClick = { myNav.navigate(navTo) })
.padding(vertical = if(isWear){6.dp}else{10.dp}, horizontal = 6.dp), .padding(vertical = if(isWear){6.dp}else{10.dp}, horizontal = 6.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
@@ -323,7 +323,7 @@ fun isProfileOwner(dpm:DevicePolicyManager): Boolean {
@Composable @Composable
@Stable @Stable
fun sections(bgColor:Color=MaterialTheme.colorScheme.primaryContainer):Modifier{ fun sections(bgColor:Color=MaterialTheme.colorScheme.primaryContainer):Modifier{
val backgroundColor = if(isSystemInDarkTheme()){bgColor.copy(0.4F)}else{bgColor.copy(0.6F)} val backgroundColor = if(isSystemInDarkTheme()){bgColor.copy(0.3F)}else{bgColor.copy(0.8F)}
return if(!LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE).getBoolean("isWear",false)){ return if(!LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE).getBoolean("isWear",false)){
Modifier Modifier
.fillMaxWidth() .fillMaxWidth()

View File

@@ -19,9 +19,9 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@@ -41,10 +41,11 @@ fun ManagedProfile() {
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
val isWear = sharedPref.getBoolean("isWear",false) val isWear = sharedPref.getBoolean("isWear",false)
val bodyTextStyle = if(isWear){ typography.bodyMedium}else{ typography.bodyLarge} val bodyTextStyle = if(isWear){ typography.bodyMedium}else{ typography.bodyLarge}
val titleColor = colorScheme.onPrimaryContainer
Column(modifier = Modifier.verticalScroll(rememberScrollState())){ Column(modifier = Modifier.verticalScroll(rememberScrollState())){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "信息", style = typography.titleLarge) Text(text = "信息", style = typography.titleLarge, color = titleColor)
if(VERSION.SDK_INT>=24){ if(VERSION.SDK_INT>=24){
if(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ if(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){
Text(text = "已是工作资料") Text(text = "已是工作资料")
@@ -77,7 +78,7 @@ fun ManagedProfile() {
if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)&&!myDpm.isOrganizationOwnedDeviceWithManagedProfile){ if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)&&!myDpm.isOrganizationOwnedDeviceWithManagedProfile){
Column(modifier = sections(colorScheme.tertiaryContainer)){ Column(modifier = sections(colorScheme.tertiaryContainer)){
Text("成为组织拥有的工作资料") Text(text = "成为组织拥有的工作资料", color = titleColor)
Text(text = "首先在“用户管理”中查看UserID然后使用ADB执行下面这条命令", style = bodyTextStyle) Text(text = "首先在“用户管理”中查看UserID然后使用ADB执行下面这条命令", style = bodyTextStyle)
SelectionContainer { SelectionContainer {
Text( Text(
@@ -90,7 +91,7 @@ fun ManagedProfile() {
} }
if(!isProfileOwner(myDpm)&&(VERSION.SDK_INT<24||(VERSION.SDK_INT>=24&&myDpm.isProvisioningAllowed(ACTION_PROVISION_MANAGED_PROFILE)))){ if(!isProfileOwner(myDpm)&&(VERSION.SDK_INT<24||(VERSION.SDK_INT>=24&&myDpm.isProvisioningAllowed(ACTION_PROVISION_MANAGED_PROFILE)))){
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "工作资料", style = typography.titleLarge) Text(text = "工作资料", style = typography.titleLarge, color = titleColor)
var skipEncrypt by remember{mutableStateOf(false)} var skipEncrypt by remember{mutableStateOf(false)}
if(VERSION.SDK_INT>=24){CheckBoxItem("跳过加密",{skipEncrypt},{skipEncrypt=!skipEncrypt})} if(VERSION.SDK_INT>=24){CheckBoxItem("跳过加密",{skipEncrypt},{skipEncrypt=!skipEncrypt})}
Button( Button(
@@ -116,7 +117,7 @@ fun ManagedProfile() {
Row(modifier = sections(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){ Row(modifier = sections(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){
var suspended by remember{mutableStateOf(false)} var suspended by remember{mutableStateOf(false)}
suspended = myDpm.getPersonalAppsSuspendedReasons(myComponent)!=PERSONAL_APPS_NOT_SUSPENDED suspended = myDpm.getPersonalAppsSuspendedReasons(myComponent)!=PERSONAL_APPS_NOT_SUSPENDED
Text(text = "挂起个人应用", style = typography.titleLarge) Text(text = "挂起个人应用", style = typography.titleLarge, color = titleColor)
Switch( Switch(
checked = suspended, checked = suspended,
onCheckedChange ={ onCheckedChange ={
@@ -131,10 +132,10 @@ fun ManagedProfile() {
Column(modifier = sections()){ Column(modifier = sections()){
var time by remember{mutableStateOf("")} var time by remember{mutableStateOf("")}
time = myDpm.getManagedProfileMaximumTimeOff(myComponent).toString() time = myDpm.getManagedProfileMaximumTimeOff(myComponent).toString()
Text(text = "资料关闭时间", style = typography.titleLarge) Text(text = "资料关闭时间", style = typography.titleLarge, color = titleColor)
Text(text = "工作资料处于关闭状态的时间达到该限制后会挂起个人应用0为无限制", style = bodyTextStyle) Text(text = "工作资料处于关闭状态的时间达到该限制后会挂起个人应用0为无限制", style = bodyTextStyle)
Text(text = "个人应用已经因此挂起:${myDpm.getPersonalAppsSuspendedReasons(myComponent)==PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT}") Text(text = "个人应用已经因此挂起:${myDpm.getPersonalAppsSuspendedReasons(myComponent)==PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT}")
TextField( OutlinedTextField(
value = time, onValueChange = {time=it}, modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp), value = time, onValueChange = {time=it}, modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp),
label = {Text("时间(ms)")}, label = {Text("时间(ms)")},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done),
@@ -156,8 +157,8 @@ fun ManagedProfile() {
if(isProfileOwner(myDpm)&&(VERSION.SDK_INT<24||(VERSION.SDK_INT>=24&&myDpm.isManagedProfile(myComponent)))){ if(isProfileOwner(myDpm)&&(VERSION.SDK_INT<24||(VERSION.SDK_INT>=24&&myDpm.isManagedProfile(myComponent)))){
Column(modifier = sections()){ Column(modifier = sections()){
var action by remember{mutableStateOf("")} var action by remember{mutableStateOf("")}
Text(text = "Intent过滤器", style = typography.titleLarge) Text(text = "Intent过滤器", style = typography.titleLarge, color = titleColor)
TextField( OutlinedTextField(
value = action, onValueChange = {action = it}, value = action, onValueChange = {action = it},
label = {Text("Action")}, label = {Text("Action")},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done),
@@ -199,8 +200,8 @@ fun ManagedProfile() {
if(VERSION.SDK_INT>=31&&(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent))){ if(VERSION.SDK_INT>=31&&(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent))){
Column(modifier = sections()){ Column(modifier = sections()){
var orgId by remember{mutableStateOf("")} var orgId by remember{mutableStateOf("")}
Text(text = "组织ID", style = typography.titleLarge) Text(text = "组织ID", style = typography.titleLarge, color = titleColor)
TextField( OutlinedTextField(
value = orgId, onValueChange = {orgId=it}, value = orgId, onValueChange = {orgId=it},
label = {Text("组织ID")}, label = {Text("组织ID")},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done),

View File

@@ -23,6 +23,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField import androidx.compose.material3.TextField
@@ -47,6 +48,7 @@ fun Network(){
val isWear = sharedPref.getBoolean("isWear",false) val isWear = sharedPref.getBoolean("isWear",false)
val bodyTextStyle = if(isWear){ typography.bodyMedium }else{ typography.bodyLarge } val bodyTextStyle = if(isWear){ typography.bodyMedium }else{ typography.bodyLarge }
val focusMgr = LocalFocusManager.current val focusMgr = LocalFocusManager.current
val titleColor = colorScheme.onPrimaryContainer
if(VERSION.SDK_INT>=24){ if(VERSION.SDK_INT>=24){
val wifimac = try { myDpm.getWifiMacAddress(myComponent).toString() }catch(e:SecurityException){ "没有权限" } val wifimac = try { myDpm.getWifiMacAddress(myComponent).toString() }catch(e:SecurityException){ "没有权限" }
@@ -66,7 +68,7 @@ fun Network(){
if(VERSION.SDK_INT>=33){ if(VERSION.SDK_INT>=33){
Column(modifier = sections()){ Column(modifier = sections()){
var selectedWifiSecLevel by remember{mutableIntStateOf(myDpm.minimumRequiredWifiSecurityLevel)} var selectedWifiSecLevel by remember{mutableIntStateOf(myDpm.minimumRequiredWifiSecurityLevel)}
Text(text = "要求最小WiFi安全等级", style = typography.titleLarge, color = colorScheme.onPrimaryContainer) Text(text = "要求最小WiFi安全等级", style = typography.titleLarge, color = titleColor)
RadioButtonItem("开放", {selectedWifiSecLevel==DevicePolicyManager.WIFI_SECURITY_OPEN}, {selectedWifiSecLevel= DevicePolicyManager.WIFI_SECURITY_OPEN}) RadioButtonItem("开放", {selectedWifiSecLevel==DevicePolicyManager.WIFI_SECURITY_OPEN}, {selectedWifiSecLevel= DevicePolicyManager.WIFI_SECURITY_OPEN})
RadioButtonItem("WEP, WPA(2)-PSK", {selectedWifiSecLevel==DevicePolicyManager.WIFI_SECURITY_PERSONAL}, {selectedWifiSecLevel= DevicePolicyManager.WIFI_SECURITY_PERSONAL}) RadioButtonItem("WEP, WPA(2)-PSK", {selectedWifiSecLevel==DevicePolicyManager.WIFI_SECURITY_PERSONAL}, {selectedWifiSecLevel= DevicePolicyManager.WIFI_SECURITY_PERSONAL})
RadioButtonItem("WPA-EAP", {selectedWifiSecLevel==DevicePolicyManager.WIFI_SECURITY_ENTERPRISE_EAP}, {selectedWifiSecLevel= DevicePolicyManager.WIFI_SECURITY_ENTERPRISE_EAP}) RadioButtonItem("WPA-EAP", {selectedWifiSecLevel==DevicePolicyManager.WIFI_SECURITY_ENTERPRISE_EAP}, {selectedWifiSecLevel= DevicePolicyManager.WIFI_SECURITY_ENTERPRISE_EAP})
@@ -108,12 +110,12 @@ fun Network(){
} }
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){refreshList(); inited=true} if(!inited){refreshList(); inited=true}
Text(text = "WiFi SSID策略", style = typography.titleLarge) Text(text = "WiFi SSID策略", style = typography.titleLarge, color = titleColor)
RadioButtonItem("白名单",{selectedPolicyType==WIFI_SSID_POLICY_TYPE_ALLOWLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_ALLOWLIST}) RadioButtonItem("白名单",{selectedPolicyType==WIFI_SSID_POLICY_TYPE_ALLOWLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_ALLOWLIST})
RadioButtonItem("黑名单",{selectedPolicyType==WIFI_SSID_POLICY_TYPE_DENYLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_DENYLIST}) RadioButtonItem("黑名单",{selectedPolicyType==WIFI_SSID_POLICY_TYPE_DENYLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_DENYLIST})
Text("SSID列表") Text("SSID列表")
Text(text = if(ssidList!=""){ssidList}else{""}, style = bodyTextStyle) Text(text = if(ssidList!=""){ssidList}else{""}, style = bodyTextStyle)
TextField( OutlinedTextField(
value = inputSsid, value = inputSsid,
label = { Text("SSID")}, label = { Text("SSID")},
onValueChange = {inputSsid = it}, onValueChange = {inputSsid = it},
@@ -161,7 +163,7 @@ fun Network(){
} }
if(VERSION.SDK_INT>=29&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=29&&isDeviceOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "私人DNS", style = typography.titleLarge) Text(text = "私人DNS", style = typography.titleLarge, color = titleColor)
val dnsStatus = mapOf( val dnsStatus = mapOf(
DevicePolicyManager.PRIVATE_DNS_MODE_UNKNOWN to "未知", DevicePolicyManager.PRIVATE_DNS_MODE_UNKNOWN to "未知",
DevicePolicyManager.PRIVATE_DNS_MODE_OFF to "关闭", DevicePolicyManager.PRIVATE_DNS_MODE_OFF to "关闭",
@@ -187,7 +189,7 @@ fun Network(){
} }
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
var inputHost by remember{mutableStateOf(myDpm.getGlobalPrivateDnsHost(myComponent) ?: "")} var inputHost by remember{mutableStateOf(myDpm.getGlobalPrivateDnsHost(myComponent) ?: "")}
TextField( OutlinedTextField(
value = inputHost, value = inputHost,
onValueChange = {inputHost=it}, onValueChange = {inputHost=it},
label = {Text("DNS主机名")}, label = {Text("DNS主机名")},
@@ -218,7 +220,7 @@ fun Network(){
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)))){ if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)))){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "收集网络日志", style = typography.titleLarge) Text(text = "收集网络日志", style = typography.titleLarge, color = titleColor)
Text(text = "功能开发中", style = bodyTextStyle) Text(text = "功能开发中", style = bodyTextStyle)
Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){ Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){
var checked by remember{mutableStateOf(myDpm.isNetworkLoggingEnabled(myComponent))} var checked by remember{mutableStateOf(myDpm.isNetworkLoggingEnabled(myComponent))}
@@ -249,8 +251,8 @@ fun Network(){
if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var keyPair by remember{mutableStateOf("")} var keyPair by remember{mutableStateOf("")}
Text(text = "WiFi密钥对", style = typography.titleLarge) Text(text = "WiFi密钥对", style = typography.titleLarge, color = titleColor)
TextField( OutlinedTextField(
value = keyPair, value = keyPair,
label = { Text("密钥对")}, label = { Text("密钥对")},
onValueChange = {keyPair = it}, onValueChange = {keyPair = it},
@@ -289,7 +291,7 @@ fun Network(){
var inputNum by remember{mutableStateOf("0")} var inputNum by remember{mutableStateOf("0")}
var nextStep by remember{mutableStateOf(false)} var nextStep by remember{mutableStateOf(false)}
val builder = Builder() val builder = Builder()
Text(text = "APN设置", style = typography.titleLarge) Text(text = "APN设置", style = typography.titleLarge, color = titleColor)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){
Text(text = "启用", style = typography.titleLarge) Text(text = "启用", style = typography.titleLarge)
Switch(checked = myDpm.isOverrideApnEnabled(myComponent), onCheckedChange = {myDpm.setOverrideApnsEnabled(myComponent,it)}) Switch(checked = myDpm.isOverrideApnEnabled(myComponent), onCheckedChange = {myDpm.setOverrideApnsEnabled(myComponent,it)})

View File

@@ -10,9 +10,11 @@ import android.os.Build.VERSION
import android.widget.Toast import android.widget.Toast
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@@ -24,9 +26,11 @@ import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.KeyboardType
@@ -144,7 +148,7 @@ fun Password(){
) { ) {
var confirmed by remember{ mutableStateOf(false) } var confirmed by remember{ mutableStateOf(false) }
Text(text = "修改密码",style = typography.titleLarge,color = titleColor) Text(text = "修改密码",style = typography.titleLarge,color = titleColor)
TextField( OutlinedTextField(
value = newPwd, value = newPwd,
onValueChange = {newPwd=it}, onValueChange = {newPwd=it},
enabled = !confirmed&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm)||myDpm.isAdminActive(myComponent)), enabled = !confirmed&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm)||myDpm.isAdminActive(myComponent)),
@@ -437,7 +441,7 @@ private fun PasswordItem(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
){ ){
TextField( OutlinedTextField(
value = inputContent, value = inputContent,
label = { Text(stringResource(textFieldLabel))}, label = { Text(stringResource(textFieldLabel))},
onValueChange = { onValueChange = {
@@ -447,30 +451,17 @@ private fun PasswordItem(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}),
enabled = isDeviceOwner(myDpm), enabled = isDeviceOwner(myDpm),
modifier = if(isWear){Modifier.fillMaxWidth()}else{Modifier.fillMaxWidth(0.8F)} modifier = Modifier.fillMaxWidth(),
trailingIcon = {
Icon(
imageVector = Icons.Outlined.Check, contentDescription = "OK",
modifier = Modifier
.clip(RoundedCornerShape(50))
.clickable(onClick = {focusMgr.clearFocus() ; setMethod(inputContent)}, enabled = isDeviceOwner(myDpm)&&ableToApply)
.padding(2.dp)
) )
if(!isWear){ }
IconButton(
onClick = { focusMgr.clearFocus() ; setMethod(inputContent) },
enabled = isDeviceOwner(myDpm)&&ableToApply,
colors = IconButtonDefaults.iconButtonColors(
contentColor = colorScheme.onPrimary,
containerColor = colorScheme.primary,
disabledContentColor = Color.Transparent,
disabledContainerColor = Color.Transparent
) )
) {
Icon(imageVector = Icons.Outlined.Check, contentDescription = null)
}}
}
if(isWear){
Button(
onClick = {focusMgr.clearFocus() ; setMethod(inputContent)},
enabled = isDeviceOwner(myDpm)&&ableToApply,
modifier = Modifier.fillMaxWidth()
) {
Text("应用")
}
} }
} }
} }

View File

@@ -18,8 +18,8 @@ import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@@ -33,7 +33,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat.startActivity import androidx.core.content.ContextCompat.startActivity
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import java.lang.IllegalArgumentException
@Composable @Composable
@@ -234,8 +233,8 @@ fun DpmPermissions(navCtrl:NavHostController){
if((VERSION.SDK_INT>=26&&isDeviceOwner(myDpm))||(VERSION.SDK_INT>=24&&isProfileOwner(myDpm))){ if((VERSION.SDK_INT>=26&&isDeviceOwner(myDpm))||(VERSION.SDK_INT>=24&&isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var orgName by remember{mutableStateOf(try{myDpm.getOrganizationName(myComponent).toString()}catch(e:SecurityException){""})} var orgName by remember{mutableStateOf(try{myDpm.getOrganizationName(myComponent).toString()}catch(e:SecurityException){""})}
Text(text = "组织名称", style = typography.titleLarge) Text(text = "组织名称", style = typography.titleLarge, color = titleColor)
TextField( OutlinedTextField(
value = orgName, onValueChange = {orgName=it}, modifier = Modifier.fillMaxWidth().padding(vertical = 3.dp), value = orgName, onValueChange = {orgName=it}, modifier = Modifier.fillMaxWidth().padding(vertical = 3.dp),
label = {Text("组织名称")}, label = {Text("组织名称")},
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
@@ -264,21 +263,14 @@ fun DpmPermissions(navCtrl:NavHostController){
accountlist = "" accountlist = ""
if (noManageAccount != null) { if (noManageAccount != null) {
var count = noManageAccount!!.size var count = noManageAccount!!.size
for(eachAccount in noManageAccount!!){ for(each in noManageAccount!!){ count -= 1; accountlist += each; if(count>0){accountlist += "\n"} }
count -= 1
accountlist += eachAccount
if(count>0){accountlist += "\n"}
} }
} }
} var inited by remember{mutableStateOf(false)}
refreshList() if(!inited){ refreshList(); inited=true }
if(accountlist!=""){ Text(text = if(accountlist==""){""}else{accountlist}, style = bodyTextStyle)
Text(text = accountlist, color = titleColor)
}else{
Text("",style=bodyTextStyle)
}
var inputText by remember{ mutableStateOf("") } var inputText by remember{ mutableStateOf("") }
TextField( OutlinedTextField(
value = inputText, value = inputText,
onValueChange = {inputText=it}, onValueChange = {inputText=it},
label = {Text("账号类型")}, label = {Text("账号类型")},
@@ -327,15 +319,15 @@ fun DpmPermissions(navCtrl:NavHostController){
Column(modifier = sections()){ Column(modifier = sections()){
var pkg by remember{mutableStateOf("")} var pkg by remember{mutableStateOf("")}
var cls by remember{mutableStateOf("")} var cls by remember{mutableStateOf("")}
Text(text = "转移所有权", style = typography.titleLarge) Text(text = "转移所有权", style = typography.titleLarge, color = titleColor)
Text(text = "把Device owner或Profile owner权限转移到另一个应用。目标必须是Device admin", style = bodyTextStyle) Text(text = "把Device owner或Profile owner权限转移到另一个应用。目标必须是Device admin", style = bodyTextStyle)
TextField( OutlinedTextField(
value = pkg, onValueChange = {pkg = it}, label = {Text("目标包名")}, value = pkg, onValueChange = {pkg = it}, label = {Text("目标包名")},
modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp), modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
keyboardActions = KeyboardActions(onNext = {focusManager.moveFocus(FocusDirection.Down)}) keyboardActions = KeyboardActions(onNext = {focusManager.moveFocus(FocusDirection.Down)})
) )
TextField( OutlinedTextField(
value = cls, onValueChange = {cls = it}, label = {Text("目标类名")}, value = cls, onValueChange = {cls = it}, label = {Text("目标类名")},
modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp), modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
@@ -350,7 +342,7 @@ fun DpmPermissions(navCtrl:NavHostController){
Toast.makeText(myContext, "失败", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, "失败", Toast.LENGTH_SHORT).show()
} }
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth().padding(top = 2.dp)
) { ) {
Text("转移") Text("转移")
} }
@@ -417,7 +409,7 @@ fun DeviceOwnerInfo(
style = if(!isWear){typography.bodyLarge}else{typography.bodyMedium}) style = if(!isWear){typography.bodyLarge}else{typography.bodyMedium})
} }
var inputContent by remember{ mutableStateOf(input()) } var inputContent by remember{ mutableStateOf(input()) }
TextField( OutlinedTextField(
value = if(inputContent!=null){ inputContent.toString() }else{""}, value = if(inputContent!=null){ inputContent.toString() }else{""},
label = {Text(stringResource(textfield))}, label = {Text(stringResource(textfield))},
onValueChange = { inputContent=it }, onValueChange = { inputContent=it },

View File

@@ -28,9 +28,10 @@ fun AppSetting(navCtrl:NavHostController){
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
val isWear = sharedPref.getBoolean("isWear",false) val isWear = sharedPref.getBoolean("isWear",false)
val bodyTextStyle = if(isWear){typography.bodyMedium}else{typography.bodyLarge} val bodyTextStyle = if(isWear){typography.bodyMedium}else{typography.bodyLarge}
val titleColor = colorScheme.onPrimaryContainer
Column(modifier = sections()) { Column(modifier = sections()) {
Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 3.dp),horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 3.dp),horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {
Text(text = "Wear", style = typography.titleLarge) Text(text = "Wear", style = typography.titleLarge, color = titleColor)
Switch( Switch(
checked = isWear, checked = isWear,
onCheckedChange = { onCheckedChange = {
@@ -41,7 +42,7 @@ fun AppSetting(navCtrl:NavHostController){
} }
if(VERSION.SDK_INT>=32){ if(VERSION.SDK_INT>=32){
Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 3.dp),horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 3.dp),horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {
Text(text = "动态取色", style = typography.titleLarge) Text(text = "动态取色", style = typography.titleLarge, color = titleColor)
Switch( Switch(
checked = sharedPref.getBoolean("dynamicColor",false), checked = sharedPref.getBoolean("dynamicColor",false),
onCheckedChange = { onCheckedChange = {
@@ -57,7 +58,7 @@ fun AppSetting(navCtrl:NavHostController){
Column( Column(
modifier = Modifier.padding(start = 8.dp, end = 8.dp, bottom = 12.dp) modifier = Modifier.padding(start = 8.dp, end = 8.dp, bottom = 12.dp)
) { ) {
Text(text = "关于", style = typography.headlineSmall, color = colorScheme.onPrimaryContainer) Text(text = "关于", style = typography.headlineSmall, color = titleColor)
Text(text = "使用安卓的Device admin、Device owner 、Profile owner全方位掌控你的设备", style = bodyTextStyle) Text(text = "使用安卓的Device admin、Device owner 、Profile owner全方位掌控你的设备", style = bodyTextStyle)
Spacer(Modifier.padding(vertical = 4.dp)) Spacer(Modifier.padding(vertical = 4.dp))
Text(text = "这个应用只在AOSP和LineageOS上测试过不确保每个功能都在其它系统可用尤其是国内的魔改系统。", style = bodyTextStyle) Text(text = "这个应用只在AOSP和LineageOS上测试过不确保每个功能都在其它系统可用尤其是国内的魔改系统。", style = bodyTextStyle)

View File

@@ -14,8 +14,8 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@@ -65,7 +65,7 @@ fun SysUpdatePolicy(){
if(selectedPolicy==2){ if(selectedPolicy==2){
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.Center) { Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.Center) {
TextField( OutlinedTextField(
value = windowedPolicyStart, value = windowedPolicyStart,
label = { Text("开始时间")}, label = { Text("开始时间")},
onValueChange = {windowedPolicyStart=it}, onValueChange = {windowedPolicyStart=it},
@@ -74,7 +74,7 @@ fun SysUpdatePolicy(){
modifier = Modifier.fillMaxWidth(0.5F) modifier = Modifier.fillMaxWidth(0.5F)
) )
Spacer(Modifier.padding(horizontal = 3.dp)) Spacer(Modifier.padding(horizontal = 3.dp))
TextField( OutlinedTextField(
value = windowedPolicyEnd, value = windowedPolicyEnd,
onValueChange = {windowedPolicyEnd=it}, onValueChange = {windowedPolicyEnd=it},
label = {Text("结束时间")}, label = {Text("结束时间")},

View File

@@ -50,8 +50,9 @@ fun UserManage() {
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
val isWear = sharedPref.getBoolean("isWear",false) val isWear = sharedPref.getBoolean("isWear",false)
val bodyTextStyle = if(isWear){ typography.bodyMedium}else{ typography.bodyLarge} val bodyTextStyle = if(isWear){ typography.bodyMedium}else{ typography.bodyLarge}
val titleColor = colorScheme.onPrimaryContainer
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "用户信息", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) Text(text = "用户信息", style = typography.titleLarge, color = titleColor)
Text("用户已解锁:${UserManagerCompat.isUserUnlocked(myContext)}",style = bodyTextStyle) Text("用户已解锁:${UserManagerCompat.isUserUnlocked(myContext)}",style = bodyTextStyle)
if(VERSION.SDK_INT>=24){ Text("支持多用户:${UserManager.supportsMultipleUsers()}",style = bodyTextStyle) } if(VERSION.SDK_INT>=24){ Text("支持多用户:${UserManager.supportsMultipleUsers()}",style = bodyTextStyle) }
if(VERSION.SDK_INT>=23){ Text(text = "系统用户:${userManager.isSystemUser}", style = bodyTextStyle) } if(VERSION.SDK_INT>=23){ Text(text = "系统用户:${userManager.isSystemUser}", style = bodyTextStyle) }
@@ -73,7 +74,7 @@ fun UserManage() {
} }
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "用户操作", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) Text(text = "用户操作", style = typography.titleLarge,color = titleColor)
var idInput by remember{ mutableStateOf("") } var idInput by remember{ mutableStateOf("") }
var userHandleById:UserHandle by remember{ mutableStateOf(android.os.Process.myUserHandle()) } var userHandleById:UserHandle by remember{ mutableStateOf(android.os.Process.myUserHandle()) }
var useUid by remember{ mutableStateOf(false) } var useUid by remember{ mutableStateOf(false) }
@@ -195,7 +196,7 @@ fun UserManage() {
if(VERSION.SDK_INT>=24){ if(VERSION.SDK_INT>=24){
Column(modifier = sections()) { Column(modifier = sections()) {
var userName by remember{ mutableStateOf("") } var userName by remember{ mutableStateOf("") }
Text(text = "创建用户", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) Text(text = "创建用户", style = typography.titleLarge, color = titleColor)
TextField( TextField(
value = userName, value = userName,
onValueChange = {userName=it}, onValueChange = {userName=it},
@@ -249,7 +250,7 @@ fun UserManage() {
} }
var inited by remember{mutableStateOf(false)} var inited by remember{mutableStateOf(false)}
if(!inited){affiliationID = myDpm.getAffiliationIds(myComponent);refresh();inited=true} if(!inited){affiliationID = myDpm.getAffiliationIds(myComponent);refresh();inited=true}
Text(text = "附属用户ID", style = typography.titleLarge) Text(text = "附属用户ID", style = typography.titleLarge, color = titleColor)
TextField( TextField(
value = input, value = input,
onValueChange = {input = it}, onValueChange = {input = it},
@@ -299,7 +300,7 @@ fun UserManage() {
if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var getContent by remember{mutableStateOf(false)} var getContent by remember{mutableStateOf(false)}
Text(text = "用户图标", style = typography.titleLarge) Text(text = "用户图标", style = typography.titleLarge, color = titleColor)
Text(text = "尽量选择正方形的图片,以免产生问题", style = bodyTextStyle) Text(text = "尽量选择正方形的图片,以免产生问题", style = bodyTextStyle)
CheckBoxItem("使用文件选择器而不是相册",{getContent},{getContent=!getContent}) CheckBoxItem("使用文件选择器而不是相册",{getContent},{getContent=!getContent})
Button( Button(

View File

@@ -124,7 +124,7 @@ fun SectionTab(txt:String,getSection:()->Boolean,setSection:()->Unit){
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
Text( Text(
text = txt, text = txt,
color = if(getSection()){ colorScheme.onTertiaryContainer }else{ colorScheme.onPrimaryContainer }, color = if(getSection()){ colorScheme.onTertiaryContainer.copy(alpha = 0.8F) }else{ colorScheme.onPrimaryContainer.copy(alpha = 0.8F) },
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
style = if(!sharedPref.getBoolean("isWear",false)){typography.headlineMedium}else{typography.titleLarge}, style = if(!sharedPref.getBoolean("isWear",false)){typography.headlineMedium}else{typography.titleLarge},
modifier = Modifier modifier = Modifier

View File

@@ -48,7 +48,7 @@ val md_theme_dark_error = Color(0xFFFFB4AB)
val md_theme_dark_errorContainer = Color(0xFF93000A) val md_theme_dark_errorContainer = Color(0xFF93000A)
val md_theme_dark_onError = Color(0xFF690005) val md_theme_dark_onError = Color(0xFF690005)
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6) val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
val md_theme_dark_background = Color(0xFF191C1C) val md_theme_dark_background = Color(0xFF000000)
val md_theme_dark_onBackground = Color(0xFFE0E3E2) val md_theme_dark_onBackground = Color(0xFFE0E3E2)
val md_theme_dark_surface = Color(0xFF191C1C) val md_theme_dark_surface = Color(0xFF191C1C)
val md_theme_dark_onSurface = Color(0xFFE0E3E2) val md_theme_dark_onSurface = Color(0xFFE0E3E2)