Skip to content

Commit 55d1903

Browse files
authored
Split calendar permission into calendarReadOnly and calendarFullAccess (#1183)
1 parent a3bacb4 commit 55d1903

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

permission_handler_platform_interface/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.12.0
2+
3+
* Adds `Permission.calendarReadOnly` and `Permission.calendarFullAccess`.
4+
* Deprecates `Permission.calendar`. Developers should use `Permission.calendarReadOnly` and `Permission.calendarFullAccess` instead.
5+
16
## 3.11.5
27

38
* Updates the mentions of Android versions throughout the plugin, now following a format of 'Android {name} (API {number})'. For example: 'Android 13 (API 33)'.

permission_handler_platform_interface/lib/src/permissions.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Permission {
2929
///
3030
/// Android: Calendar
3131
/// iOS: Calendar (Events)
32+
@Deprecated('Use [calendarReadOnly] and [calendarFullAccess].')
3233
static const calendar = Permission._(0);
3334

3435
/// Permission for accessing the device's camera.
@@ -296,8 +297,17 @@ class Permission {
296297
/// Android 13+ (API 33+)
297298
static const sensorsAlways = Permission._(35);
298299

300+
/// Permission for reading the device's calendar.
301+
///
302+
/// On iOS 16 and lower, this permission is identical to [Permission.calendarFullAccess].
303+
static const calendarReadOnly = Permission._(36);
304+
305+
/// Permission for reading from and writing to the device's calendar.
306+
static const calendarFullAccess = Permission._(37);
307+
299308
/// Returns a list of all possible [PermissionGroup] values.
300309
static const List<Permission> values = <Permission>[
310+
// ignore: deprecated_member_use_from_same_package
301311
calendar,
302312
camera,
303313
contacts,
@@ -334,6 +344,8 @@ class Permission {
334344
audio,
335345
scheduleExactAlarm,
336346
sensorsAlways,
347+
calendarReadOnly,
348+
calendarFullAccess,
337349
];
338350

339351
static const List<String> _names = <String>[
@@ -373,6 +385,8 @@ class Permission {
373385
'audio',
374386
'scheduleExactAlarm',
375387
'sensorsAlways',
388+
'calendarReadOnly',
389+
'calendarFullAccess',
376390
];
377391

378392
@override

permission_handler_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
33
homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 3.11.5
6+
version: 3.12.0
77

88
dependencies:
99
flutter:

permission_handler_platform_interface/test/src/method_channel/method_channel_permission_handler_test.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import 'package:permission_handler_platform_interface/permission_handler_platfor
33
import 'package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart';
44
import 'method_channel_mock.dart';
55

6-
List<Permission> get mockPermissions => List.of(
7-
<Permission>{Permission.calendar, Permission.camera, Permission.contacts});
6+
List<Permission> get mockPermissions => List.of(<Permission>{
7+
Permission.contacts,
8+
Permission.camera,
9+
Permission.calendarReadOnly,
10+
});
811

912
Map<Permission, PermissionStatus> get mockPermissionMap => {};
1013

@@ -21,7 +24,7 @@ void main() {
2124
);
2225

2326
final permissionStatus = await MethodChannelPermissionHandler()
24-
.checkPermissionStatus(Permission.calendar);
27+
.checkPermissionStatus(Permission.contacts);
2528

2629
expect(permissionStatus, PermissionStatus.denied);
2730
});
@@ -35,7 +38,7 @@ void main() {
3538
);
3639

3740
final permissionStatus = await MethodChannelPermissionHandler()
38-
.checkPermissionStatus(Permission.calendar);
41+
.checkPermissionStatus(Permission.contacts);
3942

4043
expect(permissionStatus, PermissionStatus.denied);
4144
});
@@ -51,7 +54,7 @@ void main() {
5154
);
5255

5356
final permissionStatus = await MethodChannelPermissionHandler()
54-
.checkPermissionStatus(Permission.calendar);
57+
.checkPermissionStatus(Permission.contacts);
5558

5659
expect(permissionStatus, PermissionStatus.restricted);
5760
});
@@ -67,7 +70,7 @@ void main() {
6770
);
6871

6972
final permissionStatus = await MethodChannelPermissionHandler()
70-
.checkPermissionStatus(Permission.calendar);
73+
.checkPermissionStatus(Permission.contacts);
7174

7275
expect(permissionStatus, PermissionStatus.limited);
7376
});
@@ -83,7 +86,7 @@ void main() {
8386
);
8487

8588
final permissionStatus = await MethodChannelPermissionHandler()
86-
.checkPermissionStatus(Permission.calendar);
89+
.checkPermissionStatus(Permission.contacts);
8790

8891
expect(permissionStatus, PermissionStatus.permanentlyDenied);
8992
});
@@ -101,7 +104,7 @@ void main() {
101104
);
102105

103106
final serviceStatus = await MethodChannelPermissionHandler()
104-
.checkServiceStatus(Permission.calendar);
107+
.checkServiceStatus(Permission.contacts);
105108

106109
expect(serviceStatus, ServiceStatus.disabled);
107110
});
@@ -115,7 +118,7 @@ void main() {
115118
);
116119

117120
final serviceStatus = await MethodChannelPermissionHandler()
118-
.checkServiceStatus(Permission.calendar);
121+
.checkServiceStatus(Permission.contacts);
119122

120123
expect(serviceStatus, ServiceStatus.enabled);
121124
});
@@ -131,7 +134,7 @@ void main() {
131134
);
132135

133136
final serviceStatus = await MethodChannelPermissionHandler()
134-
.checkServiceStatus(Permission.calendar);
137+
.checkServiceStatus(Permission.contacts);
135138

136139
expect(serviceStatus, ServiceStatus.notApplicable);
137140
});

permission_handler_platform_interface/test/src/permissions_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void main() {
66
() {
77
const values = Permission.values;
88

9-
expect(values.length, 36);
9+
expect(values.length, 38);
1010
});
1111

1212
test('check if byValue returns corresponding PermissionGroup value', () {

0 commit comments

Comments
 (0)