Commit Graph

2747 Commits

Author SHA1 Message Date
Shen Jin 7d1c827cb2 Fix spinner mode
Summary:
Okay, I think this is the best I can do David, I don't think there's an obvious/easy way for me to try to get `getIdentifier()` to return a non zero value. Setting it to what Spencer suggested works for my use case.

## Changelog

[Android] [Changed] - Update spinner mode to render spinner instead of calendar

Reviewed By: sahrens

Differential Revision: D15427793

fbshipit-source-id: b04f024a9a1f052f69f3bda47d77821782dc2c0e
2019-05-24 14:42:28 -07:00
David Vacca 6f63b054b6 Add Nullable annotation into Mounting Manager
Summary: trivial diff to remove warnings because of the lack of Nullable annotations in MountingManager.ViewState

Reviewed By: shergin

Differential Revision: D15476040

fbshipit-source-id: 2b9a4efa1be1d5aa29d4e32cf32c8ff502f7c60c
2019-05-24 11:30:30 -07:00
David Vacca 92f8fd22e2 Optimize the update of state during first render of a View
Summary: This is an optimization to avoid transfering updateState instructions twice during the frist render of a view (same a props)

Reviewed By: shergin

Differential Revision: D15476041

fbshipit-source-id: 8a62035dbbb63c93f86a2f8d217986a325cb1805
2019-05-24 11:30:30 -07:00
David Vacca cd5fe06abe Fix bottom sheet in Fabric Android
Summary: This diff fixes the rendering of Bottom Sheet in Fabric Android. In D15343702 we added state as part of the "preallocateView" method but we forgot to call viewManager.updateState(), this prevents the state to be updated during the first render.

Reviewed By: shergin

Differential Revision: D15476042

fbshipit-source-id: cd6fc9bdd178589d2e04f85723425b5e5c3e5a04
2019-05-24 11:30:30 -07:00
David Vacca c629cdc39a Remove ComponentRegistry class
Summary: This class is not necessary anymore, this diff deletes it from the repo

Reviewed By: JoshuaGross

Differential Revision: D15457346

fbshipit-source-id: c7293d93b50271efe3b3d2121c128ba6e13c7627
2019-05-24 11:30:30 -07:00
David Vacca cb1a28c859 Remove jsi package from fabric android
Summary: Refactor of packages of RN Android

Reviewed By: JoshuaGross

Differential Revision: D15457141

fbshipit-source-id: a291f7e1ca8e0be3e93daf9c34161c8f1fdbafac
2019-05-24 11:30:29 -07:00
David Vacca bbf1a7d085 Back out "[Venice][Fabric] Use startSurface on Android"
Summary: Original commit changeset: 4a506a589108

Reviewed By: ejanzer

Differential Revision: D15497094

fbshipit-source-id: 47e5d0c3c69cc56cc3dd56d28e23e1db5b562fa4
2019-05-24 11:30:29 -07:00
Oleksandr Melnykov fb6cf2552a Fix backgroundColor top level prop of TextInput
Summary:
Changelog: [Android] [FIXED] - Fix backgroundColor top level prop of TextInput

This diff fixes two issues with the `backgroundColor` top level property of TextInput on Android:
 * Now it is possible to set a **string** value for the top-level `backgroundColor` property of TextInput (crashed the app previously):
```
<TextInput backgroundColor="#ffccbb">Hello, React Native</TextInput>
```
* Now it's possible to set an **integer** value for the top-level `backgroundColor` property of TextInput (had no effect previously):
```
<TextInput backgroundColor={0xffccbbff}>Hello, React Native</TextInput>
```

A `customType = "Color"` annotation parameter must be provided for `ReactBaseTextShadowNode.setBackgroundColor(...)` since the color value must be previously processed in JS before sending it over the bridge to the native code. The JS code will parse the color value and return the proper ARGB color integer to the native platforms (https://fburl.com/uqup52tn).

Without providing the custom type for the background color, if a string value is set for the top-level `backgroundColor` property in the JS code, the Android code will crash since it expects an integer value for the color in `ReactBaseTextShadowNode.setBackgroundColor(...)`, but a string will be passed from JS without any conversion and there will be a `ClassCastException` thrown. If an integer value without the alpha component (like `0xffccbb`) is set, the Android native view would get an integer color value with its alpha component set to `0x00`, which means a transparent color.

On a side note: the alpha component of a color must always be set when using an integer value for `backgroundColor` since the JS code, while processing the color type, shifts the rightmost 8 bytes (alpha component) to the leftmost position. If those 8 bytes are not the alpha component, you will get the wrong color in the end. It doesn't seem to be a problem for string values of `backgroundColor` though.

Reviewed By: mdvacca

Differential Revision: D15453980

fbshipit-source-id: f3f5d9c9877cdbce79a67f2ed93ad4589576d166
2019-05-24 02:53:42 -07:00
David Vacca 01abcf0e83 Fix update of accessibilityStates in Android
Summary:
This diff fixes a bug on the update of accessibiltyState prop in RN Android.
In particular, this bug was reproducible when a view has an accessibiltyState = ['disabled'] and there was a state update to set the {accessibiltyState = {null}}. In this scenario, the BaseViewManager.setViewStates method did not update the view with the default values for accessibilityState

Reviewed By: sahrens

Differential Revision: D15446078

fbshipit-source-id: 75f160916e55f0ee469516db2fe9b0a7d4758cd8
2019-05-23 18:31:39 -07:00
Emily Janzer f23da3aeb0 Use startSurface on Android
Summary:
Right now calling FabricUIManager.addRootView() doesn't actually start running the application on Android. This diff:

1. Removes the #ifndef so that we actually call UIManagerBinding.startSurface() on Android
2. Passes through the JS module name from addRootView so we can render the surface (falls back to an empty string if not provided, which is the current behavior)
3. Adds an option for starting the surface using `RN$SurfaceRegistry` instead of `AppRegistry`, if that global property has been defined in JS. This is used for Venice (bridgeless RN)

Reviewed By: shergin

Differential Revision: D15366200

fbshipit-source-id: 4a506a589108905d4852b9723aac6fb0fad2d86e
2019-05-23 13:47:30 -07:00
Emily Janzer d742c7be36 Auto-formatting for Binding
Summary:
I just learned about Nuclide's auto-formatting (cmd-shift-c) and started using it in another diff, but I didn't want to pollute the diff with a bunch of formatting changes, so here we are.

I don't know if anyone else uses Nuclide's auto-formatting, or something else - happy to ditch this if that's not how we roll.

Reviewed By: shergin

Differential Revision: D15389601

fbshipit-source-id: e3b20acd073adf3cc7bab1f62d86c5b5dab8c4fc
2019-05-23 13:47:29 -07:00
Marc Mulcahy 099be9b356 New Accessibility states API. (#24608)
Summary:
As currently defined, accessibilityStates is an array of strings, which represents the state of an object. The array of strings notion doesn't well encapsulate how various states are related, nor enforce any level of correctness.

This PR converts accessibilityStates to an object with a specific definition. So, rather than:

<View
...
accessibilityStates={['unchecked']}>

We have:

<View
accessibilityStates={{'checked': false}}>

And specifically define the checked state to either take a boolean or the "mixed" string (to represent mixed checkboxes).

We feel this API is easier to understand an implement, and provides better semantic definition of the states themselves, and how states are related to one another.

## Changelog

[general] [change] - Convert accessibilityStates to an object instead of an array of strings.
Pull Request resolved: https://github.com/facebook/react-native/pull/24608

Differential Revision: D15467980

Pulled By: cpojer

fbshipit-source-id: f0414c0ef6add3f10f7f551d323d82d978754278
2019-05-23 05:37:33 -07:00
Vojtech Novak 04564a0322 allow overriding spannedFromShadowNode in ReactTextInputShadowNode (#24995)
Summary:
Motivation is the same as in https://github.com/facebook/react-native/pull/24927 - when building a custom textinput (eg with rich text editing), one needs custom text processing logic. `ReactTextInputShadowNode` contains https://github.com/facebook/react-native/blob/6671165f69e37a49af8b709b4807f9049f7606c3/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java#L211

where an instance of `ReactTextUpdate` is created. For the custom use case, we'd like to just change the usage of [`spannedFromShadowNode()`](https://github.com/facebook/react-native/blob/6671165f69e37a49af8b709b4807f9049f7606c3/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java#L217) to our own implementation.

from there:
It's easy to subclass `ReactTextInputShadowNode` and override `public void onCollectExtraUpdates()` but the problem is that the method accesses private members. It also means overriding more code than necessary as we only care for `spannedFromShadowNode()`.

Solution might be changing the members to protected, but that seemed weird because there are already setters for them. Creating getters also seemed weird, as we'd end up having unused getters hanging around.

So the second way which I find nicer is changing `protected static Spannable spannedFromShadowNode(ReactBaseTextShadowNode textShadowNode, String text)` to just `protected` since that will allow subclasses to override just this behavior.

## Changelog

[Android] [Added] - allow custom spannedFromShadowNode in ReactTextInputShadowNode subclasses
Pull Request resolved: https://github.com/facebook/react-native/pull/24995

Differential Revision: D15468066

Pulled By: cpojer

fbshipit-source-id: 73d5f0b9e06f3e02a03bf9db5effac62cecc80c4
2019-05-23 05:31:00 -07:00
Blair Vanderhoof 9fb31d1538 Fix layout animation crash
Summary: As of D14529038, LayoutAnimations can sometimes throw an exception due to the view being null.  This can happen when elements are removed/added and is not fixable in product code. This is a temporary fix - the root cause for this issue will be fixed soon.

Reviewed By: lunaleaps

Differential Revision: D15428791

fbshipit-source-id: 41200e572ed7d5d470754792c5576a0ea23fe946
2019-05-22 13:25:00 -07:00
Ramanpreet Nara 5127ac5c2a Implement support for legacy CxxModules
Summary:
## Background
Legacy Cxx NativeModules are implemented as Hybrid classes. Essentially, when a Cxx NativeModule is requested, you instantiate its hybrid class, which then creates a C++ counterpart. Then, the bridge uses the C++ counterpart's `getModule()` method to obtain ownership of the Cxx NativeModule.

## Summary
This diff implements backwards-compability for Cxx NativeModules.

If a Cxx NativeModule implements the `TurboModule` interface, then when the module is requested by name, we:
1. Instantiate its Java hybrid class, createing a C++ counterpart.
3. Obtain the CxxModule from the C++ counterpart using `getModule()` and use it to create a `TurboCxxModule` instance (this forwards all JavaScript method calls to the CxxModule) inside `TurboModuleManager`.
5. Return this `TurboCxxModule` to JS.

Reviewed By: mdvacca

Differential Revision: D15252041

fbshipit-source-id: cdbb62632d7a8735f7687daf62de63df9e3ad2c5
2019-05-22 13:16:13 -07:00
Ramanpreet Nara 37583bd6e8 Only create TurboModule jsi::HostObject if Java module is non-null
Summary:
## Summary
If the Java instance of a TurboModule is null, then the resultant JS object returned from `TurboModuleRegistry` should also be null.

Reviewed By: mdvacca

Differential Revision: D15253476

fbshipit-source-id: 83a6b9aa97b547aeecf9b285986ad0f5b9e413da
2019-05-22 13:16:13 -07:00
Ramanpreet Nara e1102b43ff Implement Android Cxx TurboModule support
Summary:
## Summary
This diff does a bunch of things:
1. The TurboModule resolution algorithm on Android now supports C++ TurboModules.
2. `SampleTurboCxxModule` is moved from `ReactCommon/turbomodule/samples/platform/ios/` to `ReactCommon/turbomodule/samples` so that both iOS and Android can share it.
3. `CatalystTurboModuleManagerDelegate::getTurboModule(std::string, JSCallInvoker)` now understands and returns `SampleTurboCxxModule`.

Reviewed By: mdvacca

Differential Revision: D15253477

fbshipit-source-id: 3def91911b091f8cf93be17decd245a0499ed718
2019-05-22 13:16:13 -07:00
Ramanpreet Nara 08d87cdacc Introduce ReactPackageTurboModuleManagerDelegate
Summary:
## Summary
People use `ReactPackage` instances to create NativeModules. To make the migration from NativeModule to TurboModule easy, I'm introducing a `TurboModuleManagerDelegate` that understands `ReactPackage`s, and uses them to lookup and create the Java TurboModule objects. This way, we don't have to change the way we declare NativeModules for the migration.

## TurboModule registration
Each application should have its own subclass of `ReactPackageTurboModuleManagerDelegate`. This subclass is a hybrid class with a C++ and a Java part. The Java part can (and probably should) do nothing (for now). The C++ part has to implement the `moduleName -> jni::HostObject` and `moduleName, javaInstance -> jni::HostObject` functions for all TurboModules in the application.

**Use Case: Migrating a NativeModule to TurboModule system**
1. Make the Java NativeModule extend `TurboModule`. (The reason why this doesn't happen automatically is probably because we haven't changed the Java codegen yet).
2. Modify the `moduleName -> jni::HostObject` or `moduleName, javaInstance -> jni::HostObject` functions to return the `TurboModule`.

**Use Case: Adding a new TurboModule**
1. Add the TurboModule to a `ReactPackage` in the application.
2. Modify the `moduleName -> jni::HostObject` or `moduleName, javaInstance -> jni::HostObject` functions to return the TurboModule `jsi::HostObject`.

**Note:** It's also possible to declare TurboModules by overriding the `getModule(String moduleName)` function of `ReactPackageTurboModuleManagerDelegate`. It's not a good idea, because it'll make switching between the NativeModule/TurboModule system difficult.

Reviewed By: mdvacca

Differential Revision: D15209129

fbshipit-source-id: 4b0a303595145be9b19d6f4934f956b91990f859
2019-05-22 13:16:13 -07:00
Ramanpreet Nara 12c0ec85f7 Implement ReactContext.getNativeModule support
Summary: `ReactContext.getNativeModule` can be used to access NativeModules. With these changes, it can also be used to instantiate (if necessary) and retrieve a TurboModule.

Reviewed By: mdvacca

Differential Revision: D15167631

fbshipit-source-id: 3cb0d9a4be16cbadebbf6648c3f1481ba26513c3
2019-05-22 13:16:12 -07:00
nossbigg cea0a2b61a Set duration=0 for android keyboard events (#24994)
Summary:
Set duration=0 for android keyboard events. Brings actual implementation closer to existing flowtypes, and duration is set to 0 to minimize impact on existing keyboard event consumers.
Follow up to #24947, upon cpojer's [input](https://github.com/facebook/react-native/pull/24947#issuecomment-494681618) :)

## Changelog

[Android] [Added] - Set duration=0 for android keyboard events
Pull Request resolved: https://github.com/facebook/react-native/pull/24994

Differential Revision: D15449394

Pulled By: cpojer

fbshipit-source-id: d43096238bd38d189fbec54fc2d93f17010d9ddb
2019-05-22 05:41:22 -07:00
Joshua Gross b05761f1bb Pass State to preallocateView and createView methods whenever possible
Summary:
For some components, we will have state as soon as the ShadowNode is created that may be meaningful. In those cases, ViewManagers should be able to use State to create or preallocate views.

FB: This will be used in following diffs for Litho support.

Reviewed By: mdvacca

Differential Revision: D15343702

fbshipit-source-id: 8fd672251cb88dea662b5cae5a9efc96877d28a9
2019-05-21 15:05:18 -07:00
Vojtech Novak c9df1db00a allow custom maybeSetText logic for ReactEditText subclasses (#24927)
Summary:
We're working on a custom EditText that supports some rich text editing, and one of the places where our logic has to be different from the textinput provided by RN is the text setting logic:

https://github.com/facebook/react-native/blob/7abfd23b90db08b426c3c91b0cb6d01d161a9b9e/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L377

However, some of the important members are private and our subclass cannot access them (we work around this now with reflection). It would be nice if we could work with them directly, either using getters and setters or by changing the  access. Let me know what you think about this. Thanks.

## Changelog

[Android] [Added] - allow custom maybeSetText logic for ReactEditText subclasses
Pull Request resolved: https://github.com/facebook/react-native/pull/24927

Differential Revision: D15431682

Pulled By: cpojer

fbshipit-source-id: 91860cadac0798a101ff7df6f6b868f3980ba9b1
2019-05-21 06:41:19 -07:00
nossbigg 168a67e4b2 Return endCoordinates for keyboardDidHide keyboard event (#24947)
Summary:
This pull request enhances the Keyboard API event emitter for Android upon `keyboardDidHide` by returning a `KeyboardEvent` with a meaningful `endCoordinates` property (instead of emitting a null as of current implementation). This change standardizes the `keyboardDidHide` keyboard event emission across both iOS and Android, which makes it easier for developers to use the API.

In particular, the semantics of `endCoordinates` emitted during the `keyboardDidHide` event on Android will match nicely with semantics of the same event emitted on iOS:
- `screenY` will be height of the screen, as that the keyboard has collapsed to the bottom of the screen
- `screenX` will be 0, as the keyboard will always be flush to the sides of the screen
- `height` will be 0, as the keyboard has fully collapsed
- `width` will be the width of the screen, as the keyboard will always extend to the width of the screen

Also, the flowtypes for `KeyboardEvent` have been further improved and are more explicit to better highlight the different object shapes (see `IOSKeyboardEvent` and `AndroidKeyboardEvent`) depending on the platform.

## Changelog

[Android] [Added] - Return endCoordinates for keyboardDidHide keyboard event
Pull Request resolved: https://github.com/facebook/react-native/pull/24947

Differential Revision: D15413441

Pulled By: cpojer

fbshipit-source-id: aa3998542b7068e9852467038f57310355018379
2019-05-21 03:46:50 -07:00
David Vacca 563e0bce97 Refactor sComponentNames Map out of FabricUIManager
Summary:
Easy diff to refactor the sComponentNames map out of the FabricUIManager class.
This is a necessary clean-up to perform a slightly major refactor of the Fabric classes

Reviewed By: JoshuaGross

Differential Revision: D15421769

fbshipit-source-id: 3be73a6e20b338c8cea23ef0c88db417df7e3aa9
2019-05-20 15:43:32 -07:00
David Vacca 3b8fc8b10a Remove warnings
Summary: Easy diff to remove warnings in FabricUIManager

Reviewed By: JoshuaGross

Differential Revision: D15421771

fbshipit-source-id: 647391a0826272d0bc9320196fc8b3cb80eecfac
2019-05-20 15:43:31 -07:00
David Vacca 651ca3bc9f Refactor RootTag -> surfaceId
Summary:
Quick diff to refactor RootTag for surfaceId in Binding.cpp class
This is the first diff to start moving away from rootTag naming in Fabric

Reviewed By: JoshuaGross

Differential Revision: D15421770

fbshipit-source-id: 7bca7782f96be3d7148ee93f5d5a3a54e0d768dd
2019-05-20 15:43:31 -07:00
Eric Lewis 2231263b8b Fix typo in error handler (#24940)
Summary:
Fixes a typo!

## Changelog

[Android] [Fixed] - Typo in NativeModuleRegistryBuilder error handler
Pull Request resolved: https://github.com/facebook/react-native/pull/24940

Differential Revision: D15411931

Pulled By: cpojer

fbshipit-source-id: c5d9305e00160a3a2e8619188ccff77a5b39e910
2019-05-20 02:44:34 -07:00
Uilque Messias 2ad3bb2e2d fix(android): Normalize start and end args (#24938)
Summary:
Fixes #18579

Normalize `start` and `end` arguments when `onSelectionChange` is
dispatched on Android.

It just applies a [fix](https://github.com/facebook/react-native/issues/18579#issuecomment-474466525) sent by TheSavior (Thanks, by the way 😄)

## Changelog

[Android] [Fixed] - fix(android): Normalize start and end args
Pull Request resolved: https://github.com/facebook/react-native/pull/24938

Differential Revision: D15412005

Pulled By: cpojer

fbshipit-source-id: bb132313cfb8877a682f3865a5f9e48d45ac20ac
2019-05-20 01:45:51 -07:00
Sharon Gong 14b4668947 Extended Accessibility Actions Support (#24695)
Summary:
This is a reconstitution of #24190. It extends accessibility actions to include both a name and user facing label. These extensions support both standard and custom actions.

We've also added actions support on Android, and added examples to RNTester showing how both standard and custom accessibility actions are used.

## Changelog

[general] [changed] - Enhanced accessibility actions support
Pull Request resolved: https://github.com/facebook/react-native/pull/24695

Differential Revision: D15391408

Pulled By: cpojer

fbshipit-source-id: 5ed48004d46d9887da53baea7fdcd0e7e15c5739
2019-05-20 01:32:53 -07:00
luancurti bb060d6cf8 Fix DatePickerAndroid with mode spinner on Android Nougat(7.0) (#24739)
Summary:
When mode is spinner in Android Nougat the DatePicker shows calendar

I got it from https://gist.github.com/jeffdgr8/6bc5f990bf0c13a7334ce385d482af9f and
did some adjustments in order to work with `DatePicker`. Workaround for this bug: https://code.google.com/p/android/issues/detail?id=222208. In Android 7.0 Nougat, spinner mode for the DatePicker in DatePickerDialog is incorrectly displayed as calendar.

## Changelog

[Android][Fixed] Fix date picker with mode spinner on Android Nougat (7.0)
Pull Request resolved: https://github.com/facebook/react-native/pull/24739

Differential Revision: D15391354

Pulled By: cpojer

fbshipit-source-id: 09f45367250aa14857a9c68846c7f2ce7c49ee3b
2019-05-17 02:54:12 -07:00
Oleg Lokhvitsky 7abfd23b90 Fix error in Animated Interpolation when inputMin === inputMax
Summary:
This is already handled cleanly on the JS side of things in AnimatedInterpolation.js: https://github.com/facebook/react-native/blob/0ee5f68929610106ee6864baa04ea90be0fc5160/Libraries/Animated/src/nodes/AnimatedInterpolation.js#L133-L142

However, the native driver interpolation will try to divide by 0, produce NaN and then crash. This change just copies the logic from the JS version of the interpolation logic and adds it to the Java version.

Note that this bug only reproduces on Android Q. It seems that RenderNode::setCameraDistance now crashes when receiving NaN on Android Q.

Reviewed By: sahrens

Differential Revision: D15380844

fbshipit-source-id: cfa82d8f58574e1040a851aaa5b5af1e23c9daa8
2019-05-16 18:15:11 -07:00
David Vacca 016afe26bc Adding @Nullable into Fabric UI Manager
Summary: cleanup diff to add Nullable annotations into Fabric UI Manager classes

Reviewed By: shergin

Differential Revision: D15365295

fbshipit-source-id: b9d39addd5b71377389a7687ea3176cd4359c5ba
2019-05-16 13:00:25 -07:00
Alexey Lang 1ece46b42c Use array map from android support library
Summary: `android.util.ArrayMap` ins't available on API < 19. Let's use the one that Android Support Library (aka AndroidX) provides.

Reviewed By: mdvacca

Differential Revision: D15372704

fbshipit-source-id: 5c2ea3c7ea7368bb75ff22c54af0b258558556b5
2019-05-16 11:02:58 -07:00
Sidharth Guglani a2707ac97d added listener in flipper plugin for yoga
Summary:
Adds YogaEventListener interface and it's implementation which will be used in flipper for events coming from Yoga
After this diff , we will start getting layout calculate events in flipper listener

Reviewed By: davidaurelio

Differential Revision: D15316928

fbshipit-source-id: da3a53374a52386037b553d460038d988b0162c2
2019-05-15 01:20:08 -07:00
Joshua Gross 04782ff57a Send ReactNative C++ State to Android measure API
Summary:
The `measure` API receives LocalData and Props, it should also receive State.

This will also be used in future diffs.

Reviewed By: mdvacca

Differential Revision: D15325182

fbshipit-source-id: 6cb46dd603ce7d46673def16f0ddb517e2cf0c4f
2019-05-14 14:22:10 -07:00
Moti Zilberman a05e9f8e09 Android: Sort modules by ID when serializing delta bundle
Summary:
Fixes redbox/yellowbox symbolication when the Java delta client is enabled. Previously the modules would get concatenated in a nondeterministic order (owing to Metro's parallelism) which differed from their order in the source map, where they're explicitly sorted by module ID.

This diff changes the data structure holding modules in memory from a `LinkedHashMap` (which iterates in insertion order) to a `TreeMap` (which iterates in key order).

NOTE: Similar to this change in the Chrome debugger's delta client: https://github.com/react-native-community/cli/pull/279

Reviewed By: dcaspi

Differential Revision: D15301927

fbshipit-source-id: 27bdecfb3d6963aa358e4d542c8b7663fd9eb437
2019-05-14 10:24:57 -07:00
wojteg1337 e4aff423ac fix: set js delta bundle default value to false (#24848)
Summary:
When running Android app for the first time, the packager is requesting delta bundles from metro instead of a bundle (in dev settings delta bundles are disabled by default and marked as experimental). UI of dev settings is not consistent with the current state, to turn off delta bundles you have to enable them and then disable.

[Android] [Fixed] - Disable delta bundles on the first app run
Pull Request resolved: https://github.com/facebook/react-native/pull/24848

Differential Revision: D15334059

Pulled By: cpojer

fbshipit-source-id: 384a8abba64c54db3656a4d5d0e24acc825870c8
2019-05-14 04:20:14 -07:00
Luna Wei 0d7a0dc997 Add log to view that is being dropped
Summary:
We are getting errors where views are being dropped twice.
This is following from logic that viewManagers are only removed from `mTagsToViewManagers` from `dropView`.

This log will hopefully identify if we are getting improper operations because we shouldn't be re-using tags

Reviewed By: mdvacca

Differential Revision: D15152869

fbshipit-source-id: 914ee9c1772fa066adefde0753075ecba6377a0c
2019-05-13 11:00:55 -07:00
David Vacca 1b4678105b Ensures constraintSurfaceLayout is executed before 'JS run application' starts
Summary:
This diff ensures the method scheduler.constraintSurfaceLayout is executed before the JS run application start.
This is necessary to properly set the pointScaleFactor for the Root before running JS.

This is a workaround to fix a bug when the pointScaleFactor changes over time for the rootShadowNode. The bug is easily reproducible when rendering the "fabric" indicator on Fabric screens. During the first render of a Fabric screen this method was called before "JS run application" starts, and the Fabric indicator was render correctly.
Beacuse of timing of measure APIS, the second time a Fabric screen is rendered the method is called after the "JS run application process started", as a consecuence the Fabric indicator is not rendered correctlly (the pointScaleFactor is incorrectly assigned into the layout metrics of the Fabric indicator text).

We still need to analyze why the pointScaleFactor is not correctly assigned when it is set after the "JS run application process started", but this will be part of another diff.

Reviewed By: shergin

Differential Revision: D15303554

fbshipit-source-id: 7d985cefee20fd40dbe04166c1a1358b3f3ddc85
2019-05-10 16:32:01 -07:00
Valentin Shergin 184073813e Fabric: Making YogaStylableProps.yogaStyle protected
Summary: `YogaStylableProps.yogaStyle` is designed to be consumed by Yoga only. Making it `protected` allows us to avoid confusion and misuse of this props.

Reviewed By: JoshuaGross

Differential Revision: D15296474

fbshipit-source-id: cf9e416afee99fb426d72765557b34d303a63dbe
2019-05-10 15:34:25 -07:00
Kudo Chien 310cc38a5a Fix PickerAndroid will reset selected value during items update. (#24793)
Summary:
Fixes #13351

Two root causes:
1. Android Spinner will reset selection to undefined after setAdapter()
   which will trigger onValueChange().
   The behavior is not expected for RN.
   And the solution is to setSelection() explicitly

2. In original implementation, it setups `items` immediately,
   but delays the `selected` setup after update transaction.
   There will be some race condition and incosistency
   if update `items` only.
   The fix will do the setup all after update transaction.

[Android] [Fixed] - Fix #13351 PickerAndroid will reset selected value during items update.
Pull Request resolved: https://github.com/facebook/react-native/pull/24793

Differential Revision: D15293516

Pulled By: cpojer

fbshipit-source-id: 5a99a60015c7e1b2968252cdc0b2661d52a15b9d
2019-05-10 02:01:14 -07:00
Maciej Srokowski ebeb893b50 Fix Android Camera Roll crash on mime type guessing (#24780)
Summary:
Fixes this issue:
https://github.com/facebook/react-native/issues/24468
It was incorrectly closed by a fix on react-native-community CameraRoll implementation. CameraRoll in react-native still crashes when finding a file with # sign

[Android] [Fix] - Fix Android Camera Roll crash on mime type guessing
Pull Request resolved: https://github.com/facebook/react-native/pull/24780

Reviewed By: mdvacca

Differential Revision: D15281062

Pulled By: lunaleaps

fbshipit-source-id: ca3364c8478d9bfc9a0a6657b531ffb384145d8c
2019-05-09 18:40:59 -07:00
Emily Janzer d5b27fc0a8 Allow creating ThemedReactContext without a CatalystInstance
Summary: In the future we're planning to decouple ThemedReactContext from the bridge (CatalystInstance). For now, we just need to be able to create a ThemedReactContext with a ReactContext that has no Catalyst instance.

Reviewed By: mdvacca

Differential Revision: D15246442

fbshipit-source-id: 99ebda6521f4df72969011ea0e6ea41b046875c8
2019-05-09 17:47:18 -07:00
Emily Janzer db40c28728 Move message queue initialization in ReactContext into its own method
Summary: Refactoring ReactContext to move message queue initialization into its own function that can be called independently of initializeWithInstance. This allows you to create a ReactContext with message queue threads without a CatalystInstance.

Reviewed By: mdvacca

Differential Revision: D15246287

fbshipit-source-id: 4b8c53e68112af7eded47d8c31311500cc296dfe
2019-05-09 15:49:18 -07:00
Emily Janzer 078f14c5d2 Require passing in JSCallInvokerHolder to TurboModuleManager
Summary: Right now TurboModuleManager gets the JSCallInvokerHolder from the bridge in its constructor; this diff changes the constructor to make the JSCallInvokerHolder a required argument so that TurboModuleManager doesn't directly depend on the bridge.

Reviewed By: axe-fb, RSNara

Differential Revision: D15227184

fbshipit-source-id: b16e6abaa727587986a132d0e124163acdf55408
2019-05-09 11:28:30 -07:00
David Aurelio 7d44113bee **breaking:** remove YGNodeGetInstanceCount
Summary:
@public

`YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments.

It was completely replaced with event-based counting for tests.

Here we remove public API around the counter, and the counter itself.

Reviewed By: SidharthGuglani

Differential Revision: D15174857

fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
2019-05-09 04:22:42 -07:00
Joshua Gross d7447fadeb Core React/Litho support and Java codegen
Summary:
Core React/Litho support and Java codegen. View updating still in progress.

Generated ViewManager code:

```
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Autogenerated by ComponentsReactNativeSupportProcessor
package com.facebook.catalyst.samples.componentsembedding;

import com.facebook.litho.Component;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.reactnative.ComponentsShadowNode;
import com.facebook.litho.reactnative.ComponentsViewManager;
import com.facebook.litho.reactnative.ReactLithoView;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;
import java.util.HashMap;
import java.util.Map;

ReactModule(
    name = "SampleComponent"
)
public class GeneratedSampleComponentViewManager extends ComponentsViewManager {
  Override
  public String getName() {
    return "SampleComponent";
  }

  Override
  public ReactLithoView createViewInstanceWithProps(ThemedReactContext context,
      ReactStylesDiffMap props) {
    Map<String, Object> propsMap;
    if (props != null && props.toMap() != null) {
      propsMap = props.toMap();
    } else {
      // Non-Fabric will always follow this path, initial props are never provided;
      return ReactLithoView.create(context, null, null);
    }
    Component component = createComponentInstanceWithPropsMap(new ComponentContext(context), propsMap);
    return ReactLithoView.create(context, component, propsMap);
  }

  Override
  public Component createComponentInstanceWithPropsMap(ComponentContext context,
      Map<String, Object> propsMap) {
    SampleComponent.Builder componentBuilder = SampleComponent.create(context);
    setComponentBuilderPropsWithMap(componentBuilder, propsMap);
    return componentBuilder.build();
  }

  Override
  public void updateProperties(ReactLithoView view, ReactStylesDiffMap props) {
    super.updateProperties(view, props);
    Map<String, Object> propsMap = props.toMap();
    Map<String, Object> oldProps = view.getProps();
    if (oldProps == null) {
      // Non-Fabric RN will always terminate here; we do not store props, nor do we need to.;
      // Prop updating happens incrementally in non-Fabric RN.;
      return;
    }
    Map<String, Object> mergedProps = new HashMap<>(oldProps);
    mergedProps.putAll(propsMap);
    SampleComponent.Builder componentBuilder = SampleComponent.create(new ComponentContext(view.getComponentContext()));
    setComponentBuilderPropsWithMap(componentBuilder, mergedProps);
    view.setProps(mergedProps);
    view.setComponent(componentBuilder.build());
  }

  private void setComponentBuilderPropsWithMap(SampleComponent.Builder componentBuilder,
      Map<String, Object> propsMap) {
    if (propsMap != null && propsMap.containsKey("title")) {
      componentBuilder.title((((String)propsMap.getOrDefault("title", null))));
    }
    if (propsMap != null && propsMap.containsKey("imageUri")) {
      componentBuilder.imageUri(android.net.Uri.parse(((String)propsMap.getOrDefault("imageUri", null))));
    }
  }

  Override
  public GeneratedSampleComponentShadowNode createShadowNodeInstance(ReactApplicationContext context) {
    return new GeneratedSampleComponentShadowNode();
  }

  Override
  public Class<? extends ComponentsShadowNode> getShadowNodeClass() {
    return GeneratedSampleComponentShadowNode.class;
  }

  Override
  public void updateState(ReactLithoView view, StateWrapper stateWrapper) {
    view.setStateWrapper(stateWrapper);
  }
}
```

Reviewed By: shergin

Differential Revision: D14846423

fbshipit-source-id: 4eeeb991f7e32c0cec5e9307d6175b81c8fd034e
2019-05-08 14:53:51 -07:00
Ramanpreet Nara f2618fd81b Fix OSS Android build (#24764)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/24764

The `test_android` CI build was failing:

```
./scripts/circleci/buck_fetch.sh
+ buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
Not using buckd because watchman isn't installed.
Picked up _JAVA_OPTIONS: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
PARSING BUCK FILES: FINISHED IN 1.1s
No build file at ReactAndroid/src/main/libraries/fbjni/BUCK when resolving target //ReactAndroid/src/main/libraries/fbjni:java.

This error happened while trying to get dependency '//ReactAndroid/src/main/libraries/fbjni:java' of target '//ReactAndroid/src/main/java/com/facebook/react/turbomodule/core:jscallinvokerholder'
Exited with code 1
```

The problem was that I was using `react_native_dep("libraries/fbjni:java")` to access JNI classes like `HybridData`. In open source this target translates to the path `//ReactAndroid/src/main/libraries/fbjni`, which doesn't exist. Instead, the actual classes are available at the path `//ReactAndroid/src/main/java/com/facebook/jni`. Therefore, I changed the target to `react_native_dep("java/com/facebook/jni:jni")`. This is exactly how the bridge (i.e: `//ReactAndroid/src/main/java/com/facebook/react/bridge:bridge`) accesses JNI clases.

Reviewed By: hramos

Differential Revision: D15261218

fbshipit-source-id: 659a5627389bbca3603db7de347618cd400d4ffc
2019-05-08 12:28:26 -07:00
Alan Kenyon 09f17a4e29 AccessibilityInfo.announceForAccessibility (#24746)
Summary:
AccessibilityInfo.announceForAccessibility is currently only available on iOS. I've added the Android specific implementation, updated RNTester, and the documentation.

[Android] [Added] - Added AccessibilityInfo.announceForAccessibility for Android
[General] [Added] - RNTester example for AccessibilityInfo.announceForAccessibility
Pull Request resolved: https://github.com/facebook/react-native/pull/24746

Differential Revision: D15258054

Pulled By: cpojer

fbshipit-source-id: 3e057a5c32b28e30ea2ee74a18854b012cd2dbfd
2019-05-08 03:58:13 -07:00
Dulmandakh fd6386a07e custom fonts support The Android Way (#24595)
Summary:
In https://github.com/facebook/react-native/pull/23865, RN introduced support for custom fonts the Android Way. But it introduced performance regression because it'll lookup for a font using getIdentifier() every time fontFamily changed. This PR fixes regression by requiring custom fonts to be listed in **fonts** array, and populating **mTypeCache** at first use using the list.

[Android] [Changed] - Require custom fonts to list in **fonts** array. Fixes performance regression.
Pull Request resolved: https://github.com/facebook/react-native/pull/24595

Reviewed By: mdvacca

Differential Revision: D15184590

Pulled By: fkgozali

fbshipit-source-id: e3feb2396609583ebc95101130186a1f5af931da
2019-05-07 18:44:10 -07:00