Commit Graph

1141 Commits

Author SHA1 Message Date
Brad Daily 04392f2428 Android WebSocket: include cookies with request
Summary:
This commit brings Android in line with iOS WebSockets by sending along cookies from the shared CookieManager. See: https://github.com/facebook/react-native/pull/5630
Closes https://github.com/facebook/react-native/pull/6067

Differential Revision: D3841122

Pulled By: mkonicek

fbshipit-source-id: 6607424feeb31c9da4e370ebe4b33dbbedc0a446
2016-09-19 15:44:17 -07:00
Pieter De Baets 145109fc6d Remove additional JSON encoding for native->JS communication
Reviewed By: mhorowitz

Differential Revision: D3857323

fbshipit-source-id: 4386cc107b8a1425ecb7297b0f659f6c47f01a78
2016-09-19 04:44:12 -07:00
Andy Street 5deb528695 Don't crash if OEM has replaced OverScroller in ScrollView
Summary: Some OEMs have changed out the default scroller implementation in their ScrollView. We now check for that case and handle it gracefully instead of crashing.

Reviewed By: foghina

Differential Revision: D3876492

fbshipit-source-id: 4d03b88c4972e939c8352eeb9f30275e3ecf76e2
2016-09-19 04:14:01 -07:00
Janic Duplessis 6565929358 Add support for animated events
Summary:
This adds support for `Animated.event` driven natively. This is WIP and would like feedback on how this is implemented.

At the moment, it works by providing a mapping between a view tag, an event name, an event path and an animated value when a view has a prop with a `AnimatedEvent` object. Then we can hook into `EventDispatcher`, check for events that target our view + event name and update the animated value using the event path.

For now it works with the onScroll event but it should be generic enough to work with anything.
Closes https://github.com/facebook/react-native/pull/9253

Differential Revision: D3759844

Pulled By: foghina

fbshipit-source-id: 86989c705847955bd65e6cf5a7d572ec7ccd3eb4
2016-09-19 04:14:01 -07:00
Andrei Coman bdff10b4ea Fix text, textinput padding
Summary:
The issue here is that on some devices (ie. Nexus 5X), under certain
circumstances, the text gets trimmed. A simple example is P56651885, where the
text is at the end of the line and some padding is set. Digging further with
P56659346, I found that only the paddings that have integer pixel values work
correctly: these are the values P56656483, and this is the screenshot of that
test: {F63510378}.

It turns out that when we set the padding directly on the TextView, we have to
convert from float to int, and use `ceil` in the process. We lose some precision
here, since the csslayout will use the float values to compute the layout of the
views. The ideal solution would be to just set the float values on the TextView,
but since we can't do that, we should avoid using `ceil` instead of `floor`
since it can have bad side-effects in some scenarios.
Going way back to D1881202 and D1710471, we started using `ceil` because that
is how android handles non-integer
density ratios: "This figure is the factor by which you should multiply the dp
units on order to get the actual pixel count for the current screen. (Then add
0.5f to round the figure up to the nearest whole number, when converting to an
integer.)", see https://developer.android.com/guide/practices/screens_support.html.

Reviewed By: emilsjolander

Differential Revision: D3876310

fbshipit-source-id: 701c05a8b1a045d4e06fc89ffe79162c1eecb62c
2016-09-19 02:58:48 -07:00
Andrei Coman 4941cbcf1e Fix modal size
Summary:
With our previous fix to resize the Modal on orientation change, we broke the
computation of its size. The existing computation in `ModalHostShadowNode` was
in fact correct, and we were overriding it from `onSizeChanged`. By computing the
size of the Modal in `onSizeChanged` directly (and correctly), we fix this, and
simplify code by removing the `ModalHostShadowNode`.

Reviewed By: foghina

Differential Revision: D3863054

fbshipit-source-id: aaf4a8881798df4d2ab1dab882a9d9dfdc0a9342
2016-09-19 02:58:47 -07:00
ransj 44b0e6b91f optimize getNativeProps method
Summary:
The original method getNativeProps in ViewManagerPropertyUpdater.java create more HashMaps and putAll method need to re-hash the key again to avoid conflicts. This pull request pass the map as params to avoid the problem and update ReactPropertyProcessor.java to adapt the change.
Closes https://github.com/facebook/react-native/pull/9916

Differential Revision: D3873152

fbshipit-source-id: 089840e5272265662cdbf58d88580f9203153b69
2016-09-15 15:43:36 -07:00
Janic Duplessis d0d1712851 Reverted commit D3827366
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

Pulled By: fred2028

fbshipit-source-id: d346068734c5b987518794ab23e13914ed13b5c4
2016-09-15 12:13:39 -07:00
Fred Liu b7ee6adade Reverted commit D3870895
Reviewed By: foghina

Differential Revision: D3870895

fbshipit-source-id: 305534c752d1041bf03e27f28d6b5bf0a66a5a61
2016-09-15 11:58:36 -07:00
Andy Street 5c3f9547c6 Unbreak nodes that use ScrollViews
Reviewed By: foghina

Differential Revision: D3870895

fbshipit-source-id: e01130f19cca96ae1bcd0b8040e78552727fd6dc
2016-09-15 11:13:51 -07:00
Andy Street 6f42603d0e Add Dependency Injection, nodes support for RN/Components integration
Reviewed By: lexs, emilsjolander

Differential Revision: D3863226

fbshipit-source-id: f7528a9ff69697dd51fc7f7496a1c46110a42bed
2016-09-15 09:28:46 -07:00
Janic Duplessis 0e8b75b22c Implement ScrollView sticky headers on Android
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

fbshipit-source-id: cab044cfdbe2ccb98e1ecd3e02ed3ceaa253eb78
2016-09-14 20:43:29 -07:00
Chris Hopman 272d3ded4f RN: use consistent class/struct
Reviewed By: lexs

