clean up unused resources

This commit is contained in:
BinTianqi
2024-01-30 19:44:11 +08:00
parent 46820e0f6c
commit ca46a775c8
11 changed files with 42 additions and 248 deletions

View File

@@ -68,7 +68,7 @@ fun DeviceControl(){
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)|| isProfileOwner(myDpm))){
DeviceCtrlItem(R.string.backup_service,R.string.place_holder,R.drawable.backup_fill0,myDpm,{myDpm.isBackupServiceEnabled(myComponent)},{b -> myDpm.setBackupServiceEnabled(myComponent,b) })
}
if(isDeviceOwner(myDpm)|| isProfileOwner(myDpm)){
if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)|| isProfileOwner(myDpm))){
DeviceCtrlItem(R.string.disable_bt_contact_share,R.string.place_holder,R.drawable.account_circle_fill0,myDpm,{myDpm.getBluetoothContactSharingDisabled(myComponent)},{b -> myDpm.setBluetoothContactSharingDisabled(myComponent,b)})
}
if(VERSION.SDK_INT>=31&&isDeviceOwner(myDpm)){

View File

@@ -214,34 +214,35 @@ fun HomePage(navCtrl:NavHostController){
}
}
}
HomePageItem(R.string.device_ctrl, R.drawable.mobile_phone_fill0, R.string.device_ctrl_desc, "DeviceControl", navCtrl)
HomePageItem(R.string.app_manage, R.drawable.apps_fill0, R.string.apps_ctrl_description, "ApplicationManage", navCtrl)
HomePageItem(R.string.user_restrict, R.drawable.manage_accounts_fill0, R.string.user_restrict_desc, "UserRestriction", navCtrl)
HomePageItem(R.string.user_manage,R.drawable.account_circle_fill0,R.string.user_manage_desc,"UserManage",navCtrl)
HomePageItem(R.string.password, R.drawable.password_fill0,R.string.security_desc, "Password",navCtrl)
HomePageItem(R.string.setting, R.drawable.info_fill0, R.string.setting_desc, "AppSetting",navCtrl)
HomePageItem(R.string.device_ctrl, R.drawable.mobile_phone_fill0, "DeviceControl", navCtrl)
HomePageItem(R.string.app_manage, R.drawable.apps_fill0, "ApplicationManage", navCtrl)
HomePageItem(R.string.user_restrict, R.drawable.manage_accounts_fill0, "UserRestriction", navCtrl)
HomePageItem(R.string.user_manage,R.drawable.account_circle_fill0,"UserManage",navCtrl)
HomePageItem(R.string.password, R.drawable.password_fill0, "Password",navCtrl)
HomePageItem(R.string.setting, R.drawable.info_fill0, "AppSetting",navCtrl)
Spacer(Modifier.padding(vertical = 20.dp))
}
}
@Composable
fun HomePageItem(name:Int, imgVector:Int, description:Int, navTo:String, myNav:NavHostController){
fun HomePageItem(name:Int, imgVector:Int, navTo:String, myNav:NavHostController){
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
val isWear = sharedPref.getBoolean("isWear", false)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = if (!sharedPref.getBoolean("isWear", false)) { 4.dp } else { 2.dp }, horizontal = if (!sharedPref.getBoolean("isWear", false)) { 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))
.background(color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.8F))
.clickable(onClick = { myNav.navigate(navTo) })
.padding(6.dp),
.padding(vertical = if(isWear){6.dp}else{10.dp}, horizontal = 6.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
painter = painterResource(imgVector),
contentDescription = null,
modifier = Modifier.padding(horizontal = if(!sharedPref.getBoolean("isWear",false)){10.dp}else{6.dp}),
modifier = Modifier.padding(horizontal = if(!sharedPref.getBoolean("isWear",false)){12.dp}else{6.dp}),
tint = MaterialTheme.colorScheme.primary
)
Column {
@@ -250,11 +251,7 @@ fun HomePageItem(name:Int, imgVector:Int, description:Int, navTo:String, myNav:N
style = MaterialTheme.typography.headlineSmall,
color = MaterialTheme.colorScheme.onPrimaryContainer
)
if(!sharedPref.getBoolean("isWear",false)){
Text(
text = stringResource(description)
)
}
Spacer(Modifier.padding(top = 2.dp))
}
}
}

View File

