Summary:
Setting the line height with the help of Android-provided StaticLayout is incorrect. A
simple example app will display the following when `setLineSpacing(50.f, 0.f)`
is set: {F62987699}. You'll notice that the height of the first line is a few
pixels shorter than the other lines.
So we use a custom LineHeightSpan instead, which needs to be applied to the text
itself, and no height-related attributes need to be set on the TextView itself.
Reviewed By: lexs
Differential Revision: D3751097
fbshipit-source-id: 6c5a8d01a6dca4ff6eef9c3aadd1b550054432d2
Summary:
Setting the line height with the help of Android-provided StaticLayout is incorrect. A
simple example app will display the following when `setLineSpacing(50.f, 0.f)`
is set: {F62987699}. You'll notice that the height of the first line is a few
pixels shorter than the other lines.
So we use a custom LineHeightSpan instead, which needs to be applied to the text
itself, and no height-related attributes need to be set on the TextView itself.
Reviewed By: lexs
Differential Revision: D3751097
fbshipit-source-id: c3574a1080efec26436a5c61afbff89afa8679e7
Summary: Runtime annotation processing uses reflection which is slow. We'll use build time annotation processing instead and create at build time static ModuleInfo classes which have "name", "canOverrideExistingModule", "supportsWebWorkers", "needsEagerInit".
Reviewed By: lexs
Differential Revision: D3752243
fbshipit-source-id: 3518c6f38087d8799a61410864007041389c0e15
Summary: Add support for `useNativeDriver: true` to `Animated.decay`. Add example in Native Animated Example UIExplorer app.
Reviewed By: ritzau
Differential Revision: D3690127
fbshipit-source-id: eaa5e61293ed174191cec72255ea2677dbaa1757
Summary: Border colors broke with recent change to default values in csslayout Spacing. This is a quick fix until we move react-native borders away from using Spacing.java which is a hack in the first place.
Reviewed By: lexs
Differential Revision: D3735435
fbshipit-source-id: 747c85798cb02e1a5139de038eb26b64ac4c5bf3
Summary: Sometimes the main component name is not known at activity construction time and depends on e.g. reading shared preferences. To support this use case, make `(Fragment)ReactActivity#getMainComponentName()` nullable and return `null` by default. In this case, the app will not be loaded in `onCreate` by default and the user has to call `loadApp` manually once the component name is known.
Reviewed By: andreicoman11
Differential Revision: D3722517
fbshipit-source-id: 062eed158798606e4160f1c142b23fd98ca618c8
Summary:
The Android lifecycle is weird: turns out `onActivityResult` is called before `onResume`. This means `getCurrentActivity()` could return the wrong instance, or `null` if the activity was destroyed. To give developers access to the Activity receiving the result (which is also about to become the current activity), pass it as an argumento the listener.
Fixes github issue #8694.
Reviewed By: donyu
Differential Revision: D3704141
fbshipit-source-id: e7e00ccc28114f97415e5beab8c9b10cb1e530be
Summary: This dependency on okhttp is unused. Removing this to lower the method-count increase from including the core RN modules.
Reviewed By: AaaChiuuu
Differential Revision: D3711870
fbshipit-source-id: 54b92edb4a55140b33cc74a5e9270650ced56ab9
Summary: This move lets us remove the dependency on okhttp3 from react/bridge. The classes I moved are all strictly related to dev support features and don't need to go into the core bridge module that gets shipped to production.
Reviewed By: AaaChiuuu
Differential Revision: D3698977
fbshipit-source-id: 6ba1517377061690cef289a544ec1622122cef85
Summary:
`ThemedReactContext` wraps the actual `ReactContext` but doesn't actually receive any lifecycle events, which would set `mCurrentActivity`, so that's always stuck as `null`. To fix, we override `has/getCurrentActivity` and forward the call to the wrapped context, which actually has the correct lifecycle status.
Fixes issue #9310 on github.
Reviewed By: mkonicek
Differential Revision: D3703005
fbshipit-source-id: 363e87ac91d50516899b413e823d5312cbb807f4
Summary:
LazyReactPackage is an extension of ReactPackage that allows us to lazily construct native modules.
It's a separate class to avoid breaking existing packages both internally and in open source.
Reviewed By: astreet
Differential Revision: D3334258
fbshipit-source-id: e090e146adc4e8e156cae217689e2258ab9837aa
Summary:
**Motivation**
For the `Text` component, if `numberOfLines` is set to `0`, the behavior on iOS is such that there is no limit.
On Android, the behavior is such that `numberOfLines={0}` will not render the `Text` component.
Since we want behavior to be the same across platforms, this change will make sure Android behaves the same as iOS.
**Test Plan**
Create a `Text` component specifying `numberOfLines={0}` on an Android project.
Expected:
- `Text` component displays, with no limit to number of lines.
Result:
- `Text` component does not appear at all.
Closes https://github.com/facebook/react-native/pull/9188
Differential Revision: D3697115
fbshipit-source-id: c1768ac22bab3c0e41a9df38b7314f3201512eb2
Summary: Add `isPrefSet` and `setPref` function to make I18nUtil cleaner
Reviewed By: fkgozali
Differential Revision: D3684958
fbshipit-source-id: 96f51d495d700d46096dc162c7599bc51a0b37cd
Summary:
**Motivation**
In iOS you cannot dismiss alerts by clicking outside of their box, while on Android you can. This can create some inconsistency if you want to have identical behavior on both platforms. This change makes it possible for Android apps to have irremovable/required alert boxes just like in iOS.
This adds an additional parameter to the Alert method. The way to use it is by providing an object with the cancelable property. The cancelable property accepts a boolean value.
This utilizes the Android DialogFragment method [setCancelable](https://developer.android.com/reference/android/app/DialogFragment.html#setCancelable(boolean))
**Usage example**
```js
Alert.alert(
'Alert Title',
null,
[
{text: 'OK', onPress: () => console.log('OK Pressed!')},
],
{
cancelable: false
}
);
```
**Test plan (required)**
I added an additional alert to the UIExplorer project where it can be tested. I also added a part in the Dialog Module test to make sure setting canc
Closes https://github.com/facebook/react-native/pull/8652
Differential Revision: D3690093
fbshipit-source-id: 4cf6cfc56f464b37ce88451acf33413393454721
Summary: Add FragmentActivity-based ReactFragmentActivity to support apps using the v4 support lib. Add delegate class to share implementation details between the new class and ReactActivity.
Reviewed By: astreet
Differential Revision: D3655428
fbshipit-source-id: d3ff916538e13b6f0d594bbb91555e322645e954
Summary:
If a paused activity is destroyed (e.g. because of resource contention), we send onHostDestroyed to all modules even if there's an on-screen, resumed activity using the current react instance.
This diff adds a check to make sure lifecycle events come from the current activity, and ignores ones that don't.
Reviewed By: astreet
Differential Revision: D3655422
fbshipit-source-id: 0f95fda124df3732447853b9bc34c40836a4b1da
Summary: It doesn't make sense to clear mCurrentActivity in onHostPause -- we're not going to leak a paused activity. Only keeping it around after onDestroy could lead to leaks. This allows us to check the source of lifecycle events and only send them if they come from the current activity (upcoming diff).
Reviewed By: astreet
Differential Revision: D3655370
fbshipit-source-id: f54b04a95c5c090636219832e63a348f3ae5a5c3