Skip to content

Commit

Permalink
added partial media permission to android (#1347)
Browse files Browse the repository at this point in the history
* added partial media permission to android and bumped compileSDK to 34. Also set android project to use local interface

* updated unit test with total permissions count + reset pubspec to not use local path

* baked the partial permission into original photo

* removed the partial permission as its baked into photos now

* added new limited to videos as well

* fixed format

* Versioning + reset platform_interface
  • Loading branch information
LulleBulle authored Aug 5, 2024
1 parent 42e1c85 commit 0de4345
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions permission_handler_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
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 @@ -100,7 +100,7 @@ final class PermissionConstants {
PERMISSION_GROUP_SCHEDULE_EXACT_ALARM,
PERMISSION_GROUP_CALENDAR_WRITE_ONLY,
PERMISSION_GROUP_CALENDAR_FULL_ACCESS,
PERMISSION_GROUP_ASSISTANT
PERMISSION_GROUP_ASSISTANT,
})
@interface PermissionGroup {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,18 @@ private int determinePermissionStatus(final @PermissionConstants.PermissionGroup
} else {
permissionStatuses.add(PermissionConstants.PERMISSION_STATUS_GRANTED);
}
} else {
} 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, name);
if (permissionStatusLimited == PackageManager.PERMISSION_GRANTED){
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));
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
2 changes: 1 addition & 1 deletion permission_handler_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 0de4345

Please sign in to comment.