[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;
|
||||
}
|
||||
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) {
|
||||
_logger.severe(
|
||||
"sync requested with invalid permission",
|
||||
|
|
|
@ -48,7 +48,14 @@ class _HomeHeaderWidgetState extends State<HomeHeaderWidget> {
|
|||
onTap: () async {
|
||||
try {
|
||||
final PermissionState state =
|
||||
await PhotoManager.requestPermissionExtend();
|
||||
await PhotoManager.requestPermissionExtend(
|
||||
requestOption: const PermissionRequestOption(
|
||||
androidPermission: AndroidPermission(
|
||||
type: RequestType.common,
|
||||
mediaLocation: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
await LocalSyncService.instance.onUpdatePermission(state);
|
||||
} on Exception catch (e) {
|
||||
Logger("HomeHeaderWidget").severe(
|
||||
|
|
|
@ -91,7 +91,14 @@ class GrantPermissionsWidget extends StatelessWidget {
|
|||
key: const ValueKey("grantPermissionButton"),
|
||||
child: Text(S.of(context).grantPermission),
|
||||
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 ||
|
||||
state == PermissionState.limited) {
|
||||
await SyncService.instance.onPermissionGranted(state);
|
||||
|
|
|
@ -203,7 +203,14 @@ class AddPhotosPhotoWidget extends StatelessWidget {
|
|||
}
|
||||
} catch (e) {
|
||||
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) {
|
||||
await showChoiceDialog(
|
||||
context,
|
||||
|
|
Loading…
Reference in a new issue