@@ -160,7 +160,7 @@ fun Password(){
modifier = sections()
) {
var confirmed by remember{ mutableStateOf(false) }
Text(text = "修改密码",style = MaterialTheme.typography.titleLarge,color = titleColor)
Text(text = "修改密码",style = typography.titleLarge,color = titleColor)
TextField(
value = newPwd,
onValueChange = {newPwd=it},
@@ -172,9 +172,11 @@ fun Password(){
)
Text(text = stringResource(R.string.reset_pwd_desc), modifier = Modifier.padding(vertical = 3.dp),style=if(!isWear){typography.bodyLarge}else{typography.bodyMedium})
var resetPwdFlag by remember{ mutableIntStateOf(0) }
RadioButtonItem("开机时不要求密码(如果有指纹等其他解锁方式)",
{resetPwdFlag==DevicePolicyManager.RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT},
{resetPwdFlag=DevicePolicyManager.RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT})
if(VERSION.SDK_INT>=23){
RadioButtonItem("开机时不要求密码(如果有指纹等其他解锁方式)",
{resetPwdFlag==DevicePolicyManager.RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT},
{resetPwdFlag=DevicePolicyManager.RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT})
}
RadioButtonItem("要求立即输入新密码",{resetPwdFlag==DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY},
{resetPwdFlag=DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY})
RadioButtonItem("",{resetPwdFlag==0},{resetPwdFlag=0})

View File

@@ -54,6 +54,7 @@ fun SysUpdatePolicy(myDpm:DevicePolicyManager,myComponent:ComponentName,myContex
}
}
}
if(VERSION.SDK_INT>=23){
Column(modifier = sections()) {
var selectedPolicy by remember{ mutableStateOf(myDpm.systemUpdatePolicy?.policyType) }
Text(text = "系统更新策略", style = MaterialTheme.typography.titleLarge)
@@ -101,7 +102,7 @@ fun SysUpdatePolicy(myDpm:DevicePolicyManager,myComponent:ComponentName,myContex
) {
Text("应用")
}
}
}}
/*val policy = myDpm.systemUpdatePolicy
if(VERSION.SDK_INT>=28&&policy!=null){
Column {

View File

@@ -253,15 +253,11 @@ fun userOperationResultCode(result:Int): String {
private fun createWorkProfile(myContext: Context) {
val intent = Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE)
intent.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, ComponentName(myContext,MyDeviceAdminReceiver::class.java))
if(VERSION.SDK_INT>=23){
intent.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, ComponentName(myContext,MyDeviceAdminReceiver::class.java))
}
intent.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, myContext.packageName)
if (VERSION.SDK_INT >= 33) { intent.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_ALLOW_OFFLINE,true) }
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,"hello")
myContext.startActivity(intent)
}
private fun createManagedDevice(myContext: Context) {
val intent = Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_DEVICE)
intent.putExtra(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, ComponentName(myContext,MyDeviceAdminReceiver::class.java))
myContext.startActivity(intent)
}

View File

@@ -51,7 +51,6 @@ private data class Restriction(
fun UserRestriction(){
val myContext = LocalContext.current
val myDpm = myContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val myComponent = ComponentName(myContext,MyDeviceAdminReceiver::class.java)
var internetVisible by remember{ mutableStateOf(false) }
var connectivityVisible by remember{ mutableStateOf(false) }
var applicationVisible by remember{ mutableStateOf(false) }
@@ -83,42 +82,42 @@ fun UserRestriction(){
items(1){ SectionTab("网络和互联网",{internetVisible}, { internetVisible=!internetVisible}) }
items(restrictionData().internet()){data->
if(internetVisible){
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico,myContext,myComponent, myDpm)
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico)
}
}
items(1){ SectionTab("更多连接",{connectivityVisible}) { connectivityVisible=!connectivityVisible } }
items(restrictionData().connectivity()){data->
if(connectivityVisible){
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico,myContext,myComponent, myDpm)
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico)
}
}
items(1){ SectionTab("应用",{applicationVisible}) { applicationVisible=!applicationVisible } }
items(restrictionData().application()){data->
if(applicationVisible){
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico,myContext,myComponent, myDpm)
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico)
}
}
items(1){ SectionTab("用户",{userVisible}) { userVisible=!userVisible } }
items(restrictionData().user()){data->
if(userVisible){
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico,myContext,myComponent, myDpm)
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico)
}
}
items(1){ SectionTab("媒体",{mediaVisible}) { mediaVisible=!mediaVisible } }
items(restrictionData().media()){data->
if(mediaVisible){
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico,myContext,myComponent, myDpm)
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico)
}
}
items(1){ SectionTab("其他",{otherVisible}) { otherVisible=!otherVisible } }
items(restrictionData().other()){data->
if(otherVisible){
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico,myContext,myComponent, myDpm)
UserRestrictionItem(data.restriction,data.name,data.desc,data.ico)
}
}
@@ -174,11 +173,11 @@ fun SectionTab(txt:String,getSection:()->Boolean,setSection:()->Unit){
private fun UserRestrictionItem(
restriction:String, itemName:Int,
restrictionDescription:String,
leadIcon:Int,
myContext: Context,
myComponent: ComponentName,
myDpm: DevicePolicyManager
leadIcon:Int
){
val myContext = LocalContext.current
val myDpm = myContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val myComponent = ComponentName(myContext,MyDeviceAdminReceiver::class.java)
var strictState by remember{ mutableStateOf(false) }
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
Row(
@@ -252,7 +251,7 @@ private class restrictionData{
list += Restriction(UserManager.DISALLOW_WIFI_TETHERING,R.string.wifi_tethering,"",R.drawable.wifi_tethering_fill0)
list += Restriction(UserManager.DISALLOW_SHARING_ADMIN_CONFIGURED_WIFI,R.string.share_admin_wifi,"",R.drawable.share_fill0)
}
list += Restriction(UserManager.DISALLOW_NETWORK_RESET,R.string.network_reset,"",R.drawable.reset_wrench_fill0)
if(VERSION.SDK_INT>=23){ list += Restriction(UserManager.DISALLOW_NETWORK_RESET,R.string.network_reset,"",R.drawable.reset_wrench_fill0) }
list += Restriction(UserManager.DISALLOW_CONFIG_TETHERING,R.string.config_tethering,"",R.drawable.wifi_tethering_fill0)
list += Restriction(UserManager.DISALLOW_CONFIG_VPN,R.string.config_vpn,"",R.drawable.vpn_key_fill0)
if(VERSION.SDK_INT>=29){list += Restriction(UserManager.DISALLOW_CONFIG_PRIVATE_DNS,R.string.config_private_dns,"",R.drawable.dns_fill0)}
@@ -270,7 +269,7 @@ private class restrictionData{
}
list += Restriction(UserManager.DISALLOW_SHARE_LOCATION,R.string.share_location,"",R.drawable.location_on_fill0)
if(VERSION.SDK_INT>=28){list += Restriction(UserManager.DISALLOW_CONFIG_LOCATION,R.string.config_location,"",R.drawable.location_on_fill0)}
list += Restriction(UserManager.DISALLOW_OUTGOING_BEAM,R.string.outgoing_beam,"",R.drawable.nfc_fill0)
if(VERSION.SDK_INT>=22){list += Restriction(UserManager.DISALLOW_OUTGOING_BEAM,R.string.outgoing_beam,"",R.drawable.nfc_fill0)}
list += Restriction(UserManager.DISALLOW_USB_FILE_TRANSFER,R.string.usb_file_transfer,"",R.drawable.usb_fill0)
list += Restriction(UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,R.string.mount_physical_media, "包括TF卡和USB-OTG",R.drawable.sd_card_fill0)
if(VERSION.SDK_INT>=28){list += Restriction(UserManager.DISALLOW_PRINTING,R.string.printing,"",R.drawable.print_fill0)}
@@ -329,7 +328,7 @@ private class restrictionData{
list += Restriction(UserManager.DISALLOW_CREATE_WINDOWS,R.string.create_windows, "可能包括Toast和浮动通知",R.drawable.web_asset)
if(VERSION.SDK_INT>=24){list += Restriction(UserManager.DISALLOW_SET_WALLPAPER,R.string.set_wallpaper,"",R.drawable.wallpaper_fill0)}
if(VERSION.SDK_INT>=34){ list += Restriction(UserManager.DISALLOW_GRANT_ADMIN,R.string.grant_admin,"",R.drawable.android_fill0) }
list += Restriction(UserManager.DISALLOW_FUN,R.string.`fun`,"可能会影响谷歌商店的游戏",R.drawable.stadia_controller_fill0)
if(VERSION.SDK_INT>=23){ list += Restriction(UserManager.DISALLOW_FUN,R.string.`fun`,"可能会影响谷歌商店的游戏",R.drawable.stadia_controller_fill0) }
list += Restriction(UserManager.DISALLOW_MODIFY_ACCOUNTS,R.string.modify_accounts,"",R.drawable.manage_accounts_fill0)
if(VERSION.SDK_INT>=28){
list += Restriction(UserManager.DISALLOW_CONFIG_LOCALE,R.string.config_locale,"",R.drawable.language_fill0)
@@ -337,7 +336,7 @@ private class restrictionData{
}
if(VERSION.SDK_INT>=28){list += Restriction(UserManager.DISALLOW_SYSTEM_ERROR_DIALOGS,R.string.sys_err_dialog,"",R.drawable.android_fill0)}
list += Restriction(UserManager.DISALLOW_FACTORY_RESET,R.string.factory_reset,"",R.drawable.android_fill0)
list += Restriction(UserManager.DISALLOW_SAFE_BOOT,R.string.safe_boot,"",R.drawable.security_fill0)
if(VERSION.SDK_INT>=23){ list += Restriction(UserManager.DISALLOW_SAFE_BOOT,R.string.safe_boot,"",R.drawable.security_fill0) }
list += Restriction(UserManager.DISALLOW_DEBUGGING_FEATURES,R.string.debug_features,"",R.drawable.adb_fill0)
return list
}