Differential Revision: D3858508

fbshipit-source-id: 6f49b09844cb70fae8078d650af69b200779c2f1
2016-09-14 14:44:15 -07:00
leeight 3182b608fc Fix invalid package name and Remove unsupported prop in Image.android.js
Summary:
1. `textfrescosupport` -> `text.frescosupport`
2. `defaultImageSrc`, `imageTag` and `progressHandlerRegistered` looks like never exists in `ReactImageManager.java`
Closes https://github.com/facebook/react-native/pull/9885

Differential Revision: D3864980

fbshipit-source-id: 48a85563c60b6853c505177558520f5e48f4eb03
2016-09-14 13:43:48 -07:00
Emil Sjolander a6e1e33a50 Reverted commit D3855801
Summary: Introduce `overflow:scroll` so that scrolling can be implemented without the current overflow:visible hackiness. Currently we use AT_MOST to measure in the cross axis but not in the main axis. This was done to enable scrolling containers where children are not constraint in the main axis by their parent. This caused problems for non-scrolling containers though as it meant that their children cannot be measured correctly in the main axis. Introducing `overflow:scroll` fixes this.

Reviewed By: astreet

Differential Revision: D3855801

fbshipit-source-id: 3c365f9e6ef612fd9d9caaaa8c650e9702176e77
2016-09-14 11:28:34 -07:00
Andy Street 2cf2fdbc04 Update ScrollView ctor's to take a ReactContext
Reviewed By: lexs

Differential Revision: D3863966

fbshipit-source-id: 8580f65663c58552304cfd6043794eae0190757d
2016-09-14 11:13:52 -07:00
Emil Sjolander 1f9c9ecb4b BREAKING - Fix unconstraint sizing in main axis
Summary: Introduce `overflow:scroll` so that scrolling can be implemented without the current overflow:visible hackiness. Currently we use AT_MOST to measure in the cross axis but not in the main axis. This was done to enable scrolling containers where children are not constraint in the main axis by their parent. This caused problems for non-scrolling containers though as it meant that their children cannot be measured correctly in the main axis. Introducing `overflow:scroll` fixes this.

Reviewed By: astreet

Differential Revision: D3855801

fbshipit-source-id: 6077b0bcb68fe5ddd4aa22926acab40ff4d83949
2016-09-14 09:14:02 -07:00
Andrew Y. Chen df83f05737 Remove ReactRootView's MeasureSpec assertion
Reviewed By: AaaChiuuu

Differential Revision: D3854737

fbshipit-source-id: d72975e49875049ed4411258e9a449b394ca7ece
2016-09-13 09:43:37 -07:00
Aaron Chiu 6f75591620 clean up
Reviewed By: andreicoman11

Differential Revision: D3855861

fbshipit-source-id: 810d1ea4e6a64231356a4b6953f97de2f54d2558
2016-09-13 08:13:39 -07:00
Andy Street e2cf37a5a6 Breaking: Move ReactClippingViewGroup + Helper to uimanager package
Summary: This is to be able to depend on ReactClippingViewGroup from BaseViewManager. Devs using ReactClippingViewGroup may need to update their imports when updating past this commit.

Reviewed By: lexs

Differential Revision: D3835328

fbshipit-source-id: 290c08b130d837e553b68a90377bd9a30b7ec6dc
2016-09-13 06:13:40 -07:00
Aaron Chiu a4916b8c98 add a way to enable / disable lazy native modules
Reviewed By: lexs

Differential Revision: D3849947

fbshipit-source-id: 0a4a1cd5b9f165269a53b69de46c9cc1939d9d08
2016-09-13 04:43:34 -07:00
Andrei Coman 82c8c97898 Support orientation change on modals
Summary:
This automatically changes the size of the modal by listening to dialog size changes and propagating
those changes through UIManager.

In detail: I've looked into three ways of doing this:

1. Send `onSizeChanged` events/info from the View to the CSSNode directly. This is kinda hacky because you would need to hold a reference to the CSSNode somewhere, either in the View or in the ViewManager. But then you'll have to take care of the lifecycle of the CSSNode, so that you don't update it after it has been dismissed. Not great.
2. The version we went for, is to just update the size of the corresponding CSSNode in the same way we do it for root nodes: we inform the UIManager that the size of the root node has changed, and it will propagate that change, triggering a `dispatchViewUpdates` if none is underway, so that the layout is updated.
3. The other solution we thought of is to treat the Modal as a root view. This would mean rendering an application with the tag of the Modal as the root of the application. That tag would be received by calling some method into UIManager and ReactModalHostManager to create a new RootView, create a Dialog and plop the root view in it. The idea was to maintain the JS API that we now have, but make the implementation more correct (ie. since both RootView and the Modal must deal with touch handling), and could have other benefits (ie. no hacks necessary for making the inspector work on top of modals). However, the change is not trivial and I don't know just how much code would have to be changed to make this work correctly. We might revisit this at a later stage, after we've done more work on having several root views at the same time in the app.

Reviewed By: foghina

Differential Revision: D3841379

fbshipit-source-id: f5e363e27041b785cf44eb59da04bc789306ddb9
2016-09-13 04:28:52 -07:00
Aaron Chiu 406a1b3ca2 move com.facebook.react.Lifecycle to com.facebook.react.common.Lifecycle
Reviewed By: lexs

Differential Revision: D3849487

fbshipit-source-id: 3f21969e092ccef9cad610ae86198de41b2f6552
2016-09-12 05:58:56 -07:00
Andrei Coman c79f617742 Fix Text incorrect line height
Summary:
Setting the line height with the help of Android-provided StaticLayout is incorrect. A
simple example app will display the following when `setLineSpacing(50.f, 0.f)`
is set: {F62987699}. You'll notice that the height of the first line is a few
pixels shorter than the other lines.
So we use a custom LineHeightSpan instead, which needs to be applied to the text
itself, and no height-related attributes need to be set on the TextView itself.

