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

Fix: [Android] Opening camera/gallery does not work on Android 11 #3420

Merged

Conversation

kidroca
Copy link
Contributor

@kidroca kidroca commented Jun 8, 2021

Details

Update the image picker and document picker libraries to their latest versions
Migrate usages to match the newer version specs

Fixed Issues

Fixes #2531

Tests

Try for both Android 10, 11 and iOS, desktop/web implementation haven't been changed but you can test that as well

  1. Open a chat
  2. Press the (+) button and select "Add Attachment"
  3. Try all the 3 options - Take Photo | Gallery | Documents
  • selecting photos documents should work
  • cancelling from take photo or the other options should not produce errors
  • changing permissions to "deny" using the camera should handle the error gracefully - see the videos bellow

QA Steps

Same as above

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Expensify.cash.-.Google.Chrome.2021-06-10.21-07-36.mp4

Mobile Web

Screen.Recording.2021-06-10.at.21.10.15.mov

Desktop

Screen.Recording.2021-06-10.at.21.04.25.mov

iOS

When a user have manually denied permissions
2021-06-10.20-57-48.mp4
Selecting a file from gallery or documents

Uploading Screen Recording 2021-06-10 at 21.47.51.mov…

Android

Android 11
When a user have manually denied permissions
Android.Emulator.-.Samsung_Galaxy_S10_API_30_5556.2021-06-10.20-39-19.mp4
Selecting a file from gallery or documents
Android.Emulator.-.Samsung_Galaxy_S10_API_30_5556.2021-06-10.20-42-37.mp4
Android 10
When a user have manually denied permissions
Android.Emulator.-.Pixel_2_API_29_5554.2021-06-10.20-27-53.mp4
Selecting a file from gallery or documents
Android.Emulator.-.Pixel_2_API_29_5554.2021-06-10.20-30-39.mp4

@kidroca kidroca force-pushed the kidroca/update-image-picker-dependencies branch 2 times, most recently from 3f76120 to 2b4d0d3 Compare June 8, 2021 10:44
Copy link
Contributor Author

@kidroca kidroca left a comment

Choose a reason for hiding this comment

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

Added some notes on the changes

android/app/src/main/AndroidManifest.xml Show resolved Hide resolved
* @param {CameraOptions} options
* @param {function} callback - callback called with the result
*/
export default function launchCameraAndroid(options, callback) {
Copy link
Contributor Author

@kidroca kidroca Jun 8, 2021

Choose a reason for hiding this comment

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

As per react-native-image-picker: https://github.com/react-native-image-picker/react-native-image-picker#android

Note: This library does not require Manifest.permission.CAMERA, if your app declares as using this permission in manifest then you have to obtain the permission before using launchCamera.

E.cash has Manifest.permission.CAMERA declared in the Manifest

I've also found out that if the user manually revokes the camera permission the "Take Photo" button
would stop working, but the "General" alert "An error occurred while selecting an attachment, please try again" would be displayed for the user, instead the user should see "Expensify.cash does not have access to your camera, please enable the permission and try again." with a link to "Settings". This code achieves the desired behavior

Before extracting launchCamera.android.js

image

@kidroca kidroca force-pushed the kidroca/update-image-picker-dependencies branch from 2b4d0d3 to 41cb6f3 Compare June 10, 2021 14:29
When an user installs E.cash on Android they've automatically granted camera permission
since it's included in the manifest, but if they ever revoke the Permission we
need to check and request it again as the image-picker library does not handle this
@kidroca kidroca force-pushed the kidroca/update-image-picker-dependencies branch from 41cb6f3 to dc447db Compare June 10, 2021 18:00
@kidroca kidroca marked this pull request as ready for review June 10, 2021 18:23
@kidroca kidroca requested a review from a team as a code owner June 10, 2021 18:23
@MelvinBot MelvinBot requested review from Gonals and removed request for a team June 10, 2021 18:23
It seems the timeout fix is still needed for this to work on iOS
Copy link
Contributor

@Gonals Gonals left a comment

Choose a reason for hiding this comment

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

Looks good, but there are a few conflicts!

…picker-dependencies

# Conflicts:
#	ios/Podfile.lock
#	package-lock.json
#	package.json
#	src/components/AttachmentPicker/index.native.js
@kidroca
Copy link
Contributor Author

kidroca commented Jun 15, 2021

Merged main and resolved conflicts

@kidroca kidroca requested a review from Gonals June 18, 2021 07:48
@kidroca
Copy link
Contributor Author

kidroca commented Jun 18, 2021

Bump, @Gonals this is ready

@Gonals Gonals merged commit 6626eb9 into Expensify:main Jun 18, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging in version: 1.0.71-1🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.73-3🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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.

[Android] Opening camera/gallery does not work on Android 11
3 participants