Merge branch 'master_hyx'
This commit is contained in:
commit
51ba82226e
@ -32,14 +32,30 @@ class PermissionDialog {
|
||||
return false;
|
||||
}
|
||||
bool application = true;
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
List<Permission> permissions = [
|
||||
Permission.bluetooth,
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
].request();
|
||||
];
|
||||
Future<bool> getPermissionStatus(List<Permission> permissions) async {
|
||||
bool isGranted = true;
|
||||
List<PermissionStatus> permissionStatus = [];
|
||||
for (Permission per in permissions) {
|
||||
permissionStatus.add(await per.status);
|
||||
}
|
||||
for (PermissionStatus per in permissionStatus) {
|
||||
isGranted = isGranted && per.isGranted;
|
||||
}
|
||||
if (GetPlatform.isIOS) {
|
||||
isGranted = permissionStatus[0].isGranted;
|
||||
}
|
||||
return isGranted;
|
||||
}
|
||||
|
||||
Permission permission = Permission.bluetoothScan;
|
||||
dynamic cache = await Storage.getString(titles[permission]);
|
||||
bool isGranted = statuses.values.every((element) => element.isGranted);
|
||||
if (AppPlatform.isAndroid && !isGranted && cache is! String) {
|
||||
bool isGranted = await getPermissionStatus(permissions);
|
||||
if (GetPlatform.isAndroid && !isGranted && cache is! String) {
|
||||
application = await showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
@ -69,16 +85,19 @@ class PermissionDialog {
|
||||
if (application) {
|
||||
await Storage.setString(titles[permission], titles[permission]);
|
||||
}
|
||||
} else if (cache is String) {
|
||||
bool isDenied = statuses.values.every((element) => element.isDenied);
|
||||
if (isDenied) {
|
||||
} else if (cache is! String) {
|
||||
await Storage.setString(titles[permission], titles[permission]);
|
||||
} else {
|
||||
bool isGranted = await getPermissionStatus(permissions);
|
||||
if (!isGranted) {
|
||||
showSet(permission);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (application) {
|
||||
PermissionStatus status = await permission.request();
|
||||
return status.isGranted;
|
||||
await permissions.request();
|
||||
bool isGranted = await getPermissionStatus(permissions);
|
||||
return isGranted;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user