1、取消相机功能,防止敏感权限
This commit is contained in:
shenzuqiang 2026-03-26 10:30:22 +08:00
parent 69645e3526
commit 02999f0d54
2 changed files with 11 additions and 10 deletions

View File

@ -1,14 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<!-- 读取相册权限-Android 12及以下版本的权限如果你不需要特定相机功能可以添加下面这行降低过滤限制 -->
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<!-- 在Android14及以上版本读取SelectedPhotoAccess需要添加READ_MEDIA_VISUAL_USER_SELECTED权限 --> <!-- 在Android14及以上版本读取SelectedPhotoAccess需要添加READ_MEDIA_VISUAL_USER_SELECTED权限 -->
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" /> <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
<!--相机权限,用于打开相机和拍照:如用户反馈等-->
<uses-permission android:name="android.permission.CAMERA" />
<!-- 写入外部存储权限用于保存拍照后的图片或者下载文件主要兼容Android 13及以下版本Android13以上高版本不需要但低版本必须 --> <!-- 写入外部存储权限用于保存拍照后的图片或者下载文件主要兼容Android 13及以下版本Android13以上高版本不需要但低版本必须 -->
<uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" <uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" android:maxSdkVersion="32"

View File

@ -86,7 +86,7 @@ fun ImagePicker(
val tempImageUri = remember { mutableStateOf<Uri?>(null) } val tempImageUri = remember { mutableStateOf<Uri?>(null) }
// 新增选择对话框 // 新增选择对话框
var showChoiceDialog by remember { mutableStateOf(false) } //var showChoiceDialog by remember { mutableStateOf(false) }
// 新增大图预览状态 // 新增大图预览状态
var previewImageUri by remember { mutableStateOf<Uri?>(null) } var previewImageUri by remember { mutableStateOf<Uri?>(null) }
@ -130,7 +130,7 @@ fun ImagePicker(
} }
} }
/*
if (showChoiceDialog) { if (showChoiceDialog) {
AlertDialog( AlertDialog(
onDismissRequest = { showChoiceDialog = false }, onDismissRequest = { showChoiceDialog = false },
@ -160,6 +160,7 @@ fun ImagePicker(
} }
) )
} }
*/
// 全屏大图对话框 // 全屏大图对话框
previewImageUri?.let { uri -> previewImageUri?.let { uri ->
@ -217,7 +218,10 @@ fun ImagePicker(
AddSingleButton( AddSingleButton(
imageHeight = imageHeight, imageHeight = imageHeight,
aspectRatio = aspectRatio, aspectRatio = aspectRatio,
onClick = { showChoiceDialog = true }, onClick = {
galleryLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
//showChoiceDialog = true
},
label = addButtonName, label = addButtonName,
) )
}else{ }else{
@ -226,7 +230,10 @@ fun ImagePicker(
contentAlignment = Alignment.BottomCenter contentAlignment = Alignment.BottomCenter
) { ) {
AddButton( AddButton(
onClick = { showChoiceDialog = true }, onClick = {
galleryLauncher.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
//showChoiceDialog = true
},
label = addButtonName, label = addButtonName,
) )
} }