From 32df117f866ab8d8d0915951df53f294982864b3 Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:09:53 +0200 Subject: [PATCH 1/7] added partial media permission to android and bumped compileSDK to 34. Also set android project to use local interface --- permission_handler_android/android/build.gradle | 2 +- .../baseflow/permissionhandler/PermissionConstants.java | 4 +++- .../com/baseflow/permissionhandler/PermissionUtils.java | 7 +++++++ .../example/android/app/build.gradle | 4 ++-- .../example/android/app/src/main/AndroidManifest.xml | 1 + permission_handler_android/pubspec.yaml | 3 ++- .../lib/src/permissions.dart | 7 ++++++- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/permission_handler_android/android/build.gradle b/permission_handler_android/android/build.gradle index 315b0761f..73622f51d 100644 --- a/permission_handler_android/android/build.gradle +++ b/permission_handler_android/android/build.gradle @@ -26,7 +26,7 @@ android { if (project.android.hasProperty("namespace")) { namespace 'com.baseflow.permissionhandler' } - compileSdk 33 + compileSdk 34 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java index 841595e6a..934b966c3 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java @@ -62,6 +62,7 @@ final class PermissionConstants { static final int PERMISSION_GROUP_CALENDAR_FULL_ACCESS = 37; static final int PERMISSION_GROUP_ASSISTANT = 38; static final int PERMISSION_GROUP_BACKGROUND_REFRESH = 39; + static final int PERMISSION_GROUP_PARTIAL_MEDIA = 40; @Retention(RetentionPolicy.SOURCE) @IntDef({ @@ -100,7 +101,8 @@ final class PermissionConstants { PERMISSION_GROUP_SCHEDULE_EXACT_ALARM, PERMISSION_GROUP_CALENDAR_WRITE_ONLY, PERMISSION_GROUP_CALENDAR_FULL_ACCESS, - PERMISSION_GROUP_ASSISTANT + PERMISSION_GROUP_ASSISTANT, + PERMISSION_GROUP_PARTIAL_MEDIA }) @interface PermissionGroup { } diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java index 888a3893e..199ccd473 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java @@ -94,6 +94,8 @@ static int parseManifestName(String permission) { return PermissionConstants.PERMISSION_GROUP_AUDIO; case Manifest.permission.SCHEDULE_EXACT_ALARM: return PermissionConstants.PERMISSION_GROUP_SCHEDULE_EXACT_ALARM; + case Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED: + return PermissionConstants.PERMISSION_GROUP_PARTIAL_MEDIA; default: return PermissionConstants.PERMISSION_GROUP_UNKNOWN; } @@ -352,6 +354,11 @@ static List getManifestNames(Context context, @PermissionConstants.Permi if (hasPermissionInManifest(context, permissionNames, Manifest.permission.SCHEDULE_EXACT_ALARM)) permissionNames.add(Manifest.permission.SCHEDULE_EXACT_ALARM); break; + case PermissionConstants.PERMISSION_GROUP_PARTIAL_MEDIA: + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE & hasPermissionInManifest(context, permissionNames, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)){ + permissionNames.add(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED); + } + break; case PermissionConstants.PERMISSION_GROUP_MEDIA_LIBRARY: case PermissionConstants.PERMISSION_GROUP_REMINDERS: case PermissionConstants.PERMISSION_GROUP_UNKNOWN: diff --git a/permission_handler_android/example/android/app/build.gradle b/permission_handler_android/example/android/app/build.gradle index 1ed3dcef4..93c36181d 100644 --- a/permission_handler_android/example/android/app/build.gradle +++ b/permission_handler_android/example/android/app/build.gradle @@ -26,13 +26,13 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { namespace 'com.baseflow.permissionhandler.example' - compileSdk 33 + compileSdk 34 defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.baseflow.permissionhandler.example" minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/permission_handler_android/example/android/app/src/main/AndroidManifest.xml b/permission_handler_android/example/android/app/src/main/AndroidManifest.xml index 6f7c32fd4..c9457c995 100644 --- a/permission_handler_android/example/android/app/src/main/AndroidManifest.xml +++ b/permission_handler_android/example/android/app/src/main/AndroidManifest.xml @@ -26,6 +26,7 @@ + diff --git a/permission_handler_android/pubspec.yaml b/permission_handler_android/pubspec.yaml index 51b3acba3..a3ddef663 100644 --- a/permission_handler_android/pubspec.yaml +++ b/permission_handler_android/pubspec.yaml @@ -18,7 +18,8 @@ flutter: dependencies: flutter: sdk: flutter - permission_handler_platform_interface: ^4.2.0 + permission_handler_platform_interface: #^4.2.0 + path: ../permission_handler_platform_interface dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_platform_interface/lib/src/permissions.dart b/permission_handler_platform_interface/lib/src/permissions.dart index 8f6a6a63b..1914ec178 100644 --- a/permission_handler_platform_interface/lib/src/permissions.dart +++ b/permission_handler_platform_interface/lib/src/permissions.dart @@ -326,6 +326,9 @@ class Permission { /// Permission for reading the current background refresh status. (iOS only) static const backgroundRefresh = Permission._(39); + /// Permission for partial media access on Android 14+ + static const partialMediaAccess = Permission._(40); + /// Returns a list of all possible [PermissionGroup] values. static const List values = [ // ignore: deprecated_member_use_from_same_package @@ -369,6 +372,7 @@ class Permission { calendarFullAccess, assistant, backgroundRefresh, + partialMediaAccess ]; static const List _names = [ @@ -411,7 +415,8 @@ class Permission { 'calendarWriteOnly', 'calendarFullAccess', 'assistant', - 'backgroundRefresh' + 'backgroundRefresh', + 'partialMediaAccess' ]; @override From a52e7bf103d849725b9bf24feebe3f65d31d5e4e Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:18:33 +0200 Subject: [PATCH 2/7] updated unit test with total permissions count + reset pubspec to not use local path --- permission_handler_android/pubspec.yaml | 3 +-- .../test/src/permissions_test.dart | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/permission_handler_android/pubspec.yaml b/permission_handler_android/pubspec.yaml index a3ddef663..51b3acba3 100644 --- a/permission_handler_android/pubspec.yaml +++ b/permission_handler_android/pubspec.yaml @@ -18,8 +18,7 @@ flutter: dependencies: flutter: sdk: flutter - permission_handler_platform_interface: #^4.2.0 - path: ../permission_handler_platform_interface + permission_handler_platform_interface: ^4.2.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_platform_interface/test/src/permissions_test.dart b/permission_handler_platform_interface/test/src/permissions_test.dart index 0f8beb470..86256a40c 100644 --- a/permission_handler_platform_interface/test/src/permissions_test.dart +++ b/permission_handler_platform_interface/test/src/permissions_test.dart @@ -5,7 +5,7 @@ void main() { test('Permission has the right amount of possible Permission values', () { const values = Permission.values; - expect(values.length, 40); + expect(values.length, 41); }); test('check if byValue returns corresponding Permission value', () { From ba222f1236f4689e4cf065ed2170c26a060899ba Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:14:04 +0200 Subject: [PATCH 3/7] baked the partial permission into original photo --- .../permissionhandler/PermissionManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java index ad420830d..fa5b55fa0 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java @@ -537,7 +537,19 @@ private int determinePermissionStatus(final @PermissionConstants.PermissionGroup } else { permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_GRANTED); } - } else { + } else if (permission == PermissionConstants.PERMISSION_GROUP_PHOTOS){ + final int permissionStatusLimited = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED); + final int permissionStatus = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES); + if (permissionStatusLimited == PackageManager.PERMISSION_GRANTED){ + //return PermissionConstants.PERMISSION_STATUS_LIMITED; + permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_LIMITED); + } + else{ + if (permissionStatus != PackageManager.PERMISSION_GRANTED) { + permissionStatuses.add(PermissionUtils.determineDeniedVariant(activity, name)); + } + } + }else { final int permissionStatus = ContextCompat.checkSelfPermission(context, name); if (permissionStatus != PackageManager.PERMISSION_GRANTED) { permissionStatuses.add(PermissionUtils.determineDeniedVariant(activity, name)); From 73a27b3b6c175aeb701adc808d964471a2ca6e6b Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:28:35 +0200 Subject: [PATCH 4/7] removed the partial permission as its baked into photos now --- .../baseflow/permissionhandler/PermissionConstants.java | 2 -- .../com/baseflow/permissionhandler/PermissionManager.java | 1 - .../com/baseflow/permissionhandler/PermissionUtils.java | 7 ------- .../lib/src/permissions.dart | 2 -- .../test/src/permissions_test.dart | 2 +- 5 files changed, 1 insertion(+), 13 deletions(-) diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java index 934b966c3..0262db176 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java @@ -62,7 +62,6 @@ final class PermissionConstants { static final int PERMISSION_GROUP_CALENDAR_FULL_ACCESS = 37; static final int PERMISSION_GROUP_ASSISTANT = 38; static final int PERMISSION_GROUP_BACKGROUND_REFRESH = 39; - static final int PERMISSION_GROUP_PARTIAL_MEDIA = 40; @Retention(RetentionPolicy.SOURCE) @IntDef({ @@ -102,7 +101,6 @@ final class PermissionConstants { PERMISSION_GROUP_CALENDAR_WRITE_ONLY, PERMISSION_GROUP_CALENDAR_FULL_ACCESS, PERMISSION_GROUP_ASSISTANT, - PERMISSION_GROUP_PARTIAL_MEDIA }) @interface PermissionGroup { } diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java index fa5b55fa0..fe6de2410 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java @@ -541,7 +541,6 @@ private int determinePermissionStatus(final @PermissionConstants.PermissionGroup final int permissionStatusLimited = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED); final int permissionStatus = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES); if (permissionStatusLimited == PackageManager.PERMISSION_GRANTED){ - //return PermissionConstants.PERMISSION_STATUS_LIMITED; permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_LIMITED); } else{ diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java index 199ccd473..888a3893e 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java @@ -94,8 +94,6 @@ static int parseManifestName(String permission) { return PermissionConstants.PERMISSION_GROUP_AUDIO; case Manifest.permission.SCHEDULE_EXACT_ALARM: return PermissionConstants.PERMISSION_GROUP_SCHEDULE_EXACT_ALARM; - case Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED: - return PermissionConstants.PERMISSION_GROUP_PARTIAL_MEDIA; default: return PermissionConstants.PERMISSION_GROUP_UNKNOWN; } @@ -354,11 +352,6 @@ static List getManifestNames(Context context, @PermissionConstants.Permi if (hasPermissionInManifest(context, permissionNames, Manifest.permission.SCHEDULE_EXACT_ALARM)) permissionNames.add(Manifest.permission.SCHEDULE_EXACT_ALARM); break; - case PermissionConstants.PERMISSION_GROUP_PARTIAL_MEDIA: - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE & hasPermissionInManifest(context, permissionNames, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)){ - permissionNames.add(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED); - } - break; case PermissionConstants.PERMISSION_GROUP_MEDIA_LIBRARY: case PermissionConstants.PERMISSION_GROUP_REMINDERS: case PermissionConstants.PERMISSION_GROUP_UNKNOWN: diff --git a/permission_handler_platform_interface/lib/src/permissions.dart b/permission_handler_platform_interface/lib/src/permissions.dart index 1914ec178..1cd18aae9 100644 --- a/permission_handler_platform_interface/lib/src/permissions.dart +++ b/permission_handler_platform_interface/lib/src/permissions.dart @@ -372,7 +372,6 @@ class Permission { calendarFullAccess, assistant, backgroundRefresh, - partialMediaAccess ]; static const List _names = [ @@ -416,7 +415,6 @@ class Permission { 'calendarFullAccess', 'assistant', 'backgroundRefresh', - 'partialMediaAccess' ]; @override diff --git a/permission_handler_platform_interface/test/src/permissions_test.dart b/permission_handler_platform_interface/test/src/permissions_test.dart index 86256a40c..0f8beb470 100644 --- a/permission_handler_platform_interface/test/src/permissions_test.dart +++ b/permission_handler_platform_interface/test/src/permissions_test.dart @@ -5,7 +5,7 @@ void main() { test('Permission has the right amount of possible Permission values', () { const values = Permission.values; - expect(values.length, 41); + expect(values.length, 40); }); test('check if byValue returns corresponding Permission value', () { From 78392bd199023ea501a9ba6428f1673428a2ebc3 Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:36:22 +0200 Subject: [PATCH 5/7] added new limited to videos as well --- .../com/baseflow/permissionhandler/PermissionManager.java | 4 ++-- .../lib/src/permission_status.dart | 2 +- .../lib/src/permissions.dart | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java index fe6de2410..4e08a04f7 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionManager.java @@ -537,9 +537,9 @@ private int determinePermissionStatus(final @PermissionConstants.PermissionGroup } else { permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_GRANTED); } - } else if (permission == PermissionConstants.PERMISSION_GROUP_PHOTOS){ + } else if (permission == PermissionConstants.PERMISSION_GROUP_PHOTOS || permission == PermissionConstants.PERMISSION_GROUP_VIDEOS){ final int permissionStatusLimited = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED); - final int permissionStatus = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES); + final int permissionStatus = ContextCompat.checkSelfPermission(context, name); if (permissionStatusLimited == PackageManager.PERMISSION_GRANTED){ permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_LIMITED); } diff --git a/permission_handler_platform_interface/lib/src/permission_status.dart b/permission_handler_platform_interface/lib/src/permission_status.dart index 52db045db..305cdd3da 100644 --- a/permission_handler_platform_interface/lib/src/permission_status.dart +++ b/permission_handler_platform_interface/lib/src/permission_status.dart @@ -19,7 +19,7 @@ enum PermissionStatus { /// The user has authorized this application for limited access. So far this /// is only relevant for the Photo Library picker. /// - /// *Only supported on iOS (iOS14+).* + /// *Only supported on iOS (iOS14+).* and Android 14+ limited, /// Permission to the requested feature is permanently denied, the permission diff --git a/permission_handler_platform_interface/lib/src/permissions.dart b/permission_handler_platform_interface/lib/src/permissions.dart index 1cd18aae9..562f774cc 100644 --- a/permission_handler_platform_interface/lib/src/permissions.dart +++ b/permission_handler_platform_interface/lib/src/permissions.dart @@ -326,8 +326,6 @@ class Permission { /// Permission for reading the current background refresh status. (iOS only) static const backgroundRefresh = Permission._(39); - /// Permission for partial media access on Android 14+ - static const partialMediaAccess = Permission._(40); /// Returns a list of all possible [PermissionGroup] values. static const List values = [ From 264392417965e92a7addb5705e370f8bf9273d28 Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:29:15 +0200 Subject: [PATCH 6/7] fixed format --- permission_handler_platform_interface/lib/src/permissions.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/permission_handler_platform_interface/lib/src/permissions.dart b/permission_handler_platform_interface/lib/src/permissions.dart index 562f774cc..f9bd33567 100644 --- a/permission_handler_platform_interface/lib/src/permissions.dart +++ b/permission_handler_platform_interface/lib/src/permissions.dart @@ -326,7 +326,6 @@ class Permission { /// Permission for reading the current background refresh status. (iOS only) static const backgroundRefresh = Permission._(39); - /// Returns a list of all possible [PermissionGroup] values. static const List values = [ // ignore: deprecated_member_use_from_same_package From 88792683a0087db641f71182ffca6a733b205aa1 Mon Sep 17 00:00:00 2001 From: LulleBulle <11162271+LulleBulle@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:12:20 +0200 Subject: [PATCH 7/7] Versioning + reset platform_interface --- permission_handler_android/CHANGELOG.md | 4 ++++ permission_handler_android/pubspec.yaml | 2 +- .../lib/src/permission_status.dart | 2 +- .../lib/src/permissions.dart | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/permission_handler_android/CHANGELOG.md b/permission_handler_android/CHANGELOG.md index 04ab8b1d3..bdf0a9a5c 100644 --- a/permission_handler_android/CHANGELOG.md +++ b/permission_handler_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 12.0.8 + +* Added support for limited photo and video permission on Android. + ## 12.0.7 * Removes additional Android v1 embedding class reference. diff --git a/permission_handler_android/pubspec.yaml b/permission_handler_android/pubspec.yaml index 51b3acba3..c05ef60a8 100644 --- a/permission_handler_android/pubspec.yaml +++ b/permission_handler_android/pubspec.yaml @@ -1,7 +1,7 @@ name: permission_handler_android description: Permission plugin for Flutter. This plugin provides the Android API to request and check permissions. homepage: https://github.com/baseflow/flutter-permission-handler -version: 12.0.7 +version: 12.0.8 environment: sdk: ">=2.15.0 <4.0.0" diff --git a/permission_handler_platform_interface/lib/src/permission_status.dart b/permission_handler_platform_interface/lib/src/permission_status.dart index 305cdd3da..52db045db 100644 --- a/permission_handler_platform_interface/lib/src/permission_status.dart +++ b/permission_handler_platform_interface/lib/src/permission_status.dart @@ -19,7 +19,7 @@ enum PermissionStatus { /// The user has authorized this application for limited access. So far this /// is only relevant for the Photo Library picker. /// - /// *Only supported on iOS (iOS14+).* and Android 14+ + /// *Only supported on iOS (iOS14+).* limited, /// Permission to the requested feature is permanently denied, the permission diff --git a/permission_handler_platform_interface/lib/src/permissions.dart b/permission_handler_platform_interface/lib/src/permissions.dart index f9bd33567..8f6a6a63b 100644 --- a/permission_handler_platform_interface/lib/src/permissions.dart +++ b/permission_handler_platform_interface/lib/src/permissions.dart @@ -411,7 +411,7 @@ class Permission { 'calendarWriteOnly', 'calendarFullAccess', 'assistant', - 'backgroundRefresh', + 'backgroundRefresh' ]; @override