diff --git a/app/src/main/java/com/binbin/androidowner/ApplicationManage.kt b/app/src/main/java/com/binbin/androidowner/ApplicationManage.kt index 0f02715..7e29c63 100644 --- a/app/src/main/java/com/binbin/androidowner/ApplicationManage.kt +++ b/app/src/main/java/com/binbin/androidowner/ApplicationManage.kt @@ -60,6 +60,7 @@ fun ApplicationManage(){ val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val isWear = sharedPref.getBoolean("isWear",false) val bodyTextStyle = if(isWear){ typography.bodyMedium }else{ typography.bodyLarge } + val titleColor = colorScheme.onPrimaryContainer Column{ if(!isWear){ TextField( @@ -81,7 +82,7 @@ fun ApplicationManage(){ keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}) ) - } + }else{Spacer(Modifier.padding(vertical = 2.dp))} if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ 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)){ Column(modifier = sections()){ 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(text = "有时候无法正确获取防卸载状态", style = bodyTextStyle) Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth()) { @@ -166,7 +167,7 @@ fun ApplicationManage(){ } var inited by remember{mutableStateOf(false)} if(!inited){refresh();inited=true} - Text(text = "禁止用户控制", style = typography.titleLarge) + Text(text = "禁止用户控制", style = typography.titleLarge, color = titleColor) Text(text = "用户将无法清除应用的存储空间和缓存", style = bodyTextStyle) Text(text = "应用列表:") if(listText!=""){ @@ -220,7 +221,7 @@ fun ApplicationManage(){ Column(modifier = sections()){ var inputPermission by remember{mutableStateOf("android.permission.")} var currentState by remember{mutableStateOf(grantState[myDpm.getPermissionGrantState(myComponent,pkgName,inputPermission)])} - Text(text = "权限管理", style = typography.titleLarge) + Text(text = "权限管理", style = typography.titleLarge, color = titleColor) OutlinedTextField( value = inputPermission, label = { Text("权限")}, @@ -266,7 +267,7 @@ fun ApplicationManage(){ if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ Column(modifier = sections()){ - Text(text = "跨资料应用", style = typography.titleLarge) + Text(text = "跨资料应用", style = typography.titleLarge, color = titleColor) var list by remember{mutableStateOf("")} val refresh = { crossProfilePkg = myDpm.getCrossProfilePackages(myComponent) @@ -314,7 +315,7 @@ fun ApplicationManage(){ } var inited by remember{mutableStateOf(false)} if(!inited){refresh();inited=true} - Text(text = "跨资料微件", style = typography.titleLarge) + Text(text = "跨资料微件", style = typography.titleLarge, color = titleColor) Text(text = "(跨资料桌面小部件提供者)", style = bodyTextStyle) Text(text = if(list!=""){list}else{"无"}, style = bodyTextStyle) Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ @@ -358,7 +359,7 @@ fun ApplicationManage(){ var inited by remember{mutableStateOf(false)} if(!inited){refreshPolicy(); refreshText(); inited = true} Column(modifier = sections()){ - Text(text = "凭据管理策略", style = typography.titleLarge) + Text(text = "凭据管理策略", style = typography.titleLarge, color = titleColor) RadioButtonItem("无",{policyType==-1},{policyType=-1}) RadioButtonItem("黑名单",{policyType==PACKAGE_POLICY_BLOCKLIST},{policyType=PACKAGE_POLICY_BLOCKLIST}) RadioButtonItem("白名单",{policyType==PACKAGE_POLICY_ALLOWLIST},{policyType=PACKAGE_POLICY_ALLOWLIST}) @@ -415,7 +416,7 @@ fun ApplicationManage(){ if(isProfileOwner(myDpm)||isDeviceOwner(myDpm)){ Column(modifier = sections()) { - Text(text = "许可的无障碍应用", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) + Text(text = "许可的无障碍应用", style = typography.titleLarge, color = titleColor) var listText by remember{ mutableStateOf("") } val refreshList = { listText = "" @@ -460,7 +461,7 @@ fun ApplicationManage(){ if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){ Column(modifier = sections()) { - Text(text = "许可的输入法", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) + Text(text = "许可的输入法", style = typography.titleLarge, color = titleColor) var imeListText by remember{ mutableStateOf("") } val refreshList = { imeListText = "" @@ -503,7 +504,7 @@ fun ApplicationManage(){ if(VERSION.SDK_INT>=28&&isDeviceOwner(myDpm)){ Column(modifier = sections()){ - Text(text = "保持卸载的应用", style = typography.titleLarge) + Text(text = "保持卸载的应用", style = typography.titleLarge, color = titleColor) Text(text = "作用未知", style = bodyTextStyle) var listText by remember{mutableStateOf("")} val refresh = { @@ -591,7 +592,7 @@ fun ApplicationManage(){ } Column(modifier = sections()){ - Text(text = "卸载应用", style = typography.titleLarge) + Text(text = "卸载应用", style = typography.titleLarge, color = titleColor) Text(text = "静默卸载需Device owner", style = bodyTextStyle) Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Button( @@ -619,7 +620,7 @@ fun ApplicationManage(){ } Column(modifier = sections()){ - Text(text = "安装应用", style = typography.titleLarge) + Text(text = "安装应用", style = typography.titleLarge, color = titleColor) Text(text = "静默安装需Device owner", style = bodyTextStyle) Button( onClick = { diff --git a/app/src/main/java/com/binbin/androidowner/DeviceControl.kt b/app/src/main/java/com/binbin/androidowner/DeviceControl.kt index a3da0a0..497ce35 100644 --- a/app/src/main/java/com/binbin/androidowner/DeviceControl.kt +++ b/app/src/main/java/com/binbin/androidowner/DeviceControl.kt @@ -42,6 +42,7 @@ fun DeviceControl(){ val myComponent = ComponentName(myContext,MyDeviceAdminReceiver::class.java) val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val isWear = sharedPref.getBoolean("isWear",false) + val titleColor = colorScheme.onPrimaryContainer val userManager = myContext.getSystemService(Context.USER_SERVICE) as UserManager val bodyTextStyle = if(isWear){typography.bodyMedium}else{typography.bodyLarge} val focusMgr = LocalFocusManager.current @@ -126,7 +127,7 @@ fun DeviceControl(){ } Column(modifier = sections()){ - Text(text = "锁屏", style = typography.titleLarge) + Text(text = "锁屏", style = typography.titleLarge, color = titleColor) 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} }) } Button( @@ -162,10 +163,10 @@ fun DeviceControl(){ if(VERSION.SDK_INT>=28){ Column(modifier = sections()){ - Text(text = "修改时间", style = typography.titleLarge) + Text(text = "修改时间", style = typography.titleLarge, color = titleColor) var inputTime by remember{mutableStateOf("")} Text(text = "从Epoch(1970/1/1 00:00:00 UTC)到你想设置的时间(毫秒)", style = bodyTextStyle) - TextField( + OutlinedTextField( value = inputTime, label = { Text("时间(ms)")}, onValueChange = {inputTime = it}, @@ -205,7 +206,7 @@ fun DeviceControl(){ if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ Column(modifier = sections()){ 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_AUTO_GRANT}, {selectedPolicy= PERMISSION_POLICY_AUTO_GRANT}) RadioButtonItem("自动拒绝", {selectedPolicy==PERMISSION_POLICY_AUTO_DENY}, {selectedPolicy= PERMISSION_POLICY_AUTO_DENY}) @@ -223,7 +224,7 @@ fun DeviceControl(){ if(VERSION.SDK_INT>=34&&isDeviceOwner(myDpm)){ Column(modifier = sections()){ - Text(text = "MTE策略", style = typography.titleLarge, color = colorScheme.onPrimaryContainer) + Text(text = "MTE策略", style = typography.titleLarge, color = titleColor) Text("MTE:内存标记拓展,安卓14和ARMv9的高端功能") var selectedMtePolicy by remember{mutableIntStateOf(myDpm.mtePolicy)} 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))){ Column(modifier = sections()){ 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_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem("禁用",{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED}) @@ -265,7 +266,7 @@ fun DeviceControl(){ } Spacer(Modifier.padding(vertical = 3.dp)) 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_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem("禁用",{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED}) @@ -317,7 +318,7 @@ fun DeviceControl(){ 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 } Text(text = "在锁定任务模式下:", style = bodyTextStyle) RadioButtonItem("禁用全部",{!custom},{custom=false}) @@ -368,9 +369,9 @@ fun DeviceControl(){ } } refreshWhitelist() - Text(text = "白名单应用", style = typography.titleLarge) + Text(text = "白名单应用", style = typography.titleLarge, color = titleColor) if(listText!=""){ Text(listText) }else{ Text(("无")) } - TextField( + OutlinedTextField( value = inputPkg, onValueChange = {inputPkg=it}, label = {Text("包名")}, @@ -420,7 +421,7 @@ fun DeviceControl(){ } LaunchedEffect(exist){ launch{isCaCertSelected(600){refresh()}} } 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") } Button( onClick = { @@ -471,7 +472,7 @@ fun DeviceControl(){ if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isOrganizationOwnedDeviceWithManagedProfile))){ Column(modifier = sections()){ - Text(text = "收集安全日志", style = typography.titleLarge) + Text(text = "收集安全日志", style = typography.titleLarge, color = titleColor) Text(text = "功能开发中", style = bodyTextStyle) Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){ 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>=29){ CheckBoxItem("静默清除",{silent},{silent=!silent}, colorScheme.onErrorContainer) } AnimatedVisibility(!silent&&VERSION.SDK_INT>=28) { - TextField( + OutlinedTextField( value = reason, onValueChange = {reason=it}, label = {Text("原因")}, enabled = !confirmed, diff --git a/app/src/main/java/com/binbin/androidowner/MainActivity.kt b/app/src/main/java/com/binbin/androidowner/MainActivity.kt index 13363db..45df71c 100644 --- a/app/src/main/java/com/binbin/androidowner/MainActivity.kt +++ b/app/src/main/java/com/binbin/androidowner/MainActivity.kt @@ -200,7 +200,7 @@ fun HomePage(navCtrl:NavHostController){ .fillMaxWidth() .padding(vertical = if (!isWear) { 5.dp } else { 2.dp }, horizontal = if (!isWear) { 8.dp } else { 4.dp }) .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") }) .padding( horizontal = 5.dp, @@ -244,7 +244,7 @@ fun HomePageItem(name:Int, imgVector:Int, navTo:String, myNav:NavHostController) .fillMaxWidth() .padding(vertical = if (!isWear) { 4.dp } else { 2.dp }, horizontal = if (!isWear) { 7.dp } else { 4.dp }) .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) }) .padding(vertical = if(isWear){6.dp}else{10.dp}, horizontal = 6.dp), verticalAlignment = Alignment.CenterVertically @@ -323,7 +323,7 @@ fun isProfileOwner(dpm:DevicePolicyManager): Boolean { @Composable @Stable 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)){ Modifier .fillMaxWidth() diff --git a/app/src/main/java/com/binbin/androidowner/ManagedProfile.kt b/app/src/main/java/com/binbin/androidowner/ManagedProfile.kt index d85cfb9..66e2351 100644 --- a/app/src/main/java/com/binbin/androidowner/ManagedProfile.kt +++ b/app/src/main/java/com/binbin/androidowner/ManagedProfile.kt @@ -19,9 +19,9 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Switch import androidx.compose.material3.Text -import androidx.compose.material3.TextField import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -41,10 +41,11 @@ fun ManagedProfile() { val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val isWear = sharedPref.getBoolean("isWear",false) val bodyTextStyle = if(isWear){ typography.bodyMedium}else{ typography.bodyLarge} + val titleColor = colorScheme.onPrimaryContainer Column(modifier = Modifier.verticalScroll(rememberScrollState())){ Column(modifier = sections()){ - Text(text = "信息", style = typography.titleLarge) + Text(text = "信息", style = typography.titleLarge, color = titleColor) if(VERSION.SDK_INT>=24){ if(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ Text(text = "已是工作资料") @@ -77,7 +78,7 @@ fun ManagedProfile() { if(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)&&!myDpm.isOrganizationOwnedDeviceWithManagedProfile){ Column(modifier = sections(colorScheme.tertiaryContainer)){ - Text("成为组织拥有的工作资料") + Text(text = "成为组织拥有的工作资料", color = titleColor) Text(text = "首先在“用户管理”中查看UserID,然后使用ADB执行下面这条命令", style = bodyTextStyle) SelectionContainer { Text( @@ -90,7 +91,7 @@ fun ManagedProfile() { } if(!isProfileOwner(myDpm)&&(VERSION.SDK_INT<24||(VERSION.SDK_INT>=24&&myDpm.isProvisioningAllowed(ACTION_PROVISION_MANAGED_PROFILE)))){ Column(modifier = sections()) { - Text(text = "工作资料", style = typography.titleLarge) + Text(text = "工作资料", style = typography.titleLarge, color = titleColor) var skipEncrypt by remember{mutableStateOf(false)} if(VERSION.SDK_INT>=24){CheckBoxItem("跳过加密",{skipEncrypt},{skipEncrypt=!skipEncrypt})} Button( @@ -116,7 +117,7 @@ fun ManagedProfile() { Row(modifier = sections(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically){ var suspended by remember{mutableStateOf(false)} suspended = myDpm.getPersonalAppsSuspendedReasons(myComponent)!=PERSONAL_APPS_NOT_SUSPENDED - Text(text = "挂起个人应用", style = typography.titleLarge) + Text(text = "挂起个人应用", style = typography.titleLarge, color = titleColor) Switch( checked = suspended, onCheckedChange ={ @@ -131,10 +132,10 @@ fun ManagedProfile() { Column(modifier = sections()){ var time by remember{mutableStateOf("")} time = myDpm.getManagedProfileMaximumTimeOff(myComponent).toString() - Text(text = "资料关闭时间", style = typography.titleLarge) + Text(text = "资料关闭时间", style = typography.titleLarge, color = titleColor) Text(text = "工作资料处于关闭状态的时间达到该限制后会挂起个人应用,0为无限制", style = bodyTextStyle) Text(text = "个人应用已经因此挂起:${myDpm.getPersonalAppsSuspendedReasons(myComponent)==PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT}") - TextField( + OutlinedTextField( value = time, onValueChange = {time=it}, modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp), label = {Text("时间(ms)")}, 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)))){ Column(modifier = sections()){ var action by remember{mutableStateOf("")} - Text(text = "Intent过滤器", style = typography.titleLarge) - TextField( + Text(text = "Intent过滤器", style = typography.titleLarge, color = titleColor) + OutlinedTextField( value = action, onValueChange = {action = it}, label = {Text("Action")}, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), @@ -199,8 +200,8 @@ fun ManagedProfile() { if(VERSION.SDK_INT>=31&&(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent))){ Column(modifier = sections()){ var orgId by remember{mutableStateOf("")} - Text(text = "组织ID", style = typography.titleLarge) - TextField( + Text(text = "组织ID", style = typography.titleLarge, color = titleColor) + OutlinedTextField( value = orgId, onValueChange = {orgId=it}, label = {Text("组织ID")}, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), diff --git a/app/src/main/java/com/binbin/androidowner/Network.kt b/app/src/main/java/com/binbin/androidowner/Network.kt index f9db9ee..15aa1d7 100644 --- a/app/src/main/java/com/binbin/androidowner/Network.kt +++ b/app/src/main/java/com/binbin/androidowner/Network.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextField @@ -47,6 +48,7 @@ fun Network(){ val isWear = sharedPref.getBoolean("isWear",false) val bodyTextStyle = if(isWear){ typography.bodyMedium }else{ typography.bodyLarge } val focusMgr = LocalFocusManager.current + val titleColor = colorScheme.onPrimaryContainer if(VERSION.SDK_INT>=24){ val wifimac = try { myDpm.getWifiMacAddress(myComponent).toString() }catch(e:SecurityException){ "没有权限" } @@ -66,7 +68,7 @@ fun Network(){ if(VERSION.SDK_INT>=33){ Column(modifier = sections()){ 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("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}) @@ -108,12 +110,12 @@ fun Network(){ } var inited by remember{mutableStateOf(false)} 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_DENYLIST},{selectedPolicyType=WIFI_SSID_POLICY_TYPE_DENYLIST}) Text("SSID列表:") Text(text = if(ssidList!=""){ssidList}else{"无"}, style = bodyTextStyle) - TextField( + OutlinedTextField( value = inputSsid, label = { Text("SSID")}, onValueChange = {inputSsid = it}, @@ -161,7 +163,7 @@ fun Network(){ } if(VERSION.SDK_INT>=29&&isDeviceOwner(myDpm)){ Column(modifier = sections()){ - Text(text = "私人DNS", style = typography.titleLarge) + Text(text = "私人DNS", style = typography.titleLarge, color = titleColor) val dnsStatus = mapOf( DevicePolicyManager.PRIVATE_DNS_MODE_UNKNOWN to "未知", DevicePolicyManager.PRIVATE_DNS_MODE_OFF to "关闭", @@ -187,7 +189,7 @@ fun Network(){ } Spacer(Modifier.padding(vertical = 3.dp)) var inputHost by remember{mutableStateOf(myDpm.getGlobalPrivateDnsHost(myComponent) ?: "")} - TextField( + OutlinedTextField( value = inputHost, onValueChange = {inputHost=it}, label = {Text("DNS主机名")}, @@ -218,7 +220,7 @@ fun Network(){ if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)))){ Column(modifier = sections()){ - Text(text = "收集网络日志", style = typography.titleLarge) + Text(text = "收集网络日志", style = typography.titleLarge, color = titleColor) Text(text = "功能开发中", style = bodyTextStyle) Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){ var checked by remember{mutableStateOf(myDpm.isNetworkLoggingEnabled(myComponent))} @@ -249,8 +251,8 @@ fun Network(){ if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ Column(modifier = sections()){ var keyPair by remember{mutableStateOf("")} - Text(text = "WiFi密钥对", style = typography.titleLarge) - TextField( + Text(text = "WiFi密钥对", style = typography.titleLarge, color = titleColor) + OutlinedTextField( value = keyPair, label = { Text("密钥对")}, onValueChange = {keyPair = it}, @@ -289,7 +291,7 @@ fun Network(){ var inputNum by remember{mutableStateOf("0")} var nextStep by remember{mutableStateOf(false)} 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){ Text(text = "启用", style = typography.titleLarge) Switch(checked = myDpm.isOverrideApnEnabled(myComponent), onCheckedChange = {myDpm.setOverrideApnsEnabled(myComponent,it)}) diff --git a/app/src/main/java/com/binbin/androidowner/Password.kt b/app/src/main/java/com/binbin/androidowner/Password.kt index 05c21a5..1f9789e 100644 --- a/app/src/main/java/com/binbin/androidowner/Password.kt +++ b/app/src/main/java/com/binbin/androidowner/Password.kt @@ -10,9 +10,11 @@ import android.os.Build.VERSION import android.widget.Toast import androidx.activity.ComponentActivity import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.clickable import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll @@ -24,9 +26,11 @@ import androidx.compose.material3.MaterialTheme.typography import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType @@ -144,7 +148,7 @@ fun Password(){ ) { var confirmed by remember{ mutableStateOf(false) } Text(text = "修改密码",style = typography.titleLarge,color = titleColor) - TextField( + OutlinedTextField( value = newPwd, onValueChange = {newPwd=it}, enabled = !confirmed&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm)||myDpm.isAdminActive(myComponent)), @@ -437,7 +441,7 @@ private fun PasswordItem( horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth() ){ - TextField( + OutlinedTextField( value = inputContent, label = { Text(stringResource(textFieldLabel))}, onValueChange = { @@ -447,30 +451,17 @@ private fun PasswordItem( keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}), 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("应用") - } } } } diff --git a/app/src/main/java/com/binbin/androidowner/Permissions.kt b/app/src/main/java/com/binbin/androidowner/Permissions.kt index 907ec5a..e62ff3a 100644 --- a/app/src/main/java/com/binbin/androidowner/Permissions.kt +++ b/app/src/main/java/com/binbin/androidowner/Permissions.kt @@ -18,8 +18,8 @@ import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text -import androidx.compose.material3.TextField import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -33,7 +33,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.core.content.ContextCompat.startActivity import androidx.navigation.NavHostController -import java.lang.IllegalArgumentException @Composable @@ -234,8 +233,8 @@ fun DpmPermissions(navCtrl:NavHostController){ if((VERSION.SDK_INT>=26&&isDeviceOwner(myDpm))||(VERSION.SDK_INT>=24&&isProfileOwner(myDpm))){ Column(modifier = sections()){ var orgName by remember{mutableStateOf(try{myDpm.getOrganizationName(myComponent).toString()}catch(e:SecurityException){""})} - Text(text = "组织名称", style = typography.titleLarge) - TextField( + Text(text = "组织名称", style = typography.titleLarge, color = titleColor) + OutlinedTextField( value = orgName, onValueChange = {orgName=it}, modifier = Modifier.fillMaxWidth().padding(vertical = 3.dp), label = {Text("组织名称")}, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), @@ -264,21 +263,14 @@ fun DpmPermissions(navCtrl:NavHostController){ accountlist = "" if (noManageAccount != null) { var count = noManageAccount!!.size - for(eachAccount in noManageAccount!!){ - count -= 1 - accountlist += eachAccount - if(count>0){accountlist += "\n"} - } + for(each in noManageAccount!!){ count -= 1; accountlist += each; if(count>0){accountlist += "\n"} } } } - refreshList() - if(accountlist!=""){ - Text(text = accountlist, color = titleColor) - }else{ - Text("无",style=bodyTextStyle) - } + var inited by remember{mutableStateOf(false)} + if(!inited){ refreshList(); inited=true } + Text(text = if(accountlist==""){"无"}else{accountlist}, style = bodyTextStyle) var inputText by remember{ mutableStateOf("") } - TextField( + OutlinedTextField( value = inputText, onValueChange = {inputText=it}, label = {Text("账号类型")}, @@ -327,15 +319,15 @@ fun DpmPermissions(navCtrl:NavHostController){ Column(modifier = sections()){ var pkg 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) - TextField( + OutlinedTextField( value = pkg, onValueChange = {pkg = it}, label = {Text("目标包名")}, modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next), keyboardActions = KeyboardActions(onNext = {focusManager.moveFocus(FocusDirection.Down)}) ) - TextField( + OutlinedTextField( value = cls, onValueChange = {cls = it}, label = {Text("目标类名")}, modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), @@ -350,7 +342,7 @@ fun DpmPermissions(navCtrl:NavHostController){ Toast.makeText(myContext, "失败", Toast.LENGTH_SHORT).show() } }, - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth().padding(top = 2.dp) ) { Text("转移") } @@ -417,7 +409,7 @@ fun DeviceOwnerInfo( style = if(!isWear){typography.bodyLarge}else{typography.bodyMedium}) } var inputContent by remember{ mutableStateOf(input()) } - TextField( + OutlinedTextField( value = if(inputContent!=null){ inputContent.toString() }else{""}, label = {Text(stringResource(textfield))}, onValueChange = { inputContent=it }, diff --git a/app/src/main/java/com/binbin/androidowner/Setting.kt b/app/src/main/java/com/binbin/androidowner/Setting.kt index c0a945a..d85eb06 100644 --- a/app/src/main/java/com/binbin/androidowner/Setting.kt +++ b/app/src/main/java/com/binbin/androidowner/Setting.kt @@ -28,9 +28,10 @@ fun AppSetting(navCtrl:NavHostController){ val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val isWear = sharedPref.getBoolean("isWear",false) val bodyTextStyle = if(isWear){typography.bodyMedium}else{typography.bodyLarge} + val titleColor = colorScheme.onPrimaryContainer Column(modifier = sections()) { 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( checked = isWear, onCheckedChange = { @@ -41,7 +42,7 @@ fun AppSetting(navCtrl:NavHostController){ } if(VERSION.SDK_INT>=32){ 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( checked = sharedPref.getBoolean("dynamicColor",false), onCheckedChange = { @@ -57,7 +58,7 @@ fun AppSetting(navCtrl:NavHostController){ Column( 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) Spacer(Modifier.padding(vertical = 4.dp)) Text(text = "这个应用只在AOSP和LineageOS上测试过,不确保每个功能都在其它系统可用,尤其是国内的魔改系统。", style = bodyTextStyle) diff --git a/app/src/main/java/com/binbin/androidowner/SystemUpdatePolicy.kt b/app/src/main/java/com/binbin/androidowner/SystemUpdatePolicy.kt index eef332c..413bd3b 100644 --- a/app/src/main/java/com/binbin/androidowner/SystemUpdatePolicy.kt +++ b/app/src/main/java/com/binbin/androidowner/SystemUpdatePolicy.kt @@ -14,8 +14,8 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme.colorScheme import androidx.compose.material3.MaterialTheme.typography +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text -import androidx.compose.material3.TextField import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -65,7 +65,7 @@ fun SysUpdatePolicy(){ if(selectedPolicy==2){ Spacer(Modifier.padding(vertical = 3.dp)) Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.Center) { - TextField( + OutlinedTextField( value = windowedPolicyStart, label = { Text("开始时间")}, onValueChange = {windowedPolicyStart=it}, @@ -74,7 +74,7 @@ fun SysUpdatePolicy(){ modifier = Modifier.fillMaxWidth(0.5F) ) Spacer(Modifier.padding(horizontal = 3.dp)) - TextField( + OutlinedTextField( value = windowedPolicyEnd, onValueChange = {windowedPolicyEnd=it}, label = {Text("结束时间")}, diff --git a/app/src/main/java/com/binbin/androidowner/User.kt b/app/src/main/java/com/binbin/androidowner/User.kt index 6b64671..918017f 100644 --- a/app/src/main/java/com/binbin/androidowner/User.kt +++ b/app/src/main/java/com/binbin/androidowner/User.kt @@ -50,8 +50,9 @@ fun UserManage() { val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) val isWear = sharedPref.getBoolean("isWear",false) val bodyTextStyle = if(isWear){ typography.bodyMedium}else{ typography.bodyLarge} + val titleColor = colorScheme.onPrimaryContainer Column(modifier = sections()) { - Text(text = "用户信息", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) + Text(text = "用户信息", style = typography.titleLarge, color = titleColor) Text("用户已解锁:${UserManagerCompat.isUserUnlocked(myContext)}",style = bodyTextStyle) if(VERSION.SDK_INT>=24){ Text("支持多用户:${UserManager.supportsMultipleUsers()}",style = bodyTextStyle) } if(VERSION.SDK_INT>=23){ Text(text = "系统用户:${userManager.isSystemUser}", style = bodyTextStyle) } @@ -73,7 +74,7 @@ fun UserManage() { } Column(modifier = sections()) { - Text(text = "用户操作", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) + Text(text = "用户操作", style = typography.titleLarge,color = titleColor) var idInput by remember{ mutableStateOf("") } var userHandleById:UserHandle by remember{ mutableStateOf(android.os.Process.myUserHandle()) } var useUid by remember{ mutableStateOf(false) } @@ -195,7 +196,7 @@ fun UserManage() { if(VERSION.SDK_INT>=24){ Column(modifier = sections()) { var userName by remember{ mutableStateOf("") } - Text(text = "创建用户", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) + Text(text = "创建用户", style = typography.titleLarge, color = titleColor) TextField( value = userName, onValueChange = {userName=it}, @@ -249,7 +250,7 @@ fun UserManage() { } var inited by remember{mutableStateOf(false)} if(!inited){affiliationID = myDpm.getAffiliationIds(myComponent);refresh();inited=true} - Text(text = "附属用户ID", style = typography.titleLarge) + Text(text = "附属用户ID", style = typography.titleLarge, color = titleColor) TextField( value = input, onValueChange = {input = it}, @@ -299,7 +300,7 @@ fun UserManage() { if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ Column(modifier = sections()){ var getContent by remember{mutableStateOf(false)} - Text(text = "用户图标", style = typography.titleLarge) + Text(text = "用户图标", style = typography.titleLarge, color = titleColor) Text(text = "尽量选择正方形的图片,以免产生问题", style = bodyTextStyle) CheckBoxItem("使用文件选择器而不是相册",{getContent},{getContent=!getContent}) Button( diff --git a/app/src/main/java/com/binbin/androidowner/UserRestrict.kt b/app/src/main/java/com/binbin/androidowner/UserRestrict.kt index 7f1c353..70010b0 100644 --- a/app/src/main/java/com/binbin/androidowner/UserRestrict.kt +++ b/app/src/main/java/com/binbin/androidowner/UserRestrict.kt @@ -124,7 +124,7 @@ fun SectionTab(txt:String,getSection:()->Boolean,setSection:()->Unit){ val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE) Text( 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, style = if(!sharedPref.getBoolean("isWear",false)){typography.headlineMedium}else{typography.titleLarge}, modifier = Modifier diff --git a/app/src/main/java/com/binbin/androidowner/ui/theme/Color.kt b/app/src/main/java/com/binbin/androidowner/ui/theme/Color.kt index eab553d..6f8dc50 100644 --- a/app/src/main/java/com/binbin/androidowner/ui/theme/Color.kt +++ b/app/src/main/java/com/binbin/androidowner/ui/theme/Color.kt @@ -48,7 +48,7 @@ val md_theme_dark_error = Color(0xFFFFB4AB) val md_theme_dark_errorContainer = Color(0xFF93000A) val md_theme_dark_onError = Color(0xFF690005) 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_surface = Color(0xFF191C1C) val md_theme_dark_onSurface = Color(0xFFE0E3E2) diff --git a/app/src/main/res/xml/device_admin.xml b/app/src/main/res/xml/device_admin.xml index 0a4da1a..359d299 100644 --- a/app/src/main/res/xml/device_admin.xml +++ b/app/src/main/res/xml/device_admin.xml @@ -13,4 +13,4 @@ - \ No newline at end of file +