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

[Android] CameraRoll support for Videos #13715

Closed
wants to merge 1,104 commits into from
Closed

[Android] CameraRoll support for Videos #13715

wants to merge 1,104 commits into from

Conversation

kesha-antonov
Copy link
Contributor

Motivation

[Android] CameraRoll does not support videos. This PR adds ability to get videos too.

Test Plan

I don't know how to test it automatically. I even wasn't able to build source code and ran just ./gradlew :ReactAndroid:installArchives && cp ./android ... everytime I changed the code.

And I didn't find any tests for CameraRoll so can't provide any tests. I'm a beginner in java dev.

Please guide me in this.


P.S.
This is a fork from this PR: #11877
See some details there

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact [email protected] if you have any questions.

@kesha-antonov kesha-antonov changed the title [Android] Cameraroll support for Videos [Android] CameraRoll support for Videos Apr 30, 2017
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 30, 2017
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@kesha-antonov
Copy link
Contributor Author

Also I've noticed that vertical videos do have wrong dimensions.
Neither MediaStore.Video.VideoColumns.RESOLUTION has correct resolution. Android thinks that these videos are horizontal.

My workaround for now is to listen onLoad event in react-native-video and get correct dimensions from there. This PR TheWidlarzGroup/react-native-video#239 added video dimensions

By wrong dimensions I mean: 640x320 should be 320x640

Maybe you guys can tell me how to get correct dimensions straight from android CameraRoll?

@zr0n
Copy link

zr0n commented May 2, 2017

Hey @kesha-antonov , nice beard.
I'm using the plugin react-native-camera-roll-picker (https://www.npmjs.com/package/react-native-camera-roll-picker)
And I tried to merge your changes into my react-native, but when I try to use assetType="Videos" it keep showing only photos.
Am I missing something?

@kesha-antonov
Copy link
Contributor Author

Hey! @zr0n Thanks!

Did you build android after merging?

@zr0n
Copy link

zr0n commented May 4, 2017

@kesha-antonov Yes, twice. But when I open the picker, keep showing only photos. Even if I use the assetType="All" it does not show video files.

@kesha-antonov
Copy link
Contributor Author

I'd suggest to pass some other strings "somestring" as "assetType"
If you'll get error - then you built it successfully.
If not - you should build it with these changes.

Telling this because it's working for me in simulator and a real device.

kesha-antonov referenced this pull request May 13, 2017
Summary:
Currently, Android camera roll videos cannot be retrieved in RN since

1) `CameraRollManager.java` doesn't do anything with the `assetType` param
2) Unspecifying MIME types doesn't show videos

This diff allows videos to be shown in the `CameraRoll.getPhotos(..)` call by reading `assetType`. Future diffs will come where the thumbnail and other info will be returned as well.

Reviewed By: furdei

Differential Revision: D5019202

fbshipit-source-id: a920273761b31f1a59ba6b8bc49c05852506829c
@zr0n
Copy link

zr0n commented May 20, 2017

@kesha-antonov
Hey Kesha, thank you for answering.
So, I tried to put some crazy value at assetType and it threw me a red screen with an error. But when I set assetType to 'Videos' it does not throw error and it shows only images from my gallery.

Any Idea of what is going wrong?

@amitaymolko
Copy link

@kesha-antonov Whats the status of this PR?

Copy link

@piotrek1543 piotrek1543 left a comment

Choose a reason for hiding this comment

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

Nice work, but please fix the typo.

@@ -289,69 +324,70 @@ protected void doInBackgroundGuarded(Void... params) {
// setting a limit at all), but it works because this specific ContentProvider is backed by
// an SQLite DB and forwards parameters to it without doing any parsing / validation.
try {
Cursor photos = resolver.query(
Images.Media.EXTERNAL_CONTENT_URI,
Cursor medias = resolver.query(

Choose a reason for hiding this comment

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

change to media. Medias is a wrong phrase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same. Why media? We get multiple items

private final @Nullable ReadableArray mMimeTypes;
private final Promise mPromise;

private GetPhotosTask(
private GetMediasTask(

Choose a reason for hiding this comment

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

Change to GetMediaTask. I'm pretty sure that one medium, multiple medias. Check: https://english.stackexchange.com/questions/314099/should-i-use-media-or-medias

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think here we get medias - multiple. Isn't it? Previously we get photos. What's wrong here?

Choose a reason for hiding this comment

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

Media is already plural, the singular is medium.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, Got it

mgoovaer and others added 11 commits August 4, 2017 09:07
Reviewed By: brosenfeld

Differential Revision: D5560628

fbshipit-source-id: b1457493e8429958fbd7bc9c490cffaa33b4a95a
Summary:
I added troubleshooting docs for connection to the development server from device, otherwise it's maybe hard to find out why it's not working.

Due to a disparity in what GitHub's API return the original PR (#14885) couldn't get imported, so I created a new PR as hramos suggested.
Closes #15304

Differential Revision: D5537615

Pulled By: hramos

fbshipit-source-id: b94e887b1b771be9e93854124bd0a56b27fd0097
Summary:
properties that has been set before -> properties that have been set before
Closes #15370

Differential Revision: D5563802

Pulled By: hramos

fbshipit-source-id: 288032555308a7e89ac365ff091b01ca381d4c80
Reviewed By: furdei

Differential Revision: D5558385

fbshipit-source-id: 11f00acbbdf61bfa4b7e86675b0912d6edc39e9b
Summary:
Same as #11819 but for Android. I didn't notice the bug initially in my app because I was using different animations on Android which did not trigger this issue.

**Test plan**
Created a simple repro example and tested that this fixes it. https://gist.github.com/janicduplessis/0f3eb362dae63fedf99a0d3ee041796a
Closes #12842

Differential Revision: D5556439

Pulled By: hramos

fbshipit-source-id: d13f4ad258d03cca46c793751ebc49d942b99152
Reviewed By: ericvicenti

Differential Revision: D5519379

fbshipit-source-id: a07ea0629f98c23e1027202cc7a7957233780643
Summary:
What existing problem does the pull request solve?

Ensure users of the React Native platform are aware of transform properties they must have while using `useNativeDriver` with the Animated API.

Not applicable.

I've been messing around with this for a couple of days at this point and feel a bit silly. See this issue [here](#13522). This would have saved me some time and will likely save others time as well.

Thank you for taking the time to look over this PR. Cheers!
Closes #13524

Differential Revision: D5567584

Pulled By: hramos

fbshipit-source-id: 4be9f1ba0f21148106f596efb0be791d4d364a66
Summary:
Currently the default way to setup _fastlane_ for ReactNative projects is to set it up in the `ios` or `android` subfolder. This PR updates the path and also the URL to the new fastlane docs page.
Closes #13261

Differential Revision: D5567604

Pulled By: hramos

fbshipit-source-id: 89c27328bb2748ff1772812786e2821963dc1779
… values when removing props on Android

Differential Revision: D5556439

fbshipit-source-id: dc0e4c1db25ec7f3631e6f684f9497962f2adc7b
Summary:
Several changes here. The `Text.md` and `PixelRatio.md` files were appended to the autodocs during site generation. This seemed excessive for just two files, so I've just merged the content into the autodocs themselves. It should help us simplify the website generation process in the future.

I've also merged IssueGuidelines.md and PullRequestGuidelines.md into the Contribution/Maintainers guidelines to improve their visibility.

Finally, I renamed Help to Community in the nav bar.

Ran the website locally, and verified every page rendered as expected: the Community page, Contributing page, Maintainers page.
Closes #15374

Differential Revision: D5567400

Pulled By: hramos

fbshipit-source-id: e06056edb12c9a17319fe1af46b2ef3a2e1b5854
Summary:
Adding the proper way to setup Stetho debugging, based on this post: https://medium.com/andr3wjack/stetho-with-react-native-87642e5d7131#.352jqqavc

with updated OkHttp API.

**Test plan**

 + Manual test, DYI.
Closes #12232

Differential Revision: D5568733

Pulled By: hramos

fbshipit-source-id: 6006b9daa48024742b948f5fd33a07545549397c
terribleben and others added 2 commits September 14, 2017 12:10
Summary:
This avoids a crash when we try to load a PHAsset with nil image url. Specifically, the following condition evaluates to true when `imageURL` is nil:

```objc
if ([imageURL.scheme caseInsensitiveCompare:@"assets-library"] == NSOrderedSame) {
    assetID = [imageURL absoluteString];
    results = [PHAsset fetchAssetsWithALAssetURLs:@[imageURL] options:nil];
}
```

The crash will be "attempt to insert nil object from objects[0]" when we build the `@[imageURL]` array literal.

We've seen this emerge as a very common crash among Expo users, so I wanted to at least provide a clear error message instead of terminating the app.

Load an image from the photo library with a nil request url.
Closes #15952

Differential Revision: D5835219

Pulled By: ericnakagawa

fbshipit-source-id: 7be00a15e674a0905cf5c27c526ce9085d1b308f
@marceloduarteuy
Copy link

Hi!
I am very interested to have it solved. We need to show videos at Android platform.
Please merge the changes to include support.

Tim Wang and others added 15 commits September 18, 2017 22:55
Summary:
React Native v0.48.0 shipped `WebSocketModule` support with `BlobModule` as dependency. But `BlobModule` is not mocked in jest which will cause render tests failed.

Reference implantation: [BlobModule.java](https://github.com/facebook/react-native/blob/ed903099b42259958d8a6eb3af1a6460c1bc8b2c/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java)

Related PR: #11417
Related issue: #15810

Passed CI tests.
Need render a component in jest with WebSocketModule as dependency.
Closes #15843

Differential Revision: D5783263

Pulled By: shergin

fbshipit-source-id: 2386692f4a644796da2fd66b3135da9f5911663e
Summary:
Basic implementation of the proposal in #15271

Note that this should not affect facebook internally since they are not using OSS releases.

Points to consider:
- How strict should the version match be, right now I just match exact versions.
- Wasn't able to use haste for ReactNativeVersion because I was getting duplicate module provider caused by the template file in scripts/versiontemplates. I tried adding the scripts folder to modulePathIgnorePatterns in package.json but that didn't help.
- Redscreen vs. warning, I think warning is useless because if the app crashes you won't have time to see the warning.
- Should the check and native modules be __DEV__ only?

**Test plan**
Tested that it works when version match and that it redscreens when versions don't before getting other errors on Android and iOS.
Closes #15518

Differential Revision: D5813551

Pulled By: hramos

fbshipit-source-id: 901757e25724b0f22bf39de172b56309d0dd5a95
Summary:
This lets us import fishhook like `<fishhook/fishhook.h>`.
Closes #16192

Differential Revision: D5971639

Pulled By: shergin

fbshipit-source-id: c46503953a08a74bdd10ed35cbd30029f1666c7d
Differential Revision: D5839414

fbshipit-source-id: 7a0c7b3d27be728c74e08d3a8209deb3ca68dd63
Reviewed By: yungsters

Differential Revision: D5857305

fbshipit-source-id: 2fc20a848fa4dce5c1ac3fb7e986536618e25548
… is present

Summary: In some enviroments PlatformConstants native module may not be presented in a project, which results in a call to undefined property and a RedBox

Reviewed By: javache

Differential Revision: D5960879

fbshipit-source-id: 80aecbe2f2a61cb410abd5f0dce8ba855e166991
Summary:
Fails on my machine due to fact that `replace` returns an instance of a String, rather than an instance of ShellString (that includes `to` on its prototype).

Solution is to use an explicit `writeFileSync`. You can see that change in the wild on 0.50-stable branch.

CC janicduplessis (edit by hramos)
Closes #16303

Differential Revision: D6031331

Pulled By: hramos

fbshipit-source-id: 41c583d53df75bea1a55fa19174d912e414209c0
@pull-bot
Copy link

Warnings
⚠️

📝 Blog post - This PR appears to add a new blog post, and may require further review from the React Native team.

⚠️

📝 Blog post - This PR appears to edit an existing blog post, and may require further review from the React Native team.

⚠️

🔒 package.json - Changes were made to package.json. This will require a manual import by a Facebook employee.

⚠️

❗ Big PR - This PR is extremely unlikely to get reviewed because it touches 207144 lines.

⚠️

❗ Bots - This PR appears to modify the list of people that may issue commands to the GitHub bot.

Messages
📖

📄 Docs - Thanks for your contribution to the docs!

@facebook-github-bot label Documentation

@facebook-github-bot large-pr

Attention: @hramos, @janicduplessis, @shergin, @mhorowitz, @grabbou, @Kureev

Generated by 🚫 dangerJS

@hramos
Copy link
Contributor

hramos commented Oct 17, 2017

Hey, I missed the notifications here. Looks like a merge with master added a bunch of unrelated commits. If you fix this, in a new PR, maybe we can continue working on getting this merged.

@kesha-antonov
Copy link
Contributor Author

@hramos
Hello!
Yes, I messed up things.
New PR is here: #16429

Waiting for your feedback!

@ghentzi
Copy link

ghentzi commented Oct 20, 2017

Hi,
I test your new PR but when I try to retrieve list of videos, I have the error :

E/unknown:ReactNative: Could not get width/height for content://media/external/images/media/546
java.io.FileNotFoundException: No entry for content://media/external/images/media/546
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:692)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1158)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:995)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:918)
at com.facebook.react.modules.camera.CameraRollManager.putImageInfo(CameraRollManager.java:413)
at com.facebook.react.modules.camera.CameraRollManager.putEdges(CameraRollManager.java:365)
at com.facebook.react.modules.camera.CameraRollManager.access$300(CameraRollManager.java:61)
at com.facebook.react.modules.camera.CameraRollManager$GetPhotosTask.doInBackgroundGuarded(CameraRollManager.java:317)
at com.facebook.react.modules.camera.CameraRollManager$GetPhotosTask.doInBackgroundGuarded(CameraRollManager.java:249)
at com.facebook.react.bridge.GuardedAsyncTask.doInBackground(GuardedAsyncTask.java:34)
at com.facebook.react.bridge.GuardedAsyncTask.doInBackground(GuardedAsyncTask.java:22)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

How can I fix it ?
Thanks

@kesha-antonov
Copy link
Contributor Author

kesha-antonov commented Oct 20, 2017

Hi @WemagineGuillaume

Try this (new PR) #16429

I do not support this anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.