修复上架审核出现的拒绝相机权限后无法使用头像功能问题
This commit is contained in:
parent
e078a67af5
commit
21854e97a1
@ -30,7 +30,6 @@
|
|||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<!--允许麦克风权限,用于录音发送-->
|
<!--允许麦克风权限,用于录音发送-->
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
|
|||||||
@ -64,7 +64,7 @@ post_install do |installer|
|
|||||||
# 'PERMISSION_CONTACTS=1',
|
# 'PERMISSION_CONTACTS=1',
|
||||||
|
|
||||||
## dart: PermissionGroup.camera
|
## dart: PermissionGroup.camera
|
||||||
# 'PERMISSION_CAMERA=1',
|
'PERMISSION_CAMERA=1',
|
||||||
|
|
||||||
## dart: PermissionGroup.microphone
|
## dart: PermissionGroup.microphone
|
||||||
# 'PERMISSION_MICROPHONE=1',
|
# 'PERMISSION_MICROPHONE=1',
|
||||||
@ -73,7 +73,7 @@ post_install do |installer|
|
|||||||
# 'PERMISSION_SPEECH_RECOGNIZER=1',
|
# 'PERMISSION_SPEECH_RECOGNIZER=1',
|
||||||
|
|
||||||
## dart: PermissionGroup.photos
|
## dart: PermissionGroup.photos
|
||||||
# 'PERMISSION_PHOTOS=1',
|
'PERMISSION_PHOTOS=1',
|
||||||
|
|
||||||
# dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
|
# dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
|
||||||
'PERMISSION_LOCATION=1',
|
'PERMISSION_LOCATION=1',
|
||||||
|
|||||||
@ -43,48 +43,42 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
|||||||
backgroundColor: AppColors.mainColor),
|
backgroundColor: AppColors.mainColor),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Obx(() => CommonItem(
|
CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.avatar!.tr,
|
leftTitel: TranslationLoader.lanKeys!.avatar!.tr,
|
||||||
rightTitle: "",
|
rightTitle: "",
|
||||||
allHeight: 100.h,
|
allHeight: 100.h,
|
||||||
isHaveLine: true,
|
isHaveLine: true,
|
||||||
isHaveDirection: true,
|
isHaveDirection: true,
|
||||||
isHaveRightWidget: true,
|
isHaveRightWidget: true,
|
||||||
rightWidget: ClipOval(
|
rightWidget: ClipOval(
|
||||||
child: state.mineInfoData.value.headUrl != null
|
child: state.image != null
|
||||||
? CachedNetworkImage(
|
? Image.file(
|
||||||
imageUrl: Uri.encodeFull(
|
File(state.image!.path),
|
||||||
state.mineInfoData.value.headUrl!),
|
width: 72.w,
|
||||||
width: 72.w,
|
height: 72.w,
|
||||||
height: 72.w,
|
fit: BoxFit.fill,
|
||||||
fit: BoxFit.fill,
|
)
|
||||||
placeholder: (context, url) => Image.asset(
|
: Image.asset(
|
||||||
'images/controls_user.png',
|
'images/controls_user.png',
|
||||||
width: 72.w,
|
width: 72.w,
|
||||||
height: 72.w,
|
height: 72.w,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
))
|
),
|
||||||
: Image.asset(
|
),
|
||||||
'images/controls_user.png',
|
action: () async {
|
||||||
width: 72.w,
|
//安卓平台下首次进入应用需向用户告知获取权限用途弹窗
|
||||||
height: 72.w,
|
if (Platform.isAndroid) {
|
||||||
fit: BoxFit.fill,
|
AppFirstEnterHandle()
|
||||||
),
|
.getAppFirstEnter(context, isAgreeCamera);
|
||||||
),
|
var getFlag = await Storage.getString(isAgreeCamera);
|
||||||
action: () async {
|
if (getFlag == isAgreeCamera) {
|
||||||
//安卓平台下首次进入应用需向用户告知获取权限用途弹窗
|
_openModalBottomSheet();
|
||||||
if (Platform.isAndroid) {
|
}
|
||||||
AppFirstEnterHandle()
|
} else {
|
||||||
.getAppFirstEnter(context, isAgreeCamera);
|
_openModalBottomSheet();
|
||||||
var getFlag = await Storage.getString(isAgreeCamera);
|
}
|
||||||
if (getFlag == isAgreeCamera) {
|
},
|
||||||
requestCameraPermission();
|
),
|
||||||
}
|
|
||||||
} else {
|
|
||||||
requestCameraPermission();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
Obx(() => CommonItem(
|
Obx(() => CommonItem(
|
||||||
leftTitel: TranslationLoader.lanKeys!.nickName!.tr,
|
leftTitel: TranslationLoader.lanKeys!.nickName!.tr,
|
||||||
rightTitle: state.mineInfoData.value.nickname != null
|
rightTitle: state.mineInfoData.value.nickname != null
|
||||||
@ -189,7 +183,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
|||||||
if (status.isGranted) {
|
if (status.isGranted) {
|
||||||
// 如果权限已经被授予,执行您的相机操作
|
// 如果权限已经被授予,执行您的相机操作
|
||||||
// 这里可以调用打开相机的方法或者跳转到相机页面等
|
// 这里可以调用打开相机的方法或者跳转到相机页面等
|
||||||
_openModalBottomSheet();
|
selectCamera();
|
||||||
} else {
|
} else {
|
||||||
// 如果权限尚未被授予,请求相机权限
|
// 如果权限尚未被授予,请求相机权限
|
||||||
// 此处会显示系统权限请求对话框
|
// 此处会显示系统权限请求对话框
|
||||||
@ -197,28 +191,53 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
|||||||
|
|
||||||
if (status.isGranted) {
|
if (status.isGranted) {
|
||||||
// 如果用户授予了相机权限,执行您的相机操作
|
// 如果用户授予了相机权限,执行您的相机操作
|
||||||
_openModalBottomSheet();
|
selectCamera();
|
||||||
} else {
|
} else {
|
||||||
// 如果用户拒绝了相机权限,您可以提供适当的提示
|
// 如果用户拒绝了相机权限,您可以提供适当的提示
|
||||||
// 或者引导用户手动授予权限
|
// 或者引导用户手动授予权限
|
||||||
_showPermissinDialog();
|
showPermissionDeniedDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _showPermissinDialog() async {
|
Future<void> requestPhotoPermission() async {
|
||||||
|
// 检查是否已经授予相机权限
|
||||||
|
PermissionStatus status = await Permission.photos.status;
|
||||||
|
|
||||||
|
if (status.isGranted) {
|
||||||
|
// 如果权限已经被授予,执行您的相机操作
|
||||||
|
// 这里可以调用打开相机的方法或者跳转到相机页面等
|
||||||
|
selectImage();
|
||||||
|
} else {
|
||||||
|
// 如果权限尚未被授予,请求相机权限
|
||||||
|
// 此处会显示系统权限请求对话框
|
||||||
|
status = await Permission.photos.request();
|
||||||
|
|
||||||
|
if (status.isGranted) {
|
||||||
|
// 如果用户授予了相机权限,执行您的相机操作
|
||||||
|
selectImage();
|
||||||
|
} else {
|
||||||
|
// 如果用户拒绝了相机权限,您可以提供适当的提示
|
||||||
|
// 或者引导用户手动授予权限
|
||||||
|
showPermissionDeniedDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示权限被永久拒绝的提示对话框
|
||||||
|
void showPermissionDeniedDialog() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('Permission Required'),
|
title: const Text('权限被拒绝'),
|
||||||
content: const Text(
|
content: const Text('请手动在系统设置中开启相册权限以继续使用应用。'),
|
||||||
'You need to grant camera permission to use this feature.'),
|
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
TextButton(
|
TextButton(
|
||||||
child: const Text('OK'),
|
child: const Text('去设置'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
openAppSettings(); // 打开系统设置页面
|
||||||
|
Navigator.of(context).pop(); // 关闭对话框
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -240,9 +259,11 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
|||||||
int getSelectIndex = value;
|
int getSelectIndex = value;
|
||||||
if (getSelectIndex == 0) {
|
if (getSelectIndex == 0) {
|
||||||
//拍照选项
|
//拍照选项
|
||||||
selectCamera();
|
// selectCamera();
|
||||||
|
requestCameraPermission();
|
||||||
} else if (getSelectIndex == 1) {
|
} else if (getSelectIndex == 1) {
|
||||||
selectImage();
|
// selectImage();
|
||||||
|
requestPhotoPermission();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -278,4 +299,24 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// child: state.mineInfoData.value.headUrl != null
|
||||||
|
// ? CachedNetworkImage(
|
||||||
|
// imageUrl: Uri.encodeFull(
|
||||||
|
// state.mineInfoData.value.headUrl!),
|
||||||
|
// width: 72.w,
|
||||||
|
// height: 72.w,
|
||||||
|
// fit: BoxFit.fill,
|
||||||
|
// placeholder: (context, url) => Image.asset(
|
||||||
|
// 'images/controls_user.png',
|
||||||
|
// width: 72.w,
|
||||||
|
// height: 72.w,
|
||||||
|
// fit: BoxFit.fill,
|
||||||
|
// ))
|
||||||
|
// : Image.asset(
|
||||||
|
// 'images/controls_user.png',
|
||||||
|
// width: 72.w,
|
||||||
|
// height: 72.w,
|
||||||
|
// fit: BoxFit.fill,
|
||||||
|
// ),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,6 +140,7 @@ dependencies:
|
|||||||
#侧滑删除
|
#侧滑删除
|
||||||
flutter_slidable: ^3.0.1
|
flutter_slidable: ^3.0.1
|
||||||
audio_service: ^0.18.12
|
audio_service: ^0.18.12
|
||||||
|
app_settings: ^5.1.1
|
||||||
|
|
||||||
system_settings: ^2.0.0
|
system_settings: ^2.0.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user