[mobile][photos] Explicitly ask for media location (#1261)
## Description On bumping up photo_manager version, it introduced a breaking change where we need to explicitly ask for ACCESS_MEDIA_LOCATION permission. ## Tests Tested on android 13 and 14 devices.
This commit is contained in:
parent
6974672f8c
commit
7950f1ec26
4 changed files with 32 additions and 4 deletions
|
@ -61,7 +61,14 @@ class LocalSyncService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Platform.isAndroid && AppLifecycleService.instance.isForeground) {
|
if (Platform.isAndroid && AppLifecycleService.instance.isForeground) {
|
||||||
final permissionState = await PhotoManager.requestPermissionExtend();
|
final permissionState = await PhotoManager.requestPermissionExtend(
|
||||||
|
requestOption: const PermissionRequestOption(
|
||||||
|
androidPermission: AndroidPermission(
|
||||||
|
type: RequestType.common,
|
||||||
|
mediaLocation: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
if (permissionState != PermissionState.authorized) {
|
if (permissionState != PermissionState.authorized) {
|
||||||
_logger.severe(
|
_logger.severe(
|
||||||
"sync requested with invalid permission",
|
"sync requested with invalid permission",
|
||||||
|
|
|
@ -48,7 +48,14 @@ class _HomeHeaderWidgetState extends State<HomeHeaderWidget> {
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
try {
|
try {
|
||||||
final PermissionState state =
|
final PermissionState state =
|
||||||
await PhotoManager.requestPermissionExtend();
|
await PhotoManager.requestPermissionExtend(
|
||||||
|
requestOption: const PermissionRequestOption(
|
||||||
|
androidPermission: AndroidPermission(
|
||||||
|
type: RequestType.common,
|
||||||
|
mediaLocation: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
await LocalSyncService.instance.onUpdatePermission(state);
|
await LocalSyncService.instance.onUpdatePermission(state);
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
Logger("HomeHeaderWidget").severe(
|
Logger("HomeHeaderWidget").severe(
|
||||||
|
|
|
@ -91,7 +91,14 @@ class GrantPermissionsWidget extends StatelessWidget {
|
||||||
key: const ValueKey("grantPermissionButton"),
|
key: const ValueKey("grantPermissionButton"),
|
||||||
child: Text(S.of(context).grantPermission),
|
child: Text(S.of(context).grantPermission),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final state = await PhotoManager.requestPermissionExtend();
|
final state = await PhotoManager.requestPermissionExtend(
|
||||||
|
requestOption: const PermissionRequestOption(
|
||||||
|
androidPermission: AndroidPermission(
|
||||||
|
type: RequestType.common,
|
||||||
|
mediaLocation: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
if (state == PermissionState.authorized ||
|
if (state == PermissionState.authorized ||
|
||||||
state == PermissionState.limited) {
|
state == PermissionState.limited) {
|
||||||
await SyncService.instance.onPermissionGranted(state);
|
await SyncService.instance.onPermissionGranted(state);
|
||||||
|
|
|
@ -203,7 +203,14 @@ class AddPhotosPhotoWidget extends StatelessWidget {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e is StateError) {
|
if (e is StateError) {
|
||||||
final PermissionState ps = await PhotoManager.requestPermissionExtend();
|
final PermissionState ps = await PhotoManager.requestPermissionExtend(
|
||||||
|
requestOption: const PermissionRequestOption(
|
||||||
|
androidPermission: AndroidPermission(
|
||||||
|
type: RequestType.common,
|
||||||
|
mediaLocation: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
if (ps != PermissionState.authorized && ps != PermissionState.limited) {
|
if (ps != PermissionState.authorized && ps != PermissionState.limited) {
|
||||||
await showChoiceDialog(
|
await showChoiceDialog(
|
||||||
context,
|
context,
|
||||||
|
|
Loading…
Reference in a new issue