Commit Graph

5556 Commits

Author SHA1 Message Date
Gabriel Donadel Dall'Agnol 3e97d5fe58 feat: Add id prop to Text, TouchableWithoutFeedback and View components (#34522)
Summary:
This adds the `id` prop to `Text`, `TouchableWithoutFeedback` and `View` components as requested on https://github.com/facebook/react-native/issues/34424 mapping the existing `nativeID` prop to `id`. As this components are inherited by others this also adds the `id` prop support to `Image`, `TouchableBounce`, `TouchableHighlight`, `TouchableOpacity` and `TextInput`.
This PR also adds android tests ensuring that the `id` property is passed to the native view via the `nativeID` prop, these tests were based on the existing `nativeID` tests ([NativeIdTestCase.java](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/androidTest/java/com/facebook/react/tests/NativeIdTestCase.java)).

## Changelog

[General] [Added] - Add id prop to Text, TouchableWithoutFeedback and View components

Pull Request resolved: https://github.com/facebook/react-native/pull/34522

Test Plan: Ensure that the new `id` prop android tests pass on CircleCI

Reviewed By: lunaleaps

Differential Revision: D39089639

Pulled By: cipolleschi

fbshipit-source-id: 884fb2461720835ca5048004fa79096dac89c51c
2022-09-09 11:16:28 -07:00
Nicola Corti 5cb02ee5be Cleanup the Kotlin code in the .defaults package
Summary:
With the IDE autocompletion now working \o/ I was able to apply some suggestions
to the Kotlin code I wrote inside the .defaults package (like remove redudant qualifiers and similar).

Changelog:
[Internal] [Changed] - Cleanup the Kotlin code in the .defaults package

Reviewed By: cipolleschi

Differential Revision: D39348983

fbshipit-source-id: b443a6be179c85d2a4f4293051c4f26af93eb5f1
2022-09-09 03:12:13 -07:00
Rubén Norte b06cae3681 Extract use of renderer to its own module
Summary:
This diff creates a proxy module to interact with the React Native renderer. The goal of this proxy is to decouple usages of several functions (e.g.: `findNodeHandle`, etc.) from the actual renderer used in an app. This way, we can easily switch between renderers without having to change code depending on it.

This will be useful to remove a specific renderer from an app bundle when it's no longer used (e.g.: Paper on the Facebook App).

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D39205975

fbshipit-source-id: 05289c0c3c8cd26d81aa1d2163097c73ec40c6ad
2022-09-08 11:12:06 -07:00
Pieter De Baets a888f0c0a1 Fix broken systrace marker in getViewManagerNames
Summary:
Noticed this marker was not properly ended in the case where an early return happens. The fact that that early return is happening there is problematic too, so added a warning to follow-up on.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D39271917

fbshipit-source-id: 86dd5b1a46978629584f7cb0d615f2ad99d5a2f8
2022-09-08 06:10:50 -07:00
Pieter De Baets e7d7563195 Remove deprecated UIImplementationProvider
Summary:
UIImplementation(Provider) is not compatible with the new renderer (Fabric) and the relevant constructors have been marked deprecated for a while. While ReactInstanceManagerBuilder creates a default instance, it's not even used by CoreModulesPackage.

Changelog: [Android][Removed] Removed deprecated UIImplementationProvider

Reviewed By: NickGerleman

Differential Revision: D39271916

fbshipit-source-id: 20a3b02843ea9a2ba4bfc1352037239febbafc64
2022-09-08 05:35:00 -07:00
Kudo Chien 32d12e89f8 add debugging settings (#34489)
Summary:
For brownfield apps, it is possible to have multiple hermes runtimes serving different JS bundles. Hermes inspector currently only supports single JS bundle. The latest loaded JS bundle will overwrite previous JS bundle. This is because we always use the ["Hermes React Native" as the inspector page name](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/executor/HermesExecutorFactory.cpp#L157) and [the latest page name will overwrite previous one](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp#L77-L86).

This PR adds more customization for HermesExecutorFactory:
- `setEnableDebugger`: provide a way to disable debugging features for the hermes runtime
- `setDebuggerName`: provide a way to customize inspector page name other than the default "Hermes React Native"

## Changelog

[General] [Added] - Add more debugging settings for *HermesExecutorFactory*

Pull Request resolved: https://github.com/facebook/react-native/pull/34489

Test Plan:
Verify the features by RNTester.

1. `setEnableDebugger`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setEnableDebugger(false);
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return empty array.
Run `curl http://localhost:8081/json` and returns `[]`

2. `setDebuggerName`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setDebuggerName("Custom Hermes Debugger");
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return an entry with *Custom Hermes Debugger*
Run `curl http://localhost:8081/json` and returns

```json
[
  {
    "id": "2-1",
    "description": "com.facebook.react.uiapp",
    "title": "Custom Hermes Debugger",
    "faviconUrl": "https://reactjs.org/favicon.ico",
    "devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D2 (https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7)%26page%3D1 (https://github.com/facebook/react-native/commit/ea93151f21003df6f65dd173dd5dcb3135b0ae94)",
    "type": "node",
    "webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=2&page=1",
    "vm": "Hermes"
  }
]
```

Reviewed By: mdvacca

Differential Revision: D38982104

Pulled By: cipolleschi

fbshipit-source-id: 78003c173db55448a751145986985b3e1d1c71bb
2022-09-07 12:52:37 -07:00
Rubén Norte 34e7d48472 Remove unused JSDevSupport module
Summary:
The `JSDevSupport` module is incompatible with Fabric. Given it's not used internally and it's undocumented in OSS, we decided to remove it altogether.

Changelog: [Internal]

Reviewed By: javache, nlutsenko

Differential Revision: D39305892

fbshipit-source-id: 82455701a0b9ba83e6f971fc774280dceb2b22e0
2022-09-07 12:20:58 -07:00
Riccardo Cipolleschi 12e5842e11 Fix/android (#34573)
Summary:
This PR should fix the issues introduced by commit c34659a5d3.
The problem is that `Collections.emptyList` creates a `List<Object>` which is not compatible with the `List<TargetView>` type.

## Changelog

[Android] [Fixed] - Make Android CI build again.

Pull Request resolved: https://github.com/facebook/react-native/pull/34573

Test Plan: test_buck and the "test Docker android"  must be green.

Reviewed By: cipolleschi

Differential Revision: D39235674

Pulled By: cortinico

fbshipit-source-id: 574338e74aeb4635c67d91de28780fb784c9f405
2022-09-02 03:23:45 -07:00
Luna Wei c34659a5d3 PointerEvents: Store last hitPath, eventCoordinates for different pointers
Summary:
Changelog: [Internal] - Key cached values between different MotionEvents by pointerId.

Currently the implementation uses one cached list and array to store the last hitPath and event coordinates. We use these to determine if we've entered or left any views.

With more pointers, we need to be tracking these values for each pointer.

As well, clean up usage of `mLastTargetCoordinates`. This doesn't need to be a global as its an array that's updated by reference in `findTargetPathAndCoordinatesForTouch`

Reviewed By: vincentriemer

Differential Revision: D39152528

fbshipit-source-id: 28c18629bf974f41950401c7726a4757ad43ac28
2022-09-01 16:15:30 -07:00
Luna Wei b09821591c PointerEvents: Fix x/y coordinate system for PointerEvents, set some properties for "mouse" pointerType
Summary:
Changelog: [Internal] - Fix more pointer event platform tests.
* Fix the coordinate system to use DIP
* Set some properties for when pointerType="mouse"

Reviewed By: vincentriemer

Differential Revision: D39184713

fbshipit-source-id: d86f798f3e0a377ff1c159fb308329a2c9ae03ff
2022-09-01 13:11:44 -07:00
Luna Wei 64ae12e553 PointerEvents: Refactor JSPointerDispatcher to share logic for UP/DOWN for secondary pointers
Summary:
Changelog: [Internal] -  Refactor JSPointerDispatcher to group secondary actions (pointer_up, pointer_down) to use same logic and emit non-direct events

This diff re-arranges some code and re-uses some logic for different MotionEvent types.

Specifically, before our code for handling a motionEvent looked like
```
func onMotionEvent(event) {
    if (event is HOVER_MOVE) {
        handleHoverEvent(event)
    }
    if (event is ACTION_DOWN) {
       // logic for dispatching down, enter, over
    }
    if (event is ACTION_POINTER_DOWN) { // this represents any secondary pointer going down
       // logic for dispatching down
    }
    if (event is ACTION_MOVE) {
       // logic for dispatching touch move
    }
    if (event is ACTION_UP) {
       // logic for dispatching up, out, leave
    }
    if (event is ACTION_POINTER_UP) { // this represents any secondary pointer going up
       // logic for dispatching up
    }
   ....
}
```

now, we've refactored it to be like:
```
func onMotionEvent(event) {
    if (event is HOVER_MOVE) { // Still keep this as separate because it does some special things. Will refactor in follow-up diff
        handleHoverEvent(event)
    }

    switch() {
         case ACTION_DOWN or ACTION_POINTER_DOWN:
             // do same logic
         break;
         case ACTION_UP or ACTION_POINTER_UP:
             // do same logic
         break;
         case ACTION_MOVE:
             // do same logic, we will want to converge this logic with HOVER_MOVE, todo in a follow-up
         break;
         ...
    }
   ....
}
```
This refactor adds the functionality of `enter, over, out, leave` to secondary pointer events in which they weren't fired before.

Reviewed By: vincentriemer

Differential Revision: D39142820

fbshipit-source-id: 8b89db6dc22f24583f8c14dbb8392d4dc8ff6e4d
2022-09-01 13:11:44 -07:00
Luna Wei 823f6b7704 NativeGestureUtil.notifyNativeGestureEnded is called
Summary:
Changelog: [Internal] - Make sure `onChildEndedNativeGesture` is called for view managers that call `onChildStartedNativeGesture`

This affects `JSTouchDispatcher`, `JSPointerDispatcher` as they track what view is reporting native gesturing handling.

This is a bug that view managers never shared the fact that they've stopped managing a native gesture. Both `JSTouchDispatcher`, `JSPointerDispatcher` get around this by manually resetting their internal flag on ACTION_DOWN event (we will get rid of this in a later diff)

Reviewed By: javache

Differential Revision: D38850609

fbshipit-source-id: ef4afb591249bb621f42667608dc1ef20424b65c
2022-08-31 11:32:57 -07:00
Evan Charlton 361b310bcc fix: Correctly resolve classes with FindClass(..) (#34533)
Summary:
`JNIEnv`'s `FindClass(..)` function takes the classes in the standard
`foo/bar/Baz` class specification (unless they're special, like arrays).
Specifying them with `Lfoo/bar/Baz;` results in a
`ClassNotFoundException` being raised -- which is especially unhelpful
when intending to re-throw an exception.

The docs for `JNIEnv#FindClass(..)` can be found [here][jnienv].

[jnienv]:
  https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#:~:text=The%20name%20argument,java/lang/String%22

## Changelog

[Android] [Fixed] - Correctly resolve classes with FindClass(..)

Pull Request resolved: https://github.com/facebook/react-native/pull/34533

Test Plan:
No exact test plan. However, if an exception is thrown during the
rendering process, a fatal `ClassNotFoundException` is raised, rather
than having the error be passed up to the `ReactNativeManager`.

Fixes: facebook/yoga#1120

Reviewed By: amir-shalem

Differential Revision: D39133326

Pulled By: jacdebug

fbshipit-source-id: 86283b7d21aed49ed0e9027b2aef85f0108cdf9a
2022-08-30 18:49:10 -07:00
Rasmus Eneman 5451cd48bd fix: Crash if WebView is disabled (#34483)
Summary:
When the webview is updated by play store, all apps that has loaded webview gets killed. For background see https://issuetracker.google.com/issues/228611949?pli=1

We have a long-running app and don't want this to happen and while we are not using webview anywhere, we are using websockets that loads it for reading cookies, however we are not using cookies to authenticate the websocket and thus want to disable the webview to avoid loading it unnecessarily and then getting killed unnecessarily.

The webview has support for beeing disabled https://developer.android.com/reference/android/webkit/WebView#disableWebView() however as-is this crashes React Native. It seems to me like this case is very similar to not having web view installed and should be handled in the same way.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Avoid crash in ForwardingCookieHandler if webview is disabled

Pull Request resolved: https://github.com/facebook/react-native/pull/34483

Test Plan: Add `WebView.disableWebView();` as the first line in `MainActivity.onCreate`.

Reviewed By: christophpurrer

Differential Revision: D38981827

Pulled By: cipolleschi

fbshipit-source-id: 335a8420568ad0c80b834ae8a3b164e55ebe26f3
2022-08-30 06:57:07 -07:00
Lulu Wu 4d642a2250 Fix isRootVisible not working with non-Venice
Summary:
## Context
```isRootViewVisible``` doesn't work as expected for non-Venice: when enter Marketplace tab, ```isRootViewVisible```  should returns true with Marketplace tab's rootViewTag, but it returns false.

## Root cause
```rootViewTag``` is added to "mVisibleRootTags" in "FbReactRootVisibilityTracker" when ```BaseFbReactFragment.onViewDidAppear()``` gets called, but ```BaseFbReactFragment.onViewDidAppear()``` is called earlier than when the ```rootViewTag``` is set.

## Fix
Move setRootViewTag to earlier when RootView is created instead of in startSurface or mounting.

Changelog:
[Android][Changed] - Move setRootViewTag to earlier when RootView is created

Reviewed By: RSNara

Differential Revision: D38586584

fbshipit-source-id: aec3ed37eb62289a19794e68b1a6b5ca213cb14a
2022-08-29 18:44:24 -07:00
David Vacca 38e1e25288 Introduce C++ component API
Summary:
This diff introduces the API that will be used to describe React Native Components written in C++

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725766

fbshipit-source-id: 292e28409ac6be8f9a1c2209b8c558e0e2cb96ea
2022-08-29 14:44:51 -07:00
David Vacca fdb8be72fc Avoid compiling subfolders of fabric folder
Summary:
Only compile files under Fabric folder, without including subfolders

changelog: [internal] internal

Reviewed By: lunaleaps

Differential Revision: D39108916

fbshipit-source-id: 5390b78cd529e7256f4e755b6d88999546fa705b
2022-08-29 14:44:51 -07:00
Luna Wei b7e7e7ff1e ReactSlider onValueChange
Summary:
Changelog: [Android][Fixed] - Emit the right bubbling event for ReactSliderEvent

In [ReactSliderManager.java](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/views/slider/ReactSliderManager.java#L277) we register `topValueChange` yet `ReactSliderEvent` dispatches `topChange`.

Reviewed By: NickGerleman

Differential Revision: D39064685

fbshipit-source-id: c1e589c2fcaee68ef21f920a950ea36eaa0e5048
2022-08-29 14:43:57 -07:00
Harrison Spain e653f2fd15 Back out "Anti-alias rounded borders on overflow: hidden views"
Summary:
Changelog:
[Android][Removed] - Anti aliased rounded corners on overflow: hidden views

Differential Revision: D39072689

fbshipit-source-id: 41b01fa67280b7b8a7df61fdb809bb97a75c781b
2022-08-26 15:52:22 -07:00
hurali97 cd6a91343e fix: border width top/bottom not matching the border radius (#34362)
Summary:
Fixes https://github.com/facebook/react-native/issues/33950

After analysing the values used for drawing the border specifically the top and bottom values of `mInnerClipTempRectForBorderRadius` weren't matching the needs when it comes to the case of borderTopWidth and borderBottomWidth, when the borderRadius is applied.

Asking for reviews cortinico

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Border width top/bottom not matching the border radius

Pull Request resolved: https://github.com/facebook/react-native/pull/34362

Test Plan:
Tested in a local project, following are the outputs(Details are in the issue attached):

Before:
<img src="https://user-images.githubusercontent.com/47336142/183289227-96b20f86-1507-46f5-a79d-f61457624e8b.png" height="550">

After:
<img src="https://user-images.githubusercontent.com/47336142/183289177-6148df29-f0de-4b99-bdf0-c28a9c7d3ac7.png" height="550">

Reviewed By: hramos

Differential Revision: D38805873

Pulled By: lunaleaps

fbshipit-source-id: 69f8ff9a9caeeaf88d1c76b639271f642c2e7ea2
2022-08-25 21:03:28 -07:00
fabriziobertoglio1987 0b70b38547 Re-implement accessibilityHint on Android to use AccessibililltyNodeInfo#setToolTipText instead of contentDescription (#34427)
Summary:
https://github.com/facebook/react-native/issues/31056#issuecomment-786349025

>Re-implement accessibilityHint on Android so that rather that concatenate into the contentDescription, it sets the toolTipText property on the AccessibilityNodeInfo (not on the view). This is the closest analog to iOS's hint that Android has, as the text is announced after the contentDescription rather than part of it. It will will not adhere to users preferences on whether they want hints disabled or not, and still has no pause before it like real hints have, but it's far closer than using the contentDescription directly.

fixes https://github.com/facebook/react-native/issues/31056

## Changelog

[Android] [Fixed] - Re-implement accessibilityHint on Android to use AccessibililltyNodeInfo#setToolTipText instead of contentDescription

Pull Request resolved: https://github.com/facebook/react-native/pull/34427

Test Plan: https://user-images.githubusercontent.com/24992535/184837154-5c65dbf1-1031-4d56-ac1e-066af7e08edc.mp4

Reviewed By: christophpurrer

Differential Revision: D38982158

Pulled By: cipolleschi

fbshipit-source-id: 7a616e6df9f83bd21ca02cc26b5918986a1d64f8
2022-08-25 15:37:29 -07:00
Harrison Spain 7708cdccef Anti-alias rounded borders on overflow: hidden views
Summary:
When a view is rendered with a combination of `overflow: hidden` and `borderRadius: >0`, the `ReactViewGroup` would apply the border radius using Canvas `clipPath`. In Android graphics, clipPath is not an anti-aliased operation and caused aliasing artifacts.

Changing the method to a bitmask using the `PorterDuff` method results in the same functionality, but with hardware accelerated antialiasing.

https://github.com/facebook/react-native/issues/24486

Changelog:
[Android][Change] - Views with overflow: hidden and borderRadius: >0 now render anti-aliased borders.

Reviewed By: javache

Differential Revision: D38914878

fbshipit-source-id: 45ac7e4aece7a76c4216412175e49d3d73b6f391
2022-08-25 14:25:08 -07:00
Pieter De Baets dd48509185 Unbreak LAYOUT_ANIMATION_VERBOSE_LOGGING
Summary:
Noticed this logging was broken when enabling the flag.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D38616851

fbshipit-source-id: acf0ab75918b389586cb713c2edf5a6bf83ee7a2
2022-08-24 05:09:12 -07:00
Nicola Corti dd6d5a78a3 Introduce the DefaultMainActivityDelegate to simplify enabling/disabling Fabric for new apps. (#34446)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34446

I'm adding another class to the .defaults package. This will take care of setting the RootView
with Fabric enabled/disabled as well as controlling concurrent root.

Changelog:
[Android] [Added] - Introduce the DefaultMainActivityDelegate to simplify enabling/disabling Fabric for new apps.

Reviewed By: cipolleschi

Differential Revision: D38823181

fbshipit-source-id: 2293b9df6b0d8fa79695bd52a8e0bb46b44c43c8
2022-08-18 07:30:23 -07:00
Nicola Corti ba2dae3318 Do not store .cpp/.h files inside src/main/java - turbomodule - take 2
Summary:
Currently we expose native code (.h, .cpp) inside the src/main/java folder.
This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for turbomodule

I've also updated all the internal usages and references to the new path.

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - turbomodule

Reviewed By: cipolleschi

Differential Revision: D38820638

fbshipit-source-id: febb3f8cef18b30e82c3a4776baa85d0c0d19e4b
2022-08-18 05:53:29 -07:00
Nicola Corti 30e54adce2 Fix test_buck by providing exported deps for textinput target (#34436)
Summary:
This is an attempt to fix the broken `test_buck` as the `/textinput` target now needs to access the Kotlin stdlib dependencies

## Changelog

[Internal] - Fix test_buck by providing exported deps for textinput target

Pull Request resolved: https://github.com/facebook/react-native/pull/34436

Test Plan: Will wait for a CircleCI result

Reviewed By: cipolleschi

Differential Revision: D38782473

Pulled By: cortinico

fbshipit-source-id: 72265c34092372189d75df732b64a1e370453472
2022-08-17 07:34:09 -07:00
Nicola Corti 4706d13ec8 Do not store .cpp/.h files inside src/main/java - fabricjni (#34435)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34435

Currently we expose native code (.h, .cpp) inside the src/main/java folder.
This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for fabricjni

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - fabricjni

Reviewed By: cipolleschi

Differential Revision: D38741130

fbshipit-source-id: f9e3e4514d3ae0ddeac65256928d71d5134d08f8
2022-08-17 04:58:24 -07:00
Thuong Tran 163636db75 feat(font-feature): adding stylistics from ss01 to ss20 as new fontVariant values (#34003)
Summary:
Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20)

stylistic-three(ss01)
stylistic-two(ss02)
stylistic-three(ss03)
stylistic-four(ss04)
stylistic-five(ss05)
stylistic-six(ss06)
stylistic-seven(ss07)
stylistic-eight(ss08)
stylistic-nine(ss09)
stylistic-ten(ss10)
stylistic-eleven(ss11)
stylistic-twelve(ss12)
stylistic-thirteen(ss13)
stylistic-fourteen(ss14)
stylistic-fifteen(ss15)
stylistic-sixteen(ss16)
stylistic-seventeen(ss17)
stylistic-eighteen(ss18)
stylistic-nineteen(ss19)
stylistic-twenty(ss20)

References:
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type3
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist

Example:
`<Text
      style={{
          fontVariant: ['stylistic-three', 'stylistic-five']
        }}>
      Hello World!
    </Text>`

## Changelog

[iOS] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20)
[Android] [Added] - Add new fontVariant values: stylistic-one(ss01) -> stylistic-twenty(ss20)

Pull Request resolved: https://github.com/facebook/react-native/pull/34003

Test Plan: ![Screen Shot 2022-06-13 at 16 02 46](https://user-images.githubusercontent.com/62107729/173318839-69da379c-df13-4351-9dfa-4b548664e43d.png)

Reviewed By: cipolleschi

Differential Revision: D37118078

Pulled By: cortinico

fbshipit-source-id: 6a8366638f8181b5db6b2c12c48a5ad65e1e598f
2022-08-17 03:07:09 -07:00
Joshua Gross 4a8575617c Fix logging crash in IntBufferMountItem
Summary:
Unfortunately my last diff didn't completely fix this; now there are more printed parameters than arguments provided to the formatter.

Easy fix, confirmed this works by running internally.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D38678116

fbshipit-source-id: 51f32905debc1946bc260f06a5bdc2f43141ddf4
2022-08-16 12:21:52 -07:00
Joshua Gross 04c75ba988 Support MapBuffer in TextInput State
Summary:
Support MapBuffer in TextInput State.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D38546271

fbshipit-source-id: 93e7fd79d9d8473dd646410f3047fcfafa8516f1
2022-08-16 12:21:52 -07:00
Nicola Corti 9a2eb9089f Provide defaults for TurboModuleManagerDelegate and JSIModulePackage (#34418)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34418

This is an attempt to relax the need of specifying a custom `TurboModuleManagerDelegate` and a `JSIModulePackage` in new apps for New Architecture.
Users can just specify the name of the dynamic library to load and they'll default to use the `DefaultTurboModuleManagerDelegate` and `DefaultJSIModulePackage`.

Users will still have to provide a C++ implementation for it for the time being, but this at least removes
one extra file that we requested them to create and maintain.

If we're fine with this approach, I'll replicate it inside the default template.

Changelog:

[Android] [Added] - Provide defaults for TurboModuleManagerDelegate and JSIModulePackage

Reviewed By: cipolleschi

Differential Revision: D38701180

fbshipit-source-id: eec302c5789990700eb75353d97751358ca6799f
2022-08-16 07:55:40 -07:00
Nicola Corti d35aab45b9 Do not store .cpp/.h files inside src/main/java - reactnativeblob (#34421)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34421

Currently we expose native code (.h, .cpp) inside the src/main/java folder.
This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for reactnativeblob

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - reactnativeblob

Reviewed By: cipolleschi

Differential Revision: D38703092

fbshipit-source-id: 3d4391d8ee5587b199efa4001f68c6d4ed3ce2c2
2022-08-16 06:04:37 -07:00
fabriziobertoglio1987 9f4358142e accessibilityLabelledBy use DynamicFromObject to parse String to Dynamic (#34371)
Summary:
`accessibilityLabelledBy` accepts String or Array type.
- The JavaScript Array type corresponds to java [ReadableArray][3] ([HybridData][4])
- The JavaScript String type corresponds to the java String

Use [DynamicFromObject][5] to parse String to Dynamic.

https://github.com/facebook/react-native/blob/e509f96baf5e523301a5c9567c416508ff20d175/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java#L222-L228

All credits to [grgr-dkrk][1] (PR https://github.com/facebook/react-native/pull/32470). fixes [https://github.com/facebook/react-native/issues/30846][2]

## Changelog

[Android] [Fixed] - accessibilityLabelledBy use DynamicFromObject to parse String to Dynamic

Pull Request resolved: https://github.com/facebook/react-native/pull/34371

Test Plan:
<details><summary>testing accessibilityLabelledBy with TextInput</summary>
<p>

https://user-images.githubusercontent.com/24992535/183593138-7ced1974-6a06-4f0f-822a-1ade1edc7212.mp4

</p>
</details>

<details><summary>testing accessibilityLabelledBy with Switch</summary>
<p>

![Screen Shot 2022-08-09 at 15 53 37](https://user-images.githubusercontent.com/24992535/183596336-4b73186b-6d27-485e-a6ea-29a0f0b9ef50.png)

</p>
</details>

<details><summary>testing paper renderer after the fix</summary>
<p>

https://user-images.githubusercontent.com/24992535/183605619-01f1be64-788a-43bd-88b0-a7b2cad75148.mp4

</p>
</details>

[1]: https://github.com/grgr-dkrk
[2]: https://github.com/facebook/react-native/issues/30846
[3]: https://github.com/facebook/react-native/blob/e509f96baf5e523301a5c9567c416508ff20d175/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.java#L1
[4]: https://github.com/facebookincubator/fbjni/blob/main/java/com/facebook/jni/HybridData.java
[5]: https://github.com/facebook/react-native/blob/e509f96baf5e523301a5c9567c416508ff20d175/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromObject.java#L74

Reviewed By: lunaleaps

Differential Revision: D38706360

Pulled By: huntie

fbshipit-source-id: e4771552d3fddfad50f4d4cbbf971fe4a718e134
2022-08-16 04:26:20 -07:00
Nicola Corti 3d2185203b Do not store .cpp/.h files inside src/main/java - mapbuffer
Summary:
Currently we expose native code (.h, .cpp) inside the src/main/java folder.

This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for mapbuffer

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - mapbuffer

Reviewed By: cipolleschi

Differential Revision: D38699253

fbshipit-source-id: c1c8f8693b6da4e3428f8f280e1ca4d5c5d0f853
2022-08-16 03:20:16 -07:00
Luna Wei dfcd9faaad Add support for pointerover and pointerout
Summary: Changelog: [Internal] - Add pointerover, pointerout events

Reviewed By: vincentriemer

Differential Revision: D38559454

fbshipit-source-id: 829b9f2f22e1e41a64dcce80fcc79ab9e6352dcf
2022-08-15 12:51:58 -07:00
Nicola Corti 5d34c55523 Do not store .cpp/.h files inside src/main/java - hermes modules (#34420)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34420

Currently we expose native code (.h, .cpp) inside the src/main/java folder.

This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for hermes/reactexecutor and hermes/instrumentation

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - hermes modules

Reviewed By: yungsters

Differential Revision: D38700760

fbshipit-source-id: 50cf38a0dae4f617e6d78317e5fe2a858290d0c0
2022-08-15 09:12:08 -07:00
Nicola Corti be391844f7 Do not store .cpp/.h files inside src/main/java - jscexecutor (#34396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34396

Current we expose native code (.h, .cpp) inside the src/main/java folder.
This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:

https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots
This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for jscexecutor

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - jscexecutor

Reviewed By: sshic

Differential Revision: D38615007

fbshipit-source-id: e5085130579f37f052b5c8a5702d2c0f1b332bee
2022-08-15 04:12:24 -07:00
Nicola Corti 1246300e93 Do not store .cpp/.h files inside src/main/java - uimanager
Summary:
Currently we expose native code (.h, .cpp) inside the src/main/java folder.

This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.

AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/...

This is the diff for uimanager

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - uimanager

Reviewed By: dmitryrykun

Differential Revision: D38656400

fbshipit-source-id: f52487160fa6c05ec382842e2a6125a5c4cb1e86
2022-08-15 04:07:31 -07:00
Nicola Corti 12ba077e16 Remove deprecated jni.srcDirs from ReactAndroid build file
Summary:
As the title says, android.sourceSets.main.jni is deprecated in AGP. We should not be accessing it. Here we were setting it to the empty array (the default value).

It will cause the build to break in a future AGP bump, hence I'm removing it.

Changelog:
[Internal] [Changed] - Remove deprecated jni.srcDirs from ReactAndroid build file

Created from CodeHub with https://fburl.com/edit-in-codehub

Reviewed By: cipolleschi

Differential Revision: D38655857

fbshipit-source-id: 2eb6897964554da462bde58937a6de708bc047dc
2022-08-15 02:23:13 -07:00
Oleksandr Melnykov 23429330a6 Back out "Roll out turbo_module_binding_mode experiment"
Summary: Changelog: [Internal]

Reviewed By: jpporto

Differential Revision: D38666524

fbshipit-source-id: af5b1cf2d2db505341ce0992401cb68909e1395b
2022-08-12 12:41:08 -07:00
Nicola Corti 296d7db7a2 Do not store .cpp/.h files inside src/main/java - reactperflogger (#34386)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34386

Current we expose native code (.h, .cpp) inside the src/main/java folder.
This is making impossible for users on New Architecture to open the project
inside Android Studio.

The problem is that the src/main/java is reserved to Java/Kotlin sources only.
AGP 7.2 also removed support for mixed source roots:
https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots

This is essentially forcing users to write Java code without any autocompletion
as all the React Native Java classes are considered C++ files.

I'm addressing this issue folder by folder by moving them
from `ReactAndroid/src/main/java/com/facebook/...` to `ReactAndroid/src/main/jni/react/...`

This is the diff for reactperflogger

Changelog:
[Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - reactperflogger

Reviewed By: cipolleschi

Differential Revision: D38584681

fbshipit-source-id: 8b65b3fa47a7f106c7fea79fd739f0e4e37efa2a
2022-08-12 05:05:39 -07:00
Lulu Wu fc065151ce Add ability to store and retrieve a list of MapBuffer
Summary:
Add ability to store and retrieve a list of MapBuffer as an entry of MapBuffer.

```
Example:

MapBuffer1
{
 key1: "test string",
 key2: MapBuffer2,
 key3: [MapBuffer3, MapBuffer4]
}
```

Changelog:
[General][Added] Add ability to store and retrieve a list of MapBuffer

Reviewed By: JoshuaGross

Differential Revision: D38460204

fbshipit-source-id: 3e721418be2dca6d5f15f665753844d6f531e31c
2022-08-11 10:14:38 -07:00
Pieter De Baets 450fa4d1d3 Remove molly dep from react-native buck graph
Summary:
Folly's molly target combines a number of targets that are supposed to be useable on mobile. Since we're trying to move away from folly, we should instead list explicitly which parts of folly we're using so we can remove them over time, and track which targets no longer have any folly dependencies.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D38352060

fbshipit-source-id: 09d0d84793692f97f4d49390c99c38b23441df54
2022-08-11 04:53:34 -07:00
Nick Gerleman 063c2b4668 Enable -Wpedantic for targets inside ReactCommon
Summary:
React Native is compiled downstream with MSVC, meaning the introduction of code depending on language extensions specific to gcc/clang may cause breakage.

We can enable `-Wpedantic` to flag any behavior not officially supported by the specified C++ standard. This will includes rules beyond what MSVC has trouble with, but seems to not have too many "noisy warnings".

This change enables -Wpedantic in BUCK targets within ReactCommon.

This makes the OSS C++ build for Android/iOS slightly more permissive than the internal build, A followup is to add the changes to OSS build logic as well, to avoid contributors seeing more errors upon internal submission. (checking with cortinico on how to do this for Android).

react-native-windows uses a higher warning level than `-Wall`, which is an additional cause of compilation failures, but is not addressed as part of this change.

Changelog:
[Internal][Changed] - Enable -Wpedantic for targets inside ReactCommon

Reviewed By: rshest

Differential Revision: D38457812

fbshipit-source-id: 014da1ac0b7ad8f78154e6e447ed58def6bd0d47
2022-08-11 04:37:35 -07:00
Pieter De Baets e0be14a310 Correctly reset pivot when recyling views
Summary:
Calling `setPivotX` and `setPivotY` internally sets `isPivotExplicitlySet` in Android UI, which causes some transforms to no longer use the right transform. Instead use `resetPivot` to get the desired behaviour.

Changelog: [Android][Fixed] Bug with view transforms when view recycling is enabled

Reviewed By: NickGerleman

Differential Revision: D38579267

fbshipit-source-id: 36186286c6765f92aabaa44994546e06f34c2be0
2022-08-11 02:36:44 -07:00
Nick Gerleman 1e48274223 Use WindowInsetsCompat for Keyboard Events
Summary:
RN for Android fires `keyboardDidShow` and `keyboardDidHide` by observing changes to viewable window size. This isn't always reliable, such as when an activity has `awindowSoftInputMode` set to not have the system adjust the viewport when a keyboard is opened.

Android 11 added the direct ability to measure and check visibility of the soft keyboard via `WindowInsets`, which fixes these issues. This is exposed downlevel to API 23 via WindowInsetsComapt` with the same limitations as previously, but using it simplifies our calculations a lot.

Changelog:
[Android][Fixed] - Use WindowInsetsCompat for Keyboard Events

Reviewed By: javache

Differential Revision: D38500859

fbshipit-source-id: d4ad41d7e75e4b9c14a485539a5f9de19de74362
2022-08-11 02:22:20 -07:00
Alex Hunt 0aed5d9db2 Fix typos in ReactCxxErrorHandler message
Summary: Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D38578690

fbshipit-source-id: d0339bf1db1bb3e36f0cbf1e93cc5853a7ed6570
2022-08-10 10:52:29 -07:00
Pieter De Baets 1a8ce7a26a Roll out turbo_module_binding_mode experiment
Summary:
We ran an experiment to test different implementations of TurboModules HostObjects, as the current one has various inefficiencies, such as re-creating HostFunctions on every property access. The strategy we found to be most efficient and flexible longer-term is to represent the TurboModule with a plain JavaScript object and use a HostObject as its prototype. Whenever a property is accessed through the prototype, we cache the property value on the plain object, so it can be efficiently resolved by the VM for future accesses.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D38355134

fbshipit-source-id: 59253091412d0c6827ad7a4b1ac7dc0c7fe89cc2
2022-08-10 04:54:25 -07:00
Nick Gerleman 77c256ca91 Expose UI_MODE_TYPE_VR_HEADSET in PlatformConstants
Summary:
The Android version of PlatformConstants exposes the device's [UI Mode]( https://developer.android.com/guide/topics/resources/providing-resources#UiModeQualifier). It is missing the case for 'vrheadset', added in Android API 26. We should return the expected result when this is queried.

Changelog:
[Android][Added] - Expose UI_MODE_TYPE_VR_HEADSET in PlatformConstants

Reviewed By: rshest

Differential Revision: D38495875

fbshipit-source-id: fd904bd11213448415b7d75145d9ba6311ed407b
2022-08-08 23:41:07 -07:00
Muhammad Hur Ali be35c6dafb fix: react android kotlin plugin version conflict (#34255)
Summary:
Fixes https://github.com/facebook/react-native/issues/34229

Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now).

The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax.
See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax)

So the idea was to use the build script to resolve the kotlin plugin and it works 👍 .

Kindly asking for review cortinico :)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - refactored usage of kotlin plugin

Pull Request resolved: https://github.com/facebook/react-native/pull/34255

Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues.

Reviewed By: dmitryrykun

Differential Revision: D38468567

Pulled By: cortinico

fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01
2022-08-08 08:06:05 -07:00