Commit Graph

2728 Commits

Author SHA1 Message Date
Andrew Chen (Eng) c0d27de37e Fix removal of virtual nodes in FabricReconciler
Reviewed By: mdvacca

Differential Revision: D7338949

fbshipit-source-id: 31263c138689f9b3f59deb26851132df04b8a823
2018-03-21 14:33:09 -07:00
Andrew Chen (Eng) 657c1a45bd Add more debug logs to FabricReconciler
Reviewed By: mdvacca

Differential Revision: D7338946

fbshipit-source-id: 839de31ca26a8e45d3bb3271d3ab5a4f53f639b0
2018-03-20 20:01:53 -07:00
Andrew Chen (Eng) af42829404 Fix TextRenderingTestCase
Reviewed By: mdvacca

Differential Revision: D7330681

fbshipit-source-id: 5dd2a60382d01fb841f16851a9b2027e2b08e748
2018-03-20 01:01:53 -07:00
Andrew Chen (Eng) f136ae1362 Add test for FabricText
Reviewed By: mdvacca

Differential Revision: D7326562

fbshipit-source-id: e1229f84496e9181475979d757066e3796a24a3f
2018-03-20 01:01:53 -07:00
Andrew Chen (Eng) c49afb174f Add debug logs to FabricUIManager
Reviewed By: mdvacca

Differential Revision: D7310879

fbshipit-source-id: 3c874fd4dbd75dd865f7d94e7e31f538ef67eb66
2018-03-20 01:01:53 -07:00
Andrew Chen (Eng) 785c8f7eb9 Use native as the source of truth to decide if a test should use Fabric
Reviewed By: fkgozali

Differential Revision: D7304221

fbshipit-source-id: cdd7053e6ce6522474df261db5710e2d9c013be6
2018-03-20 01:01:53 -07:00
David Vacca 5347ecfd29 Fix removal of ReactShadowNode
Reviewed By: achen1

Differential Revision: D7323294

fbshipit-source-id: 411aa1bcd93cc4f9df78f64ceb0c0d8c127bc3b0
2018-03-19 18:31:36 -07:00
David Vacca cc3d45d2e9 Add logging to debug Fabric diffing algorithm
Reviewed By: achen1

Differential Revision: D7319185

fbshipit-source-id: fe47c21db5e1415aebe806f0d74b1f65f667a397
2018-03-19 18:31:36 -07:00
David Vacca 7d3de1016a Implement Fabric Reconciler
Reviewed By: achen1

Differential Revision: D7240208

fbshipit-source-id: 236b76146c50fb7f357190b08f8a5bfcef7f6645
2018-03-19 18:31:36 -07:00
David Vacca 3f84a0a6f4 Extend ReactShadowNode in order to have a reference to the ReactShadowNode that was used to clone a node
Reviewed By: achen1

Differential Revision: D7289345

fbshipit-source-id: 34bfba8aca43299a3a8929a0e3eb85721f736dd0
2018-03-19 18:31:36 -07:00
David Vacca b43afcdde9 Change cloning mechanism for mutableCopyWithNewChildren method
Reviewed By: achen1

Differential Revision: D7239873

fbshipit-source-id: d931e753c3a0b26d439eb450d62af93a672641f4
2018-03-19 18:31:36 -07:00
David Vacca 0930fef46d Disable YogaNode cloning in Android
Reviewed By: achen1

Differential Revision: D7313239

fbshipit-source-id: ecf905a22e04a2115ab968fd29f7582301f0f3c9
2018-03-19 18:31:36 -07:00
Héctor Ramos 41db09d573 Remove @xplat cell syntax in open source, part 2
Differential Revision: D7325421

fbshipit-source-id: 95e3ee0a6c41292b1d2e1fc8b0691861ad69468f
2018-03-19 12:30:59 -07:00
Andrew Chen (Eng) 12c208cbd4 Create a new instrumentation test that does not enforce rendering a single RN component
Reviewed By: mdvacca

Differential Revision: D7293466

fbshipit-source-id: 8ddaf9a52f4d6324e8b37f3c6fd4d3e0db6f3a12
2018-03-19 11:00:23 -07:00
tuncaulubilge 263d04d756 Added nestedScrollEnabled prop to scroll view for android
Summary:
Nested scrolling in scrollViews, listViews and flatLists are enabled on iOS by default, but needs to be enabled manually on Android. This PR introduces a `nestedScrollEnabled` property to ScrollViews to support nested scrolling on Android 21 and above.

Enabling nested scroll will resolve issues with coordinator layout in android and required to support a collapsing toolbar.

Tested on the test app. We are also using this property in our app currently to support scrolling behaviour required by coordinator layouts.

[ANDROID] [ENHANCEMENT] [ScrollView] - Added a prop to enable nested scrolling
Closes https://github.com/facebook/react-native/pull/18299

Reviewed By: sahrens

Differential Revision: D7256604

Pulled By: mdvacca

fbshipit-source-id: fb8b7f1b5bed39837a2066db7f2a8798d52a3fd6
2018-03-18 20:16:15 -07:00
miguelsm 353c070be9 Add a way to dismiss PopupMenu elements
Summary:
In native Android apps, like the YouTube app, context menus are closed when the device orientation changes.

