Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added partial media permission to android #1347

Merged
merged 7 commits into from
Aug 5, 2024

Conversation

LulleBulle
Copy link
Contributor

@LulleBulle LulleBulle commented Jul 18, 2024

Adds support for partial image permission with android. Fixes #1156

List at least one fixed issue.

Pre-launch Checklist

  • I made sure the project builds.
  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I rebased onto main.
  • I added new tests to check the change I am making, or this PR does not need tests.
  • I made sure all existing and new tests are passing.
  • I ran dart format . and committed any changes.
  • I ran flutter analyze and fixed any errors.

…. Also set android project to use local interface
@LulleBulle
Copy link
Contributor Author

LulleBulle commented Jul 18, 2024

Could use some help with the changelog and the pubspec.yaml update as versioning in open source is new to me.

Something to bear in mind is that if you grant partial permission Permission.photo comes back as PermissionStatus.permanentlyDenied. You could look into merging these two permissions however I believe when implementing them it would be better to check if either is true.

@AnujLM
Copy link
Contributor

AnujLM commented Jul 22, 2024

I have tested this branch on Android simulator with following specifications:
Properties

avd.ini.displayname      Pixel_3a_API_34_extension_level_7_x86_64
avd.ini.encoding         UTF-8
AvdId                    Pixel_3a_API_34_extension_level_7_x86_64
disk.dataPartition.size  6442450944
hw.accelerometer         yes
hw.arc                   false
hw.audioInput            yes
hw.battery               yes
hw.camera.back           emulated
hw.camera.front          emulated
hw.cpu.ncore             4
hw.device.hash2          MD5:0e6953ebf01bdc6b33a2f54746629c50
hw.device.manufacturer   Google
hw.device.name           pixel_3a
hw.dPad                  no
hw.gps                   yes
hw.gpu.enabled           yes
hw.gpu.mode              auto
hw.keyboard              yes
hw.lcd.density           440
hw.lcd.height            2220
hw.lcd.width             1080
hw.mainKeys              no
hw.ramSize               1536
hw.sdCard                yes
hw.sensors.orientation   yes
hw.sensors.proximity     yes
hw.trackBall             no
image.androidVersion.api 34
image.sysdir.1           system-images/android-34/google_apis/x86_64/
PlayStore.enabled        false
runtime.network.latency  none
runtime.network.speed    full
snapshot.present         no
tag.display              Google APIs
tag.id                   google_apis
vm.heapSize              256

But getting PermissionStatus.permanentlyDenied on selecting photos Select photos and videos in permission dialog. as report by issue #1243

Minimum reproducible code :

final permission = await Permission.photos.request();
    if (!permission.isGranted) {
      debugPrint(permission.toString());
      return;
    } 

@LulleBulle
Copy link
Contributor Author

@AnujLM that is correct, a new permission partialMediaAccess has been added. It could be that it instead should be incorporated into permission.photos and I can look into that. My first thought was that you would do something like if (permissions.photos || permissions.partialMediaAccess).

@AnujLM
Copy link
Contributor

AnujLM commented Jul 22, 2024

@LulleBulle got your point, have checked with permissions.partialMediaAccess it is returning true as expected. However, it would be more intuitive if somehow we can accommodate this change under permissions.photos itself, since the dialog is triggered by permissions.photos.request() only. Need your input on this.

@LulleBulle
Copy link
Contributor Author

@AnujLM I have now baked it into the photos permission and it will return Limited if you select partial. Same with videos.
https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_VISUAL_USER_SELECTED

The example app has an issue with not refreshing instantly that I don't know how to fix, scroll down and up again and it should return correctly.

Given that ist just an exmaple app I am not entirely sure that there's not some bugs with it.

I believe the desired use of it is all depending on user case. Let me know what you think.

@LulleBulle
Copy link
Contributor Author

@mvanbeusekom could you take a look at this?

@AnujLM
Copy link
Contributor

AnujLM commented Aug 2, 2024

@LulleBulle please add him in reviewers section

Copy link
Member

@mvanbeusekom mvanbeusekom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mvanbeusekom mvanbeusekom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LulleBulle,

Thank you for this contribution. I realize this is a bit late, however I was wondering if you could:

  1. Rollback the changes to the permission_handler_platform_interface package (these should be submitted as a separate PR).
  2. Update the version tag in the pubspec.yaml file.
  3. Update the CHANGELOG.md file mentioning the changes made.

@AnujLM
Copy link
Contributor

AnujLM commented Aug 2, 2024

Hi @mvanbeusekom ,
I have raised a PR #1354 to accommodate relevant changes to permission_handler_platform_interface.
@LulleBulle you can rollback the changes in permission_handler_platform_interface.

@LulleBulle
Copy link
Contributor Author

Hi @LulleBulle,

Thank you for this contribution. I realize this is a bit late, however I was wondering if you could:

  1. Rollback the changes to the permission_handler_platform_interface package (these should be submitted as a separate PR).
  2. Update the version tag in the pubspec.yaml file.
  3. Update the CHANGELOG.md file mentioning the changes made.

It has been taken care of. Let me know if it is satisfactory.

Copy link
Member

@mvanbeusekom mvanbeusekom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for this contribution.

@mvanbeusekom mvanbeusekom merged commit 0de4345 into Baseflow:main Aug 5, 2024
1 check passed
@AnujLM
Copy link
Contributor

AnujLM commented Aug 5, 2024

@mvanbeusekom, could you please let us know when you plan to release the next version of permission_handler that will include these changes in permission_handler_android?

Thank you!

@QL-Uday
Copy link

QL-Uday commented Aug 6, 2024

I updated the dependency in my app, but still it is not working. the permissions.photos.request() permission is still returning "PermissionStatus.denied" upon selecting limited access.

versions using:-
permission_handler: 11.3.1
permission_handler_android: 12.0.8
permission_handler_platform_interface: 4.2.2

@VladShturma
Copy link
Contributor

@QL-Uday I checked versions:
permission_handler: 11.3.1
permission_handler_android: 12.0.8
permission_handler_platform_interface: 4.2.2

There is a workaround. Permission.photos.request() is returning PermissionStatus.denied, but Permission.photos.isLimited returns true.

So you can call
Permission.photos.request()
and do not check answer of this call but than check if user granted permissions using this code

await Permission.photos.isGranted || await Permission.photos.isLimited

@VladShturma
Copy link
Contributor

I made fix in PR #1362

dogiaplinh pushed a commit to dogiaplinh/flutter-permission-handler that referenced this pull request Sep 13, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request]: Add support for Android 14+ partial media permissions
5 participants