Skip to content

Commit

Permalink
added partial media permission to android and bumped compileSDK to 34…
Browse files Browse the repository at this point in the history
…. Also set android project to use local interface
  • Loading branch information
LulleBulle committed Jul 18, 2024
1 parent 9290ecd commit 32df117
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion permission_handler_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
if (project.android.hasProperty("namespace")) {
namespace 'com.baseflow.permissionhandler'
}
compileSdk 33
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -352,6 +354,11 @@ static List<String> 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:
Expand Down
4 changes: 2 additions & 2 deletions permission_handler_android/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />

<!-- Permissions options for the `camera` group -->
<uses-permission android:name="android.permission.CAMERA"/>
Expand Down
3 changes: 2 additions & 1 deletion permission_handler_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Permission> values = <Permission>[
// ignore: deprecated_member_use_from_same_package
Expand Down Expand Up @@ -369,6 +372,7 @@ class Permission {
calendarFullAccess,
assistant,
backgroundRefresh,
partialMediaAccess
];

static const List<String> _names = <String>[
Expand Down Expand Up @@ -411,7 +415,8 @@ class Permission {
'calendarWriteOnly',
'calendarFullAccess',
'assistant',
'backgroundRefresh'
'backgroundRefresh',
'partialMediaAccess'
];

@override
Expand Down

0 comments on commit 32df117

Please sign in to comment.