Граф коммитов

18197 Коммитов

Автор SHA1 Сообщение Дата
Logan Daniels 4f7659d675 Export types so codemod can use them
Reviewed By: panagosg7

Differential Revision: D17518337

fbshipit-source-id: 253bf0fb4955efc7788be1bc4e662bed37e67acf
2019-09-24 10:00:59 -07:00
Emily Janzer 6464ef0a92 Add @DoNotStrip to JavaScriptModule interfaces
Summary: Adding `DoNotStrip` to all the interfaces that extend `JavaScriptModule` to ensure they don't get stripped from release builds (because they have no Java implementors).

Reviewed By: emma0303

Differential Revision: D17534719

fbshipit-source-id: a793764caf17040bf1252be7ec4c72176d6989d4
2019-09-24 09:36:16 -07:00
Emily Janzer 990c9ea5ec Remove bridge access from JavaTimerManager, again
Summary: Another attempt at D17282188, which got partially reverted in D17505827 due to a crash in release builds.

Reviewed By: RSNara

Differential Revision: D17512419

fbshipit-source-id: a1b0abfed2c4a1f3f02da85e84abee0127b1a7e2
2019-09-23 19:14:43 -07:00
Valentin Shergin 3bc09892c0 Fabric: Enforcing const-correctness around ImageResponseObserverCoordinator
Summary:
`addObserver` and `removeObserver` now accepts const references instead of pointers which indicates the intent (non-nullability and non-owning) clearly. The delegate methods are also marked as `const` to designate the possible concurrent execution (`const` means "thread-safe" here).

All changes are pure syntactical, nothing really changes (besides the fact overall code quality and redability).

Reviewed By: JoshuaGross

Differential Revision: D17535395

fbshipit-source-id: b0c6c872d44fee22e38fd067ccd3320e7231c94a
2019-09-23 15:59:45 -07:00
Valentin Shergin 5dc16e2f43 Fabric: Fixed possible data race in ImageResponseObserverCoordinator
Summary:
# A race condition
The practical thing of this diff is fixing a data race.
Imagine a case where a thread A calls `addObserver` and thread B calls `nativeImageResponseFailed` at the same time.
Thread A might read `status_` exclusively and store result as a local variable and then go sleep.
Then thread B starts and finishes `nativeImageResponseFailed`, it writes `status_` and notifies all observers.
Then thread B wakes up. It adds an observer to a collection of observers and finishes.
As a result, the observer from `addObserver` will never be called.

To fix this, we changed a logic a bit to lock only once per method. During the lock, we read and/or write to storage and then perform side-effects.
In contrast, previously we often locked only around the access of a particular instance variable (several times per method).

The challenge here is that idiomatic/fancy to C++/STL ways to lock mutexes don't work in our case.

# C++ idioms and readability, multiple locks for the same transaction
STL has tools to avoid calling `lock` and `unlock` methods manually (std::lock_guard<> and lamdas). Unfortunately, using that in our use case is quite problematic. That's probably possible but will lead to much less readable code and some copy-pasta in `addObserver`.
Therefore we replaced using `std::lock_guard` with simple `lock` and `unlock` where using `std::lock_guard` was problematic.

# Why we changed `shared_mutex` to a normal one?
After consolidating the locks we found that we have an only case where we can use shared lock (in `nativeImageResponseProgress`). Calling this method in real life is not concurrent, so it makes sense to replace a shared lock with a more simple and performant regular one.

Reviewed By: sammy-SC

Differential Revision: D17368739

fbshipit-source-id: 61d66fb737d8c2dc73001a80a31edaa59a16d886
2019-09-23 15:59:44 -07:00
Valentin Shergin 69f9fd4f96 Fabirc: Improvements in `ImageResponseObserverCoordinator`
Summary:
This diff contains some small improvements in `ImageResponseObserverCoordinator` which are pretty minor:
 * Now we use `small_vector` instead of a normal one. In the vast majority of cases, the coordinator has only one observer, so having `small_vector` with default size `1` saves us a memory allocation (which is a dozen of allocations for a screen, not bad).
 * Empty constructor and destructor were removed.
 * Unnecessary copying of ImageResponse was removed. ImageResponse is a practically a shared_pointer, it has value semantic and does not need to be copied. We don't need to acquire mutex to access that.

Reviewed By: sammy-SC

Differential Revision: D17368740

fbshipit-source-id: 828e27a72b9c8ac0063c5fbda00f83ddb255309c
2019-09-23 15:59:44 -07:00
Kevin Gozali bfc9839a63 iOS Image: skip CADisplayLink optimization only when weakProxy is enabled
Summary: Just need to validate the intended fix properly via simple gating mechanism.

Reviewed By: mmmulani

Differential Revision: D17536264

fbshipit-source-id: 92db4156beabd6dec2a71b6ea7c2d7bf708d44b1
2019-09-23 15:25:30 -07:00
Luna Wei 9cd2a5f86e Create ScrollViewCommands
Summary: Use NativeCommands interface to dispatch command for ScrollViewManager

Reviewed By: TheSavior

Differential Revision: D17077016

fbshipit-source-id: 3f16b0ab212a7de31ebde1515aafb137ac4f8001
2019-09-23 15:25:30 -07:00
Ramanpreet Nara f5ab719445 Make RCTClipboard, RCTI18nManager, and RCTSourceCode TurboModule-compatible
Summary: These NativeModules were easy to convert, since no other NativeModules in `React/Modules` depend on them.

Reviewed By: PeteTheHeat

Differential Revision: D16817959

fbshipit-source-id: 1036c2d437e1275776a185bf68c450c6454985df
2019-09-23 15:25:30 -07:00
Daniel 21890e964d Fix onPress prop for Touchable Components being called twice on Android Tv (#26474)
Summary:
Due to an update to react-native on the  android tv platform tapping the select button on a remote calls the onPress prop twice for `TouchableHighlight`, `TouchableOpacity`, and `TouchableWithoutFeedback`. This is happening because touchableHandlePress gets called from two places. First from the onClick prop in the touchable component and second from the TVEventHandler in the TouchableMixin.

## Changelog

[Android] [Fixed] - Adds a not android check to the select case of the TVEventHandler callback in the TouchableMixin.
Pull Request resolved: https://github.com/facebook/react-native/pull/26474

Test Plan:
Confirmed on Android Tv and Apple Tv

1) Add a TouchableOpacity to a screen with an onPress callback
2) Run app
3) Focus the TouchableOpacity
4) Press the Select Button on the Remote

**Expected Results**
onPress is called once

Differential Revision: D17530170

Pulled By: TheSavior

fbshipit-source-id: b776faba477c6231ad296abd21f072335dca5556
2019-09-23 14:46:41 -07:00
Janic Duplessis 211ea485cd Fix `includeFontPadding` for `TextInput` placeholder (#26432)
Summary:
The custom font I'm using requires using `includeFontPadding={false}` to be correctly centered vertically. The only case where this is not working is with the placeholder of `TextInput`. To fix it we call `setIncludeFontPadding` on the `EditText` instance, like we do for `Text`.

## Changelog

[Android] [Fixed] - Fix `includeFontPadding` for `TextInput` placeholder
Pull Request resolved: https://github.com/facebook/react-native/pull/26432

Test Plan:
Tested the fix in an app.

Before

![image](https://user-images.githubusercontent.com/2677334/64898120-f1de0600-d653-11e9-97b3-f53416d5f9fe.png)

After

![image](https://user-images.githubusercontent.com/2677334/64897961-5b114980-d653-11e9-8897-baa14fc0f56c.png)

Reviewed By: mdvacca, mmmulani

Differential Revision: D17468767

Pulled By: JoshuaGross

fbshipit-source-id: ae29debf9a57198a636a24ec8ed9ba3d77f0a73e
2019-09-23 10:28:05 -07:00
Janic Duplessis 8b9f790069 Fix medium font weights for TextInput on Android (#26434)
Summary:
When using a medium (500) font weight on Android the wrong weight is used for the placeholder and for the first few seconds of input (before it gets text back from JS). To fix it I refactored the way we handle text styles (family, weight, style) to create a typeface to be more like the `Text` component.

Since all these 3 props are linked and used to create the typeface object it makes more sense to do it at the end of setting props instead of in each prop handler and trying to recreate the object without losing styles set by other prop handlers. Do do that we now store fontFamily, fontStyle and fontWeight as ivar of the ReactEditText class. At the end of updating prop if any of those changed we recreate the typeface object.

This doesn't actually fix the bug but was a first step towards it. There were a bunch of TODOs in the code to remove duplication between `Text` and `TextInput` for parsing and creating the typeface object. To do that I simply moved the code to util functions in a static class. Once the duplication was removed the bug was fixed! I assume proper support for medium font weights was added for `Text` but not in the duplicated code for `TextInput`.

## Changelog

[Android] [Fixed] - Fix medium font weights for TextInput on Android
Pull Request resolved: https://github.com/facebook/react-native/pull/26434

Test Plan:
Tested in my app and in RNTester that custom styles for both text and textinput all seem to work.

Repro in RNTester:

```js
function Bug() {
  const [value, setValue] = React.useState('');
  return (
    <TextInput
      style={[
        styles.singleLine,
        {fontFamily: 'sans-serif', fontWeight: '500', fontSize: 32},
      ]}
      placeholder="Sans-Serif 500"
      value={value}
      onChangeText={setValue}
    />
  );
}
```

Before:

![font-bug-1](https://user-images.githubusercontent.com/2677334/64902280-6889fc00-d672-11e9-8f44-9e524d844a6c.gif)

After:

![font-bug-2](https://user-images.githubusercontent.com/2677334/64902282-6cb61980-d672-11e9-8163-ace0f23070b6.gif)

Reviewed By: mmmulani

Differential Revision: D17468825

Pulled By: JoshuaGross

fbshipit-source-id: bc2219facb94668551a06a68b0ee4690e5474d40
2019-09-23 10:23:29 -07:00
Janic Duplessis 0cafa0f5d1 Use `warnOnce` for excessive number of callbacks error (#26508)
Summary:
I happened to hit this error a couple times and the issue is that if there are let's say 1000 pending callbacks the error would be triggered 500 times and pretty much crash the app. I think it is reasonable to use warn once here so it only happens once.

## Changelog

[General] [Fixed] - Use `warnOnce` for excessive number of callbacks error
Pull Request resolved: https://github.com/facebook/react-native/pull/26508

Test Plan: Tested by reducing the number of pending callbacks required to trigger the error.

Reviewed By: TheSavior

Differential Revision: D17512917

Pulled By: JoshuaGross

fbshipit-source-id: 5ce8e2a0a166805cc6f3fe6d78e2716d6792a80e
2019-09-23 10:14:51 -07:00
Valentin Shergin 30e9443487 Fabric: Fixed threading issue in RCTNativeAnimatedModule
Summary:
The previous version of the code accessed `_animIdIsManagedByFabric` on the main thread (which is should be accessed on the UIManager thread) and called `flushOperationQueues` on the main thread as well (also must be called on UIManager thread because it modifies instance variables (e.g. `_operations`) which supposed to be accessed on UIManager thread).

The diff fixes that introducing an additional queue jump. That's should be fine because the overall architecture of RCTNativeAnimatedModule is appeared to be asynchronous and should be resilient to possible races.

Reviewed By: sammy-SC

Differential Revision: D17523958

fbshipit-source-id: c4b4ce38b68b009726b2f6c28c38b32b9f9d6921
2019-09-23 09:30:38 -07:00
Oleksandr Padalko 034a7d185f Add new method jsBundleURLForBundleRoot with fallback block to RCTBundleURLProvider
Reviewed By: julian-krzeminski

Differential Revision: D17336324

fbshipit-source-id: b14a08d940ec7594978d3e34f1e833f65d3bd411
2019-09-23 09:26:59 -07:00
Samuel Susla 845cbec5cf Add codegen support for EdgeInsets
Summary: Add codegen support for `EdgeInsets`.

Reviewed By: rickhanlonii

Differential Revision: D17500509

fbshipit-source-id: b2909fe296c51d3a47cc961c45294eead7707853
2019-09-23 09:12:51 -07:00
Oleksandr Melnykov 5cfe588993 Use generated Java delegate for setting properties on ReactSwitchManager
Summary: This diff migrates `ReactSwtichManager` to use the generated `ReactSwtichManagerDelegate` for setting its properties.

Reviewed By: TheSavior

Differential Revision: D17395067

fbshipit-source-id: 1489c5d08cef860030ecbd23ef19bd8de1328d71
2019-09-23 07:18:10 -07:00
Oleksandr Melnykov 81f567d4aa Use generated Java delegate for setting properties on ReactDrawerLayoutManager
Summary: This diff migrates `ReactDrawerLayoutManager` to use the generated `AndroidDrawerLayoutManagerDelegate` for setting its properties.

Reviewed By: mdvacca

Differential Revision: D17343383

fbshipit-source-id: 85cd7ee3531b152da2601048f5e458f5dad73ad6
2019-09-23 07:18:10 -07:00
Oleksandr Melnykov 92f3b4a27f Allow null as default value for float props
Summary:
Some props must have their default values set by native. To be able to support this, we have to introduce a null as a supported default value for some types. In this diff I'm adding support for null default values for float props. An example of this to be useful is `ReactDrawerLayoutManager`:

```
  Override
  public void setDrawerWidth(ReactDrawerLayout view, Nullable Float width) {
    int widthInPx =
        width == null
            ? LayoutParams.MATCH_PARENT
            : Math.round(PixelUtil.toPixelFromDIP(width));
    view.setDrawerWidth(widthInPx);
  }
```

We need to be able to generate an interface method, that accepts a boxed `Float` value instead of the primitive `float` so that the native code can decide what value to use by default (`LayoutParams.MATCH_PARENT` in this case).

Reviewed By: rickhanlonii

Differential Revision: D17343172

fbshipit-source-id: 7662a4e0e495f58d05a92892f063535a359d09ae
2019-09-23 07:18:09 -07:00
Oleksandr Melnykov 2e7545cf7e Use generated Java delegate for setting properties on ReactProgressBarViewManager
Summary: This diff migrates `ReactProgressBarViewManager` to use the generated `AndroidProgressBarManagerDelegate` for setting its properties.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D17315619

fbshipit-source-id: 6293c6fc18567a934b6f3dce9b77abcc408052d8
2019-09-23 07:18:09 -07:00
Oleksandr Melnykov 23557d1f9a Flow type AndroidSwitch and generate Android OSS classes
Summary: This diff adds Flow types to `AndroidSwitchNativeComponent`.

Reviewed By: TheSavior

Differential Revision: D17205083

fbshipit-source-id: 3d11f11e269388b78a5f0ed528be94df04f9719d
2019-09-23 07:18:09 -07:00
Oleksandr Melnykov bf89d1d536 Allow null as default value for boolean props
Summary: Some props must have their default values set by native. To be able to support this, we have to introduce a `null` as a supported default value for some types. In this diff I'm adding support for `null` default values for boolean props. Check D17260168 for the example of the usage of the nullable boolean values.

Reviewed By: rickhanlonii, TheSavior

Differential Revision: D17258234

fbshipit-source-id: 63b7864be97856704d5964230526f23c0e395a67
2019-09-23 07:18:08 -07:00
Oleksandr Melnykov ef3b16ef6d Use generated Java delegate for setting properties on SwipeRefreshLayoutManager
Summary: This diff migrates `SwipeRefreshLayoutManager` to use the generated `AndroidSwipeRefreshLayoutManagerDelegate`.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D17225894

fbshipit-source-id: e659d2a9cb5dba42c589559f61a0e98330e21612
2019-09-23 07:18:08 -07:00
Oleksandr Melnykov 1eb8ef59ad Use generated Java delegate for setting properties on ReactModalHostManager
Summary: This diff migrates `ReactModalHostManager` to use the generated `ModalHostViewManagerDelegate` for setting its properties.

Reviewed By: mdvacca

Differential Revision: D17205817

fbshipit-source-id: 6724302fd4301f9df92df04fcfb41f0c2c939d9f
2019-09-23 07:18:08 -07:00
Oleksandr Melnykov 5925b3d408 Use generated Java delegate for setting properties on ReactSliderManager
Summary: This diff migrates `ReactSliderManager` to use the generated `SliderManagerDelegate` for setting its properties.

Reviewed By: mdvacca

Differential Revision: D17203078

fbshipit-source-id: 726736ef275074ecb799b334342ac64976153e2b
2019-09-23 07:18:07 -07:00
Samuel Susla 85575dd8e5 Small adjustment in order of operations in RCTImageComponentView
Summary: Small adjustment to order of operations. In case eventEmitter is nil, we still want to set image to nil.

Reviewed By: shergin

Differential Revision: D17503570

fbshipit-source-id: fd013c60e1188bcf63ff28ff7aad814582a3ae34
2019-09-23 02:50:55 -07:00
Amir Shalem c205b1d391 Use direct access to YogaConfig mNativePointer parameter
Summary:
Use direct access to YogaConfig mNativePointer parameter

Results:
```
The following primary metrics showed statistically significant changes at the 95% confidence level:
javaFullLifecycleAllocateCalculateReadLayout	-1.25%
javaLayoutReading	0.44%
javaYogaNodeAllocateAndSetProps	-1.92%
javaYogaNodeAllocation	-2.11%
javaYogaNodeStylePropAssignment	-0.89%
```

Differential Revision: D17519542

fbshipit-source-id: c39bfe1b0ecae9149dc6da2a0a7e936df215ec5b
2019-09-22 13:48:52 -07:00
Peter Argany 5a81a204c1 Enable setTimeout [4/N]
Summary: The OSS change in this diff allows `RCTDisplayLink` to call out to an observer, even if the `RCTModuleData` isn't well formed. This is the case in bridgeless RN.

Reviewed By: ejanzer

Differential Revision: D17438647

fbshipit-source-id: 00d4d61d9126902180a7a77fc702f4221cf4d779
2019-09-20 18:28:39 -07:00
Peter Argany 3fd920583b Enable metro
Summary: The OSS file touched in this diff is just a styling change.

Reviewed By: ejanzer

Differential Revision: D17400387

fbshipit-source-id: e51884d8942ba01e7da1662ac24429070e53a504
2019-09-20 18:28:38 -07:00
Peter Argany 33e65c6fd4 Create a new Timers class to reuse old RCTTiming Native Module [2/N]
Summary:
Similar to Android Venice impl, I plan to reuse old Timing native module because it's quite complex, and there's not much to gain from re-writing it. When we delete bridge access from it, we can remove any cruft, but IMO it's quite lean already.

The name of this class is a little confusing IMO, I originally had it because it was similar to `Timers.java` but then Emily renamed :p Here's the architecture drawn out:

{F209114665}

If anyone has a better name I'm all ears.

Reviewed By: RSNara

Differential Revision: D17376028

fbshipit-source-id: 066ae0b379cd00538021a1327a4dd63d5a828608
2019-09-20 18:28:38 -07:00
Peter Argany 77c9c95840 Refactor RCTTiming to work without the bridge [1/N]
Summary:
Instead of relying on the bridge to do module setup, allow for regular initialization.

Instead of relying on the bridge to execute timers, allow for a delegate to do the work.

Reviewed By: RSNara

Differential Revision: D17375924

fbshipit-source-id: 83adabf8c962a5d90a4ea623618903cd9fb79a99
2019-09-20 18:28:38 -07:00
Kevin Gozali 4856494d32 iOS Pods: use tar.gz offline mirrors instead of pods replica
Summary: Tweaking things to allow proper offline caching for FB internal builds.

Reviewed By: PeteTheHeat

Differential Revision: D17491386

fbshipit-source-id: 77295588c121190628d38ef95d5416cba06c121e
2019-09-20 16:20:16 -07:00
Emily Janzer ed6a3a6c74 Remove timer proxy
Summary: Fix for crash introduced by D17282188; doesn't cleanly revert, so just reverting this part

Reviewed By: JoshuaGross, RSNara

Differential Revision: D17505827

fbshipit-source-id: 3232285c0f15dabeb819f8806ad35d4ec83a1e53
2019-09-20 13:55:45 -07:00
Mike Vitousek d34bc5fa64 Upgrade to Flow v0.108.0
Reviewed By: gabelevi

Differential Revision: D17488182

fbshipit-source-id: e67c5bcbd9f0bda49d52531387d92d7c83a01f21
2019-09-20 13:37:25 -07:00
Mike Vitousek e0ea5b3aeb Remove unused suppression comments ahead of v0.108.0 deploy
Summary:
```
# From the Flow directory:
$ ./tool remove-comments --bin $(which flow) ../../xplat/js --check check
# Commit, then change to xplat/js:
$ hg revert -r .^ $(hg st --change . -n | xargs grep -l 'generated')
$ prettier --write --require-pragma $(hg st --change . -n)
$ hg st --change . -n | xargs sed -i -e '/flowlint-next-line *$/d'
$ hg st --change . -n | xargs sed -i -e 's/\/\/ flowlint-line$//'
# Run prettier again and amend

```

Reverted changes to metro/cli.js, which caused errors under a separate flowconfig
drop-conflicts

Reviewed By: gabelevi

Differential Revision: D17483256

fbshipit-source-id: 4222fdb7860ebe7ab6e45741a7cedb9d2cc295ef
2019-09-20 13:37:25 -07:00
Ramanpreet Nara 689233b018 Implement async method dispatch
Summary: Now that all the plumbing is done, this diff finally implements async method dispatch on the NativeModule thread.

Reviewed By: mdvacca

Differential Revision: D17480605

fbshipit-source-id: 992aab99954c488a0327144d84a1668a2b158d04
2019-09-20 10:52:58 -07:00
Ramanpreet Nara 43807f04fe Give TurboModules access to the native CallInvoker
Summary:
Self explanatory.
1. **Existing:** We create the NativeModules thread in CatalystInstanceImpl.cpp.
2. D17422165: We wrap this thread in a `BridgeNativeCallInvoker`.
3. D17422164: We use `CatalystInstanceImpl::getNativeCallInvokerHolder()` to get a hold of the `BridgeNitiveCallInvoker` in Java.
4. D17422163: From Java, we pass this `CallInvokerHolder` to `TurboModuleManager`'s constructor.
5. **This diff:** `TurboModuleManager` then unwraps the `CallInvoker` from `CallInvokerHolder`, and passes it to all TurboModules in their constructor.

Reviewed By: PeteTheHeat

Differential Revision: D17422160

fbshipit-source-id: c0a76dfe5fdedac2e0e21f7a562bc7588dc190fb
2019-09-20 10:52:57 -07:00
Ramanpreet Nara 10d89b1eff Make TurboModuleManager accept a CallInvoker for the NativeModules thread
Summary:
In the previous diffs, I:
1. D17422165: Created a `CallInvoker` for the NativeModules thread.
2. D17422164: Exposed this `CallInvoker` via `CatalystInstance.getNativeCallInvokerHolder()`.

In this diff, I:
1. Make TurboModuleManager accept the NativeModules thread `CallInvoker` as a constructor argument.

Reviewed By: PeteTheHeat

Differential Revision: D17422163

fbshipit-source-id: cbaac2fc06f7f726d89e0c545154123ad7410e62
2019-09-20 10:52:57 -07:00
Ramanpreet Nara 77fe4f087d Introduce CatalystInstance.getNativeCallInvokerHolder()
Summary: CatalystInstanceImpl is responsible for creating the NativeModules thread. We therefore expose a method `getNativeCallInvokerHolder()` on this hybrid class to create and give us access to the `CallInvokerHolder` for the NativeModules thread.

Reviewed By: PeteTheHeat

Differential Revision: D17422164

fbshipit-source-id: 316423847518124115643549fa73a8533d493cd0
2019-09-20 10:52:57 -07:00
Ramanpreet Nara 1b91bfbf63 Introduce MessageQueueThreadCallInvoker
Summary: This abstraction will be used by TurboModules to schedule work on the NativeModules thread.

Reviewed By: PeteTheHeat

Differential Revision: D17422165

fbshipit-source-id: d5ca7837a0ecbcc2118813e1bafa6d445ba2ef3b
2019-09-20 10:52:56 -07:00
Ramanpreet Nara 4c998fd05d Rename JSCallInvoker{,Holder} to CallInvoker{,Holder}
Summary:
## Motivation
The concept behind JSCallInvoker doesn't necessarily have to apply only to the JS thread. On Android, we need to re-use this abstraction to allow execution of async method calls on the NativeModules thread.

Reviewed By: PeteTheHeat

Differential Revision: D17377313

fbshipit-source-id: 3d9075cbfce0b908d800a366947cfd16a3013d1c
2019-09-20 10:52:56 -07:00
Dulmandakh 60b57bad54 cleanup DrawerLayoutAndroid (#26497)
Summary:
This PR removes Java reflection use in ReactDrawerLayoutManager.java because we all use AndroidX and setDrawerElevation is available. Also adds NonNull annotations

## Changelog

[Android] [Changed] - cleanup DrawerLayoutAndroid
Pull Request resolved: https://github.com/facebook/react-native/pull/26497

Test Plan: RNTester is working as expected.

Differential Revision: D17488727

Pulled By: mdvacca

fbshipit-source-id: fd626e3e7aca3965f62c4c82a55c69e81facc61d
2019-09-19 23:42:02 -07:00
Eli White eb7dbc8532 Generate doc info for RN components
Summary:
We used to generate the documentation for the website but moved the docs to another repo.

There is some work on the docs to be able to ingest info from this repo in order to go back to generating API information. The current thinking is we will generate this JSON file and the website repo will pull it in to generate the docs.

I plan to make the script run on CI and fail if the generated file isn't updated, in a follow up PR.

Reviewed By: zackargyle

Differential Revision: D17183936

fbshipit-source-id: 99ce3fa5d7becc0ef20df5d439b175eedbe546f3
2019-09-19 18:36:25 -07:00
Eli White 0baacbecf5 Migrate scrollResponderScrollNativeHandleToKeyboard function to take nativeRef
Summary:
We need to get rid of findNodeHandle calls so migrating scrollResponderScrollNativeHandleToKeyboard to take a ref to a host component.

I made this change with Flow, and tested by rendering UserJobApplicationForm

Reviewed By: mdvacca

Differential Revision: D17099280

fbshipit-source-id: 96af692006aace2c206f268f5416984b00f8a438
2019-09-19 18:16:20 -07:00
Frieder Bluemle 3e4c5c09c3 Remove ignored iOS schemes from template (#26471)
Summary:
The merge of https://github.com/facebook/react-native/issues/25451 added `xcshareddata` to the .gitignore file in `template`. Two xcscheme files in the `xcschemes` subfolder were still left in the template and should have been removed at the same time.

The project opens and builds fine without the xcscheme files both from command line and in Xcode.

## Changelog

[iOS] [Changed] - Remove ignored iOS schemes from template
Pull Request resolved: https://github.com/facebook/react-native/pull/26471

Test Plan:
Generate new project, remove files, verify that project builds, and opens correctly in Xcode.

Please review karanjthakkar satya164 kelset

Differential Revision: D17491748

Pulled By: cpojer

fbshipit-source-id: 391545293c2d09d52f78f56cd91cef5dcf036a9a
2019-09-19 17:26:24 -07:00
Dulmandakh 70b735c04a extract and reuse ANDROIDX_TEST_VERSION (#26487)
Summary:
This PR is extracts and reuses ANDROIDX_TEST_VERSION, and is part of Gradle script refactoring effort.

## Changelog

[Android] [Changed] - extract and reuse ANDROIDX_TEST_VERSION
Pull Request resolved: https://github.com/facebook/react-native/pull/26487

Differential Revision: D17488766

Pulled By: mdvacca

fbshipit-source-id: f1968ffc403074d78d792eb5cc773cc6366ad2d1
2019-09-19 15:35:29 -07:00
Emily Janzer f054928124 Split up createTimer into two methods, createTimer and createAndMaybeCallTimer
Summary:
This diff splits up the current `createTimer` method (which is used for setTimeout, setInterval, etc.) into two methods, `createTimer` and `createAndMaybeCallTimer`. The latter is what's used by the existing Timing native module, and it preserves the existing behavior of this function.

What's the difference? The current implementation of createTimer makes some assumptions about how it's called - namely, that it's called from JS asynchronously (using the bridge). Right now when you create a timer from JS, the JSTimers module passes in the timestamp for when the timer was created; in the native `createTimer`, we compare this timestamp to the current time, and if we find the timer has already expired, we immediately invoke the callback.

Presumably this is done because we don't know how much time has elapsed since when the timer was scheduled in JS, and we want to make sure that it's called as soon as possible. Of course, this also means that `setTimeout(0)` will be immediately invoked, too, without waiting for the next frame.

This all sounds fine, until we take a look at immediates. Immediates are currently implemented entirely in JS, and are called by the JS bridge; before returning control to native, we flush the immediates queue.

This means that the current behavior is: 1) `setImmediate()` is always invoked before `setTimeout(0)`; 2) `setTimeout(0)` is invoked as soon as possible, before the next frame.

However, this changes with bridgeless RN. With bridgeless RN, the native module methods are being replaced by C++ host functions, which are called synchronously. So if we keep the current logic in JavaTimerManager (where it checks if the timer has already expired), then `setTimeout(0)` will be invoked **before** immediates are called.

So the change that I'm making for bridgeless RN is to always wait until the next frame before calling timers. This preserves the order of immediates/timers, although it does mean that `setTimeout(0)` will no longer be called as soon as possible. Of the two options, this seems preferable.

Reviewed By: PeteTheHeat

Differential Revision: D17403144

fbshipit-source-id: 8230f6ebe56aa20bfcf2325177c7812bc8e9c2ec
2019-09-19 15:16:56 -07:00
Janic Duplessis d67c8d4dec Fix printing of false boolean values in the style inspector (#26431)
Summary:
React can't print false, we can just use `JSON.stringify` for any values except string to avoid adding quotes.

## Changelog

[General] [Fixed] - Fix printing of false boolean values in the style inspector
Pull Request resolved: https://github.com/facebook/react-native/pull/26431

Test Plan:
Before

![image](https://user-images.githubusercontent.com/2677334/64896741-e4724d00-d64e-11e9-82b2-57275754523b.png)

After

![image](https://user-images.githubusercontent.com/2677334/64896725-d8868b00-d64e-11e9-903b-8e5212456d78.png)

Reviewed By: TheSavior, mmmulani

Differential Revision: D17468880

Pulled By: JoshuaGross

fbshipit-source-id: 838d3f512037b067ca96fcf5c9d98e2a18fc9821
2019-09-19 13:44:25 -07:00
Ruriko Araki b782934f3f Fix excessive toggles on the Switch component (#26496)
Summary:
In Windows, if you clicked on a Switch component to toggle it, you could see it "shimmy" back and forth once before settling. The native Switch ends up toggling three times every time it's invoked.

`Switch.js` prevents the native switch from toggling to the new value by explicitly setting the switch to `this.props.value` when it receives an `onChange` event. The re-setting of the value wasn't fast enough to prevent the `Switch` from starting to toggle, causing the visual shimmy.

The solution is taken from `TextInput`. `TextInput.js` stores `_lastNativeText` when it receives an `onChange` event. In `componentDidUpdate`, it puts `this.props.text` back on the native textbox if the value of `this.props.text` isn't the same as `_lastNativeText`, which is how it ensures that it is a controlled component. Porting this to the `Switch` results in only one toggle happening per invoke, removing the shimmy, while preserving the controlled component behavior.

This bug is not visible on Android or iOS, only Windows, however the code causing the bug was in `Switch.js` and it seems reasonable to avoid changing the value of the native switch excessively.

## Changelog

[General] [Fixed] - Fix excessive toggles on the Switch component
Pull Request resolved: https://github.com/facebook/react-native/pull/26496

Test Plan: Used RNTester on Android and iOS to test the Switch component and made sure that all scenarios behave as expected visually. Also ensured through the debugger that the value of the native switch is only being changed once, instead of three times.

Reviewed By: TheSavior

Differential Revision: D17468905

Pulled By: JoshuaGross

fbshipit-source-id: 92bf511510306968c3573ee4eed6df009850fd77
2019-09-19 12:46:23 -07:00
Krzysztof Magiera 9f0dede1c9 Allow again for injecting custom root view via ReactActivityDelegate (#26495)
Summary:
This change restores the possibility of injecting custom root views via ReactAcitivtyDelegate. It has been used by react-native-gesture-handler library in order to replace default root view with a one that'd route touch events to gesture-handler internal pipeline.

The regression happened in d0792d4b8a where new `ReactDelegate` was introduced to provide support for rendering react native views in both Android fragments and activities. As a part of that change the logic responsible for creating root view has been moved from `ReactActivityDelegate` to `ReactDelegate` rendering `ReactActivityDelegate.createRootView` unused – that is there is no code path that leads to this method being called. Instead `ReactDelegate.createRootView` method has been added which now plays the same role. The custom root view injection was relying on overwriting that method and hence the method is no longer referenced overwriting it has no effect. Following the logic migration out of `ReactActivityDelegate` into `ReactDelegate` we could potentially now start overwriting methods of `ReactDelegate`. However when working with Android's activities in React Native we can only provide an instance of `ReactActivityDelegate` and in my opinion it does not make too much sense to expose also a way to provide own instance of `ReactDelegate`.

The proposed fix was to route `ReactDelegate.createRootView` to call `ReactActivityDelegate.createRootView` and this way regaining control over root view creation to `ReactActivityDelgate`. The change of the behavior has been implemented by subclassing `ReactDelegate` directly from `ReactActivityDelegate` and hooking the aforementioned methods together. Thanks to this approach, the change has no effect on `ReactDelegate` being used directly from fragments or in other scenarios where it is not being instantiated from `ReactActivityDelegate`.

This fixes an issue reported in https://github.com/kmagiera/react-native-gesture-handler/issues/745 and discussed on 0.61 release thread: https://github.com/react-native-community/releases/issues/140#issuecomment-532235945

## Changelog

[Internal] [Fixed] - Allow for custom root view to be injected via ReactActivityDelegate
Pull Request resolved: https://github.com/facebook/react-native/pull/26495

Test Plan:
1. Run RNTester, take layout snapshot, see the react root view being on the top of view hierarchy.
2. Run gesture-handler Example app (or some other app that overwrites ReactActivityDelegate.createRootView method), on layout snapshot see custom root view being used.

Differential Revision: D17482966

Pulled By: mdvacca

fbshipit-source-id: 866f551b8b077bafe1eb9e34e5dccb1240fa935e
2019-09-19 12:23:08 -07:00