3103 Commits

Author SHA1 Message Date
Emiel Mols
84e2636004 ReactAndroid: JS errors during bundle load were reported as UnknownCppException (#24648)
Summary:
This fixes a regression on Android introduced by f3e5cce where JS errors thrown during bundle load were lost (shown only as UnknownCppException). It is especially tough to debug (custom) bundling errors without seeing the javascript error.

Root cause hypothesis: since switching to clang, `JSError`s thrown in ReactCommon's `JSCRuntime::checkException` were never matched as `std::exception` in ReactAndroid's `convertCppExceptionToJavaException` due to these missing flags.

I'm a bit shy on low-level details concerning how C++ rtti works exactly around catching exceptions thrown in other libraries. All I can say that with this change, a `bundle.android.js` that only contains `throw new Error("wtf");` now nicely outputs a message and stack trace in the logcat. Before (and since DanielZlotin's switch to clang) it just outputted:

```
2019-04-29 12:17:59.365 1162-1306/com.rntest E/unknown:ReactNative: Exception in native call
    com.facebook.jni.UnknownCppException: Unknown
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:214)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
        at java.lang.Thread.run(Thread.java:764)
```

[Android] [Fixed] - JS errors during bundle load were reported as UnknownCppException.
Pull Request resolved: https://github.com/facebook/react-native/pull/24648

Differential Revision: D15123525

Pulled By: mdvacca

fbshipit-source-id: 74b5ce9ebae38d172446b6e31739d795c601947b
2019-04-30 22:32:23 +02:00
Thorben Primke
379874dc49 Adds Logic To Catch MissingWebViewPackageException (#24533)
Summary:
We are seeing crash reports that the webview is missing. In this case
it should fail gracefully so that a missing webview does not block
from using an app built with React Native.

The contains could also be changed to check for "webview" in general
to catch all webview related exception. It's currently checking on
for the specific string that I'm seeing in our app's crashreporting tool.

<img width="1507" alt="Screen Shot 2019-04-19 at 11 26 19 AM" src="https://user-images.githubusercontent.com/741767/56438307-5e1c2f80-6297-11e9-970b-a5095d18e9d7.png">

<img width="935" alt="Screen Shot 2019-04-19 at 11 32 58 AM" src="https://user-images.githubusercontent.com/741767/56438213-fa920200-6296-11e9-8008-5eb344eca8a8.png">

[Android] [Fixed] - The ReactCookieJarContainer/ForwardingCookieHandler now handles the missing WebView  gracefully.
Pull Request resolved: https://github.com/facebook/react-native/pull/24533

Differential Revision: D15062824

Pulled By: cpojer

fbshipit-source-id: 80805a47494f0d924b7ee029ce8ca0504eaeee57
2019-04-30 22:27:25 +02:00
Christoph Nakazawa
f3801d90fa Revert "improve RTL (#24069)" (#24580)
Summary:
This reverts commit b3c74967ca6b20d7bda84c690ae3a99dfe255843.

Fixes #24267

[Android] [Fixed] - Invalid text alignment for RTL fonts.
Pull Request resolved: https://github.com/facebook/react-native/pull/24580

Differential Revision: D15061667

Pulled By: cpojer

fbshipit-source-id: 6d02c9e938f1f8630ba691f57bdf79fd57db3bb2
2019-04-30 22:26:35 +02:00
Mike Grabowski
df4e67fe75 [0.59.6] Bump version numbers 2019-04-18 14:53:24 +02:00
Mike Grabowski
822bdd4a0b [0.59.5] Bump version numbers 2019-04-17 23:51:44 +02:00
Mike Grabowski
f5a31801a0 Enforced thread safety on UIImplementation methods that mutate the shadowNodeRegistry 2019-04-17 21:32:29 +02:00
Mike Diarmid
d7bd6cce38 JSStackTrace -> Ensure lineNumber exists before consuming (#24399)
Summary:
Fixes https://github.com/facebook/react-native/issues/24382

[ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsing JS stack frames without line numbers.
Pull Request resolved: https://github.com/facebook/react-native/pull/24399

Differential Revision: D14890746

Pulled By: cpojer

fbshipit-source-id: cea3653076484ad624084c370439f8a39c303083
2019-04-17 21:23:35 +02:00
Vishwesh Jainkuniya
b8aac029f1 Fix: mostRecentEventCount is not updated. (#17990)
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

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

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

Happy contributing!

-->

Update it's value as it changes on the JS thread, so that updated value is used (f7f5dc6649/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java (L243)) whenever setSelection(int start, int end) is called (f7f5dc6649/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java (L315)).
Pull Request resolved: https://github.com/facebook/react-native/pull/17990

Differential Revision: D14255969

Pulled By: mdvacca

fbshipit-source-id: 555d6752eabca5c31c1762955a56f99cc1828546
2019-04-17 21:21:46 +02:00
Mike Grabowski
d60a2fbb01 [0.59.4] Bump version numbers 2019-04-08 23:51:19 +02:00
Sunny Luo
d6bca9723e Prevent crash when setting underlineColorAndroid (#24183)
Summary:
Try to prevent the crash described in https://github.com/facebook/react-native/issues/17530

There seems to be a bug in `Drawable.mutate()` in some devices/android os versions even after you check the constant state. This error is hard to reproduce and to fix, so just try to catch the exception to prevent crash.

[Android][Fixed] Prevent random crash when setting underlineColorAndroid
Pull Request resolved: https://github.com/facebook/react-native/pull/24183

Differential Revision: D14710484

Pulled By: cpojer

fbshipit-source-id: 3af20a5cb0ecd40839beaf85118c0f5aa6905414
2019-04-08 23:18:33 +02:00
Lorenzo Sciandra
3b91a7ec23 [0.59.3] Bump version numbers 2019-04-01 12:43:47 +01:00
David Vacca
13cb5a91ed Fix IllegalStateException when tapping next on Android Keyboard
Summary: This diff fixes an IllegalStateException that is thrown when the user click is on a edit text and tap 'Next' on the keyboard to focus on the next view, but the next view is hidden.

Reviewed By: lunaleaps, mmmulani

Differential Revision: D14598410

fbshipit-source-id: 2999cc468ed24bedff163eedcfaec50f6ee005d6
2019-03-29 15:19:30 +00:00
Sergei Dryganets
e4f9ee913b OkHttp is more strict than other http libraries. (#21231)
Summary:
It crashes with IllegalStateException in case you pass a wrong URL.
It crashes if it meets unexpected symbols in the header name and value,
while standard says it is not recommended to use those symbols not that
they are prohibited.

The headers handing is a special use case as a client might have an auth token in the header. In this case, we want to get 401 error response
from the server to find out that token is wrong. In case of the onerror
client will continue to retry with an existing token.

[ANDROID][Fixed] - Networking: Passing invalid URL not crashes the app instead onerror callback of HttpClient is called. Invalid symbols are stripped from the headers to allow HTTP query to fail with 401 error code in case of the broken token.

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

Reviewed By: axe-fb

Differential Revision: D10222129

Pulled By: hramos

fbshipit-source-id: b23340692d0fb059a90e338fa85ad4d9612275f2
2019-03-29 15:14:57 +00:00
Dulmandakh
871290f33a improve RTL (#24069)
Summary:
Google recommends to use Gravity.START and Gravity.END instead of Gravity.LEFT and Gravity.RIGHT to support RTL better.

[Android] [Changed] - Improve RTL support
Pull Request resolved: https://github.com/facebook/react-native/pull/24069

Differential Revision: D14541569

Pulled By: cpojer

fbshipit-source-id: 5c104d8bd666e1270d5410216c7f2efa6152692a
2019-03-29 15:14:38 +00:00
Mike Grabowski
9bb5c32de9 [0.59.2] Bump version numbers 2019-03-25 22:22:14 +01:00
Dulmandakh
becc15468f fix switch trackColor on Android. fixes #23962 (#23977)
Summary:
fixes #23962, where trackColor is reset when value changed. This PR will set trackColor corresponding trackColor every-time value changes.

[Android] [Changed] - Fix Switch trackColor
Pull Request resolved: https://github.com/facebook/react-native/pull/23977

Differential Revision: D14495206

Pulled By: hramos

fbshipit-source-id: d712f540cd3f8359d6e85f79c12732689870a112
2019-03-22 18:27:23 +01:00
Emily Janzer
4260907b90 Pass through track color values for true/false to native component
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
2019-03-22 18:27:21 +01:00
Dulmandakh
fab86ee488 use Conscrypt as security provider if available (#23984)
Summary:
This PR adds support to use Conscrypt as Security Provider if available runtime. Consscrypt supports TLS 1.2 on Android 4.x and TLS 1.3 on all Android versions. Fixes issues (ex https://github.com/facebook/react-native/issues/23151) with HTTPS connections on Android 4.x.

Just add below to your project build.gradle and it'll use it.

```gradle
implementation('org.conscrypt:conscrypt-android:2.0.0')
```

[Android] [Changed] - Add TLS 1.3 support to all Android versions using Conscrypt.
Pull Request resolved: https://github.com/facebook/react-native/pull/23984

Differential Revision: D14506000

Pulled By: cpojer

fbshipit-source-id: 58bf18f7203d20519fb4451bae83f01e2f020a44
2019-03-22 18:21:44 +01:00
Héctor Ramos
7263a77b44 Do not use autofill methods on Android APIs older than Oreo (26)
Summary:
Autofill Hints were added in [Android API 26](https://developer.android.com/reference/android/view/View.html#setAutofillHints(java.lang.String...)). Without this runtime check, pre-26 devices will crash.

[Android][Fixed] - Fixes crash on pre-26 Android devices when setting text content type

Reviewed By: lunaleaps

Differential Revision: D14479468

fbshipit-source-id: 238c1efd6aea682a93ecb45e1123aaed6bdcd9e3
2019-03-22 18:20:25 +01:00
Peter Argany
3f1d2b0f96 Turn off Metro JS Deltas by default for Android
Summary: JS Deltas have been killing productivity of RN engineers lately. There's been several posts and questions asked that end in "Turn off JS Deltas". Disabling them until we can make them more stable.

Reviewed By: fkgozali

Differential Revision: D14491774

fbshipit-source-id: 29b1c8e5e72369882c2890e3b6347ecd2fe4bed1
2019-03-22 18:19:51 +01:00
Mike Grabowski
60cf18fad4 [0.59.1] Bump version numbers 2019-03-14 12:12:02 +01:00
Mike Grabowski
7c73f2bb5a [0.59.0] Bump version numbers 2019-03-12 13:42:02 +01:00
Vishwesh Jainkuniya
f6ca4d0a96 Add prop to configure importantForAutofill. (#22763)
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
2019-03-12 06:43:00 +01:00
Sunny Luo
8d95e734bb Text: Implement textAlign justify for android O+ (#22477)
Summary:
Add textAlign justify for android O+(api level >=26)
Resolves https://github.com/facebook/react-native/issues/22475

<img src="https://user-images.githubusercontent.com/615282/49341207-35e3b980-f685-11e8-91ab-dbc19c1ee4d0.gif" width="400" />

Changelog:
----------
[Android] [Added] - Implement textAlign justify for android O+
Pull Request resolved: https://github.com/facebook/react-native/pull/22477

Differential Revision: D13512004

Pulled By: cpojer

fbshipit-source-id: e20f4976bfd957a5faeae0bbed2ff27c03023bb1
2019-03-11 21:19:23 +01:00
Mike Grabowski
9cb4d3f2c1 [0.59.0-rc.3] Bump version numbers 2019-02-27 22:21:55 +01:00
Wei Yang
8e5eb6389f add talkback navigation support for links and header (#22447)
Summary:
1. add role description for heading
2. add talkback navigation support for link and header

Fixes #22440
Pull Request resolved: https://github.com/facebook/react-native/pull/22447

Differential Revision: D14205822

Pulled By: cpojer

fbshipit-source-id: 86bfc3bfc851f3544b1962012abaf8d1a357a9d2
2019-02-27 21:22:14 +01:00
Mike Lambert
2b7346f4b3 Fix two bugs with Location when not using ACCESS_FINE_LOCATION (#10291)
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
2019-02-27 21:21:48 +01:00
Nate Hunzaker
d7c4c37f09 Use existing character set in POST body when possible (#23603)
Summary:
This commit fixes a bug introduced in a previous attempt (https://github.com/facebook/react-native/pull/23580) to address an issue where okhttp appended `charset=utf-8` to the Content-Type header when otherwise not specified.

In that commit, I converted all characters to UTF-8, however it should instead use an existing encoding when possible.

Related issues:
https://github.com/facebook/react-native/issues/8237#issuecomment-466304854

[Android][fixed] - Respect existing character set when specified in fetch() POST request
Pull Request resolved: https://github.com/facebook/react-native/pull/23603

Differential Revision: D14191750

Pulled By: hramos

fbshipit-source-id: 11c1bfd98ccd33cd8e54ea426285b7d2ce9c2d7c
2019-02-27 21:21:39 +01:00
Nate Hunzaker
4cad737315 Prevent okhttp from adding ;charset=utf8 to ContentType Header (#23580)
Summary:
Before this commit, `fetch()` calls append `"charset=utf8"` to the `Content-Type` header on Android (and not on iOS). This is because of an implementation detail in the okhttp library. This means that you can make a call on the JavaScript side like:

```javascript
let body = JSON.stringify({ key: "value" });

let headers = {
  "Content-Type": "application/json"
};

fetch("http://10.0.2.2:3000", { method: "POST", body, headers });
```

However the resulting request appends the utf8 character:

```
POST - 13:34:32:
  content-type: application/json; charset=utf-8
  content-length: 15
  host: 10.0.2.2:3000
  connection: Keep-Alive
  accept-encoding: gzip
  user-agent: okhttp/3.12.1
```

Passing byte array into the RequestBody avoids this, as recommended by a maintainer of okhttp:

https://github.com/square/okhttp/issues/2099#issuecomment-366757161

Related issues:
https://github.com/facebook/react-native/issues/8237

[Android][fixed] - Prevent fetch() POST requests on Android from appending `charset=utf-8` to `Content-Type` header.
Pull Request resolved: https://github.com/facebook/react-native/pull/23580

Differential Revision: D14180849

Pulled By: cpojer

fbshipit-source-id: b84cadf83361331a9f64d1ff5f2e6399a55527a6
2019-02-27 21:21:34 +01:00
David Vacca
fee5031748 Fix IllegalArgumentException when creating CookieManager
Summary:
This prevents this https://bugs.chromium.org/p/chromium/issues/detail?id=559720 to crash the app.
When using this fix the webView will not function correctly

More details about the bug https://bugs.chromium.org/p/chromium/issues/detail?id=559720

Reviewed By: fkgozali

Differential Revision: D14181851

fbshipit-source-id: 5a8c149df82a7373fe8b5b32006f034868532485
2019-02-27 21:21:25 +01:00
Dulmandakh
fbf039b126 add nullable annotations to some ViewManager methods (#23610)
Summary:
Add nullable annotations to BaseViewManager and ViewManager methods. This will improve Kotlin developer experience and help Android Studio to offer better autocomplete.

[Android] [Changed] - add nullable annotations to BaseViewManager and ViewManager methods. Might break ViewManagers in Kotlin.
Pull Request resolved: https://github.com/facebook/react-native/pull/23610

Differential Revision: D14198630

Pulled By: mdvacca

fbshipit-source-id: c596c88254e1d02f0af233a466f685200fac8917
2019-02-27 21:16:10 +01:00
Dulmandakh
52e51368eb ReactTextView extends AppCompatTextView (#23321)
Summary:
Google recommends to use AppCompat widgets, and this PR changes ReactTextView to extend AppCompatTextView.

[Android] [Changed] - ReactTextView extends AppCompatTextView
Pull Request resolved: https://github.com/facebook/react-native/pull/23321

Differential Revision: D13986149

Pulled By: cpojer

fbshipit-source-id: 878849fff12dc5478bb0d0952b2c22695391e81a
2019-02-27 21:15:20 +01:00
Dulmandakh
56fc630368 SYSTEM_ALERT_WINDOW only in debug builds (#23504)
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
2019-02-27 21:14:41 +01:00
Mike Grabowski
40603bc9c4 [0.59.0-rc.2] Bump version numbers 2019-02-18 18:04:25 +01:00
Cassio Zen
179d490607 Add autoComplete prop (#21575)
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
2019-02-18 17:30:38 +01:00
Mike Grabowski
1768655971 [0.59.0-rc.1] Bump version numbers 2019-02-15 16:38:54 +01:00
Mike Grabowski
560a484fc6 Revert "[0.59.0-rc.1] Bump version numbers"
This reverts commit 199de26f42b114f77d95a7e91e4c43845748b2de.
2019-02-15 15:36:00 +01:00
Mike Grabowski
199de26f42 [0.59.0-rc.1] Bump version numbers 2019-02-14 10:12:20 +01:00
Héctor Ramos
5a314690f2 [0.59.0-rc.0] Bump version numbers 2019-02-13 12:14:47 -08:00
Héctor Ramos
2bc055a227 Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit af6de4e8c84fc724d9687cabdfbdd1a03a3b527a.
2019-02-13 12:13:49 -08:00
Héctor Ramos
af6de4e8c8 [0.59.0-rc.0] Bump version numbers 2019-02-13 12:03:09 -08:00
Héctor Ramos
cef5ad6964 Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit 517c165daee27a7e6d61f4432599fd311186fc8f.
2019-02-13 11:52:49 -08:00
Mike Grabowski
517c165dae [0.59.0-rc.0] Bump version numbers 2019-02-13 20:15:31 +01:00
Mike Grabowski
8b75677fdb Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit d47aa28ef7dc0f7f8093a481c921cee202351fb7.
2019-02-13 20:15:00 +01:00
Mike Grabowski
d47aa28ef7 [0.59.0-rc.0] Bump version numbers 2019-02-13 18:04:43 +01:00
Dulmandakh
e6d8ac8424 @Nonnull annotation for ReactPackage (#23415)
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
2019-02-13 17:12:21 +01:00
Dulmandakh
818f6bb248 bump targetSdkVersion to 28 (#23431)
Summary:
Bump targetSdkVersion to 28

[Android] [Changed] - Bump targetSdkVersion to 28
Pull Request resolved: https://github.com/facebook/react-native/pull/23431

Differential Revision: D14065177

Pulled By: cpojer

fbshipit-source-id: a161d1d385b7b40ec93d70851e5a41baeb58f830
2019-02-13 17:12:08 +01:00
Mike Grabowski
a962cb659f Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit d059e747041296d79094ed0a8ad4e721134420b7.
2019-02-13 17:10:19 +01:00
Mike Grabowski
d059e74704 [0.59.0-rc.0] Bump version numbers 2019-02-13 16:47:58 +01:00
Mike Grabowski
9f96606d32 Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit 69e5c2ddc18eee8ee6108f5fc9bad91cba9407af.
2019-02-13 16:47:27 +01:00