In React Native apps instead, when having a [PopupMenu](https://developer.android.com/reference/android/widget/PopupMenu.html) open and rotating the device, the PopupMenu is not dismissed and appears in a wrong position on the screen.

This PR exposes a `dismissPopupMenu` method to allow the application to dismiss any open PopupMenu:

```(javascript)
UIManager.dismissPopupMenu()
```
Closes https://github.com/facebook/react-native/pull/15636

Differential Revision: D6837663

Pulled By: hramos

fbshipit-source-id: 7b0f4f04341129ad45c703a50897e17d93651974
2018-03-16 17:22:05 -07:00
Tadeu Valentt 076b1cea35 Prevent show a hidden status bar when opening modals, fix #7474
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Closes the old #7474, keeping the status bar hidden when displaying a modal
or dialog, this is accomplished by verifying if the activity status bar is hidden or not.

Added a test to [RNTester](https://github.com/facebook/react-native/tree/master/RNTester), so it can be tested from there:

1. Run [RNTester](https://github.com/facebook/react-native/tree/master/RNTester) project
2. Go to <StatusBar> tests
3. Set `hidden: true` in the *StatusBar hidden* samples
4. Set `modal visible: true` and see the result

Here are some gifs to help see the results:
![fail](https://user-images.githubusercontent.com/1649955/36345378-f443ad7e-1407-11e8-850d-d6317fb34da4.gif)
![success](https://user-images.githubusercontent.com/1649955/36345392-1c590b56-1408-11e8-9244-a2e828f579ab.gif)

none

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[ GENERAL  ]   [ BUGFIX      ]   [ [StatusBar] - Prevent show a hidden status bar when opening modals
 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
[ GENERAL  ]   [ BUGFIX      ]   [StatusBar] - Prevent show a hidden status bar when opening modals
Closes https://github.com/facebook/react-native/pull/18004

Differential Revision: D7307564

Pulled By: hramos

fbshipit-source-id: 47e481ead78204865811ddf2ef3d27da77ad8b8f
2018-03-16 16:46:42 -07:00
Héctor Ramos f376fe3232 Remove @xplat cell syntax in open source
Differential Revision: D7292243

fbshipit-source-id: f1c162be8bc90669481f04de8aa71f3d9dbece36
2018-03-15 16:47:26 -07:00
Dmitry Zakharov c989ea8728 Extract NativeExtensionsProvider definition
Reviewed By: danzimm

Differential Revision: D6964355

fbshipit-source-id: e20dfa99bd9d8784a5f31a313302104d6dc33652
2018-03-15 09:27:40 -07:00
Andrew Chen (Eng) d678058402 Add Fabric integration test
Reviewed By: fkgozali

Differential Revision: D7207630

fbshipit-source-id: 69cc10d7d45031eec9f3d934b981a5e4bb62a0ef
2018-03-14 16:27:05 -07:00
Andrew Chen (Eng) 304db5cb65 Add MIT license to Fabric
Reviewed By: fkgozali

Differential Revision: D7278262

fbshipit-source-id: 39f4c73b8f693162eb037125bf64fecc7eb0cf8b
2018-03-14 15:50:13 -07:00
Khaer Ansori c595509048 Add number-pad keyboardType
Summary:
On Android there's no number-pad but numeric instead, for my use-case I need number only (without decimal and sign, for PIN input)

I write it so there's no breaking change for those already using the `TextInput` Component

None

[ANDROID][ENHANCEMENT][Component] Add number-pad keyboardType
Closes https://github.com/facebook/react-native/pull/18350

Reviewed By: achen1

Differential Revision: D7269721

Pulled By: mdvacca

fbshipit-source-id: 82571dce948e0cf2e4354dc46c69198ec69ba65a
2018-03-14 14:48:10 -07:00
Andrew Chen (Eng) 3a2bdf5c50 Move Fabric JSC bindings to oss
Reviewed By: mdvacca

Differential Revision: D7205065

fbshipit-source-id: 5876cb3e08ee96e39b80e6b377c60600f404ca21
2018-03-14 12:02:14 -07:00
Pritesh Nandgaonkar 321b107685 Expose layout diffing flag to java
Reviewed By: emilsjolander

Differential Revision: D7272067

fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
2018-03-14 08:48:52 -07:00
Ram N 9737774b96 Fix crash in Sapienz bot for Interpolator type
Reviewed By: mdvacca

Differential Revision: D7252818

fbshipit-source-id: 30c585a2e6f6c2d7a7e7013c26c6228d8ef29aa6
2018-03-13 18:11:31 -07:00
Héctor Ramos aa323d4aa9 Use MIT license
Summary: Closes https://github.com/facebook/react-native/pull/18352

Differential Revision: D7257144

Pulled By: hramos

fbshipit-source-id: 477ff82f74cfa3fd0681c9522cc5199a60b24921
2018-03-13 10:32:13 -07:00
Héctor Ramos 7a1c618de6 Change newly imported file to MIT license
Summary:
The project at large switched to MIT last month. A PR that was opened prior to the change was merged, this PR updates the file to use the correct license.

None, trivial PR

[ANDROID] [MINOR] [Image] Update license
Closes https://github.com/facebook/react-native/pull/18343

Differential Revision: D7252836

Pulled By: hramos

fbshipit-source-id: b7c207c782f4bf19c12d121e86f394e52326a5ab
2018-03-12 20:26:43 -07:00
Moti Zilberman 0459e4ffaa Support Image resizeMode=repeat on Android
Summary:
`<Image resizeMode="repeat" />` for Android, matching the iOS implementation (#7968). (Non-goal: changing the component's API for finer-grained control / feature parity with CSS - this would be nice in the future)

As requested in e.g. #14158.

Given https://github.com/facebook/fresco/issues/1575, and lacking the context to follow the specific recommendations in https://github.com/facebook/fresco/issues/1575#issuecomment-267004303, I've opted for a minimal change within RN itself.

It's likely that performance can be improved by offloading this work to Fresco in some clever way; but I'm assuming that the present naive approach is still an improvement over a userland implementation with `onLayout` and multiple `<Image>` instances.

- Picking up on a TODO note in the existing code, I implemented `MultiPostprocessor` to allow arbitrary chaining of Fresco-compatible postprocessors inside `ReactImageView`.
- Rather than extensively refactor `ImageResizeMode`, `ReactImageManager` and `ReactImageView`, I mostly preserved the existing API that maps `resizeMode` values to [`ScaleType`](http://frescolib.org/javadoc/reference/com/facebook/drawee/drawable/ScalingUtils.ScaleType.html) instances, and simply added a second mapping, to [`TileMode`](https://developer.android.com/reference/android/graphics/Shader.TileMode.html).
- To match the iOS rendering exactly for oversized images, I found that scaling with a custom `ScaleType` was required - a kind of combination of `CENTER_INSIDE` and `FIT_START` which Fresco doesn't provide - so I implemented that as `ScaleTypeStartInside`. (This is, frankly, questionable as the default behaviour on iOS to begin with - but I am aiming for parity here)
- `resizeMode="repeat"` is therefore unpacked by the view manager to the effect of:
  ```js
     view.setScaleType(ScaleTypeStartInside.INSTANCE);
     view.setTileMode(Shader.TileMode.REPEAT);
   ```
  And the added postprocessing in the view (in case of a non-`CLAMP` tile mode) consists of waiting for layout, allocating a destination bitmap and painting the source bitmap with the requested tile mode and scale type.

Note that as in https://github.com/facebook/react-native/pull/17398#issue-285235247, I have neither updated nor tested the "Flat" UI implementation - everything compiles but I've taken [this comment](https://github.com/facebook/react-native/issues/12770#issuecomment-294052694) to mean there's no point in trying to wade through it on my own right now; I'm happy to tackle it if given some pointers.

Also, I'm happy to address any code style issues or other feedback; I'm new to this codebase and a very infrequent Android/Java coder.

Tested by enabling the relevant case in RNTester on Android.

| iOS | Android |
|-|-|
| <img src=https://user-images.githubusercontent.com/2246565/34461897-4e12008e-ee2f-11e7-8581-1dc0cc8f2779.png width=300>| <img src=https://user-images.githubusercontent.com/2246565/34461894-40b2c8ec-ee2f-11e7-8a8f-96704f3c8caa.png width=300> |

Docs update: https://github.com/facebook/react-native-website/pull/106

[ANDROID] [FEATURE] [Image] - Implement resizeMode=repeat
Closes https://github.com/facebook/react-native/pull/17404

Reviewed By: achen1

Differential Revision: D7070329

Pulled By: mdvacca

fbshipit-source-id: 6a72fcbdcc7c7c2daf293dc1d8b6728f54ad0249
2018-03-12 16:14:18 -07:00
Ram N 1dde989919 Add support for springDamping in SpringInterpolator
Reviewed By: mdvacca

Differential Revision: D7201334

fbshipit-source-id: 50929b4294188cd5a2a8ffa2080c38c0a9983535
2018-03-12 14:54:58 -07:00
Alexander Tu 216c8ec04b AndroidInfoModule now also returns Android ID
Summary: Added Android ID as one of the constants returned by AndroidInfoModule

Reviewed By: fkgozali

Differential Revision: D7206029

fbshipit-source-id: 110b33235d3023b4a4607d37acc3440cfe735cef
2018-03-09 12:12:21 -08:00
Caleb Meredith a48b4d5df1 Add Sonar support to Oculus Twilight Android
Reviewed By: alex1kom

Differential Revision: D7177071

fbshipit-source-id: 685d40e564d391d18592cedfcc12d8ac743a5331
2018-03-09 11:42:40 -08:00
David Vacca c883d4e727 Add "newProps" map into ReactShadowNode
Reviewed By: achen1

Differential Revision: D7205127

fbshipit-source-id: 6c27070806de36cab7adf9c392a10c815aee90d4
2018-03-09 09:47:44 -08:00
David Vacca e31781be61 Add extra debug information to ReactShadowNodes objects
Reviewed By: achen1

Differential Revision: D7195373

fbshipit-source-id: 6611726c3e1f92f387e00e733b1b8909a3e9edc2
2018-03-09 09:47:44 -08:00
David Vacca a7558d58a0 Clone ReactShadowNode when Yoga clones a YogaNode during layout
Reviewed By: achen1

Differential Revision: D7195840

fbshipit-source-id: d596e3ada8fe48577b91295721d41c0afd33087f
2018-03-09 09:47:43 -08:00
Andrew Chen (Eng) 596bcb6d84 Initialize ReactChoreographer before creating the TimingModule
Reviewed By: mdvacca

Differential Revision: D7185838

fbshipit-source-id: f775f5668ccff3b311c95a0bdd37a420ec64b7d4
2018-03-07 18:57:42 -08:00
samsafay d52569c4a1 check for GET and Head in send request
Summary:
React Native had an underlying problem connecting to Firestore (Google's latest database) from Android devices. You can follow the issue [here](https://github.com/firebase/firebase-js-sdk/issues/283).
The main problem was in NetworkingModule.java. Please refer to section 3 of 4.5.6 in whatwg.org's guideline https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send

In this [video](https://www.youtube.com/watch?v=tILagf46ys8), I am showing how the react native behaved before adding the new fix and how it worked after the new fix added.  The new fix starts at 50 seconds.

[ANDROID] [BUGFIX] [FIRESTORE][XMLHttpRequest][ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java] - Fixes the connection to Firestore by following whatwg.org's XMLHttpRequest send() method
Closes https://github.com/facebook/react-native/pull/17940

Differential Revision: D7173468

Pulled By: hramos

fbshipit-source-id: 354d36f03d611889073553b93a7c43c6d4363ff3
2018-03-06 17:39:22 -08:00
Andrew Chen (Eng) 6fc416313c Clean up FabricUIManagerViewHierarchyTest
Reviewed By: mdvacca

Differential Revision: D7165823

fbshipit-source-id: e6d2a83bf9e089c67d69de6581d177bdf0d2ec4e
2018-03-06 16:19:04 -08:00
Andrew Chen (Eng) e7b8341024 Add Fabric test for text nodes
Reviewed By: mdvacca

Differential Revision: D7165356

fbshipit-source-id: ab5b019943d0d6f759bdb16ca646e34a2ef79e23
2018-03-06 16:19:04 -08:00
Krzysztof Ciombor b7bb2e5745 Add support for Android TV devices
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

* To be on par with Apple TV support, this makes it possible to run React Native apps on Android TV devices (See also: https://react-native.canny.io/feature-requests/p/android-tv-support)
* These changes also make it possible to navigate through the app using D-PAD buttons that are present on some mobile devices
* Since these changes affect, among others, `ReactRootView.java` and `Touchable.js` code and are closely related to Apple TV implementation, it makes sense for them to be included in the core

 - React native apps can be launched on Android TV devices and properly render their content
 - Navigation is possible using left, right, top, bottom arrows from the remote (or D-PAD)
 - Touchable components can handle D-PAD center button press events and correctly fire their `onPress` handlers
 - Touchable components will receive `onPressIn` and `onPressOut` events and can react to focus/blur changes appropriately (just like on Apple TV)
 - `Platform` constants allow to check if the react-native app is running on TV (`Platform.isTV`)
 - `ScrollView`s behave correctly (same as native implementation) when switching to view outside bounds – that is, the container would scroll such that the newly focused element is fully visible
 - Native "clicking" sounds are played when moving between focusable elements
 - Play/Pause click event is send to `TVEventHandler`
 - Rewind and FastForward events are send to `TVEventHandler`
 - Back button behaves as a normal Android back button
 - Diagonal buttons work correctly on Android TV, e.g. if there is no button directly to the right from the focused one, but there is one to the right but a bit higher/lower it will grab focus
 - Dev menu can be accessed by long pressing fast forward button

A demo showing RNTester app running on Android TV device (Amazon Fire TV Stick) can be found here:
[![RNAndroidTVDemo](http://img.youtube.com/vi/EzIQErHhY20/0.jpg)](http://www.youtube.com/watch?v=EzIQErHhY20)

- `TextInput` will not work on Android TV devices. There's an issue with native `ReactEditText` implementation that prevents it from receiving focus. This makes it impossible to navigate to `TextInput`.
This will be fixed next, but will be included in a separate Pull Request
- ~Overlay permissions cannot be granted on Android TV devices running Android version >= 6.0
This is because the overlay permission can only be granted by firing an Intent to open settings page (`ACTION_MANAGE_OVERLAY_PERMISSION`). Since this page does not exist on TV devices the permission cannot be requested. This will make the app crash when trying to open dev menu (⌘+M) or displaying a redbox error.
Note: This does not affect devices running Android version < 6.0 (for example Amazon Fire TV Stick)~
This is now fixed by: https://github.com/facebook/react-native/pull/16596

* Launch the RNTester app on Android TV device.
  * Ensure it launches without a crash
  * Ensure basic navigation is possible
  * Ensure Touchable components can receive select events
* Ensure the changes do not break current Android and iOS mobile devices functionality.
* Ensure the changes do not break current Apple TV functionality.

[RNAndroidTVDemo video](http://img.youtube.com/vi/EzIQErHhY20/0.jpg)

* Added `ReactAndroidTVViewManager` that handles TV `KeyEvent`s and dispatches events to JS - This is the core that enables basic navigation functionality on Android TV devices
* Following the above change we copy `TVEventHandler.ios.js` into `TVEventHandler.android.js` to enable JS to pick up those native navigation events and dispatch them further to subscribed views. (Note: We do not have a native `TVNavigationEventEmitter` implementation on Android, thus this file is slightly modified, e.g. it does pass `null` to `NativeEventEmitter` constructor)
* Added `uiMode` to `AndroidInfoModule`. (**Note**: This required changing `extends BaseJavaModule` to `extends ReactContextBaseJavaModule` to be able to use `getSystemService` which requires `Context` instance!
* Added `isTV` constants to both `Platform.ios.js` (keeping the deprecated `isTVOS` as well) and `Platform.android.js`
* Changed condition check on `Touchable.js` to use the newly added `isTV` flag to properly handle TV navigation events on Android as well
* Added `LEANBACK_LAUNCHER` to `RNTester` `intent-filter` so that it is possible to launch it on Android TV devices.
* See also a PR to `react-native-website` repo with updated docs for Android TV: https://github.com/facebook/react-native-website/pull/59

 - [ ] Fix `TextInput` components handling by allowing them to be focused and making a proper navigation between them (and/or other components) possible. One thing to note here that the default behavior to immediately open software keyboard when focused on `TextInput` field will need to be adjusted on Android TV as well)
 - [x] Fix overlay permissions issue by changing the way redbox/dev menu are displayed (see: https://github.com/facebook/react-native/pull/16596)
 - [ ] Adjust placement of TV-related files (e.g. the `TVEventHandler.js` file is placed inside `AppleTV` directory which is not accurate, since it does handle Android TV events as well)

Previous discussion: https://github.com/SoftwareMansion/react-native/pull/1
<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAl  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[ANDROID] [FEATURE] [TV] - Added support for Android TV devices
Closes https://github.com/facebook/react-native/pull/16500

Differential Revision: D6536847

Pulled By: hramos

fbshipit-source-id: 17bbb11e8583b97f195ced5fd9762f8902fb8a3d
2018-03-06 10:47:02 -08:00
David Vacca d2f05740a8 Add support to FabricUIManger to handle Throwable
Reviewed By: achen1

Differential Revision: D7168684

fbshipit-source-id: c655730b5bf5e181974096c2b940f6457be8a40d
2018-03-06 10:47:01 -08:00
Andrew Chen (Eng) e839c91946 Generalize JavaOnlyMap's getMap
Reviewed By: mdvacca

Differential Revision: D7165678

fbshipit-source-id: 3dd88b24c89af369c9d5f3cc57c96f29c4f10d47
2018-03-05 22:52:09 -08:00
David Vacca ac929ef4f6 Fix subtle bugs in cloning and FabricUIManager
Reviewed By: achen1

Differential Revision: D7164980

fbshipit-source-id: 86e9f3f11b67c8947b177aac23f99808083c3121
2018-03-05 21:26:19 -08:00
David Vacca 4466b6fa7c Refactor BridgeListener into JSIModulesProvider
Reviewed By: achen1

Differential Revision: D7140944

fbshipit-source-id: 092ea8569af5b5f90e005d6dc2c1819c1c9cf58f
2018-03-05 11:03:44 -08:00
Rui Araújo a1295e1707 Fix Viewpager on Android when using native navigation.
Summary:
See the "broken" video attached to really understand the problem easily.

On Android after navigating to any other screen using wix navigation library, the native viewpager would lose the settling page behaviour which is quite annoying for the users.

This is caused by the onAttachedToWindow that resets mFirstLayout to true inside ViewPager. By request another layout pass, everything works as expected.

Working video is the application with patched RN.

[broken.mp4](https://github.com/facebook/react-native/files/1128028/broken.mp4.zip)
[working.mp4](https://github.com/facebook/react-native/files/1128032/working.mp4.zip)
Closes https://github.com/facebook/react-native/pull/14867

Differential Revision: D7154981

Pulled By: hramos

fbshipit-source-id: 2b3570800a5320ed2c12c488748d9e1358936c84
2018-03-05 10:55:49 -08:00
David Vacca 0d148ad67a Refactor FabricUIManagerModule -> FabricUIManager
Reviewed By: fkgozali

Differential Revision: D7125829

fbshipit-source-id: 46f9722a20e0bbf7f99a0cc36067035b009d73d8
2018-03-02 17:22:35 -08:00
Michael Lee 5d3efa7d6f Mark targets as explicitly Android
Reviewed By: mmmulani

Differential Revision: D7141568

fbshipit-source-id: 6c8679790309e72ca220443ecf693087f82ece85
2018-03-02 17:22:35 -08:00
Andrew Chen (Eng) 78b30659bc Fix appendChild
Reviewed By: mdvacca

Differential Revision: D7128443

fbshipit-source-id: 4eedea4df2b636eb9589cbe5e84c5c6a8aa33539
2018-03-01 16:57:25 -08:00
Andrew Chen (Eng) 6404529b76 Added an Assertion that addRoot is called before completeRoot
Reviewed By: mdvacca

Differential Revision: D7127321

fbshipit-source-id: a8215fda0d854471bed9aa5476141dfffc4dc11c
2018-03-01 16:57:25 -08:00
David Vacca 22990c3ce7 Add extra information to error message reported when a ReactRawText is included as a child of a non Text component
Reviewed By: achen1

Differential Revision: D7120188

fbshipit-source-id: 553a26d04a62dceb86d791bcdcb3a5e16a12f64b
2018-03-01 16:57:25 -08:00
Andrew Chen (Eng) 3f85dc5337 Log java error messages from FabricUIManagerModule
Reviewed By: mdvacca

Differential Revision: D7126177

fbshipit-source-id: bafa6e2b3dabf39d2ca0d9a8830b877fc5ae97ec
2018-03-01 12:17:44 -08:00
David Vacca 9b3861c109 Fix unmount of ReactRootView for Fabric surfaces
Reviewed By: fkgozali

Differential Revision: D7114865

fbshipit-source-id: f0a1c47c983e610fe0dba3051ed8aa350ac052cc
2018-03-01 10:33:21 -08:00
David Vacca c0c388c8aa Adding simple View rendering support using FabricUIManager.
Reviewed By: achen1

Differential Revision: D7102725

fbshipit-source-id: d2878d036843ba01201c4df617680269b5f59039
2018-03-01 10:33:21 -08:00
David Vacca b5b0ee853e Adding configuration of Fabric inside ReactRootView.
Reviewed By: achen1

Differential Revision: D7102701

fbshipit-source-id: f655327372c42ad86042011a3af3ee693d14014a
2018-03-01 10:33:21 -08:00
David Vacca 6b45fb2cb1 Create UIManager interface and extract common classes in uimanager/common
Reviewed By: achen1

Differential Revision: D7102674

fbshipit-source-id: e14b6782ad102ec1c3d37988df4bbd4190511f09
2018-03-01 10:33:21 -08:00
Héctor Ramos b181b7797f Check PATENTS does not creep into files
Summary:
Some files have crept into the repo with the old license header. These are usually from PRs that were opened prior to the re-licensing of the project.

Let the script run, prior to fixing the errant files. The script outputs the following:

```
PATENTS crept into some new files?
 --- /dev/fd/63	2018-03-01 01:42:48.250153746 +0000
+++ /dev/fd/62	2018-03-01 01:42:48.250153746 +0000
@@ -1 +1,9 @@
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.h
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.m
+ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+ReactAndroid/src/main/java/com/facebook/react/views/text/CustomLetterSpacingSpan.java
+ReactCommon/yoga/yoga/YGLayout.cpp
+ReactCommon/yoga/yoga/YGLayout.h
+ReactCommon/yoga/yoga/YGStyle.cpp
+ReactCommon/yoga/yoga/YGStyle.h
 scripts/circleci/check_license.sh
Exited with code 1
```

Fix the headers in these files and run the script again. No output, exit code 0.
Closes https://github.com/facebook/react-native/pull/18143

Reviewed By: sophiebits

Differential Revision: D7119356

Pulled By: hramos

fbshipit-source-id: d238e4d4a3ae320a2c8e625c2fa29690057a4814
2018-03-01 08:22:05 -08:00
Pritesh Nandgaonkar d174ab8a7a Change NaN with large number
Reviewed By: emilsjolander

Differential Revision: D6969537

fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
2018-03-01 04:02:01 -08:00
Pritesh Nandgaonkar af9d6479e5 Make two separate yoga targets for QE
Reviewed By: emilsjolander

Differential Revision: D7059278

fbshipit-source-id: dd11b018edc8ea930d5eba09c6c01e349bb8b63c
2018-03-01 04:02:01 -08:00
Michael Lee 35583e52f4 Add header_namespace to handle cross-platform uses
Differential Revision: D7101683

fbshipit-source-id: 2a95cd1447d4cc5d796556e3281d08136cd130ff
2018-02-28 12:01:50 -08:00
David Vacca ddcd609a86 Refactor cloneWithNewChildren method
Reviewed By: achen1

Differential Revision: D7064266

fbshipit-source-id: 71ef5651893359a257c39a5943812853f8d0dbcd
2018-02-27 18:47:50 -08:00
Alex Hinson 2dd2529b3a Add option to hide context menu for TextInput #17335
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

There is currently no way to disable to context menu that automatically appears over a TextInput. This is especially troublesome if you would like to disable the user from pasting text into certain fields. This PR adds a `contextMenuHidden` property to TextInput that will hide it.

I'm not sure if testing is necessary here. I would be happy to investigate further on how this would be tested, if deemed necessary!

https://github.com/facebook/react-native-website/pull/95

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[FEATURE][TextInput] - Added `contextMenuHidden` property
Closes https://github.com/facebook/react-native/pull/18125

Differential Revision: D7101888

Pulled By: hramos

fbshipit-source-id: fe36603a3fbdcefbd644251a7ea894ac7e23e5b8
2018-02-27 17:32:24 -08:00
Moti Zilberman 5898817fc1 Implement letterSpacing on Android >= 5.0
Summary:
`letterSpacing` is completely missing from RN Android at the moment.

I've reviewed the `letterSpacing` implementations in #13199, #13877 and #16801 (that all seem to have stalled) and managed to put together an improved one based on #13199, updated to merge cleanly post 6114f863c3, that resolves the [issues](https://github.com/facebook/react-native/pull/13199#issuecomment-354568863) I've identified with that code.

I believe this is the closest PR yet to a correct implementation of this feature, with a few caveats:

- As with the other PRs, this only works on Android >= 5.0 (silently falling back to no letter spacing on older versions). Is this acceptable for a RN feature, in general? Would a dev mode warning be desirable?
- The other PRs seem to have explored the space of potential solutions to the layout issue ([Android renders space _around_ glyphs](https://issuetracker.google.com/issues/37079859), iOS to the _right_ of each one) and come up empty, so I've opted to merely document the difference.
- I have neither updated nor tested the "Flat" UI implementation - everything compiles but I've taken [this comment](https://github.com/facebook/react-native/issues/12770#issuecomment-294052694) to mean there's no point in trying to wade through it on my own right now; I'm happy to tackle it if given some pointers.
- The implementation in `ReactEditText` is only there to handle the placeholder text, as `ReactBaseTextShadowNode` already affects the input control's contents correctly.
  - I'm not sure whether `<TextInput>` is meant to respect `allowFontScaling`; I've taken my cue here from `ReactTextInputManager.setFontSize()`, and used the same units (SP) to interpret the value in `ReactEditText.setLetterSpacingPt()`.
  - I'm not sure whether `<TextInput>` is even meant to support `letterSpacing` - it doesn't actually work on iOS. I'm not going to be able to handle the Objective-C side of this, not as part of this PR at least.
- I have not added unit tests to `ReactTextTest` - is this desirable? I see that some other props such as `lineHeight` aren't covered there (unless I'm not looking in the right place).
- Overall, I'm new to this codebase, so it's likely I've missed something not mentioned here.

Note comment re: unit tests above; RNTester screenshots follow.

| iOS (existing functionality, amended test) | Android (new functionality & test) |
| - | - |
| <img src=https://user-images.githubusercontent.com/2246565/34458459-c8d59498-edcb-11e7-8c8f-e7426f723886.png width=300> | <img src=https://user-images.githubusercontent.com/2246565/34458473-2a1ca368-edcc-11e7-9ce6-30c6d3a48660.png width=300> |

| iOS _(not implemented, test not in this branch)_ | Android (new functionality & test) |
| - | - |
| <img src=https://user-images.githubusercontent.com/2246565/34458481-6c60a36e-edcc-11e7-9af5-9734dd722ced.png width=300> | <img src=https://user-images.githubusercontent.com/2246565/34458486-8b3cdcf8-edcc-11e7-974b-25c6085fa674.png width=300> |

| iOS _(not implemented, test not in this branch)_ | Android (new functionality & test) |
| - | - |
| <img src=https://user-images.githubusercontent.com/2246565/34458492-d69a77be-edcc-11e7-896f-21212621dbee.png width=300> | <img src=https://user-images.githubusercontent.com/2246565/34458490-b3a1139e-edcc-11e7-88c8-79d4430d1514.png width=300> |

https://github.com/facebook/react-native-website/pull/105 - this docs PR is edited slightly from what's in `TextStylePropTypes` here; happy to align either one to the other after a review.

[ANDROID] [FEATURE] [Text] - Implemented letterSpacing
Closes https://github.com/facebook/react-native/pull/17398

Reviewed By: mdvacca

Differential Revision: D6837718

Pulled By: hramos

fbshipit-source-id: 5c9d49e9cf4af6457b636416ce5fe15315aab72c
2018-02-27 14:53:58 -08:00
Josh Hargreaves b60a727adb Fix crashes onKeyPress Android
Summary:
There appear to be two different types of crashes related to the recent addition of `onKeyPress` on Android introduce in `0.53`. This PR addresses the cause of both of them.

Firstly, it seems possible to get an `indexOutOfBoundsException` with some 3rd-party keyboards as observed in https://github.com/facebook/react-native/issues/17974 & https://github.com/facebook/react-native/issues/17922. I have simplified the backspace determining logic slightly, and also put in an explicit check for zero case so it is not possible to get an indexOutOfBoundsException & it should make sense in the context of the onKeyPress logic.

Secondly, it appears that `EditText#onCreateInputConnection` can return null. In this case, if we set `null` to be the target of our subclass of `ReactEditTextInputConnectionWrapper`, we will see the crashes as seen [here](https://github.com/facebook/react-native/issues/17974#issuecomment-368471737), whereby any of methods executed in the `InputConnection` interface can result in a crash. It's hard to reason about the state when `null` is returned from `onCreateInputConnection`, however I would might reason that any soft keyboard input cannot update the `EditText` with a `null` `input connection`, as there is no way of interfacing with the `EditText`. I'm am not sure, if there is a later point where we might return/set this input connection at a later point? As without the `InputConnection` onKeyPress will not work. But for now, this will fix this crash at least.

I have not managed to reproduce these crashes myself yet, but users have confirmed that the `indexOutOfBounds` exception is fixed with the 'zero' case and has been confirmed on the respective issues https://github.com/facebook/react-native/issues/17974#issuecomment-368471737.

For the `null` inputConnection target case, I have verified that explicitly setting the target as null in the constructor of `onCreateInputConnection` results in the same stack trace as the one linked. Here is also a [reference](https://github.com/stripe/stripe-android/pull/392/files#diff-6cc1685c98457d07fd4e2dd83f54d5bb) to the same issue closed with the same fix for another project on github.

It is also important to verify that the behavior of `onKeyPress` still functions the same after this change, which can be verified by running the RNTesterProject and the `KeyboardEvents` section in `InputText`.
The cases to check that I think are important to check are:
- Cursor at beginning of input & backspace
- Return key & return key at beginning of input
- Select text then press delete
- Selection then press a key
- Space key
- Different keyboard types

This should not be a breaking change.

 [ANDROID] [BUGFIX] [TextInput] - Fixes crashes with TextInput introduced in 0.53.
Closes https://github.com/facebook/react-native/pull/18114

Differential Revision: D7099570

Pulled By: hramos

fbshipit-source-id: 75b2dc468c1ed398a33eb00487c6aa14ae04e5c2
2018-02-27 10:01:40 -08:00
Jamie Curtis da84eba318 Catch exception and report it when making a network request with invalid URL on Android
Summary:
Currently if you invoke `fetch()` with an invalid URL ("aaa" for
example) you cannot catch the error in javascript since it's not
reported. Instead the entire app crashes.

Fixes #7436 and #18087

Hopefully.

<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Fix using fetch on Android with user generated input.

Added relevant unit test

`./scripts/run-android-local-unit-tests.sh` all pass

[ANDROID] [BUGFIX] [fetch] - Allow "unexpected url" exception to be caught on Android when using fetch
<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/18103

Differential Revision: D7097110

Pulled By: hramos

fbshipit-source-id: 69144e8a0f7404d9bcc7c71a94650de36a48c84a
2018-02-27 04:39:01 -08:00
David Vacca 62efff8ab8 Implement cloning for all ReactShadowNodes
Reviewed By: achen1

Differential Revision: D7063509

fbshipit-source-id: 90df8a3d2e6f2a4efa13f5eb0337b191b690bf8f
2018-02-26 09:04:48 -08:00
Sasha Nikiforov d8bb990abc Update ReactAndroid build script to support gradle 2.3.0
Summary:
We updated to Gradle 2.3.0 and our app's build failed. Our app doesn't provide "repositoryUrl" which is intended to be an optional gradle property. However, Gradle 2.3.0 blows up on findProperty('repositoryUrl') when "repositoryUrl" isn't provided:

````
* What went wrong:
A problem occurred configuring project ':ContextMenuAndroid'.
> Could not resolve all dependencies for configuration ':ContextMenuAndroid:_debugPublish'.
   > A problem occurred configuring project ':ReactAndroid'.
      > Could not get unknown property 'repositoryUrl' for project ':ReactAndroid' of type org.gradle.api.Project.
````

To fix this, we now use "project.hasProperty('repositoryUrl')" to safely detect the presence of the optional "repositoryUrl" property.

Since I cannot check it with your build environment, I've created a small demo to show that "project.hasProperty" properly detects the presence of the gradle property "repositoryUrl". I edited "getRepositoryUrl" to throw an exception if "repositoryUrl" is set:

````
def getRepositoryUrl() {
    if (project.hasProperty('repositoryUrl')) throw new GradleException(property('repositoryUrl'))

    return project.hasProperty('repositoryUrl') ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
````
Then I ran gradle with "repositoryUrl" set like this (passing the property):
````
./gradlew -PrepositoryUrl=blah assembleDebug
````

As expected, it detected that "repositoryUrl" was set and threw an exception:
````
* What went wrong:
A problem occurred configuring project ':ContextMenuAndroid'.
> Could not resolve all dependencies for configuration ':ContextMenuAndroid:_debugPublish'.
   > A problem occurred configuring project ':ReactAndroid'.
      > blah
````

The same issue has been reported before - #14811, #14810

Minor changes in the Android build script
Closes https://github.com/facebook/react-native/pull/18075

Differential Revision: D7077788

Pulled By: hramos

fbshipit-source-id: ecfbab29d0632e7eecb3c6a247df39bc7616653e
2018-02-23 19:16:02 -08:00
David Vacca 1b63da753f Implement Cloning for ART Views
Reviewed By: achen1

Differential Revision: D7058410

fbshipit-source-id: 394330654be1ab70853f78580c2543e04a3efb7c
2018-02-23 17:52:20 -08:00
Sebastian Markbage 25b0c374b3 JSC bindings for FabricUIManager - Android
Reviewed By: fkgozali

Differential Revision: D7054214

fbshipit-source-id: 6275a8a3e2a87dfd851a09392f09658538083483
2018-02-23 16:24:24 -08:00
David Aurelio 87f98bcd7c BundleDownloader/DevServerHelper: Close http responses
Reviewed By: amnn

Differential Revision: D7067204

fbshipit-source-id: 9b3dde374280b8d7bdc028a14e9218f37cfc87f2
2018-02-23 09:50:45 -08:00
David Aurelio e214bb3971 `DevSupportManager`: tag `RELOAD` marker with metro host
Summary: Adds the configured metro host to `ReactMarker.logMarker(ReactMarkerConstants.RELOAD)`. This may be used for diagnostics in marker listeners

Reviewed By: bnham

Differential Revision: D7041086

fbshipit-source-id: 0b0777b1cd4c74b29b9245e925cf7851b24985fa
2018-02-23 03:37:59 -08:00
David Vacca d352c93487 Register ReactRootView into FabricUIManagerModule
Reviewed By: achen1

Differential Revision: D7043902

fbshipit-source-id: fecef5a019dadd3d2802baa20dd8a3711e566ed3
2018-02-22 23:06:19 -08:00
Krzysztof Magiera ef9d1fba23 Fix IllegalStateException in looped timing native animation
Summary:
This PR fixes regression introduced in #17896 with IllegalStateException being thrown in FrameBasedAnimationDriver.

After investigating it seemed that the root cause was the code responsible for looping animations that was setting next frame time by adding the frame interval to the current time. In some circumstances the next frame would run earlier than that and as a result the calculated frame index was negative.

Here is the stacktrace as reported by axemclion https://github.com/facebook/react-native/pull/17896/files#r170007224
```
Caused by: java.lang.IllegalStateException: Calculated frame index should never be lower than 0
	at com.facebook.react.animated.FrameBasedAnimationDriver.runAnimationStep(FrameBasedAnimationDriver.java:60)
	at com.facebook.react.animated.NativeAnimatedNodesManager.runUpdates(NativeAnimatedNodesManager.java:444)
	at com.facebook.react.animated.NativeAnimatedModule$1.doFrameGuarded(NativeAnimatedModule.java:100)
	at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
```

Run native animated tests suite. Run RNTester and scroll to the loop animation and see it working correctly

[ANDROID][BUGFIX][Animated] - Fix exception thrown by timing animation when looping
Closes https://github.com/facebook/react-native/pull/18061

Differential Revision: D7059335

Pulled By: hramos

fbshipit-source-id: b08dfd1398d028eeeabeb11863743666379da374
2018-02-22 13:37:26 -08:00
Andrew Chen (Eng) cf0193f9e0 More tests for FabricUIManagerModule
Reviewed By: mdvacca

Differential Revision: D7045459

fbshipit-source-id: f96758cf04b41836f73b29e62d43a122d955c67a
2018-02-22 12:24:32 -08:00
Andrew Chen (Eng) 190e6bef2e FabricUIManagerModuleTest setup and testCloneNode
Reviewed By: mdvacca

Differential Revision: D7037558

fbshipit-source-id: a62617c7e16102cf7d12ecde48a95feec264fa51
2018-02-21 12:47:51 -08:00
David Vacca 4371d1e1d0 Implement FabricUIManagerModule in Android
Reviewed By: achen1

Differential Revision: D7031902

fbshipit-source-id: a8d9d505f981ac4268760efa32f4cbc7955aec32
2018-02-21 09:33:22 -08:00
David Vacca ad06403c3e Introduce cloning mechanism for React Shadow Node
Reviewed By: achen1

Differential Revision: D7018869

fbshipit-source-id: beca45b1df9602ebbc9172091b24a2bf44e103f4
2018-02-20 19:09:52 -08:00
Sophie Alpert 26684cf3ad Update to MIT license
Summary: Manual changes.

Reviewed By: TheSavior, yungsters

Differential Revision: D7012152

fbshipit-source-id: de7459be3db13c687868b45059856f125c4f2eb1
2018-02-16 18:31:53 -08:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Toby Cox 67c3ad4e6a Fix pinch crash in touch-responsive views.
Summary:
Fork and rebase of gillessed's PR https://github.com/facebook/react-native/pull/13166 which has gotten stale.

From original PR:

Motivation (required)

Multiple react native developer (including myself) have run into a crash with the react-native-photo-view library (and possibly others). The common solution to this problem lies in the underlying java code, and thus requires a change in the react native source.

The stack trace I am getting is the same as listed here alwx/react-native-photo-view#15.

There was a PR to fix this (#12085) but it was closed. In response to the comments there, in my PR, I do log the exceptions. I don't think we can get any closer to the exception because in the next level of the stack trace, we are in the android sdk code.

Looking at some stack overflow pages and the android bug tracker, it seems that this is the common solution to this bug, and does not cause any impact any functionality.

https://code.google.com/p/android/issues/list?can=1&q=pointerindex+out+of+range&colspec=ID+Status+Priority+Owner+Summary+Stars+Reporter+Opened&cells=tiles

Test Plan (required)

I have manually tested this by compiling react native android from source and have confirmed the exception still gets hit and logged, but does not cause the app to terminate.
Closes https://github.com/facebook/react-native/pull/17167

Differential Revision: D7014296

Pulled By: hramos

fbshipit-source-id: 06b4a31062a591b726d2021e877d16f49881dcfd
2018-02-16 17:33:11 -08:00
David Vacca 1f7a48f214 Extend the FabricUIManagerModule class to integrate with JSI/JSC in Android
Reviewed By: sebmarkbage

Differential Revision: D7005419

fbshipit-source-id: 6e65be5a922ddb29fde965f5df779cc92a996ecf
2018-02-16 13:09:30 -08:00
Krzysztof Magiera b48f7e5605 Support for animated tracking in native driver
Summary:
This PR adds support for Animated tracking to Animated Native Driver implementation on Android and iOS.

Animated tracking allows for animation to be started with a "dynamic" end value. Instead of passing a fixed number as end value we can pass a reference to another Animated.Value. Then when that value changes, the animation will be reconfigured to drive the animation to the new destination point. What is important is that animation will keep its state in the process of updating "toValue". That is if it is a spring animation and the end value changes while the previous animation still hasn't settled the new animation will start from the current position and will inherit current velocity. This makes end value transitions very smooth.

Animated tracking is available in JS implementation of Animated library but not in the native implementation. Therefore until now, it wasn't possible to utilize native driver when using animated tracking. Offloading animation from JS thread turns out to be crucial for gesture driven animations. This PR is a step forward towards feature parity between JS and native implementations of Animated.

Here is a link to example video that shows how tracking can be used to implement chat heads effect: https://twitter.com/kzzzf/status/958362032650244101

In addition this PR fixes an issue with frames animation driver on Android that because of rounding issues was taking one extra frame to start. Because of that change I had to update a number of Android unit tests that were relying on that behavior and running that one additional animation step prior to performing checks.

As a part of this PR I'm adding three unit tests for each of the platforms that verifies most important aspects of this implementation. Please refer to the code and look at the test cases top level comments to learn what they do.

I'm also adding a section to "Native Animated Example" screen in RNTester app that provides a test case for tracking. In the example we have blue square that fallows the red line drawn on screen. Line uses Animated.Value for it's position while square is connected via tracking spring animation to that value. So it is ought to follow the line. When user taps in the area surrounding the button new position for the red line is selected at random and the value updates. Then we can watch blue screen animate to that position.

You can also refer to this video that I use to demonstrate how tracking can be linked with native gesture events using react-native-gesture-handler lib: https://twitter.com/kzzzf/status/958362032650244101

[GENERAL][FEATURE][Native Animated] - Added support for animated tracking to native driver. Now you can use `useNativeDriver` flag with animations that track other Animated.Values
Closes https://github.com/facebook/react-native/pull/17896

Differential Revision: D6974170

Pulled By: hramos

fbshipit-source-id: 50e918b36ee10f80c1deb866c955661d4cc2619b
2018-02-16 12:10:01 -08:00
David Vacca ad4f54ff6c Extend installFabric method to access UIFabricModule from C++
Reviewed By: sebmarkbage

Differential Revision: D7001974

fbshipit-source-id: a49c6e634ac710805fb37a50a61c2cf2e248b8a7
2018-02-15 13:41:01 -08:00
David Vacca c82b9f72de Create JNI wrapper for Fabric
Reviewed By: fkgozali

Differential Revision: D6989838

fbshipit-source-id: f092901cacc0c3eb89b08c6ac0384c4d5f6e6cfe
2018-02-15 12:17:54 -08:00
David Vacca 51def5ef7f Make Java YogaNode cloneable
Reviewed By: priteshrnandgaonkar

Differential Revision: D6935971

fbshipit-source-id: a2008f1eb849b5074585b48699b7de56d5ac90d4
2018-02-14 18:19:03 -08:00
David Vacca db391a500c Allow installing JS binding via the RN Android bridge
Reviewed By: fkgozali

Differential Revision: D6979072

fbshipit-source-id: 8b4ac3769496a6a6fe3dd9ee2aac64b66604c413
2018-02-14 11:51:58 -08:00
David Vacca ecc08adf49 Expose methods of persistent yoga for Java
Reviewed By: priteshrnandgaonkar

Differential Revision: D6918605

fbshipit-source-id: e424c78680c04e21154ebe21405671c4e90f6529
2018-02-14 09:32:57 -08:00
Andrew Chen (Eng) c281f7a3ae Support resumes without overriding the back handler
Differential Revision: D6982515

fbshipit-source-id: 5483f6c677c6653e51f6311386f31f5be6ed0e00
2018-02-14 09:32:57 -08:00
Janic Duplessis d06e143420 Bundle download progress on Android
Summary:
Android equivalent of #15066

Tested that download progress shows up properly when reloading the app.

[ANDROID] [FEATURE] [DevSupport] - Show bundle download progress on Android
Closes https://github.com/facebook/react-native/pull/17809

Differential Revision: D6982823

Pulled By: hramos

fbshipit-source-id: da01e42b8ebb1c603f4407f6bafd68e0b6b3ecba
2018-02-13 20:31:22 -08:00
Stein Strindhaug 74e54cbcc4 Fix: incorrect line-height calculation
Summary:
There seems to be a rounding error in the android code for line height, so that for some fonts and at some combinations of line height and font size the actual height of the elements seems to be slightly too short.

I've identified one issue that I mentioned here https://github.com/facebook/react-native/issues/10712#issuecomment-359382137 that could at least explain some of the problem. That when the line-height minus the original sum of the absolute value of top  and bottom from the metrics, happens to be an odd number, the division by two causes a rounding error of 1, so that the actual line height is 1pt less than it should.

The fix uses floating point division instead of integer division, and rounds (arbitrarily) the negative values up and the positive values down so that the total is still the correct for odd numbers.

It turns out that only ascent and descent is used to give the actual line-height between lines in the same text-element. The top and bottom values are only used for padding the top and bottom of the text. So when the line-height is greater than the font size and the extra padding this PR sets the ascent and descent to the same value as the top and bottom respectively.

I've renamed the shouldIncreaseAllMetricsProportionally test to evenLineHeightShouldIncreaseAllMetricsProportionally and added an extra assertion to check that bottom-top still equals the line height.

Added another test oddLineHeightShouldAlsoWork that is similar but uses an odd number for the line height to test that it still works with odd numbers. This test only uses the sum of the values so that it's indifferent to what value the implementation chooses to round up or down.

Improvement on https://github.com/facebook/react-native/pull/16448

Fix line-height calculation on Android.

| Before        | After           |
| ------------- |-------------|
| ![without fix](https://user-images.githubusercontent.com/2144849/36150230-4404a0cc-10c3-11e8-8880-4ab84339c741.png)      | ![actual fix](https://user-images.githubusercontent.com/2144849/36156620-eb496d0e-10d7-11e8-8bd1-1cb536a38fbf.png) |

(All three columns have font size 16 and lineHeight: 32. The first one is has fixed height 9*32, the second is 9 Text elements, the last is one text element with lots of text limited to 9 lines, so they should be the same height. )
Closes https://github.com/facebook/react-native/pull/17952

Differential Revision: D6980333

Pulled By: hramos

fbshipit-source-id: 0a501358cfbf7f139fca46056d0d972b1daf6ae3
2018-02-13 13:50:22 -08:00
David Vacca 331cc791ec Extend Navigation to support "is_fabric" param from native
Reviewed By: fkgozali

Differential Revision: D6955828

fbshipit-source-id: 1a77b652a7e372acf961a0b0772ae93a999b90b1
2018-02-13 13:50:22 -08:00
Paco Estevez Garcia ad2d9e7fab Forward VM version to inspector
Reviewed By: bnham

Differential Revision: D6938018

fbshipit-source-id: c79853ddf835acab86a16ebd539874d29d3aa60a
2018-02-13 08:16:50 -08:00
Andrew Chen (Eng) 427e464bb9 Fix localization crash in DevSettingsActivity
Differential Revision: D6970534

fbshipit-source-id: da1df549b6157e5ec684cf4eed5f411740a73ed0
2018-02-12 16:33:07 -08:00
Jonathan Kim e233646d09 Clean up unused macros after consolidation
Reviewed By: mzlee

Differential Revision: D6954781

fbshipit-source-id: 0ec78e6f7f2780951ac008e9b12f41cfd5441ed5
2018-02-09 16:05:29 -08:00
Wei Sun 1a790f8703 Use ConcurrentHashMap for handling concurrent Android websockets, and…
Summary:
… prevent unknown websocket IDs from crashing on Android (show warning on development builds instead)

This PR addresses #3346; an unknown websocket ID should produce a warning during development, but not cause crashes in production RN apps. This PR was created by satya164's request, and was inspired by tanthanh289's suggestion on #3346's thread.

On Android, create a websocket using a service like Pusher (`pusher-js` npm package) or manually, and then induce removal of its websocket ID. Result should be a red warning screen during development, and no crash in the app's release variant.

 [ANDROID] [BUGFIX] [WebSocket] - Prevent unknown websocket IDs from crashing on Android
Closes https://github.com/facebook/react-native/pull/17884

Differential Revision: D6954038

Pulled By: hramos

fbshipit-source-id: b346d80d7568996b8819c0de54552abb534cbfae
2018-02-09 14:47:56 -08:00
Héctor Ramos 27b6348f86 Added progress updates for all XMLHttpRequest upload types / fix crash on closed connection
Reviewed By: mdvacca

Differential Revision: D6937754

fbshipit-source-id: 89b963e16adf1bd3200806fd7374d28aa618b62f
2018-02-09 10:34:56 -08:00
David Vacca 2d35bde101 Introduce new Fabric API in RNAndroid
Summary: Introduce new Fabric FabricUIManagerModule RNAndroid

Reviewed By: achen1

Differential Revision: D6833154

fbshipit-source-id: 9ab7ff8bf0c407d833c512eb3455969573f138da
2018-02-08 18:14:54 -08:00
Brian Vaughn 6f007e8957 Ran rename-unsafe-lifecycles codemod on xplat/js
Reviewed By: trueadm

Differential Revision: D6889214

fbshipit-source-id: e815cda4b09f3650ae3b0b9a44ae6f5fcb48fe25
2018-02-08 10:58:31 -08:00
Taras Tsugrii 79a63d040f Skylarkify RN defs.
Reviewed By: adamjernst

Differential Revision: D6934209

fbshipit-source-id: 59f50b739482a53473c157f9e0183024dc88dc67
2018-02-08 09:47:28 -08:00
Héctor Ramos a5e135aed6 Add CountingOutputStream
Reviewed By: mdvacca

Differential Revision: D6932872

fbshipit-source-id: 226f30833a786d0c03564f25ec8c4f43d94c48f4
2018-02-08 09:32:14 -08:00
Héctor Ramos 2f02dd4c8c Revert PR #17312 due to buck failures in continuous integration tests
Summary:
Circle is currently failing on the `android` step due to a dependency issue introduced by the aforementioned PR. I am currently waiting for an internal diff to be reviewed which will restore this PR alongside the necessary dependency.
Closes https://github.com/facebook/react-native/pull/17902

Differential Revision: D6937173

Pulled By: hramos

fbshipit-source-id: f732a397521cc5df36f503e618318ef6d69aeaa6
2018-02-08 07:38:37 -08:00
Pritesh Nandgaonkar 528bbacf6b Expose a function which marks all descendants dirty
Reviewed By: emilsjolander

Differential Revision: D6911869

fbshipit-source-id: e0a3abcf5653f921297edfdca473d83b947cc627
2018-02-08 05:04:02 -08:00
Vishwesh Jainkuniya 09b43e479e textinput: Maintain cursor position when secureTextEntry toggles.
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

On current [master](8235a49a33), text input cursor resets to start when `secureTextEntry` prop toggles on Android. This motivate me to maintain position when `secureTextEntry ` prop toggles for better user experience.

On current [master](8235a49a33)
![ezgif com-video-to-gif-3](https://user-images.githubusercontent.com/18511177/35776882-bdc3b182-09ca-11e8-8f4e-218fae0a24a1.gif)

On this PR
![ezgif com-video-to-gif-4](https://user-images.githubusercontent.com/18511177/35776883-be082d94-09ca-11e8-9424-6164110bdf03.gif)

[ANDROID] [BUGFIX] [TextInput] - Fix: cursor positions resets to start on toggling `secureTextEntry` prop.

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/17851

Differential Revision: D6925711

Pulled By: hramos

fbshipit-source-id: 6d53ad2dbed2dca20cd21e5b1b0578be13a91aad
2018-02-07 11:03:31 -08:00
Dmitry Zakharov 0c49c1f332 Native Modules -> Native Extensions
Reviewed By: danzimm

Differential Revision: D6887988

fbshipit-source-id: 475c05f60a2e1ddcfaa9263ab363bff8a528236a
2018-02-07 08:07:13 -08:00
David Aurelio 06d8f96a64 Inline format strings in `DevServerHelper`
Summary: Having format strings and values to interpolate separated makes reading the respective calls difficult. It has also led to situations where format strings were reused with slightly different values, instead of creating a parameterized method.

Reviewed By: pakoito

Differential Revision: D6900905

fbshipit-source-id: 68b56af6a86c0b46bc8cf9c44fbe0fb93ee151ac
2018-02-07 06:31:16 -08:00
Moti Zilberman 6c38972327 Support non-integer modulus in ModulusAnimatedNode on Android
Summary:
`Animated.modulo(value, modulus)` supports a non-integer modulus in the iOS and JS implementations but crashes on Android when `useNativeDriver` is set to `true`.

Unfortunately, I'm not fluent enough with this codebase to add a Java test for this fix - especially as I couldn't find any analogous tests to extrapolate from. However, the fix itself seems straightforward enough.

None needed

[ANDROID] [BUGFIX] [Animated] - Support non-integer modulus in .modulo()
Closes https://github.com/facebook/react-native/pull/17860

Differential Revision: D6918799

Pulled By: hramos

fbshipit-source-id: 8d15e4bc881ed41a4123c6f811c0c72119f67be0
2018-02-06 16:59:30 -08:00
David Aurelio f88c9d6382 Remove unused method
Summary: Removes `BundleDownloader#cancelDownloadBundleFromURL`

Reviewed By: pakoito

Differential Revision: D6900903

fbshipit-source-id: d9297344d6296d79a984aeecb3e014c9ed23a165
2018-02-06 15:12:08 -08:00
David Aurelio 1019bda930 Extract delta client
Summary: Extracts the delta client from the bundle downloader. This will allow us to extract an interface, and provide a different implementation for C++ delta bundling (where we will pass deltas directly to native code).

Reviewed By: pakoito

Differential Revision: D6900904

fbshipit-source-id: 358705615eecc15afa0de3e50478468ad840d250
2018-02-06 15:12:08 -08:00
David Aurelio 6e44356c9b Clean up `DevServerHelper`
Summary:
- Makes methods private that are not used elsewhere
- Moves a method to `DevSupportManagerImpl`
- Removes unused methods

Reviewed By: pakoito

Differential Revision: D6900907

fbshipit-source-id: c8d9f748effd396fe610f0d4d87e0bc388e155d6
2018-02-06 15:12:08 -08:00
David Aurelio 644123aa6f Consolidate bundle URL creation
Summary:
`DevServerHelper` had multiple places that created bundle URLs.
This consolidates that logic into a single place, and uses an enum for different "bundle types" (bundle, bundle deltas, source maps).

Reviewed By: pakoito

Differential Revision: D6900906

fbshipit-source-id: 64ed9360ea85dc5755308d822d5fc55fe8cb5a55
2018-02-06 15:12:08 -08:00
David Aurelio 108f9664bf Do not expose `BundleDownloader` from `DevServerHelper`
Summary:
Adds `downloadBundleFromURL` as a delegating method to `DevServerHelper` rather than exposing the underlying `BundleDownloader`.

The additional encapsulation will allow futher factoring of `BundleDownloader` to make logic for different delta bundler clients easier to implement and maintain.

Reviewed By: pakoito

Differential Revision: D6871225

fbshipit-source-id: 6adcab5e69869a234baf38f1f1e60abd34d6b555
2018-02-05 11:47:03 -08:00
allengleyzer 9e436d1439 Added progress updates for all XMLHttpRequest upload types / fix crash on closed connection
Summary:
This PR includes the same changes made in #16541, for addressing issues #11853/#15724. It adds upload progress updates for uploads with any request body type, and not just form-data.

Additionally, this PR also includes a commit for fixing an `IllegalStateException` when a user's connection gets closed or times out (issues #10423/#11016). Since this exception was occurring within the progress updates logic, it started being thrown more frequently as a result of adding progress updates to all uploads, which was why the original PR was reverted.

To test the upload progress updates, run the following JS to ensure events are now being dispatched:
```
const fileUri = 'file:///my_file.dat';
const url = 'http://my_post_url.com/';
const xhr = new XMLHttpRequest();

xhr.upload.onprogress = (event) => {
    console.log('progress: ' + event.loaded + ' / ' + event.total);
}

xhr.onreadystatechange = () => {if (xhr.readyState === 4) console.log('done');}

console.log('start');

xhr.open('POST', url);

// sending a file (wasn't sending progress)
xhr.setRequestHeader('Content-Type', 'image/jpeg');
xhr.send({ uri: fileUri });

// sending a string (wasn't sending progress)
xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.send("some big string");

// sending form data (was already working)
xhr.setRequestHeader('Content-Type', 'multipart/form-data');
const formData = new FormData(); formData.append('test', 'data');
xhr.send(formData);
```

To test the crash fix:
In the RN Android project, before this change, set a breakpoint at `mRequestBody.writeTo(mBufferedSink);` of `ProgressRequestBody`, and wait a short while for a POST request with a non-null body to time out before resuming the app. Once resumed, if the connection was closed (the `closed` variable will be set to true in `RealBufferedSink`), an `IllegalStateException` will be thrown, which crashes the app. After the changes, an `IOException` will get thrown instead, which is already being properly handled.

As mentioned above, includes the same changes as #16541, with an additional commit.

[ANDROID] [BUGFIX] [XMLHttpRequest] - Added progress updates for all XMLHttpRequest upload types / fix crash on closed connection

Previously, only form-data request bodies emitted upload progress updates. Now, other request body types will also emit updates. Also, Android will no longer crash on certain requests when user has a poor connection.

Addresses issues: 11853/15724/10423/11016
Closes https://github.com/facebook/react-native/pull/17312

Differential Revision: D6712377

Pulled By: mdvacca

fbshipit-source-id: bf5adc774703e7e66f7f16707600116f67201425
2018-02-02 18:16:24 -08:00
Kathy Gray 28be33ac34 Remove release from ReadableNativeArray and Map
Reviewed By: mhorowitz

Differential Revision: D6846268

fbshipit-source-id: 2f750a05ee63a744e7f64b3fe67736df3614ef3d
2018-02-01 07:30:07 -08:00
Ray Shih 88980f2ef7 Implement bundle sync status
Reviewed By: pakoito

Differential Revision: D6807480

fbshipit-source-id: d71f2cecd882c47e79bb71dfb9d03d3597fa4068
2018-02-01 06:18:13 -08:00
Agastya Darma b1cdb7d553 Implementing space-evenly
Summary:
So in v0.52.0 space-evenly is introduced but not yet implemented (1050e0b by woehrl01). This pull request implements the space-evenly.

Manual Testing.
![notes marker](https://i.imgur.com/IXmezVY.png)

[IOS] [FEATURE] [Yoga] Adding space-evenly on justify-content in iOS
[ANDROID] [FEATURE] [Yoga] - Adding space-evenly on justify-content in Android
Closes https://github.com/facebook/react-native/pull/17805

Differential Revision: D6858294

Pulled By: shergin

fbshipit-source-id: 7a705ca05f58603ef4588e1bfd16c16a78f8a390
2018-01-31 10:17:22 -08:00
Dan Caspi 3fbf7856d9 Better handling exception in loadScript()
Differential Revision: D6856807

fbshipit-source-id: 36c527ee00eef56a5912ad6e4233d6cd61cb5170
2018-01-31 05:31:12 -08:00
David Aurelio e756251413 Synchronize map access
Summary:
We want applying deltas to be an atomic operation, from incrementing the delta message ID to updating the relevant maps.
This is a simple approach to synchronize the corrsponding method.

We will probably need to go with a more sophisticated approach, that makes sure that deltas are applied in order. That would also allow us to lock only on writes.

Reviewed By: kathryngray

Differential Revision: D6846560

fbshipit-source-id: 175a80b4e39223883e397d75e20109fc12a2a878
2018-01-31 03:04:13 -08:00
Chris Lewis 22efd95be1 Add back ability to customise OkHttp client
Summary:
Prior to 0a71f48b13, users could customise the OkHttp client used by React Native on Android by calling replaceOkHttpClient in OkHttpClientProvider.

This functionality has a variety of legitimate applications from changing connection timeouts or pool size to Stetho integration. The challenge is to add back support for replacing the client without causing a breaking change or reintroducing the problems olegbl sought to address in his original commit.

Introducing a client factory archives these aims, it adds a new, backwards compatible interface and is called each time a client is requested rather than re-using the same instance (unless you explicitly want this behaviour, in which case you could replicate it using a static class property inside your custom factory).

A number of PRs have been opened to add this functionality: https://github.com/facebook/react-native/pull/14675, https://github.com/facebook/react-native/pull/14068.

I don't have a lot of Java experience so I'm open to better/more idiomatic ways to achieve this :)

Create React Native application and set a custom factory in the constructor, e.g.  `OkHttpClientProvider.setOkHttpClientFactory(new CustomNetworkModule());`

Where a custom factory would look like:

```
class CustomNetworkModule implements OkHttpClientFactory {
    public OkHttpClient createNewNetworkModuleClient() {
        return new OkHttpClient.Builder().build();
    }
}
```

Remove the existing replace client method to prevent accident use and alert existing users that its functionality has changed: https://github.com/facebook/react-native/pull/16972

[Android] [Minor] [Networking] - | Provide interface for customising the OkHttp client used by React Native |
Closes https://github.com/facebook/react-native/pull/17237

Differential Revision: D6837734

Pulled By: hramos

fbshipit-source-id: 81e63df7716e6f9039ea12e99233f6336c6dd7ef
2018-01-30 11:58:45 -08:00
Héctor Ramos 964320447d Add support annotations dependency
Summary:
Should fix current test-android error in Circle CI.
Closes https://github.com/facebook/react-native/pull/17774

Differential Revision: D6837326

Pulled By: hramos

fbshipit-source-id: a53464d3abb52248c6565dee68e7e7f9be9a313f
2018-01-30 11:03:52 -08:00
Semen Zhydenko 8ffc16c6e7 Typos in code
Summary:
To fix typos

No testing required, changed only internal things names

No

addtionalStyles -> additionalStyles
occured -> occurred
recomendedType -> recommendedType
markDirtyAndPropogate -> markDirtyAndPropagate
targetting -> targeting
RCTApplyTranformationAccordingLayoutDirection -> RCTApplyTransformationAccordingLayoutDirection (tranform -> transform)
Closes https://github.com/facebook/react-native/pull/17587

Differential Revision: D6832696

Pulled By: shergin

fbshipit-source-id: 452287e5ce82df5c6b87126cb21889b7bd9d73c1
2018-01-29 19:17:33 -08:00
Alexey Lang 6224ef5301 Measure time to create ReactInstanceManager
Reviewed By: fkgozali

Differential Revision: D6591797

fbshipit-source-id: 7345b7c772eb4ae35ad570082090fbdf704102d3
2018-01-29 11:07:39 -08:00
Satyajit Sahoo be56a3efee Implement Blob support for XMLHttpRequest
Summary:
This PR is a followup to https://github.com/facebook/react-native/pull/11417 and should be merged after that one is merged.

  1. Add support for creating blobs from strings, not just other blobs
  1. Add the `File` constructor which is a superset of `Blob`
  1. Add the `FileReader` API which can be used to read blobs as strings or data url (base64)
  1. Add support for uploading and downloading blobs via `XMLHttpRequest` and `fetch`
  1. Add ability to download local files on Android so you can do `fetch(uri).then(res => res.blob())` to get a blob for a local file (iOS already supported this)

  1. Clone the repo https://github.com/expo/react-native-blob-test
  1. Change the `package.json` and update `react-native` dependency to point to this branch, then run `npm install`
  1. Run the `server.js` file with `node server.js`
  1. Open the `index.common.js` file and replace `localhost` with your computer's IP address
  1. Start the packager with `yarn start` and run the app on your device

If everything went well, all tests should pass, and you should see a screen like this:

![screen shot 2017-06-08 at 7 53 08 pm](https://user-images.githubusercontent.com/1174278/26936407-435bbce2-4c8c-11e7-9ae3-eb104e46961e.png)!

Pull to rerun all tests or tap on specific test to re-run it

  [GENERAL] [FEATURE] [Blob] - Implement blob support for XMLHttpRequest
Closes https://github.com/facebook/react-native/pull/11573

Reviewed By: shergin

Differential Revision: D6082054

Pulled By: hramos

fbshipit-source-id: cc9c174fdefdfaf6e5d9fd7b300120a01a50e8c1
2018-01-26 09:17:11 -08:00
4ndroidev 7b1915e74d Fix NPE in Android Switch during measure
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Fixes #16000

see [Issue #16000](https://github.com/facebook/react-native/issues/16000)
fix a null pointer exception while using higher version 'com.android.support:appcompat-v7'

N/A

[ANDROID][BUGFIX][Switch] - Fix NPE in Android Switch during measure
Closes https://github.com/facebook/react-native/pull/16064

Differential Revision: D6816122

Pulled By: hramos

fbshipit-source-id: ba9a6febad4884b8ab142d8c7142085367006904
2018-01-25 18:00:09 -08:00
Michael Lee 869866cc5c Continue wrapping functions as we prepare for skylark
Differential Revision: D6808010

fbshipit-source-id: f24e71558baed2c2da319e20e0faf66858eb27d5
2018-01-25 09:30:00 -08:00
Sergei Dryganets 0c18ec5b9c Popups calling error callback instead of crashing if view with passed tagId not found
Summary:
The showPopup method has an error callback. For some reason, it is asserting in case the wrong tagId is passed instead of calling the error callback on Android.

Pass not existing tagId to showPopup method and make sure it is receiving an error in js instead of crashing in native on Android.

[ANDROID] [MINOR] showPopup method calls error callback instead of crashing on errors.
Closes https://github.com/facebook/react-native/pull/17550

Differential Revision: D6776014

Pulled By: hramos

fbshipit-source-id: 1d97b762818d1591018fd43556eb41c3fb491eb9
2018-01-23 14:07:25 -08:00
Jonathan Kim 4f6c157250 Fix open source build load error
Reviewed By: hramos

Differential Revision: D6785610

fbshipit-source-id: d50aab72aa51f8aa063f23fc1e328caf9c02de0c
2018-01-23 09:51:40 -08:00
Pritesh Nandgaonkar be8e7c6e65 Made logging logic dynamic to log string length
Reviewed By: emilsjolander

Differential Revision: D6784491

fbshipit-source-id: 26e4520a84be355ff992b808297ce7a95b3d09e3
2018-01-23 06:46:08 -08:00
Sergei Dryganets 46cc4907e3 ClassCastException fix: getText() returns CharSequence not Spanned.
Summary:
ClassCastException fix: getText() returns CharSequence not Spanned.
From the other hand, EditTexts getText method returns Editable which extends Spanned.
This commit fixes two similar bugs one in flat TextView and another in standard TextView.
Also, it removes redundant checks in the ReactEditText.

Application without this change sporadically crashes with the following stack trace:
```
java.lang.ClassCastException: java.lang.String cannot be cast to android.text.Spanned
	at com.facebook.react.views.text.ReactTextView.reactTagForTouch(ReactTextView.java:195)
	at com.facebook.react.uimanager.TouchTargetHelper.getTouchTargetForView(TouchTargetHelper.java:269)
	at com.facebook.react.uimanager.TouchTargetHelper.findTargetTagAndCoordinatesForTouch$58866680(TouchTargetHelper.java:101)
	at com.facebook.react.uimanager.JSTouchDispatcher.handleTouchEvent(JSTouchDispatcher.java:77)
	at com.facebook.react.ReactRootView.dispatchJSTouchEvent(ReactRootView.java:151)
	at com.facebook.react.ReactRootView.onInterceptTouchEvent(ReactRootView.java:127)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2110)

```
Closes https://github.com/facebook/react-native/pull/15452

Differential Revision: D6775986

Pulled By: hramos

fbshipit-source-id: 6de929937cbbb3e7bd98a708a40700f883cbaef0
2018-01-22 15:15:23 -08:00
Pascal Hartig ff2658c3de Mark model fields final
Reviewed By: emilsjolander

Differential Revision: D6759564

fbshipit-source-id: 810dc8a9730fb330760d2aedecafcea81cf25cb1
2018-01-22 03:05:17 -08:00
Build Service f49f7932d5 @allow-large-files @ignore-conflict-markers[i18n] translation auto-update for i18n/instagram-directapp.config.json on master
fbshipit-source-id: ec880908d30772bf2047963013d184e01405de03
2018-01-22 02:16:31 -08:00
Build Service faa9519021 @allow-large-files @ignore-conflict-markers[i18n] translation auto-update for i18n/fb4a.config.json on master
fbshipit-source-id: c7382ae9de4fb1697190bbc9fe385bd552973fdd
2018-01-22 02:16:31 -08:00
Build Service 8bd00a2361 @allow-large-files @ignore-conflict-markers[i18n] translation auto-update for i18n/expresswifi.config.json on master
fbshipit-source-id: 42904e404f11a205af8af486e9535a8dc52da81e
2018-01-22 02:16:31 -08:00
Build Service bb6fceac27 @allow-large-files @ignore-conflict-markers[i18n] translation auto-update for i18n/creatorapp.config.json on master
fbshipit-source-id: 9ae5884ac23492feed039da32433cd8c08e2cc0e
2018-01-22 02:16:31 -08:00
Build Service c7846c4bfb @allow-large-files @ignore-conflict-markers[i18n] translation auto-update for i18n/adsmanager.config.json on master
fbshipit-source-id: a0ba2333de9b635234aa56ccd080252fa400d534
2018-01-22 02:16:31 -08:00
Jonathan Kim 4f2cc42a2d Make xplat react native files buildable
Reviewed By: mzlee

Differential Revision: D6605611

fbshipit-source-id: baa33947319a27b95020924d177a9398a276dabe
2018-01-21 22:05:05 -08:00
David Vacca 4d3519cc6a Adding JS hierarchy information when a StackOverflowException is thrown in Dev mode
Reviewed By: achen1

Differential Revision: D6716309

fbshipit-source-id: 23458cd126d13fec3aa9c09420f7cdd230ec8dd0
2018-01-19 13:02:41 -08:00
David Vacca 1aac962378 Capture StackOverflowExceptions triggered when drawing a ReactViewGroup or ReactRootView
Reviewed By: achen1

Differential Revision: D6653395

fbshipit-source-id: 849b1a2ed6ab9bc057414d451e97a673178c30dd
2018-01-18 18:48:59 -08:00
David Vacca 877f1cde2e Fix and re-enable "view flattening" optimizations for Marketplace
Reviewed By: achen1

Differential Revision: D6751078

fbshipit-source-id: 32bfb9ac64f183fabbba85755be372016722afc6
2018-01-18 17:55:08 -08:00
Ram N f5efc460ad Add support for finding multiple views with NativeIds using a single listener
Reviewed By: mdvacca

Differential Revision: D6735460

fbshipit-source-id: e038a68637a00fda7058fc82e253ae68cdf67c6e
2018-01-18 11:33:34 -08:00
David Vacca 71ec85f24c Cleanup ReactHorizontalScrollView
Reviewed By: achen1

Differential Revision: D6693605

fbshipit-source-id: e58425b2a5b0bf75ffb41ef3ab6fa7ad46222531
2018-01-18 10:46:47 -08:00
Tim Yung df2f33537a RN: Revert D6701597
Reviewed By: mdvacca

Differential Revision: D6735812

fbshipit-source-id: 8144b72883150f9d7e2614ee0f238c1b8e44c6ab
2018-01-17 15:11:14 -08:00
Kathy Gray 7891805d22 move native accesses of map into two accesses instead of per-element
Differential Revision: D6650192

fbshipit-source-id: 0eb0719fd3b7813add33a3d4fe3fb70e6f375fd7
2018-01-17 10:51:49 -08:00
Kathy Gray 5649aed6d3 Move native accesses of array into one access instead of per-element
Differential Revision: D6578349

fbshipit-source-id: 84ebd66ed791a845e9cc0fbc7e12a377534aa903
2018-01-17 10:51:49 -08:00
Felix Oghina fc6dd78935 Remove SoLoaderShim, use SoLoader
Summary:
SoLoader is more stable on older versions of Android. Switching to it should fix recurring issues that we get such as `UnsatisfiedLinkError` and so on.

CI + run showcase app.
Closes https://github.com/facebook/fresco/pull/1989

Reviewed By: erikandre

Differential Revision: D6556420

Pulled By: foghina

fbshipit-source-id: ffc3faef6452294b4d781258c64ef57e08d107b5
2018-01-16 09:16:01 -08:00
David Vacca 1f5bb374cd Revert D6704701: Refactor ReactViewGroup to reuse ReactViewBackgroundManager
Differential Revision: D6704701

fbshipit-source-id: 01feb61a9c2c263f88cca4fea5978957c5e4767f
2018-01-16 08:15:47 -08:00
Semen Zhydenko d2c569795c Typos in comments and log messages
Summary:
No code changes, no testing required.

alligned -> aligned
allignment -> alignment
completly -> completely
conseptually -> conceptually
decendents -> descendants
indefinetly -> indefinitely
dimention -> dimension
doesnt -> doesn't
safegaurd -> safeguard
intialization -> initialization
hierachy -> hierarchy
happend -> happened
gaurd -> guard
programatically -> programmatically
initalized -> initialized
immidiately -> immediately
occured -> occurred
unkown -> unknown
neccessary -> necessary
neccesarily -> necessarily
occuring -> occurring
comoponent -> component
propogate -> propagate
recieved -> received
referece -> reference
perfomance -> performance
recieving -> receiving
subsquently -> subsequently
scoll -> scroll
suprisingly -> surprisingly
targetting -> targeting
tranform -> transform
symetrical -> symmetrical
wtih -> with
Closes https://github.com/facebook/react-native/pull/17578

Differential Revision: D6718791

Pulled By: shergin

fbshipit-source-id: 4ab79c1131ec5971d35a0c7199eba7ec0a0918ad
2018-01-12 22:18:45 -08:00
David Vacca e8aa60430c Refactor ReactViewGroup to reuse ReactViewBackgroundManager
Reviewed By: achen1

Differential Revision: D6704701

fbshipit-source-id: 14bb155f2eb0951307674e257e729a1c72b08d8b
2018-01-12 17:08:00 -08:00
Brandon Williams 164f6b6afd Unset phone and visible-password keyboardType flags on Android
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Attempted fix for issue #17248

Added unit tests that cover the affected function and manually repeated the reproduction steps found in the issue.

Note: I had to apply the attached patch file to actually *run* the tests because they were not enabled. I didn't include this in the PR because it seemed like a secondary problem with possible ramifications (see comment near patched line) beyond this issue. For example, other, unrelated tests break when that line is uncommented.
[textInputTestEnable.patch.txt](https://github.com/facebook/react-native/files/1565807/textInputTestEnable.patch.txt)

If I should apply the patch to this PR or re-enable the tests in some other fashion, please let me know and I can do so.

(none)

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[ANDROID] [BUGFIX] [TextInput] - Fix an issue when swapping to and from the `'visible-password'` or `'phone-pad'` keyboard types.
Closes https://github.com/facebook/react-native/pull/17249

Differential Revision: D6713008

Pulled By: hramos

fbshipit-source-id: 85eeb5398748d48e59d33eb86d851fd02d587a31
2018-01-12 11:32:52 -08:00
Sergei Dryganets 9024f56bda Fix crash due to mishandling of UTF-8 in progressive download.
Summary:
Fixes:
```
Fatal Exception: java.lang.RuntimeException: Failed to create String from JSON
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
       at android.os.Looper.loop(Looper.java:234)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:193)
       at java.lang.Thread.run(Thread.java:818)
```
JavaScriptCore is very strict about invalid UTF symbols.
So if you pass an invalid UTF-8 string to it the string will be decoded as an empty string.

The current implementation of progressive downloading for Android blindly cuts the response in 8KB chunks.
That could cause a problem in case the last symbol in the chunk is multi-byte.

To prevent it I added a class which determines if this is the case and cut the string in the appropriate place.
A remainder is prepended to the next chunk of data.

This should fix the root cause of this issue:
https://github.com/facebook/react-native/issues/10756
Closes https://github.com/facebook/react-native/pull/15295

Differential Revision: D6712570

Pulled By: hramos

fbshipit-source-id: f07fcf0f011c2133c8e860ceb0588a29d36d07fb
2018-01-12 11:10:04 -08:00
Sergei Dryganets c8e98bbaf5 CI for Android fixed
Summary:
Fix for android github CI.

Github CI doesn't work without this change.

CI passes.

[INTERNAL] Android CI fix.
Closes https://github.com/facebook/react-native/pull/17551

Differential Revision: D6707477

Pulled By: hramos

fbshipit-source-id: f98515234da3b90ee3233523bcd7cc67ed82c1b4
2018-01-12 08:01:00 -08:00
Igor Ganapolsky 7abffc3f8c punctuation and grammar
Summary:
Use a comma for clear punctuation, and use 'wants' verb.

<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Use clear grammar for README file

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/react-native-website, and link to your PR here.)

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/17545

Differential Revision: D6711711

Pulled By: hramos

fbshipit-source-id: 315f66e5b36c4a3ffdc5407876cc0fc2ed596a56
2018-01-12 08:01:00 -08:00
Attila Jakabfi 2a22d998f8 Spacing
Differential Revision: D6683074

fbshipit-source-id: a76bc5028962d738bb931a997752f6ba194bd8ed
2018-01-12 05:13:21 -08:00
Sergei Dryganets d5e3f081c6 Fix #6228: Crash in Android dialog module.
Summary:
Android dialog module has a race condition as a result of which it crashes.
See this issue:
https://github.com/facebook/react-native/issues/6228.

The mIsInForeground flag is set on UI thread but was used from the ReactMethod thread.
Now all public methods of FragmentManagerHelper called from UI thread only.
Asserts are added in appropriate places to prevent future regressions.

Make sure that dialogs work after this change.
It will be nearly impossible to reproduce the issue manually but automatic regression tests should be able to catch this. At least our tests were crashing on some dialog scenarios from time to time.

[ANDROID] [MINOR] [BUGFIX] - Race condition fix in Android Dialogs module.
Closes https://github.com/facebook/react-native/pull/17392

Reviewed By: achen1

Differential Revision: D6708787

Pulled By: mdvacca

fbshipit-source-id: 99beb3ea3046286cc973f7677e98ff36f162b09b
2018-01-11 18:57:31 -08:00
Andrew Chen (Eng) f363dfe766 Fix redbox style
Differential Revision: D6689447

fbshipit-source-id: de6b1295e53c46bdf99f0f4a26130f516763ee66
2018-01-11 15:42:17 -08:00
Andrew Chen (Eng) e3c27f585a Add Context to Redbox report api
Differential Revision: D6700021

fbshipit-source-id: b8ba8242a68c02e608900c93a7645d61158cc0cb
2018-01-11 15:17:46 -08:00
Emil Sjölander 1c3f6acfe5 Expose more android device infos
Reviewed By: fkgozali

Differential Revision: D6692907

fbshipit-source-id: ecbcf763aae2035c9526e891d0cc14a987b6d4c1
2018-01-11 04:16:39 -08:00
Tim Yung 7e9242bd1a RN: Fix `borderRadius` for Image Background (Android)
Differential Revision: D6701597

fbshipit-source-id: 462b578c3b988c5fa7e3d25e4a6425d170ab4b62
2018-01-11 00:41:52 -08:00
David Vacca c249e52096 Fix BadTokenException when redbox was dismissed and re-displayed
Reviewed By: achen1

Differential Revision: D6690662

fbshipit-source-id: d3e3fa4108d832da0a6d9e290263121ba86afbf4
2018-01-10 16:46:35 -08:00
Steven Cable 22735f6903 Fix DeviceInfoModule LifecycleEventListener
Summary:
Fixes one of the two parts of [issue posted here](https://github.com/facebook/react-native/issues/17209).  Motivation is that we wanted our app to be able to handle user changing font size while the app is running.  Yes, we know that changing font size doesn't inherently trigger a re-render, but at the minimum it should cause `PixelRatio.getFontScale()` to return an updated value.

1. Render an interface and invoke `PixelRatio.getFontScale()`
2. Change the font scale in Settings > Accessibility > Font Size
3. Return to the React Native app (without reloading Javascript) and invoke `PixelRatio.getFontScale()` again.
4. Verify that the result of `PixelRatio.getFontScale()` has changed to reflect the new font size.

For a video of the problem, see the linked issue under the Motivation heading.  In this fixed version, the number actually does update as expected.

None.  This should require no documentation change, as it is behavior that the docs seem to indicate should be happening already.
In fact, [the documentation at the bottom of this page](https://facebook.github.io/react-native/docs/native-modules-android.html) appears to already indicate that this should be done for anything implementing LifecycleEventListener.

[ANDROID] [BUGFIX] [DeviceInfo] - Fix the DeviceInfoModule to properly respond to LifecycleEvents
Closes https://github.com/facebook/react-native/pull/17227

Differential Revision: D6692358

Pulled By: hramos

fbshipit-source-id: 3db212fe8103c7aa29a29ead6c772abb7ae4cd85
2018-01-10 05:32:09 -08:00
James Ide 7f58189605 Change inlined `okhttp3.Headers` references to a Java import
Summary:
In BundleDownloader.java, there were references to `okhttp3.Headers` instead of importing the class at the top of the file. This PR is a simple change to use an import instead.

Compile the Android app

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/react-native-website, and link to your PR here.)

[ANDROID][MINOR][BundleDownloader] - Use Java import instead of fully qualified class name
Closes https://github.com/facebook/react-native/pull/17507

Differential Revision: D6691593

Pulled By: hramos

fbshipit-source-id: 81b366db608b7be8a903d2f25b36ca5642d9eec3
2018-01-09 23:54:57 -08:00
Andrew Chen (Eng) b0319f3293 Fix ReactScrollView lints
Differential Revision: D6689492

fbshipit-source-id: c55f98f3ed25757ec192a023d2dd60c73aae8df2
2018-01-09 18:52:38 -08:00
David Vacca b2848a54b0 Adding support to float values for Android snapToInterval
Reviewed By: fkgozali

Differential Revision: D6684529

fbshipit-source-id: 51efa0a2d38acf4134bb824c462973e5c6bdf17a
2018-01-09 12:32:53 -08:00
David Vacca e5c2a66897 Fix Modal not disappearing when navigating from inside a Modal to another activity
Reviewed By: achen1

Differential Revision: D6668368

fbshipit-source-id: 809e9c978032e731478bcc8e290eb030e4ee6eca
2018-01-08 10:00:49 -08:00
David Vacca 0356cbd13b Fix BadTokenException when displaying warning messages
Reviewed By: achen1

Differential Revision: D6651871

fbshipit-source-id: fc7fc118999f0e752636a3142764bd3496e5dc81
2018-01-05 16:08:17 -08:00
Wesley Walser c49d249fd7 Send scroll velocity data to Javascript on momentum scroll events.
Reviewed By: sahrens

Differential Revision: D6643379

fbshipit-source-id: 70550274975ed7c2b43a3d668422102d0c115ba7
2018-01-05 10:46:03 -08:00
David Vacca e57a43b97a Revert D6531148: Fix BadTokenException and IllegalArgmentException thrown when showing or dismissing Modal
Differential Revision: D6531148

fbshipit-source-id: a90cc38f98d6b86151539abd2a07bfcf1c253a5f
2018-01-04 17:31:17 -08:00
Josh Hargreaves c9ff0bc212 Implement onKeyPress Android
Summary:
This implements onKeyPress for Android on TextInputs and addresses https://github.com/facebook/react-native/issues/1882.
**N.B. that this PR has not yet addressed hardware keyboard inputs**, but doing will be fairly trivial. The main challenge was doing this for soft keyboard inputs.

I've tried to match the style as much as I could. Will happily make any suggested edits be they architectural or stylistic design (edit: and of course implementation), but hopefully this is a good first pass :).
I think important to test this on the most popular keyboard types; maybe different languages too.
I have not yet added tests to test implementation, but will be happy to do that also.

- Build & run RNTester project for Android and open TextInput.
- Enter keys into 'event handling' TextInput.
- Verify that keys you enter appear in onKeyPress below the text input
- Test with autocorrect off, on same input and validate that results are the same.

Below is a gif of PR in action.
![onkeypressandroid](https://user-images.githubusercontent.com/1807207/27512892-3f95c098-5949-11e7-9364-3ce9437f7bb9.gif)
Closes https://github.com/facebook/react-native/pull/14720

Differential Revision: D6661592

Pulled By: hramos

fbshipit-source-id: 5d53772dc2d127b002ea5fb84fa992934eb65a42
2018-01-04 12:51:38 -08:00
Jimmy Zhuang ddd65f1ba9 Support snapToInterval for horizontal scrollview on Android
Summary:
`snapToInterval` is available on iOS but on android yet. This PR is to add support for `snapToInterval` on android.

Example:

![android_snap](https://cloud.githubusercontent.com/assets/1699429/19086983/39d3ee1c-8a25-11e6-9c84-20f25a751f32.gif)

TO: lelandrichardson spikebrehm
Closes https://github.com/facebook/react-native/pull/10242

Differential Revision: D4168527

fbshipit-source-id: de3dd9ac5d9e0fddfce5e5bc0aa6a4f33f1e30b3
2018-01-03 10:33:07 -08:00
Héctor Ramos f9e742aadf Fix buck failure
Summary:
Buck is failing due to missing args: https://circleci.com/gh/facebook/react-native/29268
Closes https://github.com/facebook/react-native/pull/17346

Differential Revision: D6642181

Pulled By: hramos

fbshipit-source-id: 399d3c5f197ae0de9748a592def945c14ac1d348
2017-12-28 08:31:28 -08:00
Alex Dvornikov 80f9e1f7de remove "prepareReact" call from the Android bridge
Reviewed By: alexeylang

Differential Revision: D6596304

fbshipit-source-id: 0285611cfdd66ce5bdfa503c9fe8f1963a0c583f
2017-12-26 14:47:30 -08:00
Taras Tsugrii a6a66c5b39 Remove last usages of cxx_library.
Reviewed By: mzlee

Differential Revision: D6632262

fbshipit-source-id: 1ec3ba232e573b9cbc892f23827f9a7c5df34106
2017-12-23 19:41:31 -08:00
Taras Tsugrii 077c3ab349 Define internal FB macro for OSS builds.
Reviewed By: hramos

Differential Revision: D6626785

fbshipit-source-id: bb7c89499bc7c72e24dabd82899c3d9c49874101
2017-12-22 08:47:50 -08:00
Héctor Ramos c547f783c4 Update Docker images to latest Android SDK, Buck
Summary:
Test Plan

Rebuilt Docker images locally, confirmed successful image build.

Can later be reproed with

```
npm run test-android-setup
npm run test-android-build
npm run test-android-run-unit-tests
```

Note that unit tests are failing in master, but in this PR we can repro the same failure.
Closes https://github.com/facebook/react-native/pull/17313

Differential Revision: D6624899

Pulled By: hramos

fbshipit-source-id: 42b8cd708ec2a02399bb6ef30fd73faba2646f79
2017-12-21 17:31:32 -08:00
Krzysztof Magiera 7ff6657985 Add top offset for react loading view on Kitkat
Summary:
This PR fixes the problem with dev loading view on KitKat and older Android devices after #16596

Install RNTester app on Android API 19 or lower device. See green loading view show up under status bar. Do the same with full screen theme set and see it show up correctly at the top of the screen.
Verify the green loading bar displays correctly on devices with API > 19 too.

This fixes an issue introduced in #16596

[ANDROID][MINOR][DevSupport] - Fix green dev loading bar on Android Kitkat and below
Closes https://github.com/facebook/react-native/pull/17305

Differential Revision: D6621077

Pulled By: achen1

fbshipit-source-id: 3b4216af535d7db5c96d137f20004fe2651b1dc9
2017-12-21 12:36:15 -08:00
Taras Tsugrii ba31d29dc9 Replace native cxx_library with fb-specific macros.
Reviewed By: adamjernst

Differential Revision: D6618153

fbshipit-source-id: 188e2ca3cc78efad6e71f0a22547e26abf2f62e1
2017-12-21 08:58:50 -08:00
Ram N 4996b9aeb4 On Android, seperate logic to initialize JS from starting the app
Reviewed By: achen1

Differential Revision: D6606265

fbshipit-source-id: d432661b5f8aa2b7600b1140e1617aab852f343e
2017-12-19 20:31:15 -08:00
Pritesh Nandgaonkar f1055bcac8 Make YGNode as c++ struct with properties exposed through accessors
Reviewed By: emilsjolander

Differential Revision: D6592257

fbshipit-source-id: 641e8b9462ad00731a094511f9f5608b23a6bb21
2017-12-19 11:32:49 -08:00
Ben Nham bef7967f9a move page registration logic in to jsinspector
Reviewed By: pakoito

Differential Revision: D6531199

fbshipit-source-id: ed1ae9e2f0c19e7656cd022e438693798320e55a
2017-12-15 09:20:13 -08:00
Max Sherman b952365ba6 std::string to const char*
Reviewed By: danzimm

Differential Revision: D6570194

fbshipit-source-id: 84dae925b9269393b6925e0977598e3872acb14e
2017-12-14 13:36:51 -08:00
Shin-Kai Chen 29f3f55298 Do not overwrite the same text in ReactEditText
Differential Revision: D6516674

fbshipit-source-id: 246b8efeff7963912bf6b1c8a004c3103be03246
2017-12-11 21:45:37 -08:00
Ramanpreet Nara cb49877a25 Backed out changeset 4fe617216293
Reviewed By: fred2028

Differential Revision: D6539205

fbshipit-source-id: c97d4f3dbd457f59968991b043d7106e551effad
2017-12-11 18:02:02 -08:00
David Vacca c465599a27 Fix BadTokenException and IllegalArgmentException thrown when showing or dismissing Modal
Reviewed By: achen1

Differential Revision: D6531148

fbshipit-source-id: 1d3f6e041ac68ad13120c56ea5223557fca34f0d
2017-12-11 09:46:30 -08:00
Krzysztof Magiera d19afc73f5 Use currentActivity to display redbox, loading view and dev menu
Summary:
This change aims at replacing SYSTEM_ALERT_WINDOW/OVERLAY API being used for rendering dev support related views on Android (redbox, dev menu, green loading view) with API that does not require any special permission. The permission is still used for displaying perf monitor, although it is no longer requested at app startup but only when perf monitor gets enabled.

This change should not affect the way react native apps work in production environment as in release mode all dev support functionality is disabled.

There are two main reasons why requiring SYSTEM_ALERT/OVERLAY permission for displaying basic dev related windows is problematic:
 1) On Android >=6 devices it is required that overlay permission is granted in device settings for apps being side loaded (not installed via play store which is usually the case for apps being developed). Although this setting is not available on some Android devices including Google's stock Android TV version. On such devices App cannot be granted rights to draw in system alert window which cases the app to crash (instead of showing a redbox or dev menu dialog)
 2) Some Android device vendors have issues with implementation of `Settings.canDrawOverlays` that always return false (I've seen it on Xiaomi Redmi 4A with Android 6.1). This issue because of the following code in [ReactActivityDelegate.java#L90](1e8f3b1102/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java (L90)), results in the overlay permission settings screen popping up every time the app is launched even though the permission has been perviously granted which is extremely annoying. Since this change only require overlay permission for displaying perf monitor we no longer ask for it on startup but only when user switches perf monitor ON.

Test need to be performed on pre Android 6 and post Android 6 devices.

1. Run app with devserver off -> should result in redbox
2. Start packager with --reset-cache flag for the loading bar to be visible for some longer period of time. Then restart the app and see the loading bar show up
3. While the app is running, open dev menu, navigate to "dev settings", test "reload"
4. Modify JS app such that the app crashes, see it display redbox properly. Check if "reload" button works well from the redbox
5. Verify that "Show Perf Monitor" option works as expected. On Android >=6 re-install the app to see it ask for overlay permission at the moment when perf monitor option gets selected.

 - SYSTEM_ALERT_WINDOW permission will no longer be required on Android to display Redbox

 This change can break things for framework users who provide custom implementation of DevSupportManager interface on Android:

- **Who does this affect**: Owners of apps that use custom implementation of DevSupportManager interface on Android.

- **How to migrate**: Update `create` method of your `DevSupportManager`'s factory to take `ReactInstanceManagerDevHelper` type as a second argument instead of `ReactInstanceDevCommandsHandler`. The interface `ReactInstanceDevCommandsHandler` has been renamed to `ReactInstanceManagerDevHelper` but kept all the methods the same (new method got added). If you were calling one of three methods from `ReactInstanceDevCommandsHandler` interface (`onReloadWithJSDebugger`, `onJSBundleLoadedFromServer` and `toggleElementInspector`) you can call exact same methods directly on `ReactInstanceManagerDevHelper` instance that is being provided in exchange for `ReactInstanceManagerDevHelper `.

- **Why make this breaking change**:
This PR adds a new method to `ReactInstanceManagerDevHelper` called `getCurrentActivity`. In which case the prev name can no longer be justified. The activity is required for some of the DevSupportManager methods in order to start new dialogs and popups so that overlay permission isn't necessary.

- **Severity (number of people affected x effort)**:
Relatively small (perhaps Fb internally is using DevSupportManager abstraction to provide an alternative implementation but since it isn't documented I doubt anyone else uses it). Effort it very low as it boils down to updating uses of interface `ReactInstanceDevCommandsHandler` with `ReactInstanceManagerDevHelper` (all the methods in `ReactInstanceDevCommandsHandler` stays the same)
Closes https://github.com/facebook/react-native/pull/16596

Differential Revision: D6256999

Pulled By: achen1

fbshipit-source-id: 551d449e831da3de466726ead172608527fcfbb4
2017-12-07 18:39:46 -08:00
Paco Estevez Garcia 3d5dc872a4 Add callback for Connection/Disconnection to Metro
Reviewed By: bnham

Differential Revision: D6447126

fbshipit-source-id: d4c8a4dfb65c2a378f7fe696c8617ff5f3c6cb68
2017-12-07 09:52:08 -08:00
Jonathan Keljo 71006f74cd Fixes for migrating to Buck's source-only ABI feature
Reviewed By: dreiss

Differential Revision: D6475725

fbshipit-source-id: ac6725bbaaf2dbd78512a67497fbfcc044f59f60
2017-12-05 10:34:12 -08:00
Paco Estevez Garcia 7c7108a1e8 Add inspector attach to RN Dev Menu (Android)
Reviewed By: Hypuk

Differential Revision: D6405828

fbshipit-source-id: 9274c3e8748e6ce259357836dde7d53c4fce9fbf
2017-12-05 07:03:48 -08:00
Petter Hesselberg 5b83dbe25a Update stale JavaDoc reference
Summary:
I don't like JavaDoc errors

N/A; Change does not touch executable code
Closes https://github.com/facebook/react-native/pull/17023

Differential Revision: D6472273

Pulled By: shergin

fbshipit-source-id: 3131e17ca9925c42def02047082378fb3169c82b
2017-12-03 21:01:15 -08:00
Cory Reed d2f0abdf4e Fix Android comment and docblock typos
Summary:
👋 Hello! Thanks for react-native, it’s a great project.

I was digging into the Android implementation in _ReactAndroid_ and noticed a couple typos in the documentation. I went through and tried to fix all the typos I could find using [aspell](http://aspell.net).

Not applicable: these changes are only to comments, and CI should be skipped.

[ANDROID][ENHANCEMENT][*] - Correct comment and docblock typos
Closes https://github.com/facebook/react-native/pull/17049

Differential Revision: D6472182

Pulled By: shergin

fbshipit-source-id: 7e62cab118609596b483d1cf16c3abf651d6753b
2017-12-03 20:16:36 -08:00
Jonathan Keljo 801cbdb047 Autofixes for migrating to Buck's source-only ABI feature
Reviewed By: asp2insp

Differential Revision: D6441284

fbshipit-source-id: cfc96c5eb93a7260705fabc361763405c9fb38c6
2017-12-01 21:03:07 -08:00
Andres Suarez d674d48a7b Run buildifier over all BUCK files
Reviewed By: mzlee, dinhviethoa

Differential Revision: D6439498

fbshipit-source-id: ec847595afdd79434e48652d237d2533bbd2cad2
2017-11-29 20:30:43 -08:00
Ramanpreet Nara ca7fe72c31 Fix border-rendering in APIs < 18 cont.
Reviewed By: achen1

Differential Revision: D6418192

fbshipit-source-id: 2186a6103d6542f5ced332d5cb083b1f58bfd43d
2017-11-27 17:51:15 -08:00
Valentin Shergin 0bef872f3f TextInput: Fixed autoscroll to cursor on Android
Summary:
This feature was disabled for multiline textinputs in D3528202 ... seems without a good reason.
The broken autoscroll-to-cursor feature is terribly harmful and counter-intuitive in ALL cases.
I also add a contentSize tracking in the example app to make sure that it is unaffected by this change.

https://pxl.cl/9RHP

https://github.com/facebook/react-native/issues/12799
https://github.com/facebook/react-native/issues/15778

Special thanks to konradkierus!

Reviewed By: sahrens

Differential Revision: D6405985

fbshipit-source-id: 337a390a9db7b3528200ef66c4a079b87608294e
2017-11-27 16:46:43 -08:00
Alexey Lang 028b64bcd3 Fix logging unpacking time when it happens concurrently with eager unpacking
Reviewed By: dcaspi

Differential Revision: D6413546

fbshipit-source-id: 9ae167ea2f816b070da29cf81f653af568aed01a
2017-11-27 12:32:32 -08:00
Ben Nham 70c359000a move inspector out of jschelpers
Differential Revision: D6385924

fbshipit-source-id: 1913d903077494cc0d86d5a8c8839620f1ecab0c
2017-11-27 07:23:37 -08:00
Lukas Wöhrl 1050e0b476 Add justify-content: space-evenly
Summary:
Adds new ```space-evenly``` for ```justify-content```.

Also adds a typofix in one of the other justify-content tests.

Fixes #657
Closes https://github.com/facebook/yoga/pull/658

Differential Revision: D6407996

Pulled By: emilsjolander

fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
2017-11-27 04:01:02 -08:00
Dmitry Zakharov dd888d3346 Fix boolean conversion in sync RN method calls.
Reviewed By: fromcelticpark

Differential Revision: D6408182

fbshipit-source-id: 251ab0cfe3197e59de0cb86816d5f0b908433b43
2017-11-24 12:31:41 -08:00
David Detlefs 05e862d48d Add Systrace-based telemetry to Hermes GC.
Reviewed By: amnn

Differential Revision: D6393879

fbshipit-source-id: d35a4647d000356dc99bce3187acc50d3a69ddeb
2017-11-23 15:15:54 -08:00
Rafael Oleza 968c88d141 Enable end to end deltas by default on Android
Reviewed By: mjesun

Differential Revision: D6406466

fbshipit-source-id: ab776d9ea89ed2ab83b8ede78be4e5d5f3074e34
2017-11-23 13:04:48 -08:00
James Reggio dc01eff72d Fix crash with non-zero blurRadius less than 1
Summary:
There's a crash-inducing bug with `Image.blurRadius` on Android.

`blurRadius` is specified in JavaScript as a `float`, but it's cast to `int` before being passed to the `IterativeBoxBlurPostProcessor`. However, in `IterativeBoxBlurPostProcessor`, there is an argument precondition requiring the integer `blurRadius` to be non-zero.

Because the `== 0` condition is evaluated on the `float`, it's possible for a `blurRadius` in the range of `(0, 1)` (non-inclusive) to pass the conditional, and then be truncated to `0` and passed as an argument to `IterativeBoxBlurPostProcessor`, which will fail its precondition and crash the app.

This change works in our app, which was previously crashing.

[ANDROID] [BUGFIX] [Image] Fixed crash when specifying an Image.blurRadius between (0, 1)
Closes https://github.com/facebook/react-native/pull/16845

Differential Revision: D6387416

Pulled By: shergin

fbshipit-source-id: d5191aa97e949ffd41e6d68c96b3c7bcbc82a52e
2017-11-21 12:30:49 -08:00
Ramanpreet Nara 5aa1fb3ff3 Fix border-rendering in APIs < 18
Summary:
`Canvas.clipPath` isn't supported with hardware acceleration in APIs below 18. The rounded border rendering logic for Android relies on this method. Therefore, rounded borders do not render correctly on such devices.

**Screenshot of Nexus 5 running API 17 (Before these changes):**
https://pxl.cl/9rsf

**The fix**: If the API version is less than 18 and we're rendering rounded borders, I disable hardware acceleration. Otherwise, I enable it. I'm going to check to see if this has perf regressions by running a CT-Scan.

With this change, rounded borders render correctly on Android devices running versions of Android between Honeycomb to JellyBean MR2.

**Screenshot of Nexus 5 running API 17 (After these changes):**
https://pxl.cl/9rrk

Reviewed By: xiphirx

Differential Revision: D6153087

fbshipit-source-id: 16e35be096051ac817c8b8bcdd132ecff3b4b167
2017-11-21 11:17:03 -08:00
Gabriel Peal 1e18d907bf Prevent a crash when no cursor drawable is set
Summary:
React Native 0.43 added additional functionality to setSelectionColor that also tints the cursor drawable of the View. However, some views may not have a cursor drawable set in which case, the code will crash when attempting to load a drawable with resource id 0.

We encountered this in our RN 0.45 upgrade in the Airbnb app.

lelandrichardson
Closes https://github.com/facebook/react-native/pull/14789

Differential Revision: D6386076

Pulled By: shergin

fbshipit-source-id: faa5a1edb3be8d08988f46205c0f22d17b63b5bc
2017-11-21 10:36:10 -08:00
Rafael Oleza f587f8d51d Enable end to end deltas by default on Android
Reviewed By: mjesun

Differential Revision: D6374111

fbshipit-source-id: f372242ddbb8a278041d1ebb2aace227a571c2e0
2017-11-20 13:16:11 -08:00
Dmitry Zakharov f1015664e9 Fix crash when destroying catalyst
Reviewed By: fromcelticpark

Differential Revision: D6373275

fbshipit-source-id: c36b53f023800097b301d530250b05e5b2a4dfca
2017-11-20 07:38:53 -08:00
Alexander Komissarov ad89ea7b50 check if listener is still in the set before calling onHostResume
Reviewed By: achen1

Differential Revision: D6341419

fbshipit-source-id: e49188803bbf3641bad6a9cc8c497d453798bbce
2017-11-17 11:20:45 -08:00
Rafael Oleza 231c7a0304 Add end to end Delta support to Android devices
Reviewed By: davidaurelio

Differential Revision: D6338677

fbshipit-source-id: 8fa8f618bf8d6cb2291ce4405093cad23bd47fc3
2017-11-17 07:47:38 -08:00
allengleyzer 3e4cf0e8d2 Added progress updates for all XMLHttpRequest upload types
Summary:
Previously, only form-data request bodies emitted upload progress updates. Now,
other request body types will also emit updates.

Addresses issues:
https://github.com/facebook/react-native/issues/15724
https://github.com/facebook/react-native/issues/11853

This is a bug fix for functionality that's missing on Android. These events are already working correctly on iOS.

Run the following code on Android, and ensure that events are being sent:
```
const fileUri = 'file:///my_file.dat';
const url = 'http://my_post_url.com/';
const xhr = new XMLHttpRequest();

xhr.upload.onprogress = (event) => {
    console.log('progress: ' + event.loaded + ' / ' + event.total);
}

xhr.onreadystatechange = () => {if (xhr.readyState === 4) console.log('done');}

console.log('start');

xhr.open('POST', url);

xhr.send({ uri: fileUri }); // sending a file (wasn't sending progress)
xhr.send("some big string"); // sending a string (wasn't sending progress)

const formData = new FormData(); formData.set('test', 'data');
xhr.send(formData); // sending form data (was already working)
```

[ANDROID] [BUGFIX] [XMLHttpRequest] - Added progress updates for all XMLHttpRequest upload types

Previously, only form-data request bodies emitted upload progress updates. Now,
other request body types will also emit updates.

Addresses issues:
https://github.com/facebook/react-native/issues/15724
https://github.com/facebook/react-native/issues/11853
Closes https://github.com/facebook/react-native/pull/16541

Differential Revision: D6325252

Pulled By: hramos

fbshipit-source-id: 4fe617216293e6f451e2a1af4fa872e8f56d4f93
2017-11-14 11:01:17 -08:00
Dmitry Zakharov cfa2bbf2f6 Remove minNumShakes from ReactInstaneManager
Reviewed By: kathryngray

Differential Revision: D6313521

fbshipit-source-id: ffef1f96fbec88cdcc7597fa81505aee59e10bb8
2017-11-14 09:38:03 -08:00
Dmitry Zakharov 4f886a29a1 Remove android_react_native_perf.use_separate_ui_bg_thread experiment.
Reviewed By: AaaChiuuu

Differential Revision: D6313250

fbshipit-source-id: 583a729a157a2053827631a43e38917753e78477
2017-11-14 06:58:46 -08:00
Dmitry Zakharov 053776338e Cleanup ReactInstanceManager
Reviewed By: kathryngray

Differential Revision: D6296922

fbshipit-source-id: 2fbf11f09a3c25ff3e7c222edc2e01b81e687943
2017-11-14 05:46:08 -08:00
Dmitry Zakharov 4894ac430d Remove splitting to BridgeCorePackage and ReactNativePackage.
Reviewed By: kathryngray

Differential Revision: D6286129

fbshipit-source-id: 8d75e610291402ccbffb137ce46e64d11826b950
2017-11-14 04:56:43 -08:00
Alex Dvornikov a47431ed74 Adopt split segments registration approach on Android
Differential Revision: D6284863

fbshipit-source-id: 0df6b90eb0cbeab4c8a2b11f1e4dcbd5d5dfab72
2017-11-09 12:23:51 -08:00
Alex Dvornikov cff0d8e0e5 Register split segment paths with RAMBundleRegistry
Differential Revision: D6284466

fbshipit-source-id: c80cf929af38f92f06cca5b366c58785ae992d83
2017-11-09 12:23:46 -08:00
Dmitry Zakharov 260e6d2355 Remove shared bridge experiment
Reviewed By: kathryngray

Differential Revision: D6284437

fbshipit-source-id: 14e0516f22dde04c0bbc4eb8fac603590d32d66a
2017-11-09 09:55:05 -08:00
Ramanpreet Nara 7170543e80 Make direction-aware borders work with APIs >= 17
Reviewed By: achen1

Differential Revision: D6189497

fbshipit-source-id: 848ca35540c5a4eb1581e0b7c39f8fa880540317
2017-11-08 10:31:21 -08:00
Alex Dvornikov 6ecae73fe5 Remove RAMBundleRegistry subclasses
Differential Revision: D6262247

fbshipit-source-id: 708f919e34f1706d9aca19a34ad8ea506e9f8d8b
2017-11-08 04:12:20 -08:00
Brent Erickson e6f542d620 When subscribing for network connectivity broadcasts, also query the value so we always have the most up-to-date value.
Summary:
We've seen cases (based on logs) where NetInfo is reporting no connectivity, but network requests still work. This will keep status up to date after app foreground <-> backgrounds, since we don't listen to broadcasts when backgrounded.

This is rather difficult to test given we haven't nailed an internal repro (evidence is solely based on device/app logs).  Testing has been done to ensure that there are no behavioural changes on devices that were previously working (no regressions).
Closes https://github.com/facebook/react-native/pull/15558

Differential Revision: D6264708

Pulled By: hramos

fbshipit-source-id: 1648cadb59949103d0a595614b38024ec9236719
2017-11-07 14:56:23 -08:00
Dmitry Zakharov 1b71e03932 Make RN Events registered disregarding ViewManager use pattern.
Reviewed By: fromcelticpark

Differential Revision: D6260009

fbshipit-source-id: f3d00162f8473976264ebef040d01163950f2170
2017-11-07 11:32:34 -08:00
Omri Gindi a6465d1c17 Backed out changeset 322626be193e
Reviewed By: wutalman

Differential Revision: D6258856

fbshipit-source-id: 392dc91f87148c70817f13858a7fcd368f028b2d
2017-11-07 04:53:40 -08:00
Alex Dvornikov f1258181ee Rename "js-bundles" to "js-segments"
Differential Revision: D6244399

fbshipit-source-id: d1606d126e3b598b19fa8a0955438c8dec76f5d0
2017-11-06 18:25:52 -08:00
Marc Horowitz 515eb0e801 Fix a race condition in the animation module
Summary:
update() is called from the choreographer, so it can be
invoked asynchronously relative to RN.  If it's called while the node
tree is incomplete, this can be called with no parent.  Don't treat an
unparented node as an invariant failure, just skip over it.

Reviewed By: AaaChiuuu

Differential Revision: D6249038

fbshipit-source-id: d22807dff1659bf29a81893ab97d0fe7c19de512
2017-11-06 13:49:46 -08:00
Dmitry Zakharov fdf04953c0 Make RN Events registered disregarding ViewManager use pattern.
Reviewed By: bvaughn

Differential Revision: D6223864

fbshipit-source-id: 322626be193e5fa840d3e5477e86adaa90f2726d
2017-11-06 06:40:19 -08:00
Bartol Karuza 3f1b021506 Inverted descent/ascent Android prioritisation to match iOS lineHeight behaviour
Summary:
We noticed that on Android the lineHeight behaviour is different from iOS for built in fonts and custom fonts. The problem becomes visible when the lineHeight approaches the fontSize, showing a cut-off on the bottom of the TextView. This issue has been raised before in #10712. There is a mention of a PR with a fix in that issue, which has not been merged yet. This implementation is a less intrusive fix leaving the current lineHeight approach in place and fixing the discrepancy only.

This proposed change prioritises ascent over descent for reduction, making the lineHeight functionality behave identical to iOS.

There is no existing test covering the lineHeight property and its behaviour in the CustomLineHeightSpan. This PR contains new unit tests that covers the various scenario's for the lineHeight calculations.

The original behaviour, before the change can against these unit tests. The case that fails is `shouldReduceAscentThird`, which can be made to succeed on the old code by changing the asserts to:
```
    assertThat(fm.top).isEqualTo(-5);
    assertThat(fm.ascent).isEqualTo(-5);
    assertThat(fm.descent).isEqualTo(-4);
    assertThat(fm.bottom).isEqualTo(-4);
```
The unit test succeeds for the current implementation, which has the values for ascent and descent inverted.

Below screenshots show before, after and iOS:

BEFORE
![screen shot 2017-10-18 at 15 35 41](https://user-images.githubusercontent.com/1605731/31721688-58d7086a-b41a-11e7-8186-9a201e2acb01.png)

AFTER
![screen shot 2017-10-18 at 15 37 02](https://user-images.githubusercontent.com/1605731/31721665-473cf86c-b41a-11e7-94d5-7a70eaf99889.png)

iOS
![screen shot 2017-10-18 at 15 35 22](https://user-images.githubusercontent.com/1605731/31721712-707e30a6-b41a-11e7-9baa-f886a66837e6.png)

[ANDROID] [BUGFIX] [Text] - Fix the lineHeight behaviour on Android to match iOS
Closes https://github.com/facebook/react-native/pull/16448

Differential Revision: D6221854

Pulled By: andreicoman11

fbshipit-source-id: 7292f0f05f212d79678ac9d73e8a46bf93f1a7c6
2017-11-06 05:00:41 -08:00
Dan Caspi 19de7fcb22 Moving some RAM logic to Instance.
Reviewed By: michalgr

Differential Revision: D6208977

fbshipit-source-id: 28339d07c58f1acc816be02f2707ef75529fa069
2017-11-03 05:32:02 -07:00
Alex Dvornikov b5651d945c Add "setJsBundlesDirectory" method to CatalystInstanceImpl
Differential Revision: D6042493

fbshipit-source-id: 950c6d6bdc2e0b62b14c9bcfc86233159a002c67
2017-11-01 06:54:44 -07:00
Pritesh Nandgaonkar 0230672275 Reverting the dirty child optimization
Reviewed By: emilsjolander

Differential Revision: D6203290

fbshipit-source-id: 8e42abb70e55f0fac90faaa21ecdbe0fbb76ce6b
2017-10-31 23:15:43 -07:00
Pritesh Nandgaonkar 587225ab45 Used hasDirtyChildren tag for the optimization
Reviewed By: emilsjolander

Differential Revision: D6134754

fbshipit-source-id: bbcfee14058140b946401de756a3f130de0f51cd
2017-10-31 08:21:54 -07:00
Dmitry Zakharov 387a3557ae Remove FlatUI references from fb4a.
Reviewed By: AaaChiuuu

Differential Revision: D6189136

fbshipit-source-id: c92a4d46098ff36ddbf267d150c6fa559a60a1e8
2017-10-31 06:46:06 -07:00
Dmitry Zakharov a5550a56ea Introduce getConstants generation for Native Modules codegen.
Reviewed By: fkgozali

Differential Revision: D6125394

fbshipit-source-id: 13b48c75056868f45394f277d75fb05d167f1c9f
2017-10-30 08:16:48 -07:00
Alexey Lang 9742bcb4ba Remove quicklog
Reviewed By: AaaChiuuu

Differential Revision: D6172832

fbshipit-source-id: d239ce8bef0918d3e90662258b6eabe3502f4897
2017-10-30 08:12:34 -07:00
David Vacca c278020633 Fixing RTL HorizontalScrolling in Android
Reviewed By: astreet

Differential Revision: D6170631

fbshipit-source-id: 254e6ed9a4d6e42b6d1215de1ff63aedb2c07a0a
2017-10-27 12:34:10 -07:00
Jonathan Keljo dd016f334c Automated fixups for Instagram
Reviewed By: dreiss

Differential Revision: D6168048

fbshipit-source-id: 0e51319d93fd697db01ea3933f48cd06a6ffac12
2017-10-27 00:52:40 -07:00
Andrew Chen (Eng) 9b6f160c04 Revert D5638458: Fixing RTL HorizontalScrolling in Android
Differential Revision: D5638458

fbshipit-source-id: f4474a12821cd2c20f57ce3bac5996c327ceaa33
2017-10-26 15:33:10 -07:00
David Vacca 36c951d24f Fixing RTL HorizontalScrolling in Android
Reviewed By: astreet

Differential Revision: D5638458

fbshipit-source-id: 08a5070a362eb43e12140cc204172d0950a1b720
2017-10-26 11:25:22 -07:00
Charles Dick 1c104310fb RN catalyst instance destroy markers
Reviewed By: alexeylang

Differential Revision: D6109891

fbshipit-source-id: 2cd1491381220a80f71f9ab205a2c6a309ed35ae
2017-10-26 10:28:41 -07:00
Dmitry Zakharov f0fb720eaa Introduce mobile config flag to load classes for View Managers
Reviewed By: kathryngray

Differential Revision: D6148468

fbshipit-source-id: d0f919f63922dae4b0720f22fa70ab4a7f67b48a
2017-10-26 08:51:11 -07:00
Ramanpreet Nara efa4d3c222 Rename I18nManager Left/Right swap methods
Reviewed By: fkgozali

Differential Revision: D6140072

fbshipit-source-id: 282dc614c036de8f217a729f21a1bbe92b8afd7d
2017-10-24 20:45:59 -07:00
Andrew Chen (Eng) 90a42396b9 React native shadow tree sonar plugin
Reviewed By: emilsjolander

Differential Revision: D6050845

fbshipit-source-id: 8c041b26ed4eb701830f1aced73d996c71cb3326
2017-10-24 18:34:40 -07:00
Rafael Magalhães ce967c6fbe Requesting permission results into ArrayIndexOutOfBoundsException
Summary:
Reported in Issue #15928

Fixing bug when permission showing dialog and user go to home and re-open minimized app.

1. Ask for permission
2. Minimize app (Press HomeButton)
3. Open app again via shortcut

 [ANDROID] [BUGFIX] [PermissionsModule.java] - Fixed bug when asked for permission Cause: java.lang.ArrayIndexOutOfBoundsException · length=0; index=0
Closes https://github.com/facebook/react-native/pull/16507

Differential Revision: D6133708

Pulled By: shergin

fbshipit-source-id: 9c05d1d5d16fedf718ad5113df69a4df3af62013
2017-10-23 23:30:08 -07:00
Jonathan Keljo 18364e95b7 Export deps to be source-ABI friendly
Reviewed By: dreiss

Differential Revision: D6124559

fbshipit-source-id: f831196724f8e171b86c58af5d2ed7944ecf6b6b
2017-10-23 12:22:53 -07:00
Alexey Lang 95073f8589 Use ReactMarker for all perf logging in the bridge
Reviewed By: AaaChiuuu

Differential Revision: D6030270

fbshipit-source-id: c9fa04d4f2816e4e0a4a14caf41795d0f547a7a0
2017-10-22 04:04:42 -07:00
Tao Huang 7e0b7ef8d0 Fix wrong error code when location service is turned off on Android device
Reviewed By: achen1

Differential Revision: D6106890

fbshipit-source-id: ab6ccdc2625745e4bbcdb0d7fe284de504d09641
2017-10-19 19:52:57 -07:00
Ramanpreet Nara 99d294bf3d Consider negative border radii and widths invalid
Reviewed By: achen1

Differential Revision: D5998369

fbshipit-source-id: d54302777f4eeb13f4521800130c17ac07f1b354
2017-10-19 18:08:25 -07:00
Ramanpreet Nara 00c9c1ad74 Implement direction-aware border clipping
Reviewed By: achen1

Differential Revision: D6015812

fbshipit-source-id: 406ddb12884a1c490cee784c6ef42322bd497b24
2017-10-18 19:33:33 -07:00
Ramanpreet Nara 875f273dba Implement border(Start|End)Color for rounded borders
Reviewed By: achen1

Differential Revision: D6014637

fbshipit-source-id: 33c10ec1f84075e0bb1c1f529aa7231497028380
2017-10-18 19:33:33 -07:00
Ramanpreet Nara 38c2c26d90 Implement rounded border(Start|End)Width
Reviewed By: achen1

Differential Revision: D6013412

fbshipit-source-id: e7aa7a3cd9e3ed72b25664efee59e42792098fbd
2017-10-18 19:33:33 -07:00
Ramanpreet Nara 1a7abcf526 Android: Implement border(Top|Bottom)(Start|End)Radius for RN
Reviewed By: achen1

Differential Revision: D5924734

fbshipit-source-id: 24759326064c11d2cd8948c7a710376ca9f41c63
2017-10-18 19:33:32 -07:00
Ramanpreet Nara 0f467a25ed Android: Implement border(Start|End)Color for RN non-rounded borders
Reviewed By: achen1

Differential Revision: D5921865

fbshipit-source-id: ed964291cba0c701de677c24c54f885cda78e7cc
2017-10-18 19:33:32 -07:00
Ramanpreet Nara 7ed7593b2b Android: Implement border(Start|End)Width for non-rounded borders
Reviewed By: achen1

Differential Revision: D5917755

fbshipit-source-id: 3ec0ab1a1e191f5f6fd956691995e95937a513cc
2017-10-18 19:33:32 -07:00
Ramanpreet Nara 04a8c62313 Android: Implement margin(Start|End) styles for RN
Reviewed By: achen1

Differential Revision: D5907651

fbshipit-source-id: 4df7583483e6f10b5433b9fa9d9345e00ccedd20
2017-10-18 19:33:32 -07:00
Ramanpreet Nara 1ed08d3c01 Android: Implement padding(Start|End) styles for RN
Reviewed By: AaaChiuuu

Differential Revision: D5907207

fbshipit-source-id: c9bb322f94d701463be35fb1ca92aab80f47d8ab
2017-10-18 19:33:31 -07:00
Ramanpreet Nara dc92e69867 Android: Forward RN start/end styles to Yoga
Reviewed By: AaaChiuuu

Differential Revision: D5906097

fbshipit-source-id: 79bd43ea54572eb612e781628551bccf5a4f948d
2017-10-18 19:33:31 -07:00
Ramanpreet Nara 98547d4bcf Implement gating support for direction-aware API changes
Reviewed By: achen1

Differential Revision: D6045083

fbshipit-source-id: 857a43029ad88d2324ec77145a1e30d92b5e8fae
2017-10-18 19:33:31 -07:00
Ramanpreet Nara f7888310d4 Implement border(Left|Right|Top|Bottom)Color for rounded borders
Reviewed By: achen1

Differential Revision: D6009609

fbshipit-source-id: 6a247a14aa48ac2edc637bf064216407a3a9a81f
2017-10-18 19:33:30 -07:00
Ramanpreet Nara 4994d6a389 Implement partial rounded borders
Reviewed By: achen1

Differential Revision: D5982241

fbshipit-source-id: 2f694daca7e1b16b5ff65f07c7d15dd558a4b7e8
2017-10-18 19:33:30 -07:00
Ramanpreet Nara de313f6fdd Fix border clipping
Reviewed By: achen1

Differential Revision: D5992045

fbshipit-source-id: fccd864dbc24592c3cd4df7300aca5096537e1d8
2017-10-18 19:33:30 -07:00
Alexey Lang 52a67db629 Fix Systrace section for Lazy View Managers
Differential Revision: D6088310

fbshipit-source-id: cf14c9cc91068cfabf4e7c1bbae5df7f25e0ced3
2017-10-18 12:18:12 -07:00
Andrew Chen (Eng) 91372e8f9a Add callback for UIImplementation layout updates
Differential Revision: D6063839

fbshipit-source-id: ae08fd2fc6c6365813b8077efe14990a0355a5c7
2017-10-17 07:47:12 -07:00
Andrew Chen (Eng) dc16150bae Expose ReactInstanceManager from ReactRootView
Reviewed By: AaaChiuuu

Differential Revision: D6051991

fbshipit-source-id: f175fc273895d7e9fedec73428d61395ae00649f
2017-10-17 04:31:03 -07:00
Max Sherman f3b117abd0 Un-revert logMarker for hermes diff
Reviewed By: mhorowitz

Differential Revision: D6051880

fbshipit-source-id: 0ce4bbed9ba8579033ee5397ff6c0975b6886fb1
2017-10-13 14:01:43 -07:00
Max Sherman e60a2d0a53 Revert D5939688: [hermes][rn] Share logPerfMarker with hermes
Differential Revision: D5939688

fbshipit-source-id: 37daeeaa01144472c26383106c88dd49bb99a37b
2017-10-12 19:21:42 -07:00
Max Sherman fe62da34a6 Share logPerfMarker with hermes
Reviewed By: mhorowitz

Differential Revision: D5939688

fbshipit-source-id: ab6a86eb66a3d9501b9b5a55b562b277b5ab0620
2017-10-12 15:33:04 -07:00
Janic Duplessis 2b4ff6ea19 Native Animated - Restore default values when removing props on Android
Summary:
Rebased version of #12842 that was reverted because of failing fb internal tests.
Closes https://github.com/facebook/react-native/pull/15919

Differential Revision: D5823956

Pulled By: hramos

fbshipit-source-id: 4ece19a403f5ebbe4829c4c26696ea0575ab1d0e
2017-10-12 13:11:00 -07:00
Valentin Shergin f2c6877b91 Fixed crash on attempt to update local data of deallocated shadow node
Summary:
Trivial.
That's okay that sometimes shadowNodes and views hierarchies have lack of synchonization.

Reviewed By: sahrens

Differential Revision: D6040022

fbshipit-source-id: 6b49a82317b620b66a87441719fddcafb1f27934
2017-10-12 09:46:29 -07:00
Michael Lee 7997a2b749 Fix platform flags to also check for linux
Reviewed By: danzimm

Differential Revision: D6036995

fbshipit-source-id: 98d7f19eb80b72090b26252864a6bd41a3295462
2017-10-12 09:16:40 -07:00
Peter Ruibal 752b68857c Add `visible-password` for TextInput.keyboardType on Android
Summary:
`visible-password` represents a very basic keyboard, typically only
letters and numbers.  Backed by InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD,
it is useful for things like password and code entry fields. It can also be more
effective than autoCorrect={false} for disabling autocompletion on some keyboards
(like Gboard).

Note `secureTextEntry` also affects `TYPE_TEXT_VARIATION_*` flags internally, so there
may be some undefined behavior when combining `secureTextEntry` with
`keyboardType="visible-password"`

Also, while here, improve the documentation on TextInput to explicitly enumerate
which keyboardType applies to Android vs. iOS (since this is the first android-specific)

Reviewed By: shergin

Differential Revision: D6005353

fbshipit-source-id: 13af90c96353f714c0e106dd0fde90184a476533
2017-10-10 18:18:34 -07:00
Dmitry Zakharov ca834f96af Fix scrolling events for RN.
Reviewed By: bvaughn

Differential Revision: D6020664

fbshipit-source-id: c9fb9069e9dcde298901ba2c03bacc8b646844d0
2017-10-10 11:08:40 -07:00
Nivetha Singara Vadivelu 9424cd7e8f Handling exceptions in video player
Reviewed By: furdei

Differential Revision: D5958119

fbshipit-source-id: 79b431a8422d60134890d44e99c358a07a5adc5b
2017-10-09 22:45:48 -07:00
Janis Peisenieks 7a7bdeec3e Omit all line terminators for ImageStore.getBase64ForTag
Summary:
FIX #11142

This fixes #11142 and supersedes #11155 as I was unsure how to add/change commits in that PR.

Wrote up a bunch of unit tests for the ImageStore module. The added tests showed that there was indeed a problem with the flags used for the Base64OutputStream, and they also show that that has been fixed now.
Closes https://github.com/facebook/react-native/pull/13856

Differential Revision: D6017764

Pulled By: shergin

fbshipit-source-id: adf667dc722ddfe31449afd8cd20a0a192eacff6
2017-10-09 22:16:20 -07:00
Janic Duplessis 0cd69e8a02 Run eslint --fix
Summary:
CI is currently failing because of a lint issue, this fixes it and a bunch of other warnings that are auto-fixable.

**Test plan**
Quick manual test, cosmetic changes only.
Closes https://github.com/facebook/react-native/pull/16229

Differential Revision: D6009748

Pulled By: TheSavior

fbshipit-source-id: cabd44fed99dd90bd0b35626492719c139c89f34
2017-10-09 17:46:44 -07:00
Yann Pringault 1c24440644 Add TimePicker modes
Summary:
In the spirit of #10932, I added the `mode` option to the `TimePicker` Android API.
There is only one mode available for **Android < 5**, the `spinner` one.
If we are on **Android >= 5** we can choose between `spinner` or `clock`. If we specify `default` it will use the default of the current Android version.

On **Android < 5**, whatever we choose it will be this:
![screen shot 2017-02-14 at 17 05 44](https://cloud.githubusercontent.com/assets/5436545/22937805/024ec67e-f2da-11e6-8b32-a680d9bc2247.png)

On **Android >= 5**, with the `spinner` mode:
![screen shot 2017-02-14 at 16 51 17](https://cloud.githubusercontent.com/assets/5436545/22937803/024e0bbc-f2da-11e6-9f4b-26102ff2eeac.png)

And with the `clock` mode, the default:
![screen shot 2017-02-14 at 16 51 02](https://cloud.githubusercontent.com/assets/5436545/22937804/024e64e0-f2da-11e6-9911-4135049f4726.png)
Closes https://github.com/facebook/react-native/pull/12384

Differential Revision: D6006689

Pulled By: hramos

fbshipit-source-id: fcd37c867c4061b9982b1687f2c10211e54df7cf
2017-10-08 12:38:45 -07:00
Max Sherman 790eabcdff Replace getInt with asInt in native collections
Reviewed By: mhorowitz

Differential Revision: D5904751

fbshipit-source-id: 995412196fd76ea60a65253719e49852322be6e6
2017-10-05 10:07:24 -07:00
Alex Dvornikov 9e01d72103 Unify supplimentary bundle path creation logic between Android and iOS
Differential Revision: D5941546

fbshipit-source-id: c9b8fab887f480faa373c26a1d5ba310e8acde78
2017-10-04 15:16:27 -07:00
Alexey Lang adde2ed5e9 Fix the debug logging regression
Reviewed By: AaaChiuuu

Differential Revision: D5975880

fbshipit-source-id: 39c632ddf84e57c814b54fac465651120e4127da
2017-10-04 15:04:53 -07:00
Ram N 0c234c90a2 Add error customizer for React Native Android
Reviewed By: achen1

Differential Revision: D5954205

fbshipit-source-id: 8b92bf1484a037b333a6f0f4aeddd39ffee25361
2017-10-04 14:06:35 -07:00
Andrew Chen (Eng) 7677af1d10 Litho UIImplementation
Reviewed By: marco-cova

Differential Revision: D5880274

fbshipit-source-id: e6741579d3de6090dea8d26cd07241d57adba84d
2017-10-04 08:31:04 -07:00
Paco Estevez Garcia ef2e29f54c Move URL escaping to Inspector layer
Reviewed By: Hypuk

Differential Revision: D5967544

fbshipit-source-id: d741e6324aff7583778cb13c862505b61ca02a3d
2017-10-04 03:51:33 -07:00
Karl Tarvas 59d9f8ca5e Fix Android 4.1-4.3 WebView source baseUrl bug
Summary:
Resolves https://github.com/facebook/react-native/issues/11753 and https://github.com/facebook/react-native/issues/9835.

Android versions 4.1-4.3 don't understand the MIME type `text/html; charset=utf-8` and default to `text/plain` instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type has no negative effects.

The same fix has already been discussed, successfully tested and incorporated in https://github.com/NativeScript/NativeScript/issues/1038.
Closes https://github.com/facebook/react-native/pull/13789

Differential Revision: D5971910

Pulled By: shergin

fbshipit-source-id: 07795bdf0f13ddb1e8eec779d1cad59244f3687e
2017-10-03 18:51:57 -07:00
Valentin Shergin cdea3c574b Fixed crash in ReactTextInputLocalData
Summary:
Motivation:

(SUDDENLY) There is a thing on Android called SpanWather, and their purpose is to notify "the watcher" about span-related changes in SpannableString. The idea is: some special kind of span can have some logic to prevent or tweak interleaving with some another kind of spans. To do so, it has to implement SpanWather interface.
So, EditText uses this to control internal spannable object (!) and SUDDENLY (#><) calls internal "layout" method as a reaction to adding new spans. So, when we are cloning SpannableString, we are (re)applying same span objects to a new spannable instance, and it causes notifying other spans in the string, and they notify EditText, and the EditText does relayout and... BOOM!
So, the solution is, easy, we should use SpannableStringBuilder instead of SpannableString because it does not notify SpanWather during cloning.

See:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/SpannableStringBuilder.java#101
(the first argument is `false`).
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/SpannableStringBuilder.java#678
Compare with:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/SpannableStringInternal.java#43

Why? I believe because SpannableStringBuilder objects are "unfinished" by design, and documentation said: "it is the caller's responsibility to restore invariants [among spans]". As we do an exact clone of the string, that's perfectly okay to assume that all invariants were already satisfied for original string.

Reviewed By: achen1

Differential Revision: D5970940

fbshipit-source-id: 590ca0e3aede4470b809c7db527c5d55ddf5edb4
2017-10-03 17:37:45 -07:00
Aaron Chiu bbcfcdb8ed bring back box-none as layout only prop
Differential Revision: D5965540

fbshipit-source-id: a4a7b32a563674cf5f94e88390483763cf49d6da
2017-10-03 11:30:57 -07:00
Aaron Chiu 13d8375323 fix spelling in ReactInstanceManager
Reviewed By: kathryngray

Differential Revision: D5959860

fbshipit-source-id: 3d5358349fd6c0f9b8e57261914c945488684a96
2017-10-03 10:31:47 -07:00
Paco Estevez Garcia e7765a32f7 Fix DeviceIdentity on RN for Android
Reviewed By: Hypuk

Differential Revision: D5963912

fbshipit-source-id: 3959e5ab6af66512f0035efea7919572554e10b4
2017-10-03 08:07:41 -07:00
Paco Estevez Garcia da14fad829 Add AppIdentity and DeviceIdentity to Inspector
Reviewed By: Hypuk

Differential Revision: D5924011

fbshipit-source-id: a81d420dbe1a5ede203d2fa313548e19664b9587
2017-10-03 06:03:23 -07:00
Dmitry Zakharov 346af557c3 Fix regression in Java->C++->JS ViewManagers interaction.
Reviewed By: bvaughn

Differential Revision: D5953937

fbshipit-source-id: 8bc5dd8a483054ab9830ab653f2a3b41cad6c791
2017-10-03 05:30:42 -07:00
Aaron Chiu 6ba9ad8ece redo D5917111
Reviewed By: fkgozali

Differential Revision: D5962566

fbshipit-source-id: 5f92890a08b6e900b8d54f35c48e783166ce5897
2017-10-03 00:22:53 -07:00
Wenting Hu f368287347 reverting D5917111
Reviewed By: zjj010104

Differential Revision: D5961716

fbshipit-source-id: 0efaf38380b0b2e9440375ce0a7623a543f3fbd0
2017-10-02 20:03:37 -07:00
Valentin Shergin c550f27a4e Intrinsic content size for ReactTextInput (aka autoexpandable <TextInput> on Android)
Summary:
After this diff the intrinsic content size of <TextInput> reflects the size of text inside EditText,
it means that if there is no additional style constraints, <TextInput> will grow with containing text.
If you want to constraint minimum or maximum height, just do it via Yoga styling.

Reviewed By: achen1

Differential Revision: D5828366

fbshipit-source-id: eccd0cb4ccf724c7096c947332a64a0a1e402673
2017-10-02 16:31:18 -07:00
Valentin Shergin d0790fea39 Introducting `UIManager.setLocalData()`, the way to provide environmental data to ShadowNode
Summary:
In some cases we need a way to provide some peice of data to shadow node
to improve layout (or do something similar), `setLocalData` allows to do this.

Reviewed By: AaaChiuuu

Differential Revision: D5828368

fbshipit-source-id: bf6a04f460dc7695a16269426d365b78909bc8eb
2017-10-02 16:31:18 -07:00
David Vacca a5d1d25f56 BREAKING: Add interface for ReactShadowNode
Reviewed By: AaaChiuuu

Differential Revision: D5943137

fbshipit-source-id: 00950190e0256303d423ae86c6c18facf173ad6a
2017-10-02 09:08:28 -07:00
Aaron Chiu 30044fd531 fix overflow hidden
Reviewed By: shergin

Differential Revision: D5917111

fbshipit-source-id: e3d97f26b6aada199f700ec6659ace0d7dffd4c5
2017-09-29 18:19:54 -07:00
Aaron Chiu e7af72b29a make view hierarchy optimizer smarter
Reviewed By: shergin

Differential Revision: D5744725

fbshipit-source-id: 4042310494a2bbd3d3472485ad8496d592eb28ac
2017-09-29 18:19:54 -07:00
Michael Lee ebb42ee1b6 Add include_defs("//ReactAndroid/DEFS") to all BUCK files in ReactAndroid
Reviewed By: mmmulani

Differential Revision: D5915945

fbshipit-source-id: 49bce07e4f5a2f4a8985b992e1e7d9ea4ef6c654
2017-09-29 16:16:06 -07:00
Alex Dvornikov 4162d73ec0 Added Android support for loading multiple RAM bundles
Differential Revision: D5901574

fbshipit-source-id: 395bae41e58505918d7ad20ac432eba3361361ea
2017-09-29 14:46:00 -07:00
Felix Oghina 7320ca5c7a Add GlobalImageLoadListener
Reviewed By: AaaChiuuu

Differential Revision: D5932865

fbshipit-source-id: 700983d7fc44c4ee5f77b58ef54cec62869009e0
2017-09-29 08:55:56 -07:00
Neo b64e6c722c fix arc drawing when sweep >= 360
Summary:
I hit this issue in my own component https://github.com/nihgwu/react-native-pie, and find this https://stackoverflow.com/questions/19383842/weird-behaviour-in-drawing-a-ring-using-path-arcto-in-android, after this change, it looks exactly the same on both Android and iOS
Closes https://github.com/facebook/react-native/pull/15042

Differential Revision: D5937957

Pulled By: shergin

fbshipit-source-id: 3c88565a1cc90d82edd819d048f40d4961f78b3c
2017-09-28 19:33:03 -07:00
Dmitry Zakharov da30b04703 Implement lazy discovery for ViewManagers.
Reviewed By: kathryngray

Differential Revision: D5865095

fbshipit-source-id: c94970e4cd7aafb20cf844c48feea053ac8b6b0f
2017-09-28 09:55:59 -07:00
Aaron Chiu 652dfd0b48 add Relay as a category
Reviewed By: achen1

Differential Revision: D5741372

fbshipit-source-id: 65d46decd26e563ab3cd9ea72c3a391ba32c67bb
2017-09-27 22:31:51 -07:00
Janic Duplessis 1af645b2fd Validate that JS and Native code versions match for RN releases
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 https://github.com/facebook/react-native/pull/15518

Differential Revision: D5813551

Pulled By: hramos

fbshipit-source-id: 901757e25724b0f22bf39de172b56309d0dd5a95
2017-09-27 18:31:15 -07:00
David Vacca 9b3cc30357 Backed out changeset 7c338fe3b747
Reviewed By: AaaChiuuu

Differential Revision: D5926999

fbshipit-source-id: 58595f74f1fab764b63b5d7d6c2f20d8edb2efda
2017-09-27 16:45:11 -07:00
Aaron Chiu 672db77eae add UI Manager operations
Reviewed By: achen1

Differential Revision: D5741087

fbshipit-source-id: f6b8f713cb3c4e48b417b47557a45ff9a4a5bf05
2017-09-27 16:16:20 -07:00
Kevin Doherty 6f6329d5e3 Only disallow changes if the value actually changed
Differential Revision: D5884661

fbshipit-source-id: 2d9fe28a0ecfc46afc9ca459975455e1fd13d19b
2017-09-26 08:18:24 -07:00
faifai21 64ffe4516e Use BitmapRegionDecoder to efficiently crop images on Android
Summary:
The Android ImageEditingManager is inefficient and slow when cropping images. It loads the full resolution image into memory and then crops it. This leads to slow performance and occasional OutOfMemory Exceptions.
[BitmapRegionDecoder](https://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html) can be used to crop without needing to load the full resolution image into memory. Using it is much more efficient and much faster.

Relevant issue: https://github.com/facebook/react-native/issues/10470

Attempt to crop a very large image (2000x2000) on Android. With this change, the crop should happen almost instantly. On the master branch, it should take 2-3 seconds (and might run out of memory).

Please let me know if there's anything else I can provide.
Closes https://github.com/facebook/react-native/pull/15439

Differential Revision: D5628223

Pulled By: shergin

fbshipit-source-id: bf314e76134cd015380968ec4533225e724c4b26
2017-09-26 05:17:40 -07:00
Guizmo Martinez 31904d523d Fix slider colors in Android
Summary:
Hey !

I noticed that the `minimumTrackTintColor` and `maximumTrackTintColor` are exchanged in iOS and Android.
In iOS, `minimumTrackTintColor` is the left color and `maximumTrackTintColor` is the right color.
In Android, `minimumTrackTintColor` is the right color and `maximumTrackTintColor` is the left color.

With this code :
```jsx
<Slider
  style={{ width: 300 }}
  minimumTrackTintColor="red"
  maximumTrackTintColor="blue"
/>
```

|iOS|Android|
|----|----|
|![image](https://user-images.githubusercontent.com/17292331/30700555-2b8ae828-9ee8-11e7-94a3-f1d3adee7fd5.png)|![screenshot_2017-09-21-15-59-59](https://user-images.githubusercontent.com/17292331/30699855-246c1280-9ee6-11e7-9653-e61c4798a50f.png)|

|iOS|Android|
|----|----|
|![image](https://user-images.githubusercontent.com/17292331/30700563-2fc8c25c-9ee8-11e7-9c0d-955d9921660f.png) (same)|![screenshot_2017-09-21-16-12-04](https://user-images.githubusercontent.com/17292331/30700418-def3e136-9ee7-11e7-982b-48aeba23a5ea.png)|
Closes https://github.com/facebook/react-native/pull/16053

Differential Revision: D5910299

Pulled By: shergin

fbshipit-source-id: 74851e4cc6d54f72ea2755200e26b0d921890b48
2017-09-26 02:15:27 -07:00
Janic Duplessis 3cbc36138a Native Animated - Allow events that are dispatched from any thread
Summary:
Instead of preventing events from working when not on the UI Thread we can just dispatch to it instead.

**Test plan**
Tested manually that animated events still work in RNTester
Closes https://github.com/facebook/react-native/pull/15953

Differential Revision: D5909816

Pulled By: shergin

fbshipit-source-id: 48d02b6aa9f2bc3bcb638e8852fccaac3f205276
2017-09-25 23:15:15 -07:00
Paul van Staden 0818f3bdf5 Adding TLSv1 support for custom SSL socket factory
Summary:
This problem tries to solve issue #14244

Implemented a fetch request to a TLSv1 server. It now successfully resolves TLS handshake.
Tested same fetch to TLSv1.2 server and still successfully resolves TLS handshake.
Closes https://github.com/facebook/react-native/pull/14245

Differential Revision: D5898689

Pulled By: shergin

fbshipit-source-id: 8766ebe6909443367651ab868aa5ff62747cd906
2017-09-23 17:22:57 -07:00
Andrew Gallagher 49359e879b Deprecate older API uses of `prebuilt_cxx_library`
Reviewed By: ttsugriy

Differential Revision: D5878523

fbshipit-source-id: 2c8c1fd1d19597ff7459bbd527c89573520db74b
2017-09-22 13:20:17 -07:00
Alex Dvornikov 7d115730dc Configure JSExector with BundleRegistry instead of JSModulesUnbundle
Differential Revision: D5890458

fbshipit-source-id: 968be95786ffbf53aa98928d4d3e3bd52a84b3dc
2017-09-22 09:58:46 -07:00
Charles Dick e9aab0d452 Add locking around CatalystInstance.getJavaScriptContext()
Reviewed By: kathryngray

Differential Revision: D5861693

fbshipit-source-id: 226ff15622d5e1a8ae3ad4c63f1434bd95c1fa21
2017-09-22 08:37:22 -07:00
Jia Li 0aa12939fd Revert D5850968: Configure JSExector with BundleRegistry instead of JSModulesUnbundle.
Differential Revision: D5850968

fbshipit-source-id: f4c9dc8d5f14cdd32195463e8786242e708770e9
2017-09-21 21:22:39 -07:00
Hector Ramos 8fa9984b11 Migrate to Circle 2.0
Summary:
Following the migration guide. Let's see what happens here.
Closes https://github.com/facebook/react-native/pull/14955

Differential Revision: D5877682

Pulled By: hramos

fbshipit-source-id: 2a40560120b5d8d28bc6c52cc5e5916fd1bba336
2017-09-21 14:01:30 -07:00
Alex Dvornikov 79821917fa Configure JSExector with BundleRegistry instead of JSModulesUnbundle.
Differential Revision: D5850968

fbshipit-source-id: e5e7ad92c2347c2641551fcf820f061ffde5fed6
2017-09-21 08:51:00 -07:00
Alexey Lang b9be9a01a9 Break down PRE_REACT_CONTEXT
Reviewed By: cwdick

Differential Revision: D5874529

fbshipit-source-id: 0ee9d740b4445419e3143942514475751763520d
2017-09-21 08:04:08 -07:00
Adam Miskiewicz 26133beda9 Add closed-form damped harmonic oscillator algorithm to Animated.spring
Summary:
As I was working on mimicking iOS animations for my ongoing work with `react-navigation`, one task I had was to match the "push from right" animation that is common in UINavigationController.

I was able to grab the exact animation values for this animation with some LLDB magic, and found that the screen is animated using a `CASpringAnimation` with the parameters:

- stiffness: 1000
- damping: 500
- mass: 3

After spending a considerable amount of time attempting to replicate the spring created with these values by CASpringAnimation by specifying values for tension and friction in the current `Animated.spring` implementation, I was unable to come up with mathematically equivalent values that could replicate the spring _exactly_.

After doing some research, I ended up disassembling the QuartzCore framework, reading the assembly, and determined that Apple's implementation of `CASpringAnimation` does not use an integrated, numerical animation model as we do in Animated.spring, but instead solved for the closed form of the equations that govern damped harmonic oscillation (the differential equations themselves are [here](https://en.wikipedia.org/wiki/Harmonic_oscillator#Damped_harmonic_oscillator), and a paper describing the math to arrive at the closed-form solution to the second-order ODE that describes the DHO is [here](http://planetmath.org/sites/default/files/texpdf/39745.pdf)).

Though we can get the currently implemented RK4 integration close by tweaking some values, it is, the current model is at it's core, an approximation. It seemed that if I wanted to implement the `CASpringAnimation` behavior _exactly_, I needed to implement the analytical model (as is implemented in `CASpringAnimation`) in `Animated`.

We add three new optional parameters to `Animated.spring` (to both the JS and native implementations):

- `stiffness`, a value describing the spring's stiffness coefficient
- `damping`, a value defining how the spring's motion should be damped due to the forces of friction (technically called the _viscous damping coefficient_).
- `mass`, a value describing the mass of the object attached to the end of the simulated spring

Just like if a developer were to specify `bounciness`/`speed` and `tension`/`friction` in the same config, specifying any of these new parameters while also specifying the aforementioned config values will cause an error to be thrown.

~Defaults for `Animated.spring` across all three implementations (JS/iOS/Android) stay the same, so this is intended to be *a non-breaking change*.~

~If `stiffness`, `damping`, or `mass` are provided in the config, we switch to animating the spring with the new damped harmonic oscillator model (`DHO` as described in the code).~

We replace the old RK4 integration implementation with our new analytic implementation. Tension/friction nicely correspond directly to stiffness/damping with the mass of the spring locked at 1. This is intended to be *a non-breaking change*, but there may be very slight differences in people's springs (maybe not even noticeable to the naked eye), given the fact that this implementation is more accurate.

The DHO animation algorithm will calculate the _position_ of the spring at time _t_ explicitly and in an analytical fashion, and use this calculation to update the animation's value. It will also analytically calculate the velocity at time _t_, so as to allow animated value tracking to continue to work as expected.

Also, docs have been updated to cover the new configuration options (and also I added docs for Animated configuration options that were missing, such as `restDisplacementThreshold`, etc).

Run tests. Run "Animated Gratuitous App" and "NativeAnimation" example in RNTester.
Closes https://github.com/facebook/react-native/pull/15322

Differential Revision: D5794791

Pulled By: hramos

fbshipit-source-id: 58ed9e134a097e321c85c417a142576f6a8952f8
2017-09-20 23:38:16 -07:00
Adam King 4d54b48167 Fix onSubmitEditing dispatch behavior with blurOnSubmit/multiline combinations.
Summary:
Fixes https://github.com/facebook/react-native/issues/15863 on master. Behavior of `onSubmitEditing` is now consistent between iOS and Android. Tapping the submit button in a TextInput dispatches the event precisely when doing so does not make a newline (when blurOnSubmit is true or multiline is false).

1. Run this app on iOS and Android:
```
// flow

import React, { Component } from 'react';
import {
  StyleSheet,
  TextInput,
  View
} from 'react-native';

type State = {
  toggled: boolean
};

type Props = {
  blurOnSubmit: boolean,
  multiline: boolean
};

class ToggleColorInput extends Component<Props, State> {
  state: State = {
    toggled: false
  };

  props: Props;

  toggle = () => {
    this.setState({
      toggled: !this.state.toggled
    });
  }

  render() {
    return (
      <TextInput
        blurOnSubmit={this.props.blurOnSubmit}
        multiline={this.props.multiline}
        onSubmitEditing={this.toggle}
        style={[styles.textInput, {backgroundColor: this.state.toggled ? 'blue' : 'azure'}]}
        underlineColorAndroid='transparent'
      />
    )
  }
}

export default class App extends Component<{}> {
  render() {
    return (
      <View>
        <ToggleColorInput blurOnSubmit={true} multiline={true} />
        <ToggleColorInput blurOnSubmit={true} multiline={false} />
        <ToggleColorInput blurOnSubmit={false} multiline={true} />
        <ToggleColorInput blurOnSubmit={false} multiline={false} />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  textInput: {
    height: 75,
    borderWidth: 1,
    borderColor: 'black'
  }
});
```
2. You see four TextInputs, with each combination of the `blurOnSubmit` and `multiline` properties. For each TextInput, type some text and tap the submit button.
3. The TextInputs in this test will toggle background color when they emit an `onSubmitEditing` event. Verify the following behavior on each platform:
 * blurOnSubmit && isMultiline => Submit event emitted, blurred, no newline inserted
 * blurOnSubmit && !isMultiline => Submit event emitted, blurred
 * !blurOnSubmit && isMultiline => Submit event emitted, newline inserted
 * !blurOnSubmit && !isMultiline => Submit event emitted
Closes https://github.com/facebook/react-native/pull/16040

Differential Revision: D5877401

Pulled By: shergin

fbshipit-source-id: 741bcc06d8b69d7025f2cb42dd0bee4fa01cd88e
2017-09-20 16:33:14 -07:00
Aaron Chiu 565a24140b add Native Module init
Reviewed By: achen1

Differential Revision: D5740540

fbshipit-source-id: 9989424812fdcfd0a54c2ccf1e973aa7cc2a1f67
2017-09-20 10:57:12 -07:00
Andrew Chen (Eng) 08befb730b Add interface for ReactShadowNode
Reviewed By: AaaChiuuu

Differential Revision: D5871546

fbshipit-source-id: 7c338fe3b747a79377a54867c789028d221b3dd5
2017-09-20 08:47:32 -07:00
Kathy Gray 6334ed2ff3 Detangle destroy and create accesses
Differential Revision: D5823786

fbshipit-source-id: d6a6e29b856361a6b1d5ab48397607a844b5ab53
2017-09-20 05:08:03 -07:00
Aaron Chiu 12f123d3e4 add JS->Java Bridge traffic
Reviewed By: achen1

Differential Revision: D5740501

fbshipit-source-id: 3a88cd95d3a58aac24968e577f4eb3096d47d4ec
2017-09-19 12:03:15 -07:00
Dmitry Zakharov 4fc9e20fce Untangle NativeAnimatedNodesManager from UIManager internals.
Reviewed By: AaaChiuuu

Differential Revision: D5861523

fbshipit-source-id: 39eb79b91d4d5e2295d03369f1be585ae7836c75
2017-09-19 10:00:52 -07:00
David Vacca 5180995666 Fix setBackground for Android sdk version 15 and below
Reviewed By: achen1

Differential Revision: D5854430

fbshipit-source-id: 1276f3d7e94b757f9a9dd412a2ef8b72e8427ffb
2017-09-19 09:39:45 -07:00
Kang Zhang 87a1dc4b76 rename catalyst animations
Reviewed By: achen1

Differential Revision: D5855613

fbshipit-source-id: 2eac7ba6a9d95f6cd3a58a1df4ec0b170f34d6ed
2017-09-19 07:33:42 -07:00
Tomas Reimers 9e373529f3 Backed out D5792012.
Reviewed By: AaaChiuuu

Differential Revision: D5855139

fbshipit-source-id: 3837769a4da90d9752de75669c6395fabcd3b18b
2017-09-18 21:37:54 -07:00
Max Sherman e764361f93 Add getter for JS Executor Factory
Reviewed By: mhorowitz

Differential Revision: D5857012

fbshipit-source-id: 8c9fc0095c512325968234f48d6728b63d61913d
2017-09-18 21:18:24 -07:00
Michał Gregorczyk d6c519bc96 Base class for all object private data passed to JSC
Reviewed By: amnn

Differential Revision: D5761937

fbshipit-source-id: de88cf8b959fc855c3c0786f817bb6032491c819
2017-09-18 18:45:27 -07:00
Ori Harel 795370789b re #15915 HeadlessJsTaskService is expected to run on UI thread
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Headless tasks are required to run in the main thread, however due to the nature of the React context creation flow, the handler may be returned outside of the main thread, causing the HeadlessJsTaskContext to throw an exception.

Swipe out the app. send push notification from a server that starts a HeadlessJsTaskService
Closes https://github.com/facebook/react-native/pull/15940

Differential Revision: D5852448

Pulled By: foghina

fbshipit-source-id: 54c58a1eb7434dd5de5c39c28f6e068ed15ead9d
2017-09-18 05:30:50 -07:00
Valentin Shergin 7efd4fabfd Text to Spannable conversion is now using PRIORITY flag to enforce the order of spans
Summary:
When we convert nested <Text> components to Spannable object we must enforce the order of spans somehow,
otherwise we will have Spannable object with unpredictable order of spans, which will produce unpredictalbe text layout.
We can do it only using `Spannable.SPAN_PRIORITY` feature because Spannable objects do not maintain the order of spans internally.

We also have to fix this to implement autoexpandable <TextInput>.

Reviewed By: achen1

Differential Revision: D5811172

fbshipit-source-id: 5bc68b869e58aba27d6986581af9fe3343d116a7
2017-09-17 22:00:16 -07:00
Brian Vaughn d1372faeb5 Re-added global event-type Map to UIManager constants
Reviewed By: sophiebits

Differential Revision: D5846806

fbshipit-source-id: 7b0a54bd5a4b877f0c5915f11392ee0d34718dbe
2017-09-15 16:47:16 -07:00
Kathy Gray cf2ef84b16 Move destroy threads in catalystinstance off the UI thread
Reviewed By: cwdick

Differential Revision: D5842135

fbshipit-source-id: e9c44c4129d4d10da8781798df121f5c676766f8
2017-09-15 05:48:57 -07:00
Brian Vaughn 75c94a8907 Native view manager event types exposed to JS via view config
Differential Revision: D5814210

fbshipit-source-id: 41291f0d6b39af77f66173f6a699d88f9f4ccc74
2017-09-14 18:17:17 -07:00
Aaron Chiu 6c2c2ecd8c add some RN Core markers
Reviewed By: achen1

Differential Revision: D5740438

fbshipit-source-id: eca6160e0ff9089e1f70ead0f2269ce152258c19
2017-09-14 12:02:29 -07:00
Ramanpreet Nara adb6646016 Make <TextInput multiline> default blurOnSubmit to false.
Reviewed By: achen1

Differential Revision: D5830633

fbshipit-source-id: 3d0880656f14cfafa0f15c4341021799f20f40ed
2017-09-14 11:30:58 -07:00
Valentin Shergin a17797940d Fixed issue with remeasuring ReactTextShadowNode
Summary:
This fixes the regression recently introduced during refactoring of text-related classes.
So, added fragment of code was lost in D5715830.
See how it looked before:
9f5bdd7b49/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java (L424-L431)

Reviewed By: TheSavior

Differential Revision: D5827424

fbshipit-source-id: 5df99620057ff6a27105dd05903c7f5def85c5d2
2017-09-13 14:33:59 -07:00
Tomas Reimers cbb0ccb185 mActivelyScrolling expected to be true so long as events are being fired.
Summary:
**Problem:**

It was observed that in [this code path](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java#L292) (i.e. horizontal, paging-enabled scroll view) if you tried to programmatically call the scrollTo method within ~1s of the onMomentumScrollEnd event (which should only be called after all scrolling has ended), the scrollView would scroll to the new location, and then scroll BACK to the original location.

For example, assume you had released the scrollView at location B, and the nearest page boundary is A. Then, 1000ms later, you call scrollTo position C. The order of operations would be:

1. Begin scrolling to A from position B (as it is the nearest page boundary)
2. Reach position A
3. Fire onMomentumScrollEnd
4. 1000ms later call scrollTo C
5. scrollView scrolls to C
6. scrollView scrolls BACK to position A (for no apparent reason).

**Reason:**

I suspect this is because the [smoothlyScrollTo](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java#L292) will continue to animate towards A, but the [scrollEvents will not fire](f954f3d9b6/ReactAndroid/src/main/java/com/facebook/react/views/scroll/OnScrollDispatchHelper.java (L45)) as they are too close to each other. So the true order of events is:

1. Begin scrolling to A from position B (as it is the nearest page boundary)

[begin smoothlyScrollTo]
[scroll towards position A]
[mActivelyScrolling is true]

2. Reach position A

[mActivelyScrolling is true]
[scroll towards position A]
[mActivelyScrolling is false, as there is another scrollEvent, but because it is close enough to the same location it is ignored]

3. Fire onMomentumScrollEnd
4. 1000ms later call scrollTo C

[scroll towards position C]

5. scrollView scrolls to C

[scroll towards position A as the original smoothlyScrollTo animation was never completed]

6. scrollView scrolls BACK to position A.

This is an untested hypothesis, but seems to explain the behavior, and the solution is more semantically correct anyway. If there is an easy way to rebuild the android binaries happy to test it myself! Just let me know!

**Solution:**

 Move the mActivelyAnimating outside the mOnScrollDispatchHelper.onScrollChanged helper, because the HorizontalScrollView event should be considered to be animating so long as onScrollChanged events are being fired.
Closes https://github.com/facebook/react-native/pull/15146

Reviewed By: AaaChiuuu

Differential Revision: D5792026

Pulled By: tomasreimers

fbshipit-source-id: 9654fda038d4a687cc32f4c32dc312baa34627ed
2017-09-12 18:30:39 -07:00
Tomas Reimers 718f4e60c2 Remove 'box-only' as a layoutOnlyProp
Summary:
Currently, having the property `pointerEvents={'box-only'}` marks a view as layoutOnly. For optimization reasons, layoutOnly nodes are [not added to the node hierarchy](b103903ec8/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java (L99)) The problem is that should this box ever need to be [transitioned to not-layout-only](b103903ec8/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java (L394)) (for example, because you add the a CSS transform property),  it must be added to the hierarchy. To add it to the hierarchy the [React Styles Diff Map](b103903ec8/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java (L396)) is passed along with the backing shadowNode to create the node. The problem is that at no point were the original `pointerEvents` and so the new node will be created with `pointerEvents =  'auto'`.

A more correct fix to this problem might be to have shadowNodes carry around their pointerEvents, although this is likely a greater design decision which is why am I proposing the quick fix now.

Will also resolve: https://github.com/react-native-community/react-native-modal/issues/11
Closes https://github.com/facebook/react-native/pull/15529

Reviewed By: AaaChiuuu

Differential Revision: D5792012

Pulled By: tomasreimers

fbshipit-source-id: 625242c53e16cb293c64811a57f6c3905b3483e0
2017-09-12 14:21:11 -07:00
Valentin Shergin 6114f863c3 Restructured inheritance around ReactTextViewManager and co.
Summary:
Abstract class `ReactBaseTextShadowNode` was decoupled from `ReactTextShadowNode` to separate two goals/roles:
 * `ReactBaseTextShadowNode` represents spanned `<Text>` nodes, which can bear text attributes (both `RCTText` and `RCTVirtualText`);
 * `ReactTextShadowNode` represents anchor `<Text>` view in Yoga terms, which can bear layout attributes (`RCTText` and `RCTTextInput`).

`ReactVirtualTextShadowNode` now inherits `ReactBaseTextShadowNode`.
The same architectural changes was applited to view managers.

Why?
 * This is just a better architecture which represents the nature of this objects.
 * Bunch of "negative" logic which turn off excessive features for some suclasses was removed.
 * Memory efficiency.
 * Now we can improve `<TextInput>` component using right inheritance. Yay!

Reviewed By: achen1

Differential Revision: D5715830

fbshipit-source-id: ecc0764a03b5b7586fe77ad31f149cd840f4da41
2017-09-11 15:49:01 -07:00
Valentin Shergin 80027ce6db ReactRawTextShadowNode does not inherit ReactTextShadowNode anymore
Summary:
ReactRawTextShadowNode represents "raw" text node (aka textContent), so it cannot have layout or styling, it is just a line of text, a pure string.
So, we must not interit it from HUGE ReactTextShadowNode (which represents <Text> node with ReactRawTextShadowNode instance inside).
We need this change to make future fancy (and valuable from product perspective) refactoring possible. Stay tuned!

Reviewed By: achen1

Differential Revision: D5712961

fbshipit-source-id: 009e48046bdf34ddfd40b93175934969af64b98b
2017-09-11 15:49:01 -07:00
Spencer Ahrens 393bf88be6 Add all test routes as server snapshot tests
Reviewed By: raluca-elena, TheSavior

Differential Revision: D5638532

fbshipit-source-id: 8db8210d0d0d08b9423b0a77f6b8e4e290f2eef0
2017-09-11 15:18:11 -07:00
Andrew Jack 96de23abf1 Android Oreo (8.0) Support
Summary:
Apps targeting Android 8.0 (API level 26) cannot use `TYPE_SYSTEM_OVERLAY ` and `TYPE_SYSTEM_OVERLAY `. Targeting 26 will cause the app to crash when in `DEV_MODE`.

https://developer.android.com/about/versions/oreo/android-8.0-changes.html#cwt

This PR replaces uses of these overlay flags with the new `TYPE_APPLICATION_OVERLAY` when running on a device with Android 8.0 or later.

When using `TYPE_APPLICATION_OVERLAY` it still requires the `SYSTEM_ALERT_WINDOW` permission, just like previous android versions.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_APPLICATION_OVERLAY

https://github.com/AndrewJack/react-native-android-oreo tested here
Closes https://github.com/facebook/react-native/pull/15601

Reviewed By: achen1

Differential Revision: D5801619

Pulled By: shergin

fbshipit-source-id: 27d1b9bb64018e7f12f9c3d3d222f1fda468b124
2017-09-11 12:48:46 -07:00
David Vacca 4ca617211b Add support for dynamically sized ReactRootView
Reviewed By: achen1, AaaChiuuu

Differential Revision: D5745093

fbshipit-source-id: 65d85252ab8a0ca38322f49a3d4812380d5228c4
2017-09-08 21:18:00 -07:00
Hongtan Du c893989d21 Add check for valid rootTag in ReactRootView
Reviewed By: AaaChiuuu

Differential Revision: D5796097

fbshipit-source-id: 1aed793dd77864f1b2cb20e64049483a084f0bc0
2017-09-08 14:17:38 -07:00
Michael Lee 1f2ca244d7 Move to fbsystrace to a new location
Reviewed By: dreiss

Differential Revision: D5760920

fbshipit-source-id: 9ff001dbd34660c14d061dec5428e82a815c719a
2017-09-07 09:17:02 -07:00
Valentin Shergin d2f3a7282b Bikeshedding in ReactTextInputShadowNode, part 2
Reviewed By: AaaChiuuu

Differential Revision: D5712962

fbshipit-source-id: b0cb5dbbd93b661252e5ddcf6c0a34e59cb7f2c6
2017-09-06 17:23:41 -07:00
Valentin Shergin 5f1f0b14f0 Bikeshedding in ReactTextInputShadowNode
Reviewed By: AaaChiuuu

Differential Revision: D5712963

fbshipit-source-id: 87c8394d82e0c206f908fb07eb8b7464b0ecabaf
2017-09-06 17:23:41 -07:00
Valentin Shergin 35cac3bf1b Introducing `ReactShadowNode.isYogaLeafNode()`
Summary:
We have to have a way to explicitly enforce the fact that some nodes cannot have Yoga child nodes.
Previously we relied on `isMeasureDefined()`, which is actually special case (so it does not cover all possible cases).

Reviewed By: AaaChiuuu

Differential Revision: D5647855

fbshipit-source-id: 59591be61ef62c61eb98748d44bb28b878f713fc
2017-09-06 17:23:41 -07:00
Michael Lee ed31f7a97d Reformat BUCK files
Reviewed By: zertosh

Differential Revision: D5756296

fbshipit-source-id: 69af6e9211648a81ba864be8d37165023cb5f9c2
2017-09-05 15:02:19 -07:00
Andrew Chen (Eng) 1ccc03c217 Fix Circle CI build missing appcompat dep
Differential Revision: D5769914

fbshipit-source-id: 51652e276165b4f61ae473bc25a19499da5bd1b4
2017-09-05 15:02:19 -07:00
Marc Horowitz d48f08cad6 Thread the JSI runtime descriptor up into the RCTDevMenu title
Reviewed By: javache

Differential Revision: D5643014

fbshipit-source-id: 977be5729c57c0d01ff67b268031ad6fdbf88a07
2017-09-05 15:02:19 -07:00
Andrew Chen (Eng) 5a3828d299 Dirty the shadow node when ReactLithoView requests layout
Reviewed By: shergin

Differential Revision: D5756680

fbshipit-source-id: 409095a2ee61db7ee7a85e12ab64c7806da3b3d9
2017-09-05 11:01:39 -07:00
Michał Gregorczyk efd728ab7e ReactInstanceManager tests with non-JSC JavaScriptExecutor
Reviewed By: johnislarry

Differential Revision: D5764234

fbshipit-source-id: ea088b025def7ed4f39e6b75b8111ac13da9b331
2017-09-05 09:45:02 -07:00
Janic Duplessis e964a7f4ef Fix scroll events getting skipped on Android
Summary:
This code related to velocity would cause some scroll events to be skipped and caused some jitter for sticky headers. Not sure if there is a better fix but removing this does fix missing events and the velocity calculation still seems to be working.

**Test plan**
Tested that sticky headers now work properly on Android, tested that velocity calculation still seem to work.
Closes https://github.com/facebook/react-native/pull/15761

Differential Revision: D5760820

Pulled By: sahrens

fbshipit-source-id: 562b5f606bdc5452ca3d85efb5e0e3e7db224891
2017-09-01 18:06:24 -07:00
Omer Strulovich b11587b19f Revert D5746286, D5717191, D5717111 to try and unblock stable
Reviewed By: mzlee

Differential Revision: D5758871

fbshipit-source-id: ea014e237246ae3b16ee2d1b5f5a7310e164d183
2017-09-01 15:18:40 -07:00
Michał Gregorczyk 9f76e9d374 Test for non-JSC JavaScriptExecutor
Reviewed By: mhorowitz

Differential Revision: D5746286

fbshipit-source-id: 5bc5d5fcbc9e3ab7de0153145b1276edd3f3aa13
2017-09-01 09:15:43 -07:00
Michał Gregorczyk 4cba3abf06 Fix NPE in ReactInstaceManager.setupReactContext
Reviewed By: AaaChiuuu, mhorowitz

Differential Revision: D5724464

fbshipit-source-id: 80d0b97f4294f6894e0d034dda6dd1a3db4b1341
2017-09-01 09:15:43 -07:00