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