From 5aab26064403a27edfc6bc7eed6394ac75cf761f Mon Sep 17 00:00:00 2001 From: BinTianqi <1220958406@qq.com> Date: Thu, 18 Jan 2024 13:46:09 +0800 Subject: [PATCH] add new icons --- .../com/binbin/androidowner/DeviceControl.kt | 39 ++++++++++++------ .../com/binbin/androidowner/UserRestrict.kt | 40 ++++++++++--------- app/src/main/res/drawable/adb_fill0.xml | 9 +++++ .../drawable/airplanemode_active_fill0.xml | 9 +++++ app/src/main/res/drawable/android_fill0.xml | 9 +++++ app/src/main/res/drawable/backup_fill0.xml | 9 +++++ app/src/main/res/drawable/bluetooth_fill0.xml | 9 +++++ .../drawable/bluetooth_searching_fill0.xml | 9 +++++ .../main/res/drawable/brightness_5_fill0.xml | 9 +++++ .../main/res/drawable/cameraswitch_fill0.xml | 9 +++++ app/src/main/res/drawable/globe_fill0.xml | 9 +++++ .../main/res/drawable/location_on_fill0.xml | 9 +++++ .../main/res/drawable/notifications_fill0.xml | 9 +++++ app/src/main/res/drawable/password_fill0.xml | 9 +++++ .../main/res/drawable/photo_camera_fill0.xml | 9 +++++ app/src/main/res/drawable/schedule_fill0.xml | 9 +++++ .../main/res/drawable/screenshot_fill0.xml | 9 +++++ .../drawable/signal_cellular_alt_fill0.xml | 9 +++++ app/src/main/res/drawable/sms_fill0.xml | 9 +++++ app/src/main/res/drawable/volume_up_fill0.xml | 9 +++++ app/src/main/res/drawable/web_asset.xml | 9 +++++ app/src/main/res/drawable/wifi_fill0.xml | 9 +++++ 22 files changed, 227 insertions(+), 32 deletions(-) create mode 100644 app/src/main/res/drawable/adb_fill0.xml create mode 100644 app/src/main/res/drawable/airplanemode_active_fill0.xml create mode 100644 app/src/main/res/drawable/android_fill0.xml create mode 100644 app/src/main/res/drawable/backup_fill0.xml create mode 100644 app/src/main/res/drawable/bluetooth_fill0.xml create mode 100644 app/src/main/res/drawable/bluetooth_searching_fill0.xml create mode 100644 app/src/main/res/drawable/brightness_5_fill0.xml create mode 100644 app/src/main/res/drawable/cameraswitch_fill0.xml create mode 100644 app/src/main/res/drawable/globe_fill0.xml create mode 100644 app/src/main/res/drawable/location_on_fill0.xml create mode 100644 app/src/main/res/drawable/notifications_fill0.xml create mode 100644 app/src/main/res/drawable/password_fill0.xml create mode 100644 app/src/main/res/drawable/photo_camera_fill0.xml create mode 100644 app/src/main/res/drawable/schedule_fill0.xml create mode 100644 app/src/main/res/drawable/screenshot_fill0.xml create mode 100644 app/src/main/res/drawable/signal_cellular_alt_fill0.xml create mode 100644 app/src/main/res/drawable/sms_fill0.xml create mode 100644 app/src/main/res/drawable/volume_up_fill0.xml create mode 100644 app/src/main/res/drawable/web_asset.xml create mode 100644 app/src/main/res/drawable/wifi_fill0.xml diff --git a/app/src/main/java/com/binbin/androidowner/DeviceControl.kt b/app/src/main/java/com/binbin/androidowner/DeviceControl.kt index 2cc428f..4e5f296 100644 --- a/app/src/main/java/com/binbin/androidowner/DeviceControl.kt +++ b/app/src/main/java/com/binbin/androidowner/DeviceControl.kt @@ -17,6 +17,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Switch import androidx.compose.material3.Text @@ -28,6 +29,7 @@ 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.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -39,18 +41,18 @@ fun DeviceControl(myDpm: DevicePolicyManager, myComponent: ComponentName){ .verticalScroll(rememberScrollState()) .padding(bottom = 20.dp) ) { - DeviceCtrlItem(R.string.disable_cam,R.string.place_holder, myDpm,{myDpm.getCameraDisabled(null)},{b -> myDpm.setCameraDisabled(myComponent,b)}) - DeviceCtrlItem(R.string.disable_scrcap,R.string.aosp_scrrec_also_work,myDpm,{myDpm.getScreenCaptureDisabled(null)},{b -> myDpm.setScreenCaptureDisabled(myComponent,b) }) + DeviceCtrlItem(R.string.disable_cam,R.string.place_holder, R.drawable.photo_camera_fill0,myDpm,{myDpm.getCameraDisabled(null)},{b -> myDpm.setCameraDisabled(myComponent,b)}) + DeviceCtrlItem(R.string.disable_scrcap,R.string.aosp_scrrec_also_work,R.drawable.screenshot_fill0,myDpm,{myDpm.getScreenCaptureDisabled(null)},{b -> myDpm.setScreenCaptureDisabled(myComponent,b) }) if(VERSION.SDK_INT>=34){ - DeviceCtrlItem(R.string.hide_status_bar,R.string.may_hide_notifi_icon_only,myDpm,{myDpm.isStatusBarDisabled},{b -> myDpm.setStatusBarDisabled(myComponent,b) }) + DeviceCtrlItem(R.string.hide_status_bar,R.string.may_hide_notifi_icon_only,R.drawable.notifications_fill0,myDpm,{myDpm.isStatusBarDisabled},{b -> myDpm.setStatusBarDisabled(myComponent,b) }) } if(VERSION.SDK_INT>=30){ - DeviceCtrlItem(R.string.auto_time,R.string.place_holder,myDpm,{myDpm.getAutoTimeEnabled(myComponent)},{b -> myDpm.setAutoTimeEnabled(myComponent,b) }) - DeviceCtrlItem(R.string.auto_timezone,R.string.place_holder,myDpm,{myDpm.getAutoTimeZoneEnabled(myComponent)},{b -> myDpm.setAutoTimeZoneEnabled(myComponent,b) }) + DeviceCtrlItem(R.string.auto_time,R.string.place_holder,R.drawable.schedule_fill0,myDpm,{myDpm.getAutoTimeEnabled(myComponent)},{b -> myDpm.setAutoTimeEnabled(myComponent,b) }) + DeviceCtrlItem(R.string.auto_timezone,R.string.place_holder,R.drawable.globe_fill0,myDpm,{myDpm.getAutoTimeZoneEnabled(myComponent)},{b -> myDpm.setAutoTimeZoneEnabled(myComponent,b) }) } - DeviceCtrlItem(R.string.master_mute,R.string.place_holder,myDpm,{myDpm.isMasterVolumeMuted(myComponent)},{b -> myDpm.setMasterVolumeMuted(myComponent,b) }) + DeviceCtrlItem(R.string.master_mute,R.string.place_holder,R.drawable.volume_up_fill0,myDpm,{myDpm.isMasterVolumeMuted(myComponent)},{b -> myDpm.setMasterVolumeMuted(myComponent,b) }) if(VERSION.SDK_INT>=26){ - DeviceCtrlItem(R.string.backup_service,R.string.place_holder,myDpm,{myDpm.isBackupServiceEnabled(myComponent)},{b -> myDpm.setBackupServiceEnabled(myComponent,b) }) + DeviceCtrlItem(R.string.backup_service,R.string.place_holder,R.drawable.backup_fill0,myDpm,{myDpm.isBackupServiceEnabled(myComponent)},{b -> myDpm.setBackupServiceEnabled(myComponent,b) }) } if(VERSION.SDK_INT>=24){ Button(onClick = {myDpm.reboot(myComponent)}) { @@ -110,6 +112,7 @@ fun DeviceControl(myDpm: DevicePolicyManager, myComponent: ComponentName){ private fun DeviceCtrlItem( itemName:Int, itemDesc:Int, + leadIcon:Int, myDpm: DevicePolicyManager, getMethod:()->Boolean, setMethod:(b:Boolean)->Unit @@ -125,13 +128,23 @@ private fun DeviceCtrlItem( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { - Column { - Text( - text = stringResource(itemName), - style = MaterialTheme.typography.titleLarge + Row( + verticalAlignment = Alignment.CenterVertically + ){ + Icon( + painter = painterResource(leadIcon), + contentDescription = null, + tint = MaterialTheme.colorScheme.onPrimaryContainer, + modifier = Modifier.padding(start = 5.dp, end = 9.dp) ) - if(itemDesc!=R.string.place_holder){ - Text(stringResource(itemDesc)) + Column { + Text( + text = stringResource(itemName), + style = MaterialTheme.typography.titleLarge + ) + if(itemDesc!=R.string.place_holder){ + Text(stringResource(itemDesc)) + } } } if(myDpm.isDeviceOwnerApp("com.binbin.androidowner")){ diff --git a/app/src/main/java/com/binbin/androidowner/UserRestrict.kt b/app/src/main/java/com/binbin/androidowner/UserRestrict.kt index 44da09c..ad3200f 100644 --- a/app/src/main/java/com/binbin/androidowner/UserRestrict.kt +++ b/app/src/main/java/com/binbin/androidowner/UserRestrict.kt @@ -27,6 +27,7 @@ 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.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -40,30 +41,30 @@ fun UserRestriction(myDpm: DevicePolicyManager, myComponent: ComponentName){ .padding(bottom = 20.dp) ) { Text("打开开关后会禁用对应的功能") - UserRestrictionItem(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,R.string.config_mobile_network,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_CONFIG_WIFI,R.string.config_wifi,"",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,R.string.config_mobile_network,"",R.drawable.signal_cellular_alt_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_CONFIG_WIFI,R.string.config_wifi,"",R.drawable.wifi_fill0,myComponent, myDpm) if(VERSION.SDK_INT>=26){ - UserRestrictionItem(UserManager.DISALLOW_BLUETOOTH,R.string.bluetooth,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_BLUETOOTH_SHARING,R.string.bt_share,"",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_BLUETOOTH,R.string.bluetooth,"",R.drawable.bluetooth_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_BLUETOOTH_SHARING,R.string.bt_share,"",R.drawable.bluetooth_searching_fill0,myComponent, myDpm) } if(VERSION.SDK_INT>=28){ - UserRestrictionItem(UserManager.DISALLOW_AIRPLANE_MODE,R.string.airplane_mode,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_CONFIG_LOCATION,R.string.config_location,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_CONFIG_BRIGHTNESS,R.string.config_brightness,"",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_AIRPLANE_MODE,R.string.airplane_mode,"",R.drawable.airplanemode_active_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_CONFIG_LOCATION,R.string.config_location,"",R.drawable.location_on_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_CONFIG_BRIGHTNESS,R.string.config_brightness,"",R.drawable.brightness_5_fill0,myComponent, myDpm) } - UserRestrictionItem(UserManager.DISALLOW_DEBUGGING_FEATURES,R.string.debug_features,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_CREATE_WINDOWS,R.string.create_windows, stringResource(R.string.create_windows_description),myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_ADJUST_VOLUME,R.string.adjust_volume,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_INSTALL_APPS,R.string.install_apps,"",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_DEBUGGING_FEATURES,R.string.debug_features,"",R.drawable.adb_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_CREATE_WINDOWS,R.string.create_windows, stringResource(R.string.create_windows_description),R.drawable.web_asset,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_ADJUST_VOLUME,R.string.adjust_volume,"",R.drawable.volume_up_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_INSTALL_APPS,R.string.install_apps,"",R.drawable.android_fill0,myComponent, myDpm) if(VERSION.SDK_INT>=31){ - UserRestrictionItem(UserManager.DISALLOW_CAMERA_TOGGLE,R.string.camera_toggle,"",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_CAMERA_TOGGLE,R.string.camera_toggle,"",R.drawable.cameraswitch_fill0,myComponent, myDpm) } - UserRestrictionItem(UserManager.DISALLOW_SMS,R.string.sms,"",myComponent, myDpm) - UserRestrictionItem(UserManager.DISALLOW_APPS_CONTROL,R.string.apps_ctrl, stringResource(R.string.apps_ctrl_description),myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_SMS,R.string.sms,"",R.drawable.sms_fill0,myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_APPS_CONTROL,R.string.apps_ctrl, stringResource(R.string.apps_ctrl_description),R.drawable.apps_fill0,myComponent, myDpm) if(VERSION.SDK_INT>=26){ - UserRestrictionItem(UserManager.DISALLOW_AUTOFILL,R.string.autofill, "",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_AUTOFILL,R.string.autofill, "",R.drawable.password_fill0,myComponent, myDpm) } - UserRestrictionItem(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,R.string.inst_unknown_src,"",myComponent, myDpm) + UserRestrictionItem(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,R.string.inst_unknown_src,"",R.drawable.android_fill0,myComponent, myDpm) if(VERSION.SDK_INT<26){ Text("以下功能需要安卓8或以上:蓝牙、自动填充服务") } @@ -77,7 +78,7 @@ fun UserRestriction(myDpm: DevicePolicyManager, myComponent: ComponentName){ } @Composable -private fun UserRestrictionItem(restriction:String, itemName:Int, restrictionDescription:String, myComponent: ComponentName, myDpm: DevicePolicyManager){ +private fun UserRestrictionItem(restriction:String, itemName:Int, restrictionDescription:String, leadIcon:Int,myComponent: ComponentName, myDpm: DevicePolicyManager){ val isdo = myDpm.isDeviceOwnerApp("com.binbin.androidowner") var strictState by remember{ mutableStateOf(false) } Row( @@ -94,9 +95,10 @@ private fun UserRestrictionItem(restriction:String, itemName:Int, restrictionDes verticalAlignment = Alignment.CenterVertically ) { Icon( - imageVector = Icons.Outlined.Info, + painter = painterResource(leadIcon), contentDescription = null, - modifier = Modifier.padding(horizontal = 8.dp) + modifier = Modifier.padding(horizontal = 8.dp), + tint = MaterialTheme.colorScheme.onPrimaryContainer ) Column( modifier = Modifier.align(Alignment.CenterVertically) diff --git a/app/src/main/res/drawable/adb_fill0.xml b/app/src/main/res/drawable/adb_fill0.xml new file mode 100644 index 0000000..4abffa5 --- /dev/null +++ b/app/src/main/res/drawable/adb_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/airplanemode_active_fill0.xml b/app/src/main/res/drawable/airplanemode_active_fill0.xml new file mode 100644 index 0000000..8c7a95f --- /dev/null +++ b/app/src/main/res/drawable/airplanemode_active_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/android_fill0.xml b/app/src/main/res/drawable/android_fill0.xml new file mode 100644 index 0000000..73f2cbf --- /dev/null +++ b/app/src/main/res/drawable/android_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/backup_fill0.xml b/app/src/main/res/drawable/backup_fill0.xml new file mode 100644 index 0000000..6fe5f62 --- /dev/null +++ b/app/src/main/res/drawable/backup_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/bluetooth_fill0.xml b/app/src/main/res/drawable/bluetooth_fill0.xml new file mode 100644 index 0000000..e198435 --- /dev/null +++ b/app/src/main/res/drawable/bluetooth_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/bluetooth_searching_fill0.xml b/app/src/main/res/drawable/bluetooth_searching_fill0.xml new file mode 100644 index 0000000..ea6f33c --- /dev/null +++ b/app/src/main/res/drawable/bluetooth_searching_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/brightness_5_fill0.xml b/app/src/main/res/drawable/brightness_5_fill0.xml new file mode 100644 index 0000000..c0d8f7c --- /dev/null +++ b/app/src/main/res/drawable/brightness_5_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/cameraswitch_fill0.xml b/app/src/main/res/drawable/cameraswitch_fill0.xml new file mode 100644 index 0000000..8e497c5 --- /dev/null +++ b/app/src/main/res/drawable/cameraswitch_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/globe_fill0.xml b/app/src/main/res/drawable/globe_fill0.xml new file mode 100644 index 0000000..dff31e2 --- /dev/null +++ b/app/src/main/res/drawable/globe_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/location_on_fill0.xml b/app/src/main/res/drawable/location_on_fill0.xml new file mode 100644 index 0000000..af7f8eb --- /dev/null +++ b/app/src/main/res/drawable/location_on_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/notifications_fill0.xml b/app/src/main/res/drawable/notifications_fill0.xml new file mode 100644 index 0000000..79f708d --- /dev/null +++ b/app/src/main/res/drawable/notifications_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/password_fill0.xml b/app/src/main/res/drawable/password_fill0.xml new file mode 100644 index 0000000..ebb3e2e --- /dev/null +++ b/app/src/main/res/drawable/password_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/photo_camera_fill0.xml b/app/src/main/res/drawable/photo_camera_fill0.xml new file mode 100644 index 0000000..bab7957 --- /dev/null +++ b/app/src/main/res/drawable/photo_camera_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/schedule_fill0.xml b/app/src/main/res/drawable/schedule_fill0.xml new file mode 100644 index 0000000..ff13756 --- /dev/null +++ b/app/src/main/res/drawable/schedule_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/screenshot_fill0.xml b/app/src/main/res/drawable/screenshot_fill0.xml new file mode 100644 index 0000000..337c870 --- /dev/null +++ b/app/src/main/res/drawable/screenshot_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/signal_cellular_alt_fill0.xml b/app/src/main/res/drawable/signal_cellular_alt_fill0.xml new file mode 100644 index 0000000..a515530 --- /dev/null +++ b/app/src/main/res/drawable/signal_cellular_alt_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/sms_fill0.xml b/app/src/main/res/drawable/sms_fill0.xml new file mode 100644 index 0000000..c6faa89 --- /dev/null +++ b/app/src/main/res/drawable/sms_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/volume_up_fill0.xml b/app/src/main/res/drawable/volume_up_fill0.xml new file mode 100644 index 0000000..ecc3f01 --- /dev/null +++ b/app/src/main/res/drawable/volume_up_fill0.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/web_asset.xml b/app/src/main/res/drawable/web_asset.xml new file mode 100644 index 0000000..4000d8b --- /dev/null +++ b/app/src/main/res/drawable/web_asset.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/wifi_fill0.xml b/app/src/main/res/drawable/wifi_fill0.xml new file mode 100644 index 0000000..307515e --- /dev/null +++ b/app/src/main/res/drawable/wifi_fill0.xml @@ -0,0 +1,9 @@ + + +