Reviewed By: lexs

Differential Revision: D3841658

fbshipit-source-id: 7257df4f1b2ce037554c7a7a5ca8f547a2056939
2016-09-12 05:13:43 -07:00
Felix Oghina 16bdbee165 Actually close packager websocket connection when destroying instance
Summary:
This is just D3835023 again since it got reverted, plus the fix from D3841918 baked in. Here's the old summary:

We never actually closed the websocket connection. Furthermore, upon calling `closeQuietly()`, `onClose()` is called, which does `reconnect()`. This results in ReactInstanceManager leaking after calling `destroy()` and nullifying all references to it.

To fix this I made sure `closeQuietly()` actually closes the connection for good, and made sure we actually call it when destroying an instance.

Reviewed By: AaaChiuuu

Differential Revision: D3849353

fbshipit-source-id: e1ce5e2d5840bfbd42a13043c3cc8c617e9fa64a
2016-09-12 03:59:03 -07:00
William Liu 027a2706d2 Backed out changeset 31811805dd97
Reviewed By: hallucinogen

Differential Revision: D3847504

fbshipit-source-id: a84eae70568f3a4a50cb6fcaf5c6f5772270d4f2
2016-09-11 01:28:39 -07:00
Aaron Chiu 4fcd316781 add the bridge breakdowns into QuickPerformanceLogger
Reviewed By: andreicoman11

Differential Revision: D3841278

fbshipit-source-id: 8c29e844e44eacc2fa7e5353ba9275494e113015
2016-09-09 09:44:12 -07:00
leeight 6efe8e1d81 ViewPagerAndroid: FIX folly::toJson: JSON object value was a NaN or INF
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

Under certain scenario, `PageScrollEvent.offset` was initialized to `NaN`, which cause `folly::toJson` failed, and FIX #9750

<e71ecb2c4d/core/java/com/android/internal/widget/ViewPager.java (L1689)>

