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

Switch to using photo picker #1288

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kevinMerizalde
Copy link

To solve the issue #1261
I apply the logic that is explained here: https://developer.android.com/training/data-storage/shared/photopicker#java

First, I need to look for situations in which the user is allowed to select an image from their gallery or files directory. I found that the user is allowed to select an image in three main cases:

  1. When creating a card and an icon or image can be defined, or in the Photos tab (to define the front and back image).
  2. When editing a card and an icon or image can be defined, or in the Photos tab (to define the front and back image).
  3. When extracting a barcode or QR code.

After identify these cases I search the code that display the gallery or the file directory and I adapt that code to use the new photo picker approach instead the old one (Only if the Android version of the phone is superior to Android R (11), because if I want to apply this approach to old versions of android, I need to enable the automatic installation of the backported photo picker module through Google Play services and the issue says that is better to not install things without the permission of the user and I agree with that).

Basically, I add some dependencies of androidx and edit the next functions:

  • addFromImageAfterPermission() - In the ScanActivity
  • selectImageFromGallery(int type) - In the LoyaltyCardEditActivity

If the phone had an Android version oldest than 11 then the old code is executed, if not then the new photo picker is used.

this new photoPicker activity only is generated if the Android version is bigger than 11
… gallery image

this new photoPicker activity only is generated if the Android version is bigger than 11. is not installing anything on the phone because we are using only compatible android versions.
Copy link
Member

@TheLastProject TheLastProject left a comment

Choose a reason for hiding this comment

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

Haven't had time to test this yet, but I have several questions. Could you please look at these?

app/src/main/java/protect/card_locker/ScanActivity.java Outdated Show resolved Hide resolved
app/build.gradle Outdated Show resolved Hide resolved
@TheLastProject
Copy link
Member

I've tested and can tell it works on my Android 13 phone. After testing on an Android 5 emulator I kinda understand your decision to have the two code paths as it somehow opens the file manager on Android 5 instead of the gallery.

I do still prefer just a single code path, also for consistency in behaviour with other apps.

But this needs to be delayed anyway given the Photo Picker currently only shows internal camera images and thus will lack many many images the user my want to select. Maybe it'll get added later.

Thanks for your contribution, it's sad Google hasn't developed the Photo Picker in a way where it'll be useful for most users.

@TheLastProject TheLastProject added the state: blocked by upstream Can't currently be done due to a limitation of Android or another upstream label May 18, 2023
@TheLastProject TheLastProject mentioned this pull request Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: blocked by upstream Can't currently be done due to a limitation of Android or another upstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants