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

Media & Text block - can't take a photo or video #1571

Closed
malinajirka opened this issue Nov 12, 2019 · 6 comments
Closed

Media & Text block - can't take a photo or video #1571

malinajirka opened this issue Nov 12, 2019 · 6 comments
Labels

Comments

@malinajirka
Copy link
Contributor

malinajirka commented Nov 12, 2019

Describe the bug
I can't add a photo or video using Media & Text block.

To Reproduce
Steps to reproduce the behavior:

  1. Create a post in WPAndroid
  2. Add "Media & Text" block
  3. Click on it
  4. Choose "Take a photo or video"
  5. Nothing happens

Expected behavior
The app opens a camera app I guess?

Screenshots
image-text-block-gb

Smartphone (please complete the following information):

  • Device: Pixel 3
  • OS: Android X
  • Version develop 6e59663f8c0eda962c8a6fa0a45212fbd17942b1
@malinajirka malinajirka added [Type] Bug Something isn't working [OS] Android labels Nov 12, 2019
@hypest
Copy link
Contributor

hypest commented Nov 13, 2019

I can reproduce the issue on WPiOS as well.

@mkevins
Copy link
Contributor

mkevins commented Nov 14, 2019

I've reproduced this on Pixel 3a - Android 10 - real device, on:

WordPress-Android:
develop: 6e59663f8c0eda962c8a6fa0a45212fbd17942b1
and also:
8088889a2992d75bed0a9ac7ef042b83b53b654a

Also in libs/gutenberg-mobile:
release/1.17: 3c5051ce425ca3cb83a2a947d94c3de8901742ad

It seems that the language "Take a Photo or Video" was introduced in this PR: WordPress/gutenberg#17145, but I couldn't find an underlying implementation which allows for capture of both image or video within a single intent. If such an intent exists, we can launch it for MediaType.MEDIA. Otherwise, it isn't exactly clear to me how to proceed.

We have launchCamera and launchVideoCamera methods for capturing photos and videos, respectively. These each prepare an intent in slightly different ways (within WPMediaUtils). The capture image intent customizes the file path with a "wp-" prefix, and the capture video intent launches the MediaStore provider intent directly (without extras). The capture photo code path also has some extra checks to make sure the destination directory exists for writing the output file.

I'm not aware of any MediaStore provider to capture either a photo or a video. It seems the intents that return with a result are mutually exclusive in that regard. https://developer.android.com/reference/android/provider/MediaStore

One solution may be to use the existing photo capture intent and change the language to reflect that. Something like this might work:

diff --git a/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java b/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java
index 1965d5f..6238c7f 100644
--- a/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java
+++ b/react-native-gutenberg-bridge/android/src/main/java/org/wordpress/mobile/WPAndroidGlue/WPAndroidGlueCode.java
@@ -182,7 +182,7 @@ public class WPAndroidGlueCode {
             public void requestMediaPickerFromDeviceCamera(MediaUploadCallback mediaUploadCallback, MediaType mediaType) {
                 mMediaPickedByUserOnBlock = true;
                 mPendingMediaUploadCallback = mediaUploadCallback;
-                if (mediaType == MediaType.IMAGE) {
+                if (mediaType == MediaType.IMAGE || mediaType == MediaType.MEDIA) {
                     mOnMediaLibraryButtonListener.onCapturePhotoButtonClicked();
                 } else if (mediaType == MediaType.VIDEO) {
                     mOnMediaLibraryButtonListener.onCaptureVideoButtonClicked();

Another solution could be to prepare an ACTION_CHOOSER intent, but that'd be one more additional tap in the user flow.

@pinarol
Copy link
Contributor

pinarol commented Nov 14, 2019

I suggest doing this in 2 iterations:

  • Temporary workaround: Let's quickly update the option as "Take a Photo" and make it work similar to Image block and ship it as soon as possible.

I think this is better than having a button doing nothing and it will give us time to address the whole thing.

  • Implement Take a photo or video option on both platforms.

@hypest
Copy link
Contributor

hypest commented Nov 14, 2019

We could also try having separate options in the bottom sheet: "Take photo" and "Take video" which we should already have the native sides ready since those are the individual actions of the Image block and the Video block.

@pinarol
Copy link
Contributor

pinarol commented Nov 14, 2019

That's even better, and it can be a long term solution! Thanks @hypest !

@hypest
Copy link
Contributor

hypest commented Dec 6, 2019

Closing since the option has been replaced by two separate ones with #1579.

@hypest hypest closed this as completed Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants