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] 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