![image](https://cloud.githubusercontent.com/assets/104052/18266416/2a01f882-744d-11e6-86c4-3a2de3a1ca25.png)

**Test plan (required)**

<http://stackoverflow.com/questions/39327429/reactnative-viewpagerandroid-rcteventemitter>
Closes https://github.com/facebook/react-native/pull/9755

Differential Revision: D3841674

Pulled By: andreicoman11

fbshipit-source-id: d4cd9f4b2f61daad9005a098161ad7f75555345d
2016-09-09 08:58:46 -07:00
Adam Comella b6735f3391 Enable developers to force Fresco to resize an image
Summary:
Here's a little background. Resizing is inferior to scaling. See http://frescolib.org/docs/resizing-rotating.html#_

Currently, React Native has a heuristic to use resize when the image is likely to be from the device's camera. However, there may be other cases where a developer wants to use resize. For example, when the developer knows they'll be downloading a large image from a service but the image will be rendered at a small size on the device.

This change adds a `resizeMethod` prop to the `Image` component so developers can choose how Fresco resizes the image. The options are 'auto', 'resize', or 'scale'. When 'auto' is specified, a heuristic is used to choose between 'resize' and 'scale'. The default value is 'auto'.

**Test plan (required)**

In a small test app, verified that the `resizeMethod` prop properly influences the mechanism that is used to resize the image (e.g. resize or scale).

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9652

Differential Revision: D3841322

Pulled By: foghina

fbshipit-source-id: 6c78b5c75ea73053aa10386afd4cbff45f5b8ffe
2016-09-09 05:13:53 -07:00
Felix Oghina 588f0b83e1 Actually close packager websocket connection when destroying instance
Summary:
Ugh. We never actually closed the websocket connection. Furthermore, upon calling `closeQuietly()`, `onClose()` is called, which does `reconnect()`. Beautiful. This results in `ReactInstanceManager` leaking after calling `destroy()` and nullifying all references to it.

To fix this I made sure `closeQuietly()` actually closes the connection for good, **and** made sure we actually call it when destroying an instance.

Reviewed By: AaaChiuuu

Differential Revision: D3835023

fbshipit-source-id: 31811805dd97b725ea5887cffed9bed49addda83
2016-09-09 04:28:33 -07:00
Aaron Chiu cc30d2f46d break down production startup with more markers
Reviewed By: lexs

Differential Revision: D3835031

fbshipit-source-id: e85c6322d11c6c7cd38b2432e7ab623ecc5908ed
2016-09-09 03:28:51 -07:00
Aaron Chiu e70d1dba58 Use the c.f.react.bridge.ReactMarker
Reviewed By: andreicoman11

Differential Revision: D3834955

fbshipit-source-id: 027150d3829e8a15f28ea76877e4ab5a29ea50cf
2016-09-08 09:13:40 -07:00
Pieter De Baets 99e0267c25 Cleanup and document native module configuration
Summary: Get rid of the old behaviour of JSON encoding in `nativeRequireModuleConfig` and consistently use the same names for function types "async/promise/sync"

Reviewed By: lexs

Differential Revision: D3819348

fbshipit-source-id: fc798a5abcaf6a3ef9d95bd8654afa7825c83967
2016-09-08 04:13:51 -07:00
Adam Comella 28ba749ba0 Android: Add support for having borders on <Text> & <TextInput> components
Summary:
Currently, `<Text>` and `<TextInput>` components on Android do not support borders.
This change adds support for the borderRadius, borderColor, and
borderWidth props on the `<Text>` and `<TextInput>` components on Android.

ReactViewGroup already implements this functionality so
we copied its implementation over into the ReactTextView
and ReactEditText classes.

**Test plan (required)**

Verified that the various border props work on Text and TextInput components in a test app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9658

Differential Revision: D3819993

Pulled By: lexs

fbshipit-source-id: 183b0aa95369dd781f03b5a1f0f409ab47284e39
2016-09-08 02:58:35 -07:00
Andrew Y. Chen bbd1e455f3 Show a redbox when scripts fail to load
Reviewed By: yungsters

Differential Revision: D3670186

fbshipit-source-id: 1c61b69c74a8f7cc255aa6d7afcdb117205922eb
2016-09-07 13:10:12 -07:00
Andrei Coman 8aeeb4d6a0 Rename native event `timeStamp` to `timestamp`
Summary: It's called `timestamp` on iOS, making it consistent.

Reviewed By: foghina

Differential Revision: D3820937

fbshipit-source-id: 2805f1fc10d6445d8b31676e0e3dca348510ffe7
2016-09-07 13:10:12 -07:00
Felix Oghina 40baf6a5b9 Fix rounding resulting in choppy timing animations
Summary: Casting to long too early here and dropping some precision, resulting in skipped (not dropped) frames.

Reviewed By: sahrens

Differential Revision: D3819153

fbshipit-source-id: 83676cf4c9129638348890c74d563db121049e4a
2016-09-07 13:10:12 -07:00
Konstantin Raev a13e1c4e2c Reverted commit D3811226
Reviewed By: astreet

Differential Revision: D3811226

fbshipit-source-id: 8ade5ef6c34e117fb10a000034b9900f8a56087d
2016-09-07 13:10:11 -07:00
Michał Gregorczyk 2618ba2d60 Allow UnpackingJSBundleLoader's client to queue action to perform after unpacking
Reviewed By: tadeuzagallo

Differential Revision: D3735948

fbshipit-source-id: 5971a5367eb4b5a90e0f23b9279759e9f4060222
2016-09-06 19:44:27 -07:00
Michał Gregorczyk d3238569bf Evacuate part of optimized bundle logic from react code
Reviewed By: lexs

Differential Revision: D3735936

fbshipit-source-id: b38960a8f25be15ccce70296980d78c0a7fa8de5
2016-09-06 19:44:27 -07:00
Michał Gregorczyk 0c2fdf4b6a Add separate JSBunldeLoader for assets
Reviewed By: mhorowitz

Differential Revision: D3735897

fbshipit-source-id: 990d45e9cb40a9afce1df8f8fd0b73c62e13158a
2016-09-06 19:44:27 -07:00
Kevin Gozali 96de161304 enable RTL layout by default for all apps
Summary:
We're now enabling RTL layout by default assuming the app has the proper localized assets. Previously, this was disabled by default to minimize surprise. Apps that don't want this RTL support can still manually disable them by using `RCTI18nUtil.allowRTL(false)` (iOS) or `I18nUtil.allowRTL(false)` (android) in the apps start-up logic, as outlined in the blog post: http://facebook.github.io/react-native/blog/2016/08/19/right-to-left-support-for-react-native-apps.html

iOS Util function: f0fb228ec7/React/Modules/RCTI18nUtil.m (L53)
Android Util function: 380830e4aa/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.java (L63)

Differential Revision: D3825054

fbshipit-source-id: 88b355fef9e3847939a414f80d2285979e27af08
2016-09-06 17:58:47 -07:00
Janic Duplessis e26c135746 Add support for DiffClamp node
Summary:
Add native support on iOS and Android for `Animated.diffClamp` that was added in #9419.

**Test plan**
Tested that it works properly using the native animations UIExplorer example.
Closes https://github.com/facebook/react-native/pull/9691

Differential Revision: D3813440

fbshipit-source-id: 48a3ecddf3708fa44b408954d3d8133ec8537f21
2016-09-06 15:43:35 -07:00
Janic Duplessis 6d978c3c8b Add support for extrapolation
Summary:
Adds support for the `extrapolate` parameter on the native interpolation node. This is pretty much a 1 to 1 port of the JS implementation.

**Test plan**
Tested by adding the `extrapolate` parameter in the native animated UIExplorer example.
Closes https://github.com/facebook/react-native/pull/9366

Differential Revision: D3824154

fbshipit-source-id: 2ef593af827a8bd3d7b8ab2d53abbdc9516c6022
2016-09-06 15:28:38 -07:00
Andrew Y. Chen 300cb03e94 Remove ReactRootView's MeasureSpec assertion
Reviewed By: astreet

Differential Revision: D3811226

fbshipit-source-id: 611e5a2960928c19d93823616d68aa11a9786bf6
2016-09-06 12:43:49 -07:00
Andrei Coman dea6b0e24c Fix `requestDisallowInterceptTouchEvent` for nested react native views
Summary:
ReactRootView currently intercepts and swallows all
`requestDisallowInterceptTouchEvent` calls, which made sense when the
ReactNativeView was the root of all views. In the context of react native views
embedded in other views though, we want to propagate the call to all parents
views, but not set it on the ReactRootView itself (because we still need the
`onInterceptTouchEvent` calls to dispatch the touch events to JS).

Reviewed By: foghina

Differential Revision: D3819255

fbshipit-source-id: 21f2dd173c76e98342193de384292fef2b407250
2016-09-06 09:58:39 -07:00
Andrei Coman 372d001a5d Smart textinput scroll
Summary:
This diff changes the textinput component to only scroll (and interrupt parent
views from scrolling), when it is possible for the text inside the component to
be scrolled. Before (D3735237), we would intercept all touch events on the
textinput if it's focused. But this makes it: a.) impossible to scroll a scrollview from within
a textinput that cannot be scrolled; b.) different from iOS behavior.

What the component now does is intercept move touches, and check if it can
scroll in any direction. If it does, it will intercept the touches and stop the parent
component from scrolling; otherwise, it will give the control back to the parent
component.

Note: this might change in the future to also detect the direction of the scroll, and
only block the scroll if the component can scroll in that direction. This is however not
trivial, since the scroll needs to be above some threshold of pixels. Blocking the
parent view from scrolling until that threshold is passed might cause incorrect behavior
in the parent component.

Reviewed By: astreet

Differential Revision: D3764267

fbshipit-source-id: 47e7b5e03855b3c85789e04fc31a8317afbafa84
2016-09-06 09:58:39 -07:00
Andrei Coman 8451585f38 Fix dimensions on orientation change
Summary:
This adds the `didUpdateDimensions` event that already exists on iOS, and
updates the internal native dimensions data that needs repopulation after
orientation change.

Reviewed By: foghina

Differential Revision: D3819364

fbshipit-source-id: fc2b3b4d1991d101e5de4439ccef2189bc65fd58
2016-09-06 08:43:39 -07:00
Andrei Coman 79f3950d62 Fix timestamps on android touch events to use milliseconds, to be
Summary:
Landing D3528215 again, now that D3593884 has landed and makes that easier.
Copy-paste summary from previous diff:

So PanReponder.onPanResponderRelease/onPanResponderTerminate receive a
gestureState object containing a onPanResponderTerminate.vx/vy property. On
Android and iOS, they appear to be orders of magnitude different, which appear
to be due to the different scale of timestamps that are used when generating
touch events.

This pull request fixes the timestamps to be milliseconds on both platforms
(since I assume iOS is the more authoritative one, and is the one that
react-native-viewpager's vx thresholds written written to compare against.)

As far as I can tell, the RN code doesn't use the vx/vy properties, so they
should be okay. And looks like the RN code only cares about relative values of
startTimestamp/currentTimestamp/previousTimestamp though, so should be fine too.
it's quite possible there will be downstream android breakage with this change,
particularly for those who are already compensating for the RN discrepancy.

Reviewed By: foghina

Differential Revision: D3819761

fbshipit-source-id: fd2d85748ae6a9cde6af715aabb620f340c2220c
2016-09-06 04:58:51 -07:00
Andrei Coman f07ca31303 Listen to device orientation changes
Summary:
Similar to iOS, send device orientation changes events. This does not have the
`getCurrentOrientation` method, because it's not used. If necessary, we'll
add it separately.
This also adds a simple example for testing.

We listen to orientation changes in `onGlobalLayout`, and check if the rotation of the device has changed. If it has, we emit the event.
But:
- `onGlobalLayout` (and `onConfigurationChanged` - which is the method usually used for checking for device orientation changes) is *not* called when the device goes from landscape
  to reverse landscape (same with portrait), as that is not a relayout / configuration change. We could detect if this happens with the help of an `OrientationEventListener`. However, this listener notifies you if the degree
  of the phone changes by a single degree, which means that you need to know by how many degrees the phone needs to change in order for the orientation to change. I haven't looked into how accurate this could be, but I suspect that in practice it would cause a lot of bugs. A simple `abgs` and google search reveals that everybody uses a different margin for detecting a rotation change (from 30 to 45 degrees), so I suspect that this won't work
  as expected in practice. Therefore, we're not using this here, and we're sticking to what android provides via `onConfigurationChanged`. If we find that we have issues because users need to know when the user goes
  from landscape to reverse landscape, then we'll have to revisit this.

Reviewed By: foghina

Differential Revision: D3797521

fbshipit-source-id: 62508efd342a9a4b41b42b6138c73553cfdefebc
2016-09-06 03:59:01 -07:00
Andrei Coman 7c268b31c2 Fix TextInput contentSize
Summary:
This fixes some inaccuracies in our reporting of textinput's contentsize.
First, we were not using the correct padding info. Then, we are converting the
contentSize width and height to ints right before sending
them over to JS. This adds some inaccuracy with the textinput behaviour,
especially in the case of auto expending text inputs, since those same sizes are
then sent right back.

Reviewed By: astreet

Differential Revision: D3806008

fbshipit-source-id: 7e32f91fde50099fd8a122833fd0042683e68df1
2016-09-06 03:13:43 -07:00
leeight 99d742c0b7 On Android `geolocationError` return PositionError object.
Summary:
Follow iOS implementation:
https://github.com/facebook/react-native/blob/master/Libraries/Geolocation/RCTLocationObserver.m#L325

and FIX #9710
Closes https://github.com/facebook/react-native/pull/9734

Differential Revision: D3819868

Pulled By: mkonicek

fbshipit-source-id: 3deb7d3d253d402bfcb88c6a94ca705128998748
2016-09-05 12:58:43 -07:00
Janic Duplessis 3c1b69c1a9 Add TextInput controlled selection prop on Android
Summary:
Android PR for TextInput selection, based on the iOS implementation in #8958.

** Test plan **
Tested using the text selection example in UIExplorer.
Closes https://github.com/facebook/react-native/pull/8962

Differential Revision: D3819285

Pulled By: andreicoman11

fbshipit-source-id: 9a2408af2a8b694258c88ab5c46322830c71452a
2016-09-05 07:13:46 -07:00
Aaron Chiu 367c71241a convert CoreModulesPackage to use @ReactModuleList
Reviewed By: astreet

Differential Revision: D3809512

fbshipit-source-id: 658284c642d55cf5f90e16901fdf6d4229d6b762
2016-09-02 19:13:27 -07:00
Aaron Chiu 3d1b79cd15 covert RNFeedPackage and it's modules to use @ReactModule and @ReactModuleList
Reviewed By: lexs

Differential Revision: D3796860

fbshipit-source-id: d4b5f3635754ef28277b79cb1ea9bab07ba3ea6e
2016-09-02 16:28:43 -07:00
Adam Comella cd1a86db36 Improve ellipsizeMode prop
Summary:
There are a couple of buggy behaviors in the current implementation of the `ellipsizeMode` prop on Android:
  - Setting the `numberOfLines` prop stomps on whatever value you provided for `ellipsizeMode` earlier.
  - The value you've provided for `ellipsizeMode` is used even if you've configured your view to have an unlimited size (i.e. `numberOfLines` is 0 or unspecified).

This change fixes these issues which makes Android's `ellipsizeMode` prop more consistent with iOS's. Additionally, it renames LineBreakMode to EllipsizeMode in a couple of places.

**Test plan (required)**

Verified that the `numberOfLines` and `ellipsizeMode` props work correctly in an Android test app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9594

Differential Revision: D3810166

Pulled By: foghina

fbshipit-source-id: 229c9bfc3ef10670a1090311ea9d095cb2c1121a
2016-09-02 00:58:41 -07:00
Aaron Chiu 605a0a62dc Add annotation processor to create static ReactModule infos
Reviewed By: lexs

Differential Revision: D3781016

fbshipit-source-id: 8169e8b55fc044df2230fd01e912c4e96a044f98
2016-09-01 19:28:57 -07:00
Andrew Y. Chen 00d65870fe Improve ReactRootView's onMeasure error message
Reviewed By: AaaChiuuu

Differential Revision: D3806888

fbshipit-source-id: 0433a7950b9673a2195b8dfdedb12b4c90156184
2016-09-01 16:28:47 -07:00
Adam Comella bcf48e74ae Include image dimensions & url in Image's onLoad callback
Summary:
This is similar to the iOS feature that was implemented by 84f68c338a.

**Test plan (required)**

Verified that the image dimensions are included in the `onLoad` callback in a test app. Also, this change is used in my team's app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9608

Differential Revision: D3797659

Pulled By: foghina

fbshipit-source-id: ea83a907bf6b0b61d9bc1e90fc7c64b7132db81f
2016-09-01 02:44:00 -07:00
Alexander Oprisnik c0de1a7011 Only initialize FrescoModule once
Summary:
Fresco should only be initialized once. Re-initializing causes a few problems (https://github.com/facebook/react-native/issues/8677) and we don't need to do it.
If a Fresco configuration needs to change, you can just restart the application or add delegates for parts that can change and manually update them instead.

Reviewed By: astreet

Differential Revision: D3790908

fbshipit-source-id: 9df4c3be15ca49433120abd7ba1a4f5ae2a3f1c1
2016-08-31 14:58:44 -07:00
Adam Comella 6897f40af7 Fix sizing of absolutely positioned nodes inside overflow:hidden parent
Summary:
When an absolutely positioned node appeared inside an overflow:hidden
parent, we were limiting its height. This is inconsistent with how
layout behaves on the web.
Closes https://github.com/facebook/css-layout/pull/218

Reviewed By: lucasr

Differential Revision: D3797285

Pulled By: emilsjolander

fbshipit-source-id: 98f98e77aa26edce86b9882c1cac284799b69a27
2016-08-31 08:13:41 -07:00
Adam Comella 06e52f8e8c Fix bug in timer clean up
Summary:
One of the impacts of this bug is that Java is firing timer
completion events into JavaScript for timers that should have
been deleted. JavaScript filters these out so it doesn't impact
the app developer. However, Java is completing more timers
than necessary.

When cleaning up a timer, we were accidentally deleting the
whole set of timers for that context. Instead, we should
just delete that timer from its context.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9361

Differential Revision: D3797573

fbshipit-source-id: c30ed600af741601f2babdfc61da9aac549cbadb
2016-08-31 07:28:39 -07:00
Felix Oghina 69c889815e Expose image cache interrogation to JS
Summary: Add a static `Image.queryCache` function that can query multiple URLs at once. The result is a map where each URL that is in cache is mapped to the cache type (memory/disk). URLs that are not cached do not appear in the result.

Reviewed By: lexs

Differential Revision: D3791333

fbshipit-source-id: b183015d97423f0c095bf891f035dac2e23d8d11
2016-08-31 05:13:39 -07:00
Felix Oghina d3282e3bb1 Clean up fresco cache clearing code
Summary: I noticed we're doing too much manual work here, when Fresco has a nice handy shortcut for clearing all caches.

Reviewed By: kirwan

Differential Revision: D3791356

fbshipit-source-id: 4a55d0280e9483267741ae75383b50ca0b74c5c6
2016-08-31 03:13:32 -07:00
Scott Buckfelder 16f76d4407 SKETCH Add performance tracking for rendering
Differential Revision: D3709400

fbshipit-source-id: a006b60feb3fc5cb55cc2e6f08275fcc8de1d3e1
2016-08-30 14:28:37 -07:00
Adam Comella fd3484481a Fix race condition in EventDispatcher
Summary:
`mRCTEventEmitter` is used by 2 different threads. It's assigned on the UI thread and it's accessed on the JavaScript thread. Currently, it can be the case that the UI thread assigns `mRCTEventEmitter` and later the JS thread accesses it but still sees null.

This change fixes the issue by marking the `mRCTEventEmitter` variable as `volatile` to ensure that both threads see the same value for `mRCTEventEmitter`.

**Test plan (required)**

This change is currently used in my team's app. We're no longer seeing a crash in `EventDispatcher`.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9655

Differential Revision: D3790888

Pulled By: andreicoman11

fbshipit-source-id: 68cdbc74faffb36dc2bca8ad3d4a78929badbe9c
2016-08-30 04:14:45 -07:00
Emil Sjolander 899adf5343 Expose flexGrow, flexShrink, and flexBasis properties
Reviewed By: javache, astreet

Differential Revision: D3785140

fbshipit-source-id: a735602c53da72e3bce69ba30936c4ed25d76b88
2016-08-30 03:13:39 -07:00
Andrew Y. Chen 22de6550d6 Add onContentSizeChange prop to WebView
Summary: Added support for WebViews to take in an onContentSizeChange prop, which will return a native event that contains the width and height of the html content in the WebView. Also moved the ContentSizeChangeEvent from the recyclerview dir to the uimanager/events dir

Reviewed By: andreicoman11

Differential Revision: D3775399

fbshipit-source-id: 19a0579f8345e5853cc7311b80f1f1393c77ab58
2016-08-29 12:28:52 -07:00
Kevin Gozali 35e7a266db allow finding the rootTag of any reactTag inside UIManager
Summary: added API to in UIManager to find the rootTag/View of any reactTag based on its layout (shadow views) hierarchy (not to be used by JS)

Reviewed By: javache

Differential Revision: D3750410

fbshipit-source-id: 68611e39930d53ece478f25245ddc7f7838daaa6
2016-08-28 22:58:28 -07:00
Adam Comella e6de198a4b Fix gradle clean task
Summary:
Running the command `./gradlew clean` resulted in the following error:

```
./node_modules/react-native/ReactAndroid/src/main/jni//xreact/jni/Android.mk:42: *** Android NDK: Aborting.    .  Stop.
Android NDK: ./node_modules/react-native/ReactAndroid/src/main/jni//xreact/jni/Android.mk: Cannot find module with tag 'cxxreact' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
```

The problem was that `REACT_COMMON_DIR` wasn't defined.

**Test plan (required)**

Running `./gradlew clean` now works.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9607

Differential Revision: D3780364

fbshipit-source-id: 2b45d538413f7ee2cf0b36a1fa33287f0b1bf23f
2016-08-26 17:13:44 -07:00
Lucas Rocha 1eddd01063 Make Spacing.release() public
Differential Revision: D3763593

fbshipit-source-id: 27436c0dbd292b38cfc98f4cfb8e2d12787b85d6
2016-08-26 04:13:45 -07:00
Emil Sjolander 2a859eb7e3 Revert changes causing layout failures
Differential Revision: D3776987

fbshipit-source-id: 06bd154a36f895782f45511cd8cf49cc6d7cbe7d
2016-08-26 03:13:41 -07:00
Emil Sjolander 06ee832928 Generate tests for flex properties
Differential Revision: D3771513

fbshipit-source-id: 1b5edc7a28bb26217e8a6d10d1829d9031c3ae2e
2016-08-25 15:44:23 -07:00
king6cong 56dd520824 fix typo
Summary: Closes https://github.com/facebook/react-native/pull/9588

Differential Revision: D3771663

Pulled By: hramos

fbshipit-source-id: 7f2aaef44c2d168484f91040ec24cfe0b65c07e3
2016-08-25 10:43:32 -07:00
Andrei Coman 5cb8b97f3c Reverted commit D3751097
Summary:
Setting the line height with the help of Android-provided StaticLayout is incorrect. A
simple example app will display the following when `setLineSpacing(50.f, 0.f)`
is set: {F62987699}. You'll notice that the height of the first line is a few
pixels shorter than the other lines.
So we use a custom LineHeightSpan instead, which needs to be applied to the text
itself, and no height-related attributes need to be set on the TextView itself.

Reviewed By: lexs

Differential Revision: D3751097

fbshipit-source-id: 6c5a8d01a6dca4ff6eef9c3aadd1b550054432d2
2016-08-25 02:43:43 -07:00
Andrei Coman 483953dab3 Fix Text incorrect line height
Summary:
Setting the line height with the help of Android-provided StaticLayout is incorrect. A
simple example app will display the following when `setLineSpacing(50.f, 0.f)`
is set: {F62987699}. You'll notice that the height of the first line is a few
pixels shorter than the other lines.
So we use a custom LineHeightSpan instead, which needs to be applied to the text
itself, and no height-related attributes need to be set on the TextView itself.

Reviewed By: lexs

Differential Revision: D3751097

fbshipit-source-id: c3574a1080efec26436a5c61afbff89afa8679e7
2016-08-24 11:13:38 -07:00
Alexander Blom b4999fca0d Don't clear queue in ProxyExecutor
Reviewed By: mhorowitz

Differential Revision: D3757216

fbshipit-source-id: 5adda2dcdfb438b65fe668c52e0d2e35705eed9f
2016-08-24 03:43:44 -07:00
Aaron Chiu 288934398b remove all @ReactModule runtime annotation processing
Summary: Runtime annotation processing uses reflection which is slow. We'll use build time annotation processing instead and create at build time static ModuleInfo classes which have "name", "canOverrideExistingModule", "supportsWebWorkers", "needsEagerInit".

Reviewed By: lexs

Differential Revision: D3752243

fbshipit-source-id: 3518c6f38087d8799a61410864007041389c0e15
2016-08-23 18:58:55 -07:00
Chris Hopman 1557325e4a Use -std=c++1y for lambda capture initializers
Reviewed By: mhorowitz

Differential Revision: D3761975

fbshipit-source-id: 5500fd25864282409eb49737eef4f703cadadf70
2016-08-23 18:58:55 -07:00
Chris Hopman 9a5d3bacb9 Remove terrible ReadableNativeArray::getMap() hack
Reviewed By: mhorowitz

Differential Revision: D3753952

fbshipit-source-id: c8ea693d3a24adad9f907ad28b811cf69ab9e68d
2016-08-23 17:13:38 -07:00
Emil Sjolander e63a7ea7bd Implement flex properties in java version as well
Reviewed By: lucasr

Differential Revision: D3753231

fbshipit-source-id: ea41d887cd99d1f03d2bc876a2fd7141dbe48320
2016-08-23 04:43:32 -07:00
Konstantin Raev b59fde817f Fixes paths to robolectric when they are downloaded from maven into buck-out
Reviewed By: mmmulani

Differential Revision: D3751888

fbshipit-source-id: 2a70e8655f3c6e6dcc2de17e85289d9db18a2699
2016-08-22 11:13:39 -07:00
Alexander Blom 38a14ffc32 Make RN background drawable respect bounds
Reviewed By: astreet

Differential Revision: D3655395

fbshipit-source-id: c8c1b953337a3c5dfa0d905bc3d774db6b3f8271
2016-08-22 03:28:36 -07:00
Aaron Chiu 924187eb9a add more Systrace to native module / view manager constants
Reviewed By: lexs

Differential Revision: D3739966

fbshipit-source-id: 4ba31aade00852132e528f96252197b823bb58a3
2016-08-19 11:58:53 -07:00
Alexander Blom e4d5dcb15b Always log exception in DevSupportManager
Reviewed By: andreicoman11

Differential Revision: D3741763

fbshipit-source-id: b4cc32e4d237955ec4a67af323024acd0d19106a
2016-08-19 07:13:45 -07:00
Felix Oghina 2a7f4be8f8 native decay animation
Summary: Add support for `useNativeDriver: true` to `Animated.decay`. Add example in Native Animated Example UIExplorer app.

Reviewed By: ritzau

Differential Revision: D3690127

fbshipit-source-id: eaa5e61293ed174191cec72255ea2677dbaa1757
2016-08-19 07:13:45 -07:00
Felix Oghina 37ab1c8844 Remove dependency on launcher from instrumentation tests
Reviewed By: bestander

Differential Revision: D3736847

fbshipit-source-id: d39a227fe8753f3766521fd23440933adba9e8c7
2016-08-19 06:58:43 -07:00
Michal Lowicki af14a5b489 Enable build file sandboxing in fbobjc
Reviewed By: darknoon

Differential Revision: D3655364

fbshipit-source-id: 0c7d37860d358a0768fe788b589e701964063092
2016-08-19 05:28:30 -07:00
Jennifer Wang 4b6af5fa63 Add wrapper class for async storage
Reviewed By: wsanville

Differential Revision: D3654554

fbshipit-source-id: bc21da4b5c46228136cc80592f84206d2deb541e
2016-08-18 10:43:32 -07:00
Emil Sjolander 805d06087b Fix border color
Summary: Border colors broke with recent change to default values in csslayout Spacing. This is a quick fix until we move react-native borders away from using Spacing.java which is a hack in the first place.

Reviewed By: lexs

Differential Revision: D3735435

fbshipit-source-id: 747c85798cb02e1a5139de038eb26b64ac4c5bf3
2016-08-18 10:28:38 -07:00
Emil Sjolander fd34c6d567 Move default spacing out of csslayout
Reviewed By: foghina

Differential Revision: D3709574

fbshipit-source-id: 6e0277bd97407a5c642d742f93ca2ac70d7307da
2016-08-18 03:28:34 -07:00
Don Yu a2a8d7f5da Fix onItemSelected firing for ReactPicker on initial layout.
Reviewed By: AaaChiuuu

Differential Revision: D3732557

fbshipit-source-id: ed031dbf205996dab8cb0555af972e6f26c0d202
2016-08-17 22:13:45 -07:00
Lukas Piatkowski 0b88dbf1a0 DevMenu option to control Sampling Profiler's sample interval
Differential Revision: D3722898

fbshipit-source-id: 7bf1528b26a1ac6ed81943144ca433a211cf7b35
2016-08-17 08:28:48 -07:00
Lukas Piatkowski fe1a39a8f2 DevMenu option to start the Sampling Profiler on init
Differential Revision: D3722550

fbshipit-source-id: 5a805753b4893a167df8bcf95c0e05ed22a15283
2016-08-17 08:28:48 -07:00
Andrei Coman db1b0e9be9 Reverted commit D3668840
Reviewed By: bestander

Differential Revision: D3668840

fbshipit-source-id: 553600a06c6a97c3a653815ba6fe61aaa1dad937
2016-08-17 02:58:30 -07:00
Connor McEwen 6df41d5184 Change Android Permission Module to use promises
Summary:
This is a follow-up to #9292 satya164
Closes https://github.com/facebook/react-native/pull/9325

Differential Revision: D3723568

fbshipit-source-id: d553a70bde53ed5d7c1f5f544c85c5c5935e3ca4
2016-08-16 12:58:39 -07:00
Emil Sjolander fc5bed8693 Support 64 bit platforms
Reviewed By: davidaurelio

Differential Revision: D3722479

fbshipit-source-id: c132f24c92c8476b328713861ad30670a43040c4
2016-08-16 08:58:53 -07:00
Felix Oghina af2bb20893 make main component name nullable
Summary: Sometimes the main component name is not known at activity construction time and depends on e.g. reading shared preferences. To support this use case, make `(Fragment)ReactActivity#getMainComponentName()` nullable and return `null` by default. In this case, the app will not be loaded in `onCreate` by default and the user has to call `loadApp` manually once the component name is known.

Reviewed By: andreicoman11

Differential Revision: D3722517

fbshipit-source-id: 062eed158798606e4160f1c142b23fd98ca618c8
2016-08-16 07:43:31 -07:00
Emil Sjolander 30847b2b35 Fix parameter order
Differential Revision: D3722391

fbshipit-source-id: 9adaf7b80d7bad93887a122c10eb06159a5189c2
2016-08-16 05:58:34 -07:00
Sriram Ramasubramanian dcef202aab Pass in the locale identifier from Android
Reviewed By: AaaChiuuu, achen1

Differential Revision: D3668583

fbshipit-source-id: f34b6e24d9ff4fa044d24f4133c9c85564a3f00f
2016-08-15 18:28:40 -07:00