Summary:
RN offers checkbox component on android: https://facebook.github.io/react-native/docs/checkbox.html
The Checkbox colors for checked and unchecked states cannot be controlled from JS at the moment; this PR adds support for that.
The essence of changing colors for the states is this:
```
ColorStateList cls = new ColorStateList(
new int[][] {
new int[] { -android.R.attr.state_checked }, // unchecked
new int[] { android.R.attr.state_checked } // checked
},
new int[] {
uncheckedColor,
checkedColor
}
);
checkBox.setSupportButtonTintList(cls);
```
Because of this, I did it so that both colors have to provided together in an object. This is similar to [switch](https://facebook.github.io/react-native/docs/switch#trackcolor)
Pull Request resolved: https://github.com/facebook/react-native/pull/18300
Differential Revision: D14180218
Pulled By: cpojer
fbshipit-source-id: 88a9d1faf061c0651e3e28950f697535b90fbfd4
Summary:
Instead of using measure specs to set certain yoga properties on the root node (like max width, auto width, specific width), use yoga's calculateLayout(width, height) instead. The measure specs will be stored in the shadow node. This allows us to remove duplicated code that processes the measure specs and allows us to remove other logic like the enableLayoutCalculation() method.
This diff also removes MeasureSpecProvider. MeasureSpecProvider was originally introduced to pass previously measured view measure specs to the initial creation of the root shadow node, but it turns out that this is unnecessary. We can update the root layout specs from the root view instead.
Reviewed By: mdvacca
Differential Revision: D9729744
fbshipit-source-id: 79b0b27ca879758f5dc3fc7cc8a0d38856a6cc79
Summary:
Clearing the android TextInput text programmatically (i.e. calling: this.textInputRef.clear()) does not clear the previously composing text, if enabled, causing inconveniences when such behaviour is desired (i.e. chat input box, where you constantly have to clear the input after sending a message). Instead, the currently observed behaviour is that, after a new text is entered (usually as soon as the first letter), the previously composing text reappears making the input unusable.
The effect is only observable on some devices, for example, we observed it on Samsung S6 devices using both Android 6 and 7, and several LG devices running Android 6.
This issue is only present when clearing the text; setting text to some other value does not produce the same effect.
<!--
Required: Write your motivation here.
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->
Pull Request resolved: https://github.com/facebook/react-native/pull/18859
Differential Revision: D14067144
Pulled By: hramos
fbshipit-source-id: 09f337edc026b83221f8a399749222cd75457ec7
Summary:
@public
`setBaseLine` was the only place where we used a capitalised *L.* Fixed here.
Reviewed By: SidharthGuglani
Differential Revision: D14152320
fbshipit-source-id: abf54fe7d6088e03775968baa8421c4bf43d6a6e
Summary:
@public
Adds the ability to opt into avoiding global weak JNI refs via `YogaConfig`.
Note that only homogeneous trees are supported, i.e. **mixing weak-ref and non-weak-ref nodes will break!**
Not using JNI refs hopefully will help with avoiding JNI reference table overflows, and will help creating trees on multiple threads, as no lock has to be acquired at any time.
Reviewed By: SidharthGuglani
Differential Revision: D14151037
fbshipit-source-id: 56d94713d39aee080d54be4cb4cdf5e3eccb473a
Summary:
Fix two bugs with Location when not using ACCESS_FINE_LOCATION:
- If we request highAccuracy=false, because we don't have ACCESS_FINE_LOCATION, but we don't have access to the NETWORK_PROVIDER...then the code should not trigger a SecurityException because it fell-back to using GPS_PROVIDER (which we don't have permission for)
- If the device is pre-lollipop, and doesn't have a provider, we should detect this properly instead of letting the pre-lollipop code raise a SecurityException.
Unfortunately, SecurityExceptions cannot be caught by the calling JS code. But I am not fixing that one here, instead choosing to fix/obviate the SecurityExceptions altogether.
Pull Request resolved: https://github.com/facebook/react-native/pull/10291
Differential Revision: D4163659
Pulled By: cpojer
fbshipit-source-id: 18bb4ee7401bc4eac4fcc97341fc2b3a2a0957c9
Summary:
This does fix the issue, however, another, perhaps related issue persists, the dialog/modal occasionally uses what would be the height of the app in non-immersive mode, in immersive mode. Meaning that the background, what ever it is set as, does not use the full available height.
See https://stackoverflow.com/a/23207365 for more info.
Known Problems:
---------
* [Date/time picker](https://facebook.github.io/react-native/docs/datepickerandroid) still brings app out of immersive mode - The date/time picker dialog needs the same treatment (this MR) as `RN Modal` using a wrapper.
* Focusing on text input, which brings up keyboard, also brings app out of immersive mode. Sometimes temporarily, sometimes permanently - Needs investigating. I have tried [this](https://stackoverflow.com/a/25129542), unfortunately it doesn't work. **Workaround I'm using for this, is to call a native module method to re-apply immersive mode flags after `keyboardDidHide` on JS side.**
Changelog:
----------
[Android] [Fixed] - Dialog (RN Modal) brings app permanently out of immersive mode
Pull Request resolved: https://github.com/facebook/react-native/pull/21078
Differential Revision: D14163127
Pulled By: cpojer
fbshipit-source-id: e0b67c91fa81880b19438a939bca26c128309799
Summary:
Native Android sets the EditText widget to multiline only if the InputType flags are set to Text (or its variants like textEmailAddress) and Multiline, which causes the React Native TextInput to not break the line when set to multiline={true} and keyboardType={'numeric'} as it only have the flags Multiline and Number set.
This fix forces the widget to enable multiline, by calling setSingleLine(false) everytime a state change needs to be commited and the multiline prop is set to true.
Pull Request resolved: https://github.com/facebook/react-native/pull/21884
Differential Revision: D14162701
Pulled By: cpojer
fbshipit-source-id: b7d3fc8c5a4444dcfd29ad74d515a8ae486c7ede
Summary:
@public
Adds `YogaConfig#avoidGlobalJNIRefs` to control whether nodes created with a config will use weak global JNI refs. Used for experimentation.
Reviewed By: SidharthGuglani
Differential Revision: D14149982
fbshipit-source-id: c777c8b3af2167d96154db5aa6afec1476dac35b
Summary: This task fixes an AssertionError in EventDispatcher class, this is produced by a race condition.
Reviewed By: JoshuaGross
Differential Revision: D14134907
fbshipit-source-id: 7b670ee35e47c0d8a9f7f7b68a3b8f7193b7de54
Summary:
@public
Here, we extract an abstract class from `YogaNode`, in order to allow for experimentation with different implementations.
The reason for not choosing an interface is to keep ABI compatibility for `YogaNode.create()`.
Reviewed By: pasqualeanatriello
Differential Revision: D14044990
fbshipit-source-id: f8eb246338b55f34f0401198c0655abfcb7c9f37
Summary:
@public
Switches instance creation from `new YogaNode()` to `YogaNode.create()`.
This allows for experimentation with different implementations, while maintaining API + ABI compatibility internally at FB, as well as for dependent projects in open source and elsewhere.
Reviewed By: amir-shalem
Differential Revision: D14122975
fbshipit-source-id: f194b146b7cd693dba1a7dafdf92d350e54cb179
Summary: Use the new copyright header format used elsewhere in the React Native repository.
Reviewed By: shergin
Differential Revision: D14091706
fbshipit-source-id: b27b8e6bcdf2f3d9402886dbc6b68c305150b7d5
Summary:
@public
Context-aware logging functions are an internal Yoga feature that will be used for Yoga’s JNI code.
It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.
Reviewed By: SidharthGuglani
Differential Revision: D14123482
fbshipit-source-id: 8ba3b6c493bf79fe09831f22d2b6da44f09e3d95
Summary:
@public
Makes logging implementation internal to Yoga.
Breaking changes: removed `YGLog` and `YGLogWithConfig`.
The upcoming changes to the JNI layer (removal of weak global refs for each node) requires adding additional parameters to the logging functions that will only be available when calculating layout.
Reviewed By: SidharthGuglani
Differential Revision: D14123390
fbshipit-source-id: 468e4a240c190342868ffbb5f8beb92324cdfdd6
Summary:
Adds a factory method to `YogaNode`.
While this is purely redundant at the moment, it will allow experimentation in follow-up diffs. We will have concrete implementations deriving from `YogaNode` (which will be abstract).
Going through `YogaNode.create()` means that we can maintain ABI compatibility.
Reviewed By: amir-shalem
Differential Revision: D14122974
fbshipit-source-id: 15d92f296d91cc8bbd79a196f370d2dbb69b3f92
Summary:
SYSTEM_ALERT_WINDOW permission is used only for debug builds to show draw overlay views or show warnings/errors. This permissions is unused in release builds, and there is an issue regarding removing unused permissions on Android build https://github.com/facebook/react-native/issues/5886#issuecomment-464495388. This PR removes SYSTEM_ALERT_WINDOW from all builds bug debug.
[Android] [Changed] - SYSTEM_ALERT_WINDOW permissions available only in debug builds
Pull Request resolved: https://github.com/facebook/react-native/pull/23504
Differential Revision: D14123045
Pulled By: cpojer
fbshipit-source-id: 68829a774ff23c7cb2721076a9d3870405f48fea
Summary:
In API 26, autofill framework was introduced in Android.
Read more about Autofill at https://developer.android.com/guide/topics/text/autofill.
Now, if in case for some text input if developer wants to disable
autofill then he can take help from this `importantForAutoFill` prop
and pass `no` to it.
Also important of auto fill can be configured with this prop, like:
* `auto`: Let the Android System use its heuristics to determine if the view is important for autofill.
* `no`: This view isn't important for autofill.
* `noExcludeDescendants`: This view and its children aren't important for autofill.
* `yes`: This view is important for autofill.
* `yesExcludeDescendants`: This view is important for autofill, but its children aren't important for autofill.
Default value if `auto`.
Read more at: https://developer.android.com/guide/topics/text/autofill-optimize
Changelog:
----------
[Android] [Added] - Add prop to configure `importantForAutofill` in `TextInput`.
Pull Request resolved: https://github.com/facebook/react-native/pull/22763
Differential Revision: D14121242
Pulled By: cpojer
fbshipit-source-id: aa4360480dd19f6dde66f0409d26a41a6a318c94
Summary: This diff implements equality for ReadableNativeMap, the underlying implementation relies on the method HashMap.equals()
Reviewed By: kathryngray
Differential Revision: D14019065
fbshipit-source-id: aeaec22ce1066241ed85f0527f5cd804e3c763dd
Summary: This diff implements equality on RedableNativeArray objects. This relies on the Arrays.deepEquals method
Reviewed By: kathryngray
Differential Revision: D14022108
fbshipit-source-id: 48b59529a9060a2bddba5fc8e3681c922ec31be4
Summary: This allows using this annotation when Buck has `java.abi_generation_mode = source_only` set.
Differential Revision: D14119311
fbshipit-source-id: 020e709924e70adb8a160069a1da9b209b99befa
Summary:
TL;DR: Setting `autoComplete` will allow the system to suggest autofill options for the `<TextInput>` component.
Android Oreo introduced the AutoFill Framework, for secure communication between an app and autofill services (e.g. Password managers). When using `<TextInput>` on Android Oreo+, the system already tries to autofill (based on heuristics), but there is no way to set configuring options or disable.
The quick solution would be to just add the same Android attributes (`autofillHints` & `importantForAutofill`) in React Native TextInput, but that doesn't bond well with the cross-platform nature of the library.
Introduces an `autoComplete` prop based on HTML's `autocomplete` attribute, mapping to Android `autofillHints` & `importantForAutofill` and serving as a proper placeholder for autofill/autocomplete in other platforms:
Also gives you the ability to disable autofill by setting autocomplete="off".
Pull Request resolved: https://github.com/facebook/react-native/pull/21575
Differential Revision: D14102949
Pulled By: hramos
fbshipit-source-id: 7601aeaca0332a1f3ce8da8020dba037b700853a
Summary:
Basically I want my cursor to be the same color of the text. Which means obviously that selecting the text will make it invisibible (ie, red text on red selection rectangle)
Today, setting a selection color does set a cursor color, which may be a good default in some cases, but we don't always couple these 2 colors together.
See original commit of janicduplessis ae57b25134
I'd like to be able to set different colors for selection and cursor.
Pull Request resolved: https://github.com/facebook/react-native/pull/20276
Differential Revision: D14102952
Pulled By: cpojer
fbshipit-source-id: 652ff782044277a0c8a821dd628f0373659a7850
Summary: Java symbols are likely being stripped at compile-time, preventing Reflection from working properly in C++. Should fix T40449334.
Reviewed By: mdvacca
Differential Revision: D14070629
fbshipit-source-id: f180fa3294b66f660ab1568250c47432cbf0c774
Summary:
This PR fixes no existing issue. BouncyCastle library is used inside React-Native but the current version is not updated anymore and this version is subject to `CVE-2013-0169`
Current maven link : http://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk16/1.46 . The descrption says that this jar is for SDK 1.6 but no updated since 2011.
Proposed maven link : http://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on The description says that that jar is for SDK 1.5 to SDK 1.8 and latest release was done in January 2018.
Nop.
But there was a discussion about bouncy castle few years ago https://github.com/facebook/react-native/issues/2793
[GENERAL] [Changes] robolectric - Upgrade bouncycastle lib to fix CSV vulnerabilities
Pull Request resolved: https://github.com/facebook/react-native/pull/19074
Reviewed By: mmmulani
Differential Revision: D14068062
Pulled By: hramos
fbshipit-source-id: 24e63cab33c3e8b5a088b9a8843afdc23b43553d
Summary:
This diff refactors JNI methods used by the Binding.cpp class in order to use ReadableMap instead of ReadableNativeMap
This will be helpful to provide a different implementation of ReadableMap from C++
Reviewed By: shergin
Differential Revision: D14077762
fbshipit-source-id: 595b0c2d3a2d6070112257b65c1141a8af36f0e1
Summary:
Here are some leftovers from nullable annotations for native modules, discovered while developing native module in Kotlin. This will help improve Kotlin developer experience
[Android] [Changed] - Add Nonnull annotations to ReactPackage
Pull Request resolved: https://github.com/facebook/react-native/pull/23415
Differential Revision: D14064607
Pulled By: cpojer
fbshipit-source-id: af2ce1fc1911ee03c54b20a4fc3a6d1aba9267da
Summary: SizeMonitoringFrameLayout was used to set layout contraints on the root shadow node when the native view's size changes. Since then, we introduced ways for the root node to use proper layout contraints using the root view's measure specs, which provides more accurate constraints for the root node, so SizeMonitoringFrameLayout is no longer needed. This ends up making a lot of UIManagerModule's method signatures cleaner
Reviewed By: mdvacca
Differential Revision: D9565720
fbshipit-source-id: c569cd15991a09987cc01e89612dc9193ad99b45
Summary:
I'm trying to fix DialogModule crashes we have in production: #6228
In this PR I'm fixing the following problem:
The fragment manager methods should be called only from the foreground. Now dismissExisting is protected by the mIsForeground variable as well as showNewAlert method.
[ANDROID] [Fixed] DialogModule - Race condition in dialog module fixed.
Pull Request resolved: https://github.com/facebook/react-native/pull/19332
Reviewed By: mdvacca
Differential Revision: D13804542
Pulled By: hramos
fbshipit-source-id: 9d59c8eaad49e2d3f141e255467627d411ae8797
Summary:
There's a bug in the OSS Switch component where the track color value is reset to the default value when the switch is toggled. It looks like the Java class resets the track color value in `setOn` (which fires in a press event): https://fburl.com/vmugfzja but these values aren't actually initialized from JS - in Switch.js we only pass through the current track color: https://fburl.com/vytekd0o.
The React component already has an API for defining both true/false track colors. However, we should also make sure not to reset these values for people using the old API of `tintColor`/`onTintColor`, so I'm changing it to only reset the value when both of those props are null.
Reviewed By: mdvacca
Differential Revision: D14035007
fbshipit-source-id: 12d968076bd47d54deedbfc15b12ff3cd77e2fd0
Summary: Enable support for using new MobileConfigNativeModule in RN Core/Fabric C++. Hack will be removed as part of T40273916 once MobileConfigNativeModule has rolled out to 100% of users and FbReactMobileConfigModule has been removed.
Reviewed By: mdvacca
Differential Revision: D14015962
fbshipit-source-id: 1b8ff0fb447040393a25fd03d9fb868877228ecc
Summary:
MobileConfig should be wrapped and presented as a ReactNativeConfig object so that core Fabric C++ code can use it.
This is just a noop plumbing diff. Real support will be added in follow-on diff.
Reviewed By: fkgozali
Differential Revision: D13985466
fbshipit-source-id: a2ac2175688e855eda3b89aa69faf07749c6bd31
Summary: Trivial cleanup of variables and methods that were not being used in ReactTextView
Reviewed By: blairvanderhoof
Differential Revision: D14027630
fbshipit-source-id: e763d6d001d4a0c2970adebc9855190845cf5a1d
Summary:
There is no reason to allocate views ahead of time on the main thread.
There is a chance that this view will not be mounted and we are not saving any time because it's a sequential process anyway (because we are doing it on the main thread). Moreover, the switching context can only slowdown JS execution.
Reviewed By: JoshuaGross
Differential Revision: D14026379
fbshipit-source-id: 2dbe93ab32b611fae942468e7812b78afeaf34fc
Summary:
Now RN has only ReactActivity which extends AppCompatActivity, subclass of FragmentActivity, therefore no need to check if activity is FragmentActivity or not. This PR changes DatePickerDialogModule to work only with FragmentActivity.
Also DialogFragment from Android is deprecated in API 28, and recommends to use DialogFragment from Support Library. Excerpt from DialogFragment documentation.
> **This class was deprecated in API level 28.**
> Use the Support Library DialogFragment for consistent behavior across all devices and access to Lifecycle.
**BREAKING CHANGE**: Brown field apps must extend FragmentActivity or its subclasses
[Android] [Changed] - DatePickerDialogModule supports only FragmentActivity
Pull Request resolved: https://github.com/facebook/react-native/pull/23371
Differential Revision: D14030765
Pulled By: cpojer
fbshipit-source-id: 3a1811102cf68b82c139f0e20b2fc8dab5d98b69
Summary:
Now RN has only ReactActivity which extends AppCompatActivity, subclass of FragmentActivity, therefore no need to check if activity is FragmentActivity or not. This PR changes TimePickerDialogModule to work only with FragmentActivity.
Also DialogFragment from Android is deprecated in API 28, and recommends to use DialogFragment from Support Library. Excerpt from DialogFragment documentation.
> **This class was deprecated in API level 28.**
> Use the Support Library DialogFragment for consistent behavior across all devices and access to Lifecycle.
[Android] [Changed] - TimePickerDialogModule supports only FragmentActivity
Pull Request resolved: https://github.com/facebook/react-native/pull/23372
Differential Revision: D14030748
Pulled By: cpojer
fbshipit-source-id: 9b3778c90eb1c014260327513bc8709264b94431
Summary: Make REACT_CLASS a public property on ReactSwitchManager (similar to our other UI managers) so we can more easily lazily load this class.
Reviewed By: mdvacca
Differential Revision: D14028452
fbshipit-source-id: 84aebd4e2e1e0039957d8c12490022386aab7847
Summary:
This diff disables OverlappingRendering for ReactTextView to avoid the exception:
```
java.lang.IllegalStateException: Unable to create layer for com.facebook.react.views.text.ReactTextView
```
during fade animations
OverlappingRendering enables an optimization during rendering of animations per component, disabling this might affect performance of animations inside TextView.
We will add a ReactFlag to experiment on how this affect other surfaces.
Reviewed By: blairvanderhoof
Differential Revision: D14027631
fbshipit-source-id: c1a84e7488c44582f7b7c78965aeb7bd27f82368
Summary:
Fix lint errors and warning, which might be a cause of various crashes on older Android OS, using Android Support Library.
```bash
./gradlew :ReactAndroid:lint
```
[Android] [Changed] - fix lint error/warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23333
Differential Revision: D14019322
Pulled By: mdvacca
fbshipit-source-id: 74c98da269c318cf3b114c8d9c876186369f2b8c
Summary:
Using Kotlin DSL in Gradle instead of Groovy will help detect problems early on using static typing, and it has advanced IDE support. This PR prepares Groovy script for Kotlin DSL migration per **Migrating build logic from Groovy to Kotlin** guide. Here is the excerpt:
>As a first migration step, it is recommended to prepare your Groovy build scripts by
> - unifying quotes using double quotes,
> - disambiguating function invocations and property assignments (using respectively parentheses and assignment operator).
See: https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/
[Android] [Changed] - Prepare Gradle scripts for Kotlin DSL migration
Pull Request resolved: https://github.com/facebook/react-native/pull/23355
Differential Revision: D14018504
Pulled By: mdvacca
fbshipit-source-id: 909982c715b640f102cbe723df578c9af7bae08e