Summary: public This diff extracts all shadow hierarchy-specific logic from UIManagerModule into a UIImplementation class. This will later allow using in alternative UIImplementations in future.
Reviewed By: astreet
Differential Revision: D2457849
fb-gh-sync-id: 532128ce1d67b525cdf03794a5a29d7e9ed0ab90
Summary: public There is really no reason NativeViewHierarchyManager.addRootView() should be performed synchroniously when called from background thread, as long as it is executed before every other command in UIViewOperationQueue, and we can ensure that by putting add view command at the front of the queue. When that happpens, the queue should always be empty anyway, but it's best to be safe.
This eliminates an unnecessary blocking call and should overall make the code simpler and safer (Semaphores can timeout).
Reviewed By: astreet
Differential Revision: D2462680
fb-gh-sync-id: 784ac6573a455019b93628c70992f3830b9d6f1f
Summary: public UIManageModule creates AnimationRegistry but never uses it, this diff moves it to NativeViewHierarchyManager who owns it. UIViewOperationQueue depends on AnimationRegistry to perform some of the enqueued operations, so it accessed it through a getting in NativeViewHierarchyManager. This will also make sure NativeViewHierarchyManager. and UIViewOperationQueue operate on the same AnimationManager (previously, that wasn't really enforced). This is needed so I can move away UIViewOperationQueue creation off the UIManagerModule. This diff should have no functional changes whatsoever.
Reviewed By: astreet
Differential Revision: D2462605
fb-gh-sync-id: 1e3cd64908f51126362f2b5fb39b1efa6521854e
Summary: ~~This is a WIP, just finished the first bit and wanted to get some feedback to see if this approach seems appropriate, as I haven't done a lot of Android development.~~
Looks ready for review now.
Closes https://github.com/facebook/react-native/pull/3791
Reviewed By: svcscm
Differential Revision: D2672262
Pulled By: mkonicek
fb-gh-sync-id: 1e8f1cc6658fb719a68f7da455f30a7c9b1db730
Summary: This PR includes a working interface to Android's `elevation` property implemented as an RN style. Elevation is the only (easy) [platform-supported way to create shadows](http://developer.android.com/training/material/shadows-clipping.html). For it to work note that you must be running on Android 5.0+, and add `elevation` to a view with a `backgroundColor` set. These are platform limitations.
This PR is not intended to be merged in its current state, but rather to inform the discussion from #2768. At a minimum, before merging we would need to add the elevation style to the docs and rebase this to master (**EDIT** I have now rebased on master because from v0.14.2 too many commits were being pulled in -- haven't tested it since the rebase though). Additionally, it might be good to add tests, although I couldn't find any for the Android code. I'm happy to get that done if this feature gets signed off by the React Native team.
Finally, as I argued in #2768 I think that `elevation` is a useful abstraction ov
Closes https://github.com/facebook/react-native/pull/4180
Reviewed By: svcscm
Differential Revision: D2684746
Pulled By: mkonicek
fb-gh-sync-id: 825f3ccd20c4b0eea9d11b5f0e3a6b018b7e4378
Summary: The anonymous class had an implicit reference back to FrescoModule that would in turn retain the context.
public
Reviewed By: astreet
Differential Revision: D2690747
fb-gh-sync-id: 8a97c102e461b903c6adf7c65956baf364fa5faf
Summary: public
We pass in a `ReactContext` but we really only need a context. Make sure we're using the application one.
Reviewed By: astreet
Differential Revision: D2690692
fb-gh-sync-id: 857d6571c9c01d35e12f09be4c8733cca007306f
Summary: public
The common case is to hit an error when the server isn't running. We shouldn't spew a stack trace for it.
Reviewed By: foghina
Differential Revision: D2685706
fb-gh-sync-id: d230af170b92a05452f04a90f23172f15e62dce6
Summary: public
This moves Android touch events to parity with iOS. The locationX,Y value passed to js now is view relative to the view that is handling the touch.
The pageX,Y is now relative to the root view.
Reviewed By: andreicoman11
Differential Revision: D2670028
fb-gh-sync-id: 5438640d6c78633629b9a308a59cc306bb07815e
Summary: This adds a persistent cookie store that shares cookies with WebView.
Add a `ForwardingCookieHandler` to OkHttp that uses the underlying Android webkit `CookieManager`.
Use a `LazyCookieHandler` to defer initialization of `CookieManager` as this will in turn trigger initialization of the Chromium stack in KitKat+ which takes some time. This was we will incur this cost on a background network thread instead of during startup.
Also add a `clearCookies()` method to the network module.
Add a cookies example to the XHR example. This example should also work for iOS (except for the clear cookies part). They are for now just scoped to Android.
Closes#2792.
public
Reviewed By: andreicoman11
Differential Revision: D2615550
fb-gh-sync-id: ff726a35f0fc3c7124d2f755448fe24c9d1caf21
Summary: Change the following classes into interfaces, with a separate
Impl file: CatalystInstance, ReactInstanceManager,
CatalystQueueConfiguration, MessageQueueThread. This is done to help
isolate the interface between React Native and applications which use it.
This will also help some intrusive development work on a branch
such as porting parts of the bridge to common C++ code, without affecting
app reliability while this work is ongoing.
public
Reviewed By: astreet
Differential Revision: D2651277
fb-gh-sync-id: f04dc04a6e68df7acbc2bbf8b2529287d7b5b2ae
Summary: make DevSupportManager PUBLIC visibility, instead of adding
to it more; put private parts of OnLoad into an anonymous namespace,
and move NativeRunnable into it; don't make NativeArray depend on
MethodCall which it does not use.
public
Reviewed By: astreet
Differential Revision: D2651270
fb-gh-sync-id: d5262da79cbd60c4eb490d43d13cc625fa163cdf
Summary: getBridge() is annotated VisibleForTesting, but still used
in DevSupportManager. Instead, add the necessary methods to the
CatalystInstance interface.
public
Reviewed By: astreet
Differential Revision: D2651265
fb-gh-sync-id: 395893a961c32843871de4451eeccb33135b7ede
Summary: This makes the exception a nested class of the interface,
which eliminates the dependency of DevSupportManager on
ProxyJavaScriptExecutor.
public
Reviewed By: astreet
Differential Revision: D2651252
fb-gh-sync-id: 99de1c308b9bce717ab749c4e239d2773a920e1f
Summary: registering with systrace checks if the bridge is
initialized, which it's not yet in the ctor. Defer registration until
after the bridge is created, and only unregister in that case.
public
Reviewed By: astreet, dreiss
Differential Revision: D2651244
fb-gh-sync-id: 8da1108e9d15fddde48d06f4ed61ee0f787016ad
Summary: public
Native view recycling implementation based on limited pools of views.
In this diff I introduced new UIManager method: dropViews. Instead of removing views from tag->view maps when they are detached we keep them there until we get a call to dropViews with the appropriate tag. JS may keep a pool of object and selectively decide not to enqueue drop for certain views. Then instead of removing those views it may decide to reuse tag that has been previously allocated for a view that is no longer in use.
Special handling is required for layout-only nodes as they only can transition from layout-only to non-layout-only (reverse transition hasn't been implemented). Because of that we'd loose benefits of view flattening if we decide to recycle existing non-layout-only view as a layout-only one.
This diff provides only a simple and manual method for configuring pools by calling `ReactNativeViewPool.configure` with a dict from native view name to the view count. Note that we may not want recycle all the views (e.g. when we render mapview we don't want to keep it in memory after it's detached)
Reviewed By: davidaurelio
Differential Revision: D2677289
fb-gh-sync-id: 29f44ce5b01db3ec353522af051b6a50924614a2
Summary: public
Changed ListView to use onLayout and onContentSizeChange (new) events instead of measure. Updated ScrollView implementation to support contentSizeChange event with an implementation based on onLayout attached to the content view. For RecyclerViewBackedScrollView we need to generate that event directly as it doesn't have a concept of content view.
This greatly improves performance of ListView that uses RecyclerViewBackedScrollView
Reviewed By: mkonicek
Differential Revision: D2679460
fb-gh-sync-id: ba26462d9d3b071965cbe46314f89f0dcfd9db9f
Summary: public
In a previous diff I've removed a need for using View attributes in requireNativeComponent. Thanks to that we can now use requireNativeComponent in View module. In a follow up diff I'll be getting rid of ReactNativeViewAttributes.
Reviewed By: sahrens
Differential Revision: D2676088
fb-gh-sync-id: d5d6e50f4629bd7982b90f3496e1fd22078e96a8
Summary: Automatically starts loading the RN instance as soon as loadApp is called instead of waiting for the UI to be constructed and attached to the window. This saves ~75ms of cold start time on GN 2011 phones.
Also, updates the contract for createReactContextInBackground such that it is only called once (so that people don't accidentally initialize more than once).
See http://imgur.com/a/d7qVm for systrace visualization.
public
Reviewed By: kmagiera
Differential Revision: D2652279
fb-gh-sync-id: 6e7b1fa5dea091af0d568834e11ed23eb1a7860e
Summary: public
Instead of using 0 as a default we should use UNDEFINED values. That is because setting 0 for left border in case when the property was deleted will interfere with horizontal border (or margin) value. Setting UNDEFINED makes CSSLayout nodes behave correctly in that case.
Reviewed By: andreicoman11
Differential Revision: D2668669
fb-gh-sync-id: 61ce62081583fc39864268333ac8c1409c276cad
Summary: Send part of the response body every 100 ms if the client has set onreadystatechange. This
is done by using the same events as the iOS code and removing the callback that Android previously
used.
Reconsolidate iOS and Android implementations.
Closes#3772
(The previous commit was reverted)
public
Reviewed By: astreet
Differential Revision: D2658153
fb-gh-sync-id: b1a32d22db7cc2995c673edd31f4bbaf16ca36cb
Summary: This adds the basic support for embedding an image in a TextView.
Implementation details :
We create a ReactTextInlineImageShadowNode whenever an Image is embedded within a Text context.
That uses the same parsing code as ReactImageView (copied, not shared) to parse the source property to figure out the Uri where the resource is.
In ReactTextShadowNode we now look for the ReactTextInlineImageShadowNode and place a TextInlineImageSpan so that we can layout appropriately
Later at the time we go to setText on the TextView, we update that TextInlineImageSpan so that the proper Drawable (downloaded via Fresco) can be shown
public
Reviewed By: mkonicek
Differential Revision: D2652667
fb-gh-sync-id: 8f24924d204f78b8bc4d5d67835cc73b3c1859dd
Summary: In some cases it's desirable to set the page in the ViewPager without animating it -- we have this in ScrollView with `scrollWithoutAnimationTo`. This PR adds `setPageWithoutAnimation` on ViewPager.
cc ide kmagiera
Closes https://github.com/facebook/react-native/pull/3621
Reviewed By: svcscm
Differential Revision: D2652056
Pulled By: mkonicek
fb-gh-sync-id: 6f1f38558c41ffdd863c0ebb2f046c75b5c0392c
Summary: Send part of the response body every 100 ms if the client has set onreadystatechange. This
is done by using the same events as the iOS code and removing the callback that Android previously
used.
Reconsolidate iOS and Android implementations.
Closes#3772
public
Reviewed By: mkonicek
Differential Revision: D2647005
fb-gh-sync-id: d006e566867fa47d5f8dff71219cb390bcb8e15a
Summary: Move the code to the github folder, add more docs and improve the example.
We might want to merge this with `LinkingIOS` later (it has the same functionality
plus support for deep links) but want to see how people use the `IntentAndroid`
API first (and what other methods we should add) to have more data points.
public
Reviewed By: lexs
Differential Revision: D2646936
fb-gh-sync-id: 751f35784d387efcd031f9b458821cdfde048a54
Summary: This patch adds two pieces of functionality:
- Exposes `JSBundleLoader` to allow a developer to load JavaScript bundles as they choose.
- Adds `ReactBridge.loadScripFromFile` method which loads a JavaScript bundle from an arbitrary file path.
Example usage:
```
JSBundleLoader jsBundleLoader = new JSBundleLoader() {
Override
public void loadScript(ReactBridge reactBridge) {
reactBridge.loadScriptFromFile("/sdcard/Download/index.android.bundle");
}
};
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setJSBundleLoader(jsBundleLoader)
.setJSMainModuleName("") /* necessary due to TODO(6803830) */
.addPackage(new MainReactPackage())
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
```
cc ide
Closes https://github.com/facebook/react-native/pull/3189
Reviewed By: svcscm
Differential Revision: D2535819
Pulled By: mkonicek
fb-gh-sync-id: f319299dbe29bab3b7e91f94249c14b270d9fec3
Summary: This allows the use of different bundle URLs & ports in Dev mode. (ie. ngrok url shared with a team member)
The bundle URL can be changed via the normal Dev Menu, or programmatically by setting the `debug_http_host` shared preference key.
For example, in your apps `MainActivity.java` before creating your `ReactRootView`:
```java
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplication());
SharedPreferences.Editor editor = mPreferences.edit();
editor.putString("debug_http_host", "my.customurlandport.com:8888");
editor.commit();
```
**Breaking change**: Custom bundle URLs added via the Dev Menu will need to also include the port. This has been noted in the documentation and also on the preference description in the Dev Menu.
Addresses: https://github.com/facebook/react-native/issues/2704
Closes https://github.com/facebook/react-native/pull/2824
Reviewed By: @svcscm
Differential Revision: D2540450
Pulled By: @javache
fb-gh-sync-id: a053de91e3095bb67640bb0f1b8761e55775bc9c
Summary: @public
See the discussion in https://github.com/facebook/react-native/pull/3019
This is temporary Gradle output and can be huge (>100MB).
Reviewed By: @foghina
Differential Revision: D2531612
fb-gh-sync-id: 8874d39b1a9b35dc4b4ce465dd149589db75bb29
Summary: The JavaScript code for Android is same as the iOS counterpart, I just added few new lines and used arrow functions instead of binding `this`.
Closes https://github.com/facebook/react-native/pull/2839
Reviewed By: @svcscm, @vjeux
Differential Revision: D2498703
Pulled By: @mkonicek
fb-gh-sync-id: 3fe958dd5af0efba00df07515f8e33b5d87eb05b
Summary: Also fixed the extra slash before first-party in that path (it was ...//first-party
and is now .../first-party). The $dir funct always produces a result that ends with
a /, so APP_MK_DIR always ends in a / and no extra / is needed when appending to it.
With these two changes all of React Native for Android, including C++, seems to
build OK on Windows 😄
Closes https://github.com/facebook/react-native/pull/2961
Reviewed By: @svcscm
Differential Revision: D2512239
Pulled By: @kmagiera
fb-gh-sync-id: 4fbc9fc85bab455b8ed1e07a8ac299a48921753e
Summary: This adds support for animated GIFs on Android! Looking forward to some meme apps :)
Also, Fresco is awesome.
Closes#2997.
@public
Reviewed By: @mkonicek
Differential Revision: D2477540
committer: Service User <svcscm@fb.com>
Summary: `ScrollView.scrollWithoutAnimationTo` is supported on iOS but not Android. This is an existing API, and this diff adds Android support.
Closes https://github.com/facebook/react-native/pull/2695
Reviewed By: @svcscm
Differential Revision: D2452630
Pulled By: @mkonicek
Summary: but the NDK build command can't be found in that directory. This
more explicit error now shows the full NDK path where it's looking
and (importantly) includes a hint that backslashes need to be escaped
on Windows for ndk.dir. When I built on Windows the first time,
I didn't realize ndk.dir backslashes needed to be escaped and the
generic "not found" error made the root cause harder to track
down. This change should help others that build on Windows & run into
the same.
Closes https://github.com/facebook/react-native/pull/2960
Reviewed By: @svcscm
Differential Revision: D2470761
Pulled By: @kmagiera
This is an early release and there are several things that are known
not to work if you're porting your iOS app to Android.
See the Known Issues guide on the website.
We will work with the community to reach platform parity with iOS.