mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
beautify UI
This commit is contained in:
@@ -6,8 +6,11 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
@@ -22,6 +25,7 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -33,80 +37,76 @@ fun DpmPermissions(myDpm: DevicePolicyManager, myComponent: ComponentName, myCon
|
||||
//da:DeviceAdmin do:DeviceOwner
|
||||
val isda = myDpm.isAdminActive(myComponent)
|
||||
val isdo = myDpm.isDeviceOwnerApp("com.binbin.androidowner")
|
||||
val ispo = myDpm.isProfileOwnerApp("com.binbin.androidowner")
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(8.dp)
|
||||
.verticalScroll(rememberScrollState())
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text("权限:DeviceAdmin < ProfileOwner < DeviceOwner")
|
||||
Column(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)
|
||||
.clip(RoundedCornerShape(8))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp)
|
||||
.padding(10.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(text = "Device Admin", style = MaterialTheme.typography.titleLarge)
|
||||
Text("Device Admin: $isda")
|
||||
Column {
|
||||
Text(text = "Device Admin", style = MaterialTheme.typography.titleLarge)
|
||||
Text(if(isda){"已激活"}else{"未激活"})
|
||||
}
|
||||
if(isda){
|
||||
Button(onClick = {myDpm.removeActiveAdmin(myComponent)}) {
|
||||
Text("撤销")
|
||||
}
|
||||
}else{
|
||||
Button(onClick = { ActivateDeviceAdmin(myDpm, myComponent, myContext) }) {
|
||||
Text("激活")
|
||||
}
|
||||
}
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)
|
||||
.clip(RoundedCornerShape(8))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column {
|
||||
Text(text = "Device Owner", style = MaterialTheme.typography.titleLarge)
|
||||
Text(if(isda){"已激活"}else{"未激活"})
|
||||
}
|
||||
if(isdo){
|
||||
Button(onClick = {myDpm.clearDeviceOwnerApp("com.binbin.androidowner")}) {
|
||||
Text("撤销")
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isdo||isda){Text("注意!在这里撤销权限不会清除配置。比如:被停用的应用会保持停用状态")}
|
||||
Spacer(Modifier.padding(5.dp))
|
||||
if(!isda){
|
||||
SelectionContainer {
|
||||
Text("dpm set-active-admin com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver")
|
||||
}
|
||||
Button(onClick = {Runtime.getRuntime().exec("su -c \"dpm set-active-admin com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver\"")}) {
|
||||
Text("获取DeviceAdmin(需root,未测试)")
|
||||
}
|
||||
Button(onClick = { ActivateDeviceAdmin(myDpm, myComponent, myContext) }) {
|
||||
Text("在设置中激活DeviceAdmin")
|
||||
}
|
||||
Button(onClick = {myDpm.removeActiveAdmin(myComponent)}) {
|
||||
Text("不当Device Admin了")
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(6.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(8))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
Text(text = "Device Owner", style = MaterialTheme.typography.titleLarge)
|
||||
Text("Device Owner: $isdo")
|
||||
if(!isdo){
|
||||
SelectionContainer {
|
||||
Text("dpm set-device-owner com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver")
|
||||
}
|
||||
Button(onClick = {Runtime.getRuntime().exec("su -c \"dpm set-device-owner com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver\"")}) {
|
||||
Text("获取DeviceOwner(需root,未测试)")
|
||||
}
|
||||
Button(onClick = {myDpm.clearDeviceOwnerApp("com.binbin.androidowner")}) {
|
||||
Text("不当Device Owner了")
|
||||
}
|
||||
Text("注意!在这里清除权限不会清除配置。比如:被停用的应用会保持停用状态")
|
||||
}
|
||||
if(isdo){
|
||||
var lockScrInfo by remember { mutableStateOf("") }
|
||||
TextField(value = lockScrInfo, onValueChange = { lockScrInfo= it}, label = { Text("锁屏信息") })
|
||||
Spacer(Modifier.padding(5.dp))
|
||||
Button(onClick = {myDpm.setDeviceOwnerLockScreenInfo(myComponent,lockScrInfo)}) {
|
||||
Text("设置锁屏DeviceOwner信息")
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(6.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(8))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp)
|
||||
) {
|
||||
Text("Profile Owner是一个过时的功能,目前在这个应用里没啥用。")
|
||||
Text(text = "Profile Owner", style = MaterialTheme.typography.titleLarge)
|
||||
Text("Profile Owner: $ispo")
|
||||
SelectionContainer {
|
||||
Text("dpm set-profile-owner com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver")
|
||||
}
|
||||
Button(onClick = {Runtime.getRuntime().exec("su -c \"dpm set-profile-owner com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver\"")}) {
|
||||
Text("获取ProfileOwner(需root,未测试)")
|
||||
}
|
||||
Button(onClick = {myDpm.clearProfileOwner(myComponent)}) {
|
||||
Text("不当Profile Owner了")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,5 +122,4 @@ fun ActivateDeviceAdmin(myDpm: DevicePolicyManager,myComponent: ComponentName,my
|
||||
} else {
|
||||
Toast.makeText(myContext, "已经激活", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user