Commit Graph

1530 Commits

Author SHA1 Message Date
Denis Koroskin b321ea98d3 Properly clip child Views in FlatViewGroup
Summary:
Everything (but Views) are drawn using AbstractDrawCommand (or its derivative, like DrawBorder or DrawBackgroundColor) and supports clipping properly. Views however are drawn using an assumption that Android will clip them manually. This is however not always true. One example is if an element A mounts to a View, and its parent B doesn't but has overflow: hidden and thus should clip the child.

There are 2 ways to fix this:
- pop every element that has overflow: hidden to its own View. In this case, its children will always be correctly clipped. This is however very inefficient, especially if overflow: hidden is default (which it is!) which means that almost every React element must be backed by an Android View.
- add clipping information to DrawView, similar to how AbstractDrawCommand has it.

This diff implements the latter approach.

Reviewed By: ahmedre

Differential Revision: D2792375
2016-12-19 13:40:18 -08:00
Denis Koroskin 3d6464d0e1 Properly mark root shadow node as mounting to a View
Summary: RootFlatShadowNode always mounts to a (top-level) View but was never marked as one that mounts to a View. This diff fixes it. Nothing in the code relied on it being marked as mounting to a View, so it worked fine. A follow up path that implements UIImplementation.measure() for nodes that don't mount to a View goes up until it finds first mounting node, and it was crashing with NPE because it tried to access RootFlatShadowNode's parent (and there isn't one).

Reviewed By: sriramramani

Differential Revision: D2800818
2016-12-19 13:40:18 -08:00
Denis Koroskin 31d2443dd4 Implement RCTTextInlineImage with Nodes
Summary:
React allows nesting <Image> inside <Text>, in which case it turns into an RCTTextInlineImage element. RNFeed is using it in a few places and thus we need to support it, too.

This diff implements it with InlineImageSpan (WithPipeline, and WithDrawee separately).

Reviewed By: ahmedre

Differential Revision: D2792569
2016-12-19 13:40:18 -08:00
Denis Koroskin 28efab0670 Fix Android Views not clipping their content
Summary: D2768643 disabled View clipping of FlatViewGroup's children by calling setClipChildren(false). Turns out, instead of disabling clipping on the View this method is called on, it disables clipping on the children, instead. While we want the clipping disabled on all children that are FlatViewGroups, it also means that everyone else gets the clipping disabled as well. This has issues with ScrollView that stopped clipping its scrolling content, resulting in visual glitches. To fix the issue, manually clip all the Views that are not FlatViewGroups.

Reviewed By: ahmedre

Differential Revision: D2792411
2016-12-19 13:40:18 -08:00
Denis Koroskin 0f2a5cffa7 Extract ImageRequest creation into a helper class
Summary: This diff add an ImageRequestHelper class to reuse code that creates ImageRequest in both RCTImageView and (upcoming) RCTTextInlineImage

Reviewed By: ahmedre

Differential Revision: D2792548
2016-12-19 13:40:18 -08:00
Denis Koroskin 368e0361dd Rename BitmapRequestHelper to PipelineRequestHelper
Summary: Minor cleanup; renames BitmapRequestHelper to PipelineRequestHelper and adds BitmapUpdateListener interface. I plan reusing these classes in an upcoming RCTTextInlineImage implementation.

Reviewed By: ahmedre

Differential Revision: D2792535
2016-12-19 13:40:18 -08:00
Denis Koroskin fd3e213593 Update RCTText.PAINT's text size to ensure that ellipsis is measured correctly
Summary: placeholder

Reviewed By: ahmedre

Differential Revision: D2786310
2016-12-19 13:40:18 -08:00
Denis Koroskin e3abc51dd7 RCTText should clip when the creates Layout is wider than requested
Summary: AbstractDrawCommand's bounds are supposed to be the rectangle that the DrawCommand will draw into, so that it can compare bounds against clip rect bounds and reliable skip clipping when it's not needed. It is however not true for RCTText that can create text Layout that in some cases can go out of it's requested bounds (happens with TextView, too). To fix the issue, instead of passing requested bounds, pass the actual ones. In this case, AbstractDrawCommand will make sure to clip DrawTextLayout if for some reason it draws outside of the allowed boundaries.

Reviewed By: ahmedre

Differential Revision: D2786306
2016-12-19 13:40:18 -08:00
Denis Koroskin d23f86e47b Implement touch intercepting in RCTView
Summary:
@public React allows excluding certain elements from touch handling by assigning `PointerEvents` filter to them, such as BOX_NONE - this element will not receive touch but its children will, BOX_ONLY - only this element will receive pointer event and not children, NONE - neither this element nor its children will receive pointer events, and AUTO - pointer events are allowed for both this element and its children.

This diff adds PointerEvents support to flat RCTView. Most of the implementation is copied from ReactViewManager/ReactViewGroup. One small change is made to TouchTargetHelper to ensure that it works correctly with virtual nodes when their parent has PointerEvents set to PointerEvents.BOX_NONE.

Reviewed By: ahmedre

Differential Revision: D2784208
2016-12-19 13:40:18 -08:00
Denis Koroskin ff77456f26 Fix DrawBorder now updating color for left border, drawing it with old color
Summary: There is a small bug in DrawBorder where we forget updating color for a left border, which makes the border draw with whatever color was previously set to the Paint. This diff fixes it by updating the color.

Reviewed By: ahmedre

Differential Revision: D2779511
2016-12-19 13:40:18 -08:00
Denis Koroskin f6b4dc68de Make sure shadow node that we set JSResponder to mounts to a View
Summary: When setJSResponder() is called on a shadow node that doesn't mount to a View, React runtime will crash in NativeViewHierarchyManager because it will fail to find a corresponding View. To fix the issue, make sure we forceMountToView() before we call enqueueSetJSResponder().

Reviewed By: ahmedre

Differential Revision: D2779523
2016-12-19 13:40:18 -08:00
Ahmed El-Helw 12023b7953 Implement numberOfLines support in React flat rendering.
Summary: Support numberOfLines in React with flat rendering.

Differential Revision: D2746855
2016-12-19 13:40:17 -08:00
Denis Koroskin c5d0cb70d7 Fixed a build failure due to a missing import
Summary: D2772438 removed some unused imports, and a parallel build landed that uses one of the imports. Both diffs landed and now master is broken. This diff is fixing it.

Reviewed By: ahmedre

Differential Revision: D2779442
2016-12-19 13:40:17 -08:00
Denis Koroskin 6f06f76e38 Implement overflow:visible/hidden attribute (defaults to visible)
Summary:
Prior to this patch DrawCommands weren't get clipped by parent DrawCommands at all. For example, a <View> element with size 200x200 with overflow:hidden should clip its child which is 400x400, but this didn't happen. However, if parent <View> would mount to an Android View, it would clip the child regardless of the overflow attribute value (because Android Views always clip whatever is drawing inside that View against its boundaries).

This diff is fixing these issue, implementing overflow attribute support and making clipping behavior consistent between nodes that mount to View and nodes that don't.

Reviewed By: ahmedre

Differential Revision: D2768643
2016-12-19 13:40:17 -08:00
Denis Koroskin f738b598d8 Properly invalidate FlatViewGroup when hotspot Drawable invalidates
Summary: I lost FlatViewGroup.verifyDrawable(Drawable) method during one of the rebases. Re-adding it now because hotspot drawable is not working without it.

Reviewed By: ahmedre

Differential Revision: D2772460
2016-12-19 13:40:17 -08:00
Denis Koroskin 98604485c4 Remove unused imports from RCTViewManager
Summary: RCTViewManager has a few extra imports that I missed. They are removed now.

Reviewed By: ahmedre

Differential Revision: D2772438
2016-12-19 13:40:17 -08:00
Denis Koroskin 79be10428b Add support for ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING to RCTView
Summary: Copied from ReactViewManager. Should provide performance improvements.

Reviewed By: ahmedre

Differential Revision: D2772832
2016-12-19 13:40:17 -08:00
Denis Koroskin 99d1c15c4d Properly implement manageChildren(), correctly handling moveFrom and moveTo
Summary: Previously, manageChildren() would throw an Exception if moveFrom != null or moveTo != null. This is obviously not correct, because no matter how rare these events are, they actually happen in practice. This diff re-implements manageChildren() to support all the cases. It does so by first removing all the elements that need to be removed. During removal, those elements that need to be moved will be temporarily put into `mNodesToMove` array. Then the next step is to add all elements (including new elements to add, and existing elements to move). There is an fast path when only one of another is present. If both types are present, they need to be sorted, first, to maintain correct orded. A similar optimization is applied to `removeChildren()`: there is a fast path when moveFrom == null and a another fast path when removeFrom == null. When both are != null, a merge sort is used (it is assumed that both moveFrom and removeFrom are sorted).

Reviewed By: ahmedre

Differential Revision: D2768689
2016-12-19 13:40:17 -08:00
Denis Koroskin 04ae4b0ba3 Dispatch OnLayoutEvent when node gets re-laid out
Summary: There is an OnLayoutEvent that needs to be dispatched when a ReactShadowNode gets re-laid out. Some applications rely on it, so we should support it. This diff adds this functionality.

Reviewed By: ahmedre

Differential Revision: D2768625
2016-12-19 13:40:17 -08:00
Denis Koroskin c144bcbc96 Implement @ReactProp nativeBackgroundAndroid in RCTView
Summary: RCTView has a property called nativeBackgroundAndroid that shows a ripple effect (or any other Drawable) when pressed and holded. This diff is adding support for the property.

Reviewed By: ahmedre

Differential Revision: D2768671
2016-12-19 13:40:17 -08:00
Denis Koroskin 381bf1b76f Implement TextNodeRegion
Summary: NodeRegion is only able to describe a rectangular region for touch, which is not good enough for text, where we want to be able to assign different touch ids to individual words (and those can span more than one line and in general have non-rectangular structure). This diff adds TextNodeRegion which inserts additional markers into text Layout to allow individual words to have unique react tags.

Reviewed By: ahmedre

Differential Revision: D2757387
2016-12-19 13:40:17 -08:00
Denis Koroskin 85cdfcd1f7 Turn FlatViewManager into ViewGroupManager
Summary: Views that can contain other Views need to have their ViewManager to extend ViewGroupManager. Otherwise, it may not remove child Views correctly when a parent View is being detached. This diff is changing FlatViewManager that create FlatViewGroups (that can have child Views) to extend from ViewGroupManager.

Reviewed By: ahmedre

Differential Revision: D2768667
2016-12-19 13:40:17 -08:00
Denis Koroskin 94052261d1 Fix RCTImageView.setBorderWidth() shadowing ShadowLayoutNode.setBorderWidths()
Summary: RCTImageView.setBorderWidth() is shadowing ShadowLayoutNode.setBorderWidths() because both are annotated with `ReactProp borderWidth`. To fix the issue, override setBorder instead (which is what LayoutShadowNode.setBorderWidths delegates to).

Reviewed By: ahmedre

Differential Revision: D2763938
2016-12-19 13:40:17 -08:00
Denis Koroskin 529390b87c Fix children of AndroidView not being re-laid out after they call requestLayout
Summary:
In ReactNative, we are fully controlling layout of all the Views, not allowing Android to layout anything for us. This is done by making onLayout() of the top-level View in the hierarchy to be empty. This works fine because we explicitly call measure/layout for all the Views when they need to be re-measured or re-laid out. There is however one case where this doesn't happen automatically: some Android Views such as DrawerLayout or ActionBar have children that don't have shadow nodes associated with them (such as a title in ActionBar). This results in situations where children of AndroidView will call requestLayout but they will never get relaid out, because shadow hierarchy doesn't know about them. Example: ActionBar has a seTitle method that will internally call TextView.setTitle() and that TextView will call requestLayout because its size may have changed. However, that TextView will never be remeasured or relaid out.

This diff is fixing it by keeping track of everyone who called requestLayout. Then, at the end of the update loop we go over the list a manually remeasure and relayout those Views.

Not a huge fan of how this is implemented (there MUST be a better way) but this works with least efforts. I'll see if I can improve it later.

Reviewed By: ahmedre

Differential Revision: D2757485
2016-12-19 13:40:16 -08:00
Denis Koroskin ad65b2a9e1 Remove referenced to dropped views
Summary:
There is currently a bug where we never release any Views that no longer display, still storing hard references in NativeViewHierarchyManager. This diff is fixing this bug, and here is how:

a) there is already logic in place to drop FlatShadowNodes (UIImplementation.removeShadowNode).
b) there is already logic in place to drop Views (NativeViewHierarchyManager.dropView(int reactTag) - used to private but needs to be protected so I can call it)
c) (the missing part) when we are about to drop a FlatShadowNode, check if it mount to a View (i.e. there is a View associated with that node), put it into a ArrayList. When we finished updates to a nodes hierarchy (which happens in non-UI thread), collect ids from those nodes and enqueue a UIOperation that will drop all the Views. We can either forward nodes as FlatShadowNode[], or only ids as int[]. Both should be fine, but as a rule of thumb we don't touch shadow node hierarchy from UI thread (as we don't touch Views from non-UI thread) so passing int[] is what this code is doing.

Reviewed By: ahmedre

Differential Revision: D2757310
2016-12-19 13:40:16 -08:00
Denis Koroskin e9753a11ae Don't collect state for virtual nodes
Summary: Virtual nodes (such as RCTRawText and RCTVirtualText) have no state or node regions, don't need to be laid out, and thus should not be checked for state.

Reviewed By: ahmedre

Differential Revision: D2757089
2016-12-19 13:40:16 -08:00
Denis Koroskin 312f04d2b7 Apply FlatShadowNode padding to View
Summary: Any padding that a FlatShadowNode is assigned by React runtime should be translated to a backing Android View so it looks correct and lays out children accordingly.

Reviewed By: sriramramani

Differential Revision: D2756562
2016-12-19 13:40:16 -08:00
Denis Koroskin dbe9cc333c Add support for custom AndroidViews
Summary: This diff adds an `AndroidView` as a proxy for custom Views in FlatUIImplementation. Any ReactShadowNode that FlatUIImplementation doesn't recognize (because they don't extend from FlatShadowNode) will be wrapped with AndroidView to ensure that it measures and displays correctly. While not perfect, this is the easiest way to support custom Views (EditTexts, DrawerLayouts, ScrollViews etc).

Reviewed By: ahmedre

Differential Revision: D2751716
2016-12-19 13:40:16 -08:00
Denis Koroskin 1da7049426 ForceMountToView when Opacity or other View-specific properties are applied to a FlatShadowNode
Summary: @public There are some properties, such as alpha or scale that we ONLY handle on a View level. This means that whenever we encounter a FlatShadowNode with this property, it should be mapped to a View. This diff is doing exactly this.

Reviewed By: ahmedre

Differential Revision: D2694495
2016-12-19 13:40:16 -08:00
Martin Kralik 0d042c2ef4 updated css-layout and fixed callsites
Summary:
This diff pulls in my changes to css-layout algorithm. (The change: https://github.com/facebook/css-layout/pull/154)
This is a breaking change, since it adds a new `height` parameter to all measure functions.

So I've fixed all existing implementations just by adding a new unused parameter `height` - it's up to owners of these functions whether they want to use it or not.

Reviewed By: foghina

Differential Revision: D2757965
2016-12-19 13:40:16 -08:00
Denis Koroskin 4fb42be0a1 Dispatch View bounds updates at the end of StateBuilder.applyUpdates()
Summary: Normally, order or `measure/layout` and `onAttachedToWindow` shouldn't matter. However, `DrawerLayout` has a `boolean mFirstLayout` flag that it resets to true in `onAttachedToWindow` that makes it ignore first layout, and it leads to bugs. To fix the issue, we need to make sure that we first call `onAttachedToWindow` and only then we call `measure/layout`. The easiest way to do it is to delay measure/layout calls until all the views are attached to their parents. This diff implements the mentioned logic.

Reviewed By: sriramramani

Differential Revision: D2694973
2016-12-19 13:40:16 -08:00
Denis Koroskin b8b4fb8a74 Apply base View properties (scale, alpha etc) to FlatShadowNode when it maps to a View
Summary: @public There are some properties that we want to handle on a View level, as opposed to a FlatShadowNode level. For example, scale or alpha, that can be done very efficiently in hardware. Once we pop FlatShadowNode to a separate View, we need to apply these properties. This is where `BaseViewManager` comes in handy.

Reviewed By: sriramramani

Differential Revision: D2694290
2016-12-19 13:40:16 -08:00
Denis Koroskin dad378e394 Add NodeRegion to allow any FlatShadowNode to respond to touch events
Summary: @public When Android dispatches `MotionEvent` to `ReactRootView`, it needs to find a correspoding react node that should receive it. To be able to do it, we need to store boundaries of every `FlatShadowNode` in `FlatViewGroup`. Then we can iterate over node boundaries and find one that contains the touch event coordinates.

Reviewed By: sriramramani

Differential Revision: D2694197
2016-12-19 13:40:16 -08:00
Denis Koroskin 8de2acd3a9 Allow FlatShadowNode mouting to its own view
Summary: @public This diff adds a `FlatShadowNode.forceMountToView()` method that will render its contents in it own `View`.

Reviewed By: sriramramani

Differential Revision: D2564502
2016-12-19 13:40:16 -08:00
Denis Koroskin 7db444c9ae Pass FlatViewGroup to DrawCommand.draw()
Summary: @public To render `View`s inside `FlatViewGroup`, we need to pass the parent to `DrawCommand.draw()` method. Used in a followup diff.

Reviewed By: sriramramani

Differential Revision: D2564478
2016-12-19 13:40:16 -08:00
Denis Koroskin f19acaed4b Implement background in FlatShadowNode
Summary: @public Similar to a `DrawBorder` patch, this diff adds `DrawBackground` and implements `ViewProps.BACKGROUND_COLOR` property in `FlatShadowNode` with it.

Reviewed By: sriramramani

Differential Revision: D2564466
2016-12-19 13:40:15 -08:00
Denis Koroskin 1c7f23c79d Implement border width, color, radius and style in RCTView
Summary: @public Initial implementation of RCTView doesn't support borders, this diff fixes it by implementing a `DrawBorder`.

Reviewed By: sriramramani

Differential Revision: D2564424
2016-12-19 13:40:15 -08:00
Denis Koroskin 71ca522c68 Support borders in RCTImageView
Summary: @public Initial RCTImageView implementation only supported 'src', 'tintColor' and 'resizeMode'. This diff adds support for the rest of the properties: 'borderColor', 'borderWidth' and 'borderRadius'. `AbstractDrawBorders` class is reused in a follow up diff to draw borders for 'RCTView'.

Reviewed By: sriramramani

Differential Revision: D2693560
2016-12-19 13:40:15 -08:00
Denis Koroskin 760422525e Add support for RCTImageView in FlatShadowHierarchyManager
Summary: @public This patch adds basic support for RCTImageView (only 'src', 'tintColor' and 'resizeMode' properties are supported for now), and a concept of AttachDetachListener that is required to support it to FlatUIImplementations.

Reviewed By: sriramramani

Differential Revision: D2564389
2016-12-19 13:40:15 -08:00
Ahmed El-Helw dfe5f9f762 Re-add Javadoc to TypefaceCache.
Summary: Accidentally removed a Javadoc in the last commit, readding it.

Differential Revision: D2750357
2016-12-19 13:40:15 -08:00
Ahmed El-Helw 1a2cf776af Support custom fonts for flat React rendering.
Summary:
Custom fonts weren't supported before, now they are when using flat
rendering in React.

Differential Revision: D2740489
2016-12-19 13:40:15 -08:00
Denis Koroskin 5b182fa0ca Extract DrawCommands tracking in StateBuilder into a helper class.
Summary: @public This is a pure refactoring diff makes `StateBuilder` code a little bit easier to read. This gets increasingly important as new features with similar logic are added to `StateBuilder`.

Reviewed By: sriramramani

Differential Revision: D2564342
2016-12-19 13:40:15 -08:00
Denis Koroskin fbe1b61fe1 Cache CustomStyleSpan in RCTVirtualText
Summary: @public `RCTVirtualText` is creating a new `CustomStyleSpan` on every `applySpans()` call, which is not very efficient. We can cache and reuse unchanged `CustomStyleSpans` for efficiency. This patch is doing just that.

Reviewed By: sriramramani

Differential Revision: D2564366
2016-12-19 13:40:15 -08:00
Denis Koroskin 007318eb52 Cache Typefaces in shadow/flat/CustomStyleSpan
Summary: @public `Typeface` handling in `shadow/flat/CustomStyleSpan` wasn't very efficient. This diff introduces `TypefaceCache` to avoid allocating duplicated `Typeface`s.

Reviewed By: sriramramani

Differential Revision: D2564363
2016-12-19 13:40:15 -08:00
Denis Koroskin 5c2f536e9a Add support for RCTText under FlatUIImplementation
Summary: @public Initial version of FlatUIImplementation lacks any primitives support (such as RCTText, RCTImageView or RCTView). This diff add the first part, RCTText (alongside with RCTVirtualText and RCTRawText).

Reviewed By: sriramramani

Differential Revision: D2693348
2016-12-19 13:40:15 -08:00
FBShipIt 44d2ee1c3f Initial commit 2016-12-19 13:40:15 -08:00
Konstantin Raev 5d4b476583 boost is downloaded from https://github.com/react-native-community/boost
Summary:
Improvement over https://github.com/facebook/react-native/pull/11469.
Depends on https://github.com/react-native-community/boost-for-react-native/issues/1, **don't merge before it is fixed**.

It would be more in line with other dependencies  to depend only on github for thirdparty bridge dependencies.

**Test plan (required)**

- Circle (testing with caches cleaned)
- ./gradlew ReactAndroid:packageReactNdkLibsForBuck (check twice to make sure caches work)
REACT_NATIVE_BOOST_PATH=./path-to-local-boost/
- ./gradlew ReactAndroid:packageReactNdkLibsForBuck (check twice to make sure caches work)
Closes https://github.com/facebook/react-native/pull/11511

Differential Revision: D4348098

fbshipit-source-id: 5c2f25cc395ae0cad19d56b7c0b2b102513580fb
2016-12-19 13:13:28 -08:00
Andrew Y. Chen 5671dc3fae Add warning for missing local image resources
Summary: Show a toast (since there isn't an easy way to show the yellow box)

Reviewed By: AaaChiuuu

Differential Revision: D4336435

fbshipit-source-id: 01b0dbdaabf51be3d23aab5c72ab2a701fcb8f80
2016-12-19 11:58:49 -08:00
Konstantin Raev 709a441ecf Disabled unit tests that need yoga libs when running
Reviewed By: hramos

Differential Revision: D4346826

fbshipit-source-id: 70855a44b27d25e49615914a845cf04fc63e322d
2016-12-19 11:43:30 -08:00
Aaron Chiu 1052d29fac create ART*ViewManager classes
Reviewed By: achen1

Differential Revision: D4050949

fbshipit-source-id: 214838c1c1cf6c66170b606ac7055e1e8790b6c9
2016-12-17 17:43:35 -08:00
Aaron Chiu c27cc9c1ac add viewManager param to @ReactModuleList
Reviewed By: achen1

Differential Revision: D4338871

fbshipit-source-id: 4ac175e0a9049d5fb08c9d01f630a3e17124e08e
2016-12-16 15:28:28 -08:00
Adam Comella 1c32385344 Android: Fix native animation crash
Summary:
An exception is thrown when the native animation code attempts to play an animation on a view that hasn't been created yet. This can happen because views are created in batches. If this particular view didn't make it into a batch yet, the view won't exist and an exception will be thrown when attempting to start an animation on it.

This change eats the exception rather than crashing. The impact is that the app may drop one or more frames of the animation.

**Notes**

I'm not familiar enough with the Android native animation code to know whether or not this is a good fix. My team is using this change in our app because dropping animation frames is better than crashing the app. [This is the code](c612c61544/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java (L874-L892)) that is creating the views in batches. Hopefully my PR at least provides some insight into the cause of the bug.

This may fix #9887
Closes https://github.com/facebook/react-native/pull/10907

Differential Revision: D4340129

Pulled By: lacker

fbshipit-source-id: 69160d9e71281a96a7445d764b4715a3e54c0357
2016-12-16 14:28:34 -08:00
Andrew 00449b2654 Little docs correction
Summary:
Comma out
Closes https://github.com/facebook/react-native/pull/11491

Differential Revision: D4339939

Pulled By: lacker

fbshipit-source-id: 4945d9804e39809a10e92f42f60434fe69552782
2016-12-16 10:13:37 -08:00
Konstantin Raev 0579efea8c Switched to npm hosted boost lib
Summary:
Boost is officially hosted on SourceForge which has ab SSL problem that Gradle complains about and also it is sometimes unavailable.
I switched to using npm hosted (yarnpkg mirrored for performance) boost lib exactly the same as from Source Forge.

Other alternatives considered:
- CDN e.g. mirror.nienbo.com started responding with 4XX code when requested by Gradle
- File sharing like DropBox are not for mass anonymous downloads
- Github is not good for binary files and is throttled for anonymous raw file downloads
- S3 or similar. Requires amazon account for maintenance and does not expose semver API and other nice features that npm has

In the future I'd like to try Yarn as dependency management tool for bridge builds, this could be the first step.

**Test plan (required)**

- Circle (testing with caches cleaned)
- `./gradlew ReactAndroid:packageReactNdkLibsForBuck` (check twice to make sure caches work)
- `REACT_NATIVE_BOOST_PATH=./bridge-dependencies/node_modules/boost-react-native-bundle ./
Closes https://github.com/facebook/react-native/pull/11469

Differential Revision: D4339446

Pulled By: mkonicek

fbshipit-source-id: ccc9196e9b675c16a235a318c4861aaa4e263d6e
2016-12-16 06:43:33 -08:00
Emil Sjolander 45fdcdc93a YGNodeChildCount -> YGNodeGetChildCount for consistency
Reviewed By: gkassabli

Differential Revision: D4333480

fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad
2016-12-16 04:44:18 -08:00
Adam Comella c0ea23cfb0 Android: Expose textBreakStrategy on Text and TextInput
Summary:
Android has a text API called breakStrategy for controlling how paragraphs are broken up into lines. For example, some modes support automatically hyphenating words so a word can be split across lines while others do not.

One source of complexity is that Android provides different defaults for `breakStrategy` for `TextView` vs `EditText`. `TextView`'s default is `BREAK_STRATEGY_HIGH_QUALITY` while `EditText`'s default is `BREAK_STRATEGY_SIMPLE`.

In addition to exposing `textBreakStrategy`, this change also fixes a couple of rendering glitches with `Text` and `TextInput`. `TextView` and `EditText` have different default values for `breakStrategy` and `hyphenationFrequency` than `StaticLayout`. Consequently, we were using different parameters for measuring and rendering. Whenever measuring and rendering parameters are inconsistent, it can result in visual glitches such as the text taking up too much space or being clipped.

This change fixes these inconsistencies by setting `breakStrategy` and `hyphenat
Closes https://github.com/facebook/react-native/pull/11007

Differential Revision: D4227495

Pulled By: lacker

fbshipit-source-id: c2d96bd0ddc7bd315fda016fb4f1b5108a2e35cf
2016-12-16 01:28:45 -08:00
Steven Goff 4394419b60 Android Text component allowFontScaling
Summary:
The reason for this change is to implement `allowFontScaling` on the Android's React Native Text component.  Prior to this PR `allowFontScaling` only works for iOS.

The following link contains images of `allowFontScaling` working in Android on small, normal, large, and huge system fonts (from native Android display settings)

http://imgur.com/a/94bF1

The following link is a video of the same thing working on an Android emulator

https://youtu.be/1jTlZhPdj9Y

Here is the sample code snippet driving the video/images
```
render() {
    const size = [12, 14, 16, 18];
    return (
      <View style={{backgroundColor: 'white', flex: 1}}>
        <Text>
          Default size no allowFontScaling prop (default true)
        </Text>
        <Text allowFontScaling={true}>
          Default size allowFontScaling: true
        </Text>
        <Text style={{ marginBottom: 10, }} allowFontScaling={false}>
          Default size allowFontScaling: false
        </Text>

        { size.map(
Closes https://github.com/facebook/react-native/pull/10898

Differential Revision: D4335190

Pulled By: lacker

fbshipit-source-id: 0480809c44983644ff2abfcaf4887569b2bfede5
2016-12-15 17:43:35 -08:00
Delyan Kratunov 1f78ea326e Remove unnecessary project_config
Differential Revision: D4326949

fbshipit-source-id: d0e8d7c3a046a89e5794be602a406ea914de50d1
2016-12-15 09:29:16 -08:00
John Shelley f3c8158773 Android - ReactNativeHost getUseDeveloperSupport to public
Summary:
Currently React Native is opinionated in that the easiest approach is to extend ReactActivity. However to more easily allow integrating with existing application, we should allow some of the methods in ReactNativeHost to be public, and this is a very good first step.
* There is no harm in making this public from what I can tell.
* This allows `ReactNativeHost` to be more easily used outside of the `ReactActivity` and `ReactActivityDelegate` ecosystem. (A `ReactFragment` would be a good example)

_No issues found_

**Test plan (required)**

* Run any sample app and verify it still works.

Make sure tests pass on both Travis and Circle CI.
Closes https://github.com/facebook/react-native/pull/11329

Differential Revision: D4287429

Pulled By: AaaChiuuu

fbshipit-source-id: 8cb76f3226aae3737af5f5bd6010d3eea8df9bfe
2016-12-15 04:13:37 -08:00
Üstün Ergenoglu 3785db2fb1 Add property to force HW acceleration on Android for modal windows
Summary:
When using React Native on Android on top of a game as an overlay, dialog windows sometimes get created with hardware acceleration disabled. This causes the UI to be unresponsive and anything that uses a TextureView stops working. Added a property for the modal view to make sure hardware acceleration flag is enabled when it's set to true.

**Test plan (required)**

set `hardwareAccelerated` property for Modal to force hardware acceleration on dialog windows on Android. Does nothing on iOS.
Closes https://github.com/facebook/react-native/pull/11421

Differential Revision: D4312912

Pulled By: andreicoman11

fbshipit-source-id: 9db6b2eca361421b92b24234b3501b5de0eecea7
2016-12-14 10:28:33 -08:00
Kirwan Lyster 14dfb525a2 Use ScaleType.getTransform() instead of util method
Summary: This changes ReactImageView to pull the transform matrix for rounding from the scale type itself instead of a utility method that forwards to the same thing.

Reviewed By: lambdapioneer

Differential Revision: D4326549

fbshipit-source-id: 82e59e3c20f83beb1d454743e6dbbce8666de8a3
2016-12-14 07:43:32 -08:00
Kevin Lacker affd5ac681 Improve Android testing scripts
Summary:
The goal of this pull request is to make it easier for contributors to run Android tests locally, specifically the unit tests and integration tests. I added a bunch of checks to the local testing scripts that will warn you if your environment is misconfigured, and tell you how to fix it. I also updated the testing docs, so that the regular "Testing" page should be a decent resource to point people to when you are telling them "hey this pull request needs a test." Just Android, though, I haven't gotten to the iOS parts yet.

I also disabled a couple tests that seemed quite flaky while running on a local machine, and don't seem to be providing much value. In particular, the `TestId` test just hangs on my emulator a lot and has been flaky on CI in the past, so I removed about half of its test cases to make the sample app smaller. The testMetions test appears to be dependent on screen size so I commented it out.
Closes https://github.com/facebook/react-native/pull/11442

Differential Revision: D4323569

Pulled By: bestander

fbshipit-source-id: 9c869f3915d5c7cee438615f37986b07ab251f8c
2016-12-13 17:13:35 -08:00
Aaron Chiu a76547f7ac force crash if a Java Module isn't lazifi-able in a Lazified app
Reviewed By: achen1

Differential Revision: D4317878

fbshipit-source-id: 61ee4b24f0de206f53d6f4b3801d81aa6f3ab36c
2016-12-13 03:58:32 -08:00
Lukas Piatkowski de82931931 Fix SamplingProfiler and HeapCapture for apps that lazy load react modules
Reviewed By: cwdick

Differential Revision: D4291903

fbshipit-source-id: 684ced8d6370494191cdb182a8e172680d69d17b
2016-12-07 10:43:48 -08:00
Don Yu bfe551d2d1 Implement onViewAppear by creating a new EventListener on ReactRootView listening for when it's attached to a RN Instance
Reviewed By: AaaChiuuu

Differential Revision: D4269272

fbshipit-source-id: 6dd54f8ab7befebd54e82ef355119ba302b9bfe5
2016-12-07 09:58:33 -08:00
Emil Sjolander 7f8c2985a8 Rename directories
Reviewed By: gkassabli

Differential Revision: D4284681

fbshipit-source-id: f0c6855c2c6e4389b7867f48f72cbb697830fc5a
2016-12-07 05:14:12 -08:00
John Shelley d21aa92480 Android - Fix Overlay for Marshmallow 23+
Summary:
Currently any React Native apps that target API 23 or greater will crash on the first initial debug/dev build due to the overlay permission.

Sadly there isn't a concrete "request permission" baked into the Marshmallow permission system.
However, we can launch the overlay screen without starting the react app and once its turned on start the app.

 - https://github.com/facebook/react-native/issues/10454 - targetSdkVersion 23 lead crash / App crash for targeting 23+
 - https://github.com/facebook/react-native/pull/10479 - Add the overlay permission information / Larger discussion around targeting API 23+
- Intent to Overlay permission goes directly to the app in question, rather then the general full listing of applications. This allows a developer who is not familiar with the system to easily toggle the overlay without getting confused.

**Test plan (required)**
* Ran UIExplorer App on fresh install with Target 23
```
cd react-native
./gradlew :Examples:UI
Closes https://github.com/facebook/react-native/pull/11316

Differential Revision: D4286351

fbshipit-source-id: 024e97c08c40ee23646dd153794fcde7127b2308
2016-12-06 12:43:36 -08:00
Emil Sjolander 86e0f39863 Fix last missing reference to libcsslayout
Reviewed By: bestander

Differential Revision: D4279530

fbshipit-source-id: 809a6317f02bc2a770f50c8cb048aa3e2dfcf33f
2016-12-05 15:13:28 -08:00
Martin Konicek 70f07b1e4e Revert to downloading Boost from SourceForge for now
Summary: The unpkg mirror started returning HTTP 403 Forbidden for some reason.

Reviewed By: mkonicek

Differential Revision:
D4278637
Ninja: OSS only, tests already broken

fbshipit-source-id: 7dbfce40e8246f2a021ebe2592d24fa86c12bf21
2016-12-05 11:58:34 -08:00
Emil Sjolander 097d3173e9 Fix library name of yogacore
Reviewed By: bestander

Differential Revision: D4276884

fbshipit-source-id: c791aa3bb27fcf4b48d84427011eae6119fe6edf
2016-12-05 07:43:29 -08:00
Emil Sjolander b8708edf0f Update java package name to yoga
Differential Revision: D4271420

fbshipit-source-id: b3cf150569a2331868410339cd19e5c694f2059e
2016-12-05 02:58:32 -08:00
David Aurelio f9f32eb426 Load Indexed RAM format on android
Reviewed By: javache

Differential Revision: D4268243

fbshipit-source-id: fc969cfc69810d0477c926ffc79c23584fcbd7eb
2016-12-04 16:13:30 -08:00
Emil Sjolander fd2fb6cd65 Update yoga library name
Reviewed By: bestander

Differential Revision: D4273387

fbshipit-source-id: 91373c6ef1e94b330fa249235ba97fec480e17c7
2016-12-04 05:28:29 -08:00
Emil Sjolander b9cedaefa6 Rename java API
Reviewed By: IanChilds

Differential Revision: D4265345

fbshipit-source-id: 69ecfd8fac214f86b8b70647b9b909acd83d78b5
2016-12-03 04:44:10 -08:00
Emil Sjolander 85ac5fc354 Rename C api
Differential Revision: D4259190

fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
2016-12-03 04:44:10 -08:00
Ben Clayton 833961e05d <Text> Expose Android's includeFontPadding property to JavaScript.
Summary:
By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.

We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Android exposes a property `includeFontPadding` that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer.
Closes https://github.com/facebook/react-native/pull/9323

Differential Revision: D4266713

Pulled By: lacker

fbshipit-source-id: f9711254bc26c09b4586a865f0e95ef4bf77cf3f
2016-12-02 12:58:36 -08:00
Emil Sjolander 779508c0ba Rename enums
Differential Revision: D4244360

fbshipit-source-id: c9fcbdd231098c9ff230a6055676bbc7cbd11001
2016-12-02 05:58:45 -08:00
Emil Sjolander 476973e789 Remove force_static
Reviewed By: gkassabli

Differential Revision: D4258293

fbshipit-source-id: 053f9e607503707830e3766b1f268ab31d3081ff
2016-12-02 05:13:32 -08:00
Emil Sjolander bed9087191 Revert D4248487: [yoga] Remove force_static
Differential Revision: D4248487

fbshipit-source-id: c826eb6543ff6b8d512bf688fbd395e9766df2fb
2016-11-30 12:28:32 -08:00
Yann Pringault fb230000a8 Call handleUpdateLayout even if the content didn't change
Summary:
This PR fixes #11096.

I don't know enough the ReactAndroid's source code so I don't know if this is correct but I hope it is.

In a recent commit (d4b8ae7a8a), the `dispatchUpdates` method now returns a boolean to dispatch or not the `onLayout` event. This works well but if the content is unchanged, the line `nativeViewHierarchyOptimizer.handleUpdateLayout(this);` is never called. I don't know if it was intended but it was this which introduces my issue. I called this again even if the content didn't change. This was the behaviour before 0.38 so I guess I didn't break anything.

**Test plan (required)**

I tested my pretty big app with this fix and every screen is ok.
Closes https://github.com/facebook/react-native/pull/11222

Differential Revision: D4252101

Pulled By: astreet

fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
2016-11-30 11:43:34 -08:00
Emil Sjolander 4902a03380 Fix usage of weak references to check for null
Reviewed By: lexs

Differential Revision: D4251133

fbshipit-source-id: 2d8949252b31447ce54bc16a35cb25fabe72230b
2016-11-30 10:13:36 -08:00
Emil Sjolander 89a380abc8 Remove force_static
Reviewed By: gkassabli

Differential Revision: D4248487

fbshipit-source-id: e5127a02561b145745cf5393a0188661469ec79b
2016-11-30 08:28:33 -08:00
Adam Comella 911c05a89b Android: Decrease cost of reflection
Summary:
This change suppresses access checking during reflection which makes reflection faster by decreasing its overhead.

**Test plan (required)**

My team uses this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11204

Differential Revision: D4250790

Pulled By: astreet

fbshipit-source-id: 0ee2f40dcadccc695980fcae14fafe1050acb52f
2016-11-30 03:58:29 -08:00
Adam Comella 528a3c776a Android: Keep ScrollView content visible after edits
Summary:
Suppose that the user is scrolled to the bottom of a ScrollView. Next, the ScrollView's content is edited such that the height of the content changes and the current scroll position is larger than the new height of the content. Consequently, the user sees a blank ScrollView. As soon as the user interacts with the ScrollView, the ScrollView will jump to its max scroll position.

This change improves this scenario by ensuring that the user is never staring at a blank ScrollView when the ScrollView has content in it. It does this by moving the ScrollView to its max scroll position when the scroll position after an edit is larger than the max scroll position of the ScrollView.

Here are some pictures to illustrate how this PR improves the scenario described above:

![image](https://cloud.githubusercontent.com/assets/199935/20408839/0e731774-accc-11e6-9f0a-3d77198645e9.png)

![image](https://cloud.githubusercontent.com/assets/199935/20408844/12877bb6-accc-11e6-8fe2-1c1bb26569cc.png)

**Test plan (require
Closes https://github.com/facebook/react-native/pull/11000

Differential Revision: D4250792

Pulled By: astreet

fbshipit-source-id: 940fff6282ad29c796726f68b4519cbdabbfe554
2016-11-30 03:58:29 -08:00
Adam Comella aac8daf378 Android: Enable ad-hoc dependencies to be pre-downloaded
Summary:
ReactAndroid/build.gradle downloads a number of ad-hoc dependencies from the internet such as boost, JSC headers, and folly. Having the build depend on the internet is problematic. For example, if the site hosting the JSC headers was to go down, then CI builds would start failing.

This change introduces the environment variable REACT_NATIVE_DEPENDENCIES which refers to a path. Developers can pre-download all of the ad-hoc dependencies into that path and then the build process will grab the dependencies from that local path rather than trying to download them from the internet. This solution is in the spirit of the existing REACT_NATIVE_BOOST_PATH hook.

**Test plan (required)**

This change is used by my team's app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11195

Differential Revision: D4247080

Pulled By: mkonicek

fbshipit-source-id: 7c4350339c8d509a829e258d8f1bf320ff8eef64
2016-11-29 14:28:34 -08:00
Emil Sjolander b58c8ad916 Remove deprecated java code
Reviewed By: AaaChiuuu

Differential Revision: D4233198

fbshipit-source-id: 736d79be266e1b9f2d62e5fe6d901de47123cdc1
2016-11-29 12:28:55 -08:00
Emil Sjolander 065af66deb Remove Style prefix in java and cs apis
Reviewed By: splhack

Differential Revision: D4232920

fbshipit-source-id: 6e2ff21bbb7e0e441892023c14df579d1bc7aa49
2016-11-29 09:13:28 -08:00
Emil Sjolander f1a5233fd2 Always use soloader. Catching exception and re-trying hides errors
Reviewed By: lexs

Differential Revision: D4243906

fbshipit-source-id: e4d691c9c49f3b9316f67e39b9f277657d78fb3c
2016-11-29 04:43:30 -08:00
Venryx c4046d62a7 * Reduce emit overhead to ~50% of prior, by caching class-name of java-script module/interface.
Summary:
Made modification to react-native code that reduces the communication channel overhead to ~50% of prior, in some cases, by caching the class-name of the java-script module/interface.

For me it reduced the run-time of the RCTDeviceEventEmitter.emit function from 1438ms to 715ms, over a period of 8 seconds in my Android app. My project requires many emit calls, as I'm transferring real-time EEG data from a Muse headband to my react-native UI to be graphed, so this optimization was very helpful in my case.
Closes https://github.com/facebook/react-native/pull/11118

Reviewed By: astreet

Differential Revision: D4232794

Pulled By: javache

fbshipit-source-id: 25ca1cfc170a343e71ff8915c3fa7e38884a402b
2016-11-29 02:58:34 -08:00
Ryan Gomba 97887c2a52 Remove unused var in NativeAnimatedNodesManager
Summary:
Should have been removed in 6f5433febe (commitcomment-19793695).

Simple enough fix.

cc/ janicduplessis
Closes https://github.com/facebook/react-native/pull/11178

Differential Revision: D4239876

fbshipit-source-id: f96e220ffdab042bded27ff16d2395741c70b61f
2016-11-28 14:13:33 -08:00
Emil Sjolander 28275836c9 Dont strip class names referenced from native
Reviewed By: lexs

Differential Revision: D4237790

fbshipit-source-id: 1bd0780d965efbb8334917011ffd65896670ece1
2016-11-28 09:28:28 -08:00
Adam Comella 8b199a7fd0 Android: Enable apps to provide a custom configuration to Fresco
Summary:
The `FrescoModule` supports providing a custom image pipeline configuration. This module is created by `MainReactPackage` but `MainReactPackage` doesn't expose any way to customize the Fresco configuration. This change adds a parameter to `MainReactPackage`'s constructor so that the `FrescoModule`'s configuration can be customized by the app. A couple of design choices were made in this change:
  - `MainReactPackage`'s new constructor parameter is a `MainPackageConfig`. Introducing `MainPackageConfig` enables `MainReactPackage` to nicely support new optional configuration options in the future. Imagine the alternative of each optional configuration being a separate parameter to the `MainReactPackage` constructor.
  - `FrescoModule` exposes its default configuration as a builder object through the `getDefaultConfigBuilder` method. This enables app's to start with `FrescoModule`'s default configuration and then modify it.

**Test plan (required)**

Verified that passing a custom config based on React Nati
Closes https://github.com/facebook/react-native/pull/10906

Differential Revision: D4237054

Pulled By: mkonicek

fbshipit-source-id: 8a62a6f0e77ca5f6d35238950094686756262196
2016-11-28 03:43:32 -08:00
Vishal Kakadiya fea1428d99 Imported "com.facebook.react.ReactPackage" twice
Summary:
"com.facebook.react.ReactPackage" is imported twice so fixed it to once.
Closes https://github.com/facebook/react-native/pull/11165

Differential Revision: D4236961

Pulled By: mkonicek

fbshipit-source-id: 84765dd9f8731b978972959f3825bf3c9c0684e3
2016-11-28 02:58:23 -08:00
Janic Duplessis 552c601921 Don't dismiss keyboard when tapping another text input
Summary:
When using text inputs inside a ScrollView with `keyboardShouldPersistTaps=false` (default behavior) tapping another text input dismisses the keyboard instead of keeping it open and focusing the new text input which I think is the better and expected behavior.

See #10628 for more discussion about that. Note that this affects nothing but the behavior with text inputs unlike #10628.

cc satya164 MaxLap ericvicenti
Closes https://github.com/facebook/react-native/pull/10887

Differential Revision: D4178474

Pulled By: ericvicenti

fbshipit-source-id: 0c62ea2fac0017d559d1f8674b0a686a5e1b3d2d
2016-11-25 05:43:30 -08:00
Connor McEwen 51efaab120 Handle "Never Ask Again" in permissions and add requestMultiplePermissions
Summary:
In order to get featured in the Google Play Store, we had to handle a few specific cases with permissions based on feedback from the editorial team.

First, which was previously possible with this permissions module was bumping the sdk to version 23.

The second is requesting multiple permissions at one time. In order for the camera + upload to work, we needed to request both camera permissions + media storage in one flow.

The last is handling the case where the user checks the "Never Ask Again" box. This will only appear after a user denies a permission once and is then prompted again. The logic for handling this case is taken from here: http://stackoverflow.com/questions/31928868/how-do-we-distinguish-never-asked-from-stop-asking-in-android-ms-runtime-permis/35495372#35495372

We were also seeing a few crashes similar to #10009 due to `onRequestPermissionsResult` being called before `onResume` (http://stackoverflow.com/questions/35205643/why-is-onresume-called-after-onrequestpermissionsresult), so I delaye
Closes https://github.com/facebook/react-native/pull/10221

Differential Revision: D4232551

fbshipit-source-id: fee698d1c48a2d86623cb87996f3d17f4c10a62e
2016-11-24 22:43:28 -08:00
Benoit Lemaire 6fef014295 Remove Jackson dependency
Summary:
This PR removes dependency to Jackson third-party library in Android React Native.

Looking at some older PRs that got merged, it seems like some work had already been done to move away from Jackson.

Anyway, there was only two classes left with a dependency on Jackson. I refactored the code to use android built-in `JsonReader` and `JsonWriter` classes instead.

Prep work was done in https://github.com/facebook/react-native/pull/10516 introducing a few unit tests around serialization, to make sure that refactoring around serialization would not break things.

All references to Jackson in build systems files (BUCK files & build.gradle) have also been removed now that no code depend anymore on this third-party library.

Motivation behind this work is that third-party dependencies in Android React Native can prove to be a pain when trying to integrate React Native components into an already existing large Android application (I know this is not the most common use case for react-native ... yet ;P), that might a
Closes https://github.com/facebook/react-native/pull/10521

Differential Revision: D4226705

Pulled By: mkonicek

fbshipit-source-id: e3a7430a79dd00c871ba3c6a705b0b0c3ec3a701
2016-11-23 08:59:50 -08:00
Emil Sjolander 5850165795 Add support for aspectRatio style prop
Summary:
Expose aspectRatio style prop from css-layout to React Native.

This means the following will now work:

    <View style={{backgroundColor: 'blue', aspectRatio: 1}}/>

Reviewed By: javache

Differential Revision: D4226472

fbshipit-source-id: c8709a7c0abbf77089a4e867879b42dcd9116f65
2016-11-23 07:43:28 -08:00
Martin Konicek 1488725db3 Use a CDN to download Boost
Summary:
Downloading from the CDN is much faster than from SourceForge, both on my home WiFi and at the office.

I checked using the `diff` utility that both files are identical.

**Test Plan**

Circle CI build on this PR.
Closes https://github.com/facebook/react-native/pull/11087

Differential Revision: D4226538

fbshipit-source-id: a30ec1d94fe3228342c4a198bf65df7a95e0c005
2016-11-23 06:58:27 -08:00
Adam Comella 1b870d2019 Android: Add disableExtractUI prop to TextInput on Android
Summary:
On Android, if there is a small amount of space available around a text input (e.g. landscape orientation on a phone), Android may choose to have the user edit the text inside of a full screen text input mode. This behavior isn't always desirable. For example, if your app offers some UI controls for controlling the formatting of the text, you want the controls to be visible while the user is editing the text. This Android feature conflicts with that desired experience because the UI controls would be hidden while the text is being edited.

The `disableExtractUI` prop enables developers to choose whether or not Android's full screen text input editing mode is enabled. When this prop is true, Android's `IME_FLAG_NO_EXTRACT_UI` flag is passed to the `setImeOptions` method.

**Test plan (required)**

Verified `disableExtractUI` works for both `true` and `false` values in a test app.

My team is also using this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/10900

Differential Revision: D4226483

Pulled By: mkonicek

fbshipit-source-id: 8f1055f6e612b05bafabe6f07a3705dd8788e3da
2016-11-23 06:43:50 -08:00
Janic Duplessis b49e7afe47 Dispatch native handled events to JS
Summary:
When native events where handled they were not sent to JS as an optimization but this caused some issues. One of the major one is touches are not handled properly inside a ScrollView with an Animated.event because it doesn't receive scroll events so it can't cancel the touch if the user scrolled.
Closes https://github.com/facebook/react-native/pull/10981

Differential Revision: D4226403

Pulled By: astreet

fbshipit-source-id: 41278d3ed4b684af142d9e273b11b974eb679879
2016-11-23 05:43:35 -08:00
Emil Sjolander dad520476e Fixup recent fix to flex basis and put it behind an experimental flag
Reviewed By: gkassabli

Differential Revision: D4222910

fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
2016-11-23 05:28:48 -08:00
Andy Street 68c6d71cea BREAKING [react_native] Don't create CSSNodes for virtual shadow nodes
Summary:
Virtual shadow nodes (e.g. text) don't use CSSNodes so we don't need to create them. This shows large savings in CSSNodes allocated, depending on the app.

This could be breaking if:
- You have virtual nodes that still set and get CSS properties. The setters now no-op for virtual nodes (I unfortunately couldn't remove them completely -- see the comment on LayoutShadowNode), but the getters will NPE. If you see these NPE's, you should almost definitely be using your own datastructure instead of a CSSNode as virtual nodes will not participate in the layout process (and the CSSNode is then behaving just as a POJO for you).

I do not anticipate this to be breaking for anyone, but am including breaking in the commit message since this is a change in API contract.

Reviewed By: emilsjolander

Differential Revision: D4220204

fbshipit-source-id: b8dc083fff420eb94180f669dd49389136111ecb
2016-11-23 05:13:28 -08:00
Pandiarajan Nagarajan eaccd7e82e Android datepicker mode configurations added
Summary:
Currently, The **DatePickerAndroid** component opens the native date picker with default mode. We can't able to change the mode via configurations. To support android **[date-picker mode](https://developer.android.com/reference/android/widget/DatePicker.html)**, existing component needs to be changed.

**For Android >= 5.0**, The DatePickerDialog doesn't provide the default method to change the mode of a date picker.  So I have added custom theme which will support two kinds of **mode('spinner','calendar')** ref:https://developer.android.com/reference/android/R.attr.html#datePickerStyle.

**For Android < 5.0,** The DatePickerDialog provides the default method to change the mode of a date picker. ref:https://developer.android.com/reference/android/widget/DatePicker.html#setCalendarViewShown(boolean).

With the help of **Build.VERSION.SDK_INT** I have done the above functionality with limited lines of code changes and also I have added the example to UIExplorer.

Closes https://github.com/facebook/react-native/pull/10932

Differential Revision: D4176089

Pulled By: ericvicenti

fbshipit-source-id: 7dfa9101214501ac2124bda7ee273a538f04e7cf
2016-11-23 04:58:31 -08:00
Adam Comella 35e75c8cdf Android: Fix WebView crash for links of unknown schemes
Summary:
When tapping on a link in a WebView with an unknown scheme, the app would crash. For example, if you have the link "something://example/" but your device doesn't have anything to handle the "something" scheme, the app would crash when the user clicks on the link. This change handles the exception to prevent the app from crashing. Instead, the click is a no-op and the WebView doesn't navigate anywhere.

**Test plan (required)**

Verified the app no longer crashes when clicking on unknown schemes in a test app. Also, my team uses this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/10903

Differential Revision: D4226371

Pulled By: mkonicek

fbshipit-source-id: a6d3957806c6063e74fe055b0979cb9d1ce40e51
2016-11-23 04:43:26 -08:00
Adam Comella ea913e4691 Android: Update coalesce to prefer newest event
Summary:
The only callsite of `coalesce` looks like this:

```
newEvent.coalesce(oldEvent);
```

The default `coalesce` implementation returns the event with the most recent timestamp. When the events have the same timestamp then, using the variable names from above, `coalesce` returns `oldEvent`.

This change updates `coalesce`'s implementation to make it explicit that it returns `this` (`newEvent` in the variable names from above) in the case of a tie.

The motivation for this change is related to scroll events. In my team's app, we were seeing scroll events being emitted with the same timestamp and the coalescing logic was causing the oldest scroll event to be chosen. This was causing our JavaScript code to receive stale scroll information and the way the JavaScript code utilized this stale scroll information resulted in the ScrollView settling on the wrong scroll position.

**Test plan (required)**

Verified that scroll events work properly in a ScrollView in a test app. Also, my team's app uses this
Closes https://github.com/facebook/react-native/pull/11080

Differential Revision: D4226152

Pulled By: andreicoman11

fbshipit-source-id: d28a2569225ca95de662f2239a0fa14de0540a7d
2016-11-23 02:13:30 -08:00
Adam Comella aa85408f56 Android: Fix inconsistency with fractional TextInput padding
Summary:
TextInput rounds padding down with `floor` when measuring. However, it rounds padding up with `ceil` when rendering.

This change makes things consistent by moving TextInput's rendering code to use `floor` as well. It looks like this is the intended behavior because commit bdff10b moved measuring from `ceil` to `floor`. It looks like TextInput's rendering code was just overlooked in that commit.

**Test plan (required)**

Verified TextInput padding works in a test app. Also, my team uses this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11003

Differential Revision: D4220855

Pulled By: mkonicek

fbshipit-source-id: 95349867ef89c021a8441b383a09052ca0dd569c
2016-11-22 10:58:24 -08:00
Lukas Woehrl 1c69b61c26 Added feature to use rounded values
Summary:
Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely  can be further improved. I'm looking forward to your ideas.
Closes https://github.com/facebook/css-layout/pull/256

Reviewed By: splhack

Differential Revision: D4214168

Pulled By: emilsjolander

fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236
2016-11-22 05:43:26 -08:00
Michał Gregorczyk 2ca507bf9e Remove supported platforms from JSC and all the things that depends on it
Reviewed By: bnham

Differential Revision: D4213580

fbshipit-source-id: 3830c15b0097030a4e4611aac814b12e1d6ae696
2016-11-21 16:43:31 -08:00
Michał Gregorczyk b1bdae99c0 Use jni int types rather than uint64/32/16_t in JSCPerfLogging.cpp
Reviewed By: bnham

Differential Revision: D4213497

fbshipit-source-id: 47e0e7d72891e1070c350a60fb7d3597e99d49a1
2016-11-21 16:43:31 -08:00
Emil Sjolander e1df3c8782 Add aspectRatio style property
Reviewed By: gkassabli

Differential Revision: D4211458

fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d
2016-11-21 10:13:34 -08:00
Andy Street 48bb3648c5 Drop CSSNode pool on low memory when app is backgrounded
Summary:
Depends on D4189532

Drops the CSSNodePool when memory gets low.

Reviewed By: emilsjolander

Differential Revision: D4190264

fbshipit-source-id: 94cd36d877372e0d6ebdd989661af74bde41486d
2016-11-21 09:13:37 -08:00
Andy Street bd8745b1fd Recycle CSSNodes
Summary: Adds a pool to recycle CSSNodes within UIManager. A follow-up diff will hook this up to a memory pressure listener to drop the pool on memory pressure.

Reviewed By: emilsjolander

Differential Revision: D4189532

fbshipit-source-id: 46583546f71a8c59853e1dd124de31657b3c617b
2016-11-21 09:13:37 -08:00
Andy Street d63ba47b59 BREAKING [react_native] Move to new C-based implementation of css-layout in RN Android
Summary:
Moves from CSSNodeDEPRECATED to CSSNode. This has shown to be a huge performance win for layout time within FB.

This is BREAKING because CSSNode contains bug fixes that were not migrated to CSSNodeDEPRECATED which may change the way your layout appears. The most common of these by far involves `flex: 1`.

Previously, developers had to put `flex: 1` in many places it didn't belong in order to work around a bug in css-layout. Now `flex: 1` is treated properly and, unfortunately, this means that your layout may no longer look correct. Specifically, you may see that your layout looks collapsed, or children don't render. The fix is to simply remove `flex: 1` from those containers.

Reviewed By: emilsjolander

Differential Revision: D3992787

fbshipit-source-id: 7a3a2a34a8941c0524e6ba3c5379e434d3e03247
2016-11-21 06:28:30 -08:00
Emil Sjolander 15f848e8d8 Only skip updating computed flex basis within the same generation
Reviewed By: dshahidehpour

Differential Revision: D4207106

fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d
2016-11-20 05:13:28 -08:00
Pieter De Baets 892231545b Remove duplicate definition of nativeLoggingHook
Reviewed By: lexs

Differential Revision: D4160267

fbshipit-source-id: 8e23ea355095f1f94610068010b7cdf385d69e40
2016-11-18 06:28:48 -08:00
leeight 1604f10889 Cleanup import *
Summary:
Cleanup import * from some java files.

**Test plan (required)**

manually run `./scripts/run-android-local-unit-tests.sh`
Closes https://github.com/facebook/react-native/pull/11009

Differential Revision: D4204415

Pulled By: javache

fbshipit-source-id: 52579c05f44471988671e7dcdcf6109203e20929
2016-11-18 05:58:25 -08:00
Kazuki Sakamoto 2af1de283c CSSNodeCopyStyle API for Java and C#
Reviewed By: emilsjolander

Differential Revision: D4189954

fbshipit-source-id: 10759fdb27bf67350d3151614f7815aa09bf7e04
2016-11-17 09:13:32 -08:00
Michał Gregorczyk 32670371e4 Evacuate unpacking logic from RN
Reviewed By: amnn

Differential Revision: D4186902

fbshipit-source-id: 02d8fe176940a678dc8f8d9c0bcf43732f45bde5
2016-11-17 03:13:44 -08:00
Emil Sjolander a07abe7188 Correctly translate nowrap -> NO_WRAP
Summary: The java enum was recently changed from NOWRAP -> NO_WRAP so the translation from js failed. This fixes that.

Reviewed By: limichaelc

Differential Revision: D4186869

fbshipit-source-id: fe35211a6632d80356d35a01a079279ef4bd7006
2016-11-15 18:58:37 -08:00
Andrew Jack c2a55baf80 Prevent hitslop crash on Android
Summary:
**Motivation**
Currently to use the `hitSlop` property on Android you must define the object properties `left`, `top`, `right`, and `bottom` or it will crash. iOS allows omitting object properties from the hitSlop.

This change guards and allows the `hitSlop` object properties to be optional like iOS.

**Test plan (required)**

Run the [example](f930270b00/Examples/UIExplorer/js/TouchableExample.js (L318)) and omit a hitslop property and check it does not crash.
Closes https://github.com/facebook/react-native/pull/10952

Differential Revision: D4182815

Pulled By: ericvicenti

fbshipit-source-id: 07d7aca67b5739d5d1939b257476c24dcb10cbb0
2016-11-15 09:29:06 -08:00
Alexander Blom f571d28e68 Allow launching inspector from dev menu
Reviewed By: davidaurelio

Differential Revision: D4095356

fbshipit-source-id: 46e43578cdcd663316efb82dffde27b77294c5c0
2016-11-15 08:59:02 -08:00
Alexander Blom 18184a83f1 Make Android connect to the inspector proxy
Summary: Maintains a single persistent connection to the packager for the inspector. It supports getting the available pages and connecting to them.

Reviewed By: foghina

Differential Revision: D4088690

fbshipit-source-id: 0c445225f5a3de573b199e7868c8693b78f45729
2016-11-15 08:59:02 -08:00
Andy Street c94a71e5bd Sort BUCK deps in open source
Reviewed By: emilsjolander

Differential Revision: D4182733

fbshipit-source-id: 245982d8155a5c3676befc2b0f2056f43f648dbc
2016-11-15 08:59:01 -08:00
Emil Sjolander ffcdf25281 Autogenerate enum defenitions for all languages
Reviewed By: gkassabli

Differential Revision: D4174263

fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10
2016-11-15 08:44:30 -08:00
Andy Street c04ab92192 Use -O3 to compile CSSLayout in open source
Summary: This is how we compile internally

Reviewed By: emilsjolander

Differential Revision: D4182691

fbshipit-source-id: 314b1a1ead7d299677ce7f71549c986e1b796b3b
2016-11-15 08:28:56 -08:00
Andy Street 3b20a39f7b Move ReactCommon/CSSLayout to ReactCommon/CSSLayout/CSSLayout
Reviewed By: emilsjolander

Differential Revision: D4182345

fbshipit-source-id: 05cb4f0b0e7971d4f66e656ea89d876264a61bd4
2016-11-15 06:28:45 -08:00
Andy Street 7cf27cfea6 Add jni-hack to RN OSS
Summary: See committed README.md. This is part of the migration to the jni implementation of CSSLayout.

Reviewed By: emilsjolander

Differential Revision: D4177009

fbshipit-source-id: f1860f5d4ffafa1375a9658227e0ac10b7df4845
2016-11-15 05:13:37 -08:00
Adam Comella e87e181998 Android: Expose Image's onError event to JavaScript
Summary:
iOS supports an Image onError event. Android was firing the event but it was never reaching JavaScript because Android didn't include this event in `getExportedCustomDirectEventTypeConstants`.

**Test plan (required)**

Verified that the `onError` event now fires in a test app.

My team uses this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/10902

Differential Revision: D4180149

Pulled By: ericvicenti

fbshipit-source-id: 4bf0b9aa7dc221d838d7b6b3e88bb47196dcadef
2016-11-14 19:43:58 -08:00
Pete Huitsing 191db90345 Prevent null header value from raising exception
Summary:
In the wild, our app will occasionally crash with:
```
Fatal Exception: java.lang.NullPointerException
value == null
```

The stack trace brings it back to `okhttp3.Headers$Builder.checkNameAndValue (Headers.java:316)`:
```
if (value == null) throw new NullPointerException("value == null");
```

In the proposed fix, we simply continue the documented functionality of the `extractHeaders` method by returning "null" for invalid data.
Closes https://github.com/facebook/react-native/pull/10861

Differential Revision: D4178624

Pulled By: ericvicenti

fbshipit-source-id: 632e742196339639cb57ea47f9d0efbf04f090be
2016-11-14 19:43:58 -08:00
Adam Comella 9a8b5d9f4f Android: Disable debug menu when monkey is running
Summary:
When testing an app on Android using the monkey, the monkey shouldn't be able to open or interact with the dev menu.

**Test plan (required)**

My team uses this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/10901

Differential Revision: D4176167

Pulled By: ericvicenti

fbshipit-source-id: 8eb64715ae7496cdf957ee963777f66ab358546c
2016-11-14 16:58:55 -08:00
Charles Chen 72b517049a Add a debug support to load js bundle from external URL
Summary: Code refactoring on the dev support class. The idea is to make the code more modular.

Reviewed By: mhorowitz

Differential Revision: D4164676

fbshipit-source-id: 0d29bdaf927cd0e9f399fe6f8e46a16dfa65fb69
2016-11-14 11:43:49 -08:00
Christian Brevik da4df3f12f Make ReactWebView & Client protected
Summary:
I'd like to make `ReactWebView` and `ReactWebViewClient` `protected` instead of `private`, inside the `ReactWebViewManager` class. The reason being that if you extend the `ReactWebViewManager` it'll be much easier to override existing logic.

In my specific case I'd like to be able to override [shouldOverrideUrlLoading](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java#L120) inside `ReactWebViewClient` and handle custom URL schemes differently. See #10055.
Closes https://github.com/facebook/react-native/pull/10105

Differential Revision: D4168359

Pulled By: hramos

fbshipit-source-id: ff6cbcf1d56536f0db0d2eea937de2cc065a09f9
2016-11-14 11:28:47 -08:00
king6cong eeba5eb774 fix typo
Summary: Closes https://github.com/facebook/react-native/pull/10872

Differential Revision: D4176240

Pulled By: ericvicenti

fbshipit-source-id: 3b3e9ccb3c456b9b76a1d34322cc12f795e36247
2016-11-14 10:43:38 -08:00
Andy Street 10e0aec62f Update ReactShadowNode to not add CSSNode children if parent has measure defined
Summary: See inline comment for rationale

Reviewed By: emilsjolander

Differential Revision: D4154168

fbshipit-source-id: 6d428d4e9f4a68c88bb994ded88c817bee744563
2016-11-14 07:13:54 -08:00
Andy Street 07ef5a8fe9 Build C-version of CSSLayout in open source
Summary: Builds and ships libcsslayout.so with Android builds. This is not used yet, but a follow up diff will shortly move us from CSSNodeDEPRECATED to CSSNode (which uses libcsslayout)

Reviewed By: emilsjolander

Differential Revision: D4168140

fbshipit-source-id: d72bded88df81e4d54df31a08e4b101834770a73
2016-11-14 06:13:48 -08:00
Andy Street 0df65bb7d4 BREAKING [react_native/css_layout] Update RN shadow nodes to hold CSSNode instead of extending CSSNode
Summary:
This diff makes it so ReactShadowNode holds a CSSNode instead of extending one. This will enable us to pool and re-use CSSNodes and will allow us to keep from breaking the CSSNode api assumption that nodes that have measure functions don't have children (right now, text nodes have measure functions, but they also have raw text children).

BREAKING
This diff makes ReactShadowNode no longer extend CSSNodeDEPRECATED. If you have code that depended on that, e.g. via instanceof checks, that will no longer work as expected. Subclasses that override getChildAt/addChildAt/etc will need to update your method signatures. There should be no runtime behavior changes.

Reviewed By: emilsjolander

Differential Revision: D4153818

fbshipit-source-id: 2836434dd925d8e4651b9bb94b602c235e1e7665
2016-11-14 04:43:40 -08:00
Emil Sjolander 307871e854 Implement standard interface for toggling experimental features
Reviewed By: gkassabli

Differential Revision: D4174260

fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd
2016-11-14 03:28:39 -08:00
Emil Sjolander a2cafb062e rename CSSWrapType to shorter CSSWrap matching java and csharp
Reviewed By: gkassabli

Differential Revision: D4174257

fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592
2016-11-14 03:28:38 -08:00
Michał Gregorczyk c612c61544 Make UnpackingJSBundleLoader.prepare a public API.
Reviewed By: brosenfeld

Differential Revision: D4161585

fbshipit-source-id: b3b835610d11e043d2406cccff2da27f07878acc
2016-11-12 14:43:48 -08:00
Andy Street 974eec8264 Add CSSLayout to ReactCommon
Summary: First step to sharing CSSLayout code between iOS and Android.

Reviewed By: emilsjolander

Differential Revision: D4160286

fbshipit-source-id: 976f5820b19a7011e0a14317c858465f932e1f59
2016-11-11 10:58:55 -08:00
Emil Sjolander 867ea1bfaf Expose CSSLayoutSetLogger to java
Reviewed By: astreet

Differential Revision: D4153502

fbshipit-source-id: 630909d9d0d36d94d7cd3027476ddb52668b8cc0
2016-11-11 08:13:34 -08:00
Ryan Gomba 6f5433febe Proper NativeAnimated node invalidation on Android
Summary:
This diff attempts to fix a number of Android native animation bugs related to incomplete node invalidation, e.g. https://github.com/facebook/react-native/pull/10657#issuecomment-258297467.

For full correctness, we should mark any node as needing update when it is:

- created
- updated (value nodes)
- attached to new parents
- detached from old parents
- attached to a view (prop nodes)

cc/ janicduplessis
Closes https://github.com/facebook/react-native/pull/10837

Differential Revision: D4166446

fbshipit-source-id: dbf6b9aa34439e286234627791bb7fef647c8396
2016-11-11 01:13:36 -08:00
Rene Weber 868fbeaa00 Make sure to re-calculate step if not explicitly set
Summary:
This causes the step to be re-calculated on every update of min, max and step value,
to use the most up to date values for the calculation,
except if step is explicitly set to a non-zero value by the user.

Fixes #10253

**Test plan (required)**
1. Create example app
2. Create a view with a slider that has a `value`, `minimumValue` and `maximumValue` set, but no step value (or step value set to 0).

   For example:

   ```
   <Slider
       maximumValue={10}
       minimumValue={1}
       value={4}
       />
   ```
3. See slider working as expected
Closes https://github.com/facebook/react-native/pull/10343

Differential Revision: D4142646

Pulled By: hramos

fbshipit-source-id: a0df87bbdbbd4b2a291d89f5579f73f517a33dfc
2016-11-09 19:58:39 -08:00
Andrew Y. Chen 1e57d1156f Remove OnGenericMotionListener from ImmersiveReactFragment
Differential Revision: D4150394

fbshipit-source-id: 0ed3e42e1bda38283c9e66adde703ee9f9a96e61
2016-11-08 16:58:43 -08:00
Michał Gregorczyk 75d940d541 3 more `ReactMarker`s for unpacking bundle to disk.
Reviewed By: martinbigio

Differential Revision: D4147688

fbshipit-source-id: 44099bbfaa573cf9f187cc55438b56d929438efc
2016-11-08 13:28:39 -08:00
Emil Sjolander 81e4139edc Remove isTextNode optimization
Reviewed By: astreet

Differential Revision: D4146785

fbshipit-source-id: e20d780fbd5759b8f38b809e8cadf29cedee82a8
2016-11-08 09:13:43 -08:00
Thomas Beverley b6a38e80e0 Expose setAllowUniversalAccessFromFileURLs in Android WebView
Summary:
This pull request exposes the `setAllowUniversalAccessFromFileURLs` method of Android WebViewSettings as a property. The reason for this is when loading pages with a `file://` baseUrl it's sometimes desirable to allow loading other assets from a file base url. (For example loading an image into a canvas). More information on its use and purpose can be found [in the android docs here](https://developer.android.com/reference/android/webkit/WebSettings.html#setAllowUniversalAccessFromFileURLs%28boolean%29)

Usage example:

``` jsx
return (
  <WebView
    source={{ html: myhtml, baseUrl: 'file://' }}
    allowUniversalAccessFromFileURLs={true}
    javaScriptEnabled={true} />
)
```
Closes https://github.com/facebook/react-native/pull/8905

Differential Revision: D4147245

Pulled By: hramos

fbshipit-source-id: 7eaa884b8c0268de52b284954a34acec0fbd4061
2016-11-08 08:43:38 -08:00
Ryan Gomba 6535858c71 Add extractOffset to Animated
Summary:
`flattenOffset` has proven extremely useful, especially when dealing with pan responders and other gesture based animations, but I've also found a number of use cases for the inverse. This diff introduces `extractOffset`, which sets the offset value to the base value, and resets the base value to zero. A common use case would be to extractOffset onGrant and flattenOffset onRelease.
Closes https://github.com/facebook/react-native/pull/10721

Differential Revision: D4145744

fbshipit-source-id: dc2aa31652df0b31450556f611db43548180c7dd
2016-11-07 20:43:37 -08:00
Antoine Rousseau be4afdde37 Android WebSocket: include cookies in request
Summary:
This PR updates #6851 from srikanthkh, fixing coding conventions and javadoc, and adding a test plan.

Added testing functions into the WebSocketExample page of the UIExplorer, including a tiny http server to set a cookie on demand. Instructions included in the UIExplorer app.
Closes https://github.com/facebook/react-native/pull/9114

Differential Revision: D4140534

Pulled By: lacker

fbshipit-source-id: e020ad0c6d1d3ea09c0c3564c1795b4e1bc4517d
2016-11-07 10:43:44 -08:00
Andy Street 0089cd7630 Make CSSNode#measure final, cache more correct methodid
Summary:
In the JNI portion of CSSLayout, there's a subtle bug where we were caching the jmethodid of the 'measure' of the first object that had measure called on it. However, if that class had overriden measure, then the jmethodid would be specific to that subclass's implementation and would not work for other classes. Conversely, if a regular CSSNode had been called first, then the super method would be called on the subclass instead of the proper overriden method.

Since there's not really a reason to overriden measure anyway (since you can just provide a different measure function), it's safest to just mark it final and explicitly cache the appropriate methodid

Reviewed By: emilsjolander

Differential Revision: D4132428

fbshipit-source-id: 6fb51597d80f1c03681e6611153b52b73b392245
2016-11-07 06:14:28 -08:00
Andy Street a320b0ab19 Lazy create children list when first child is added
Summary: We don't need to allocate a list for every node since leaf nodes don't have children.

Reviewed By: emilsjolander

Differential Revision: D4130818

fbshipit-source-id: 80d3e98fce9d2daa0676fd1cbed0e81edcf7adb3
2016-11-07 05:43:40 -08:00
leeight b67c0c964e Breaking: Ignore StatusBarManager rejected state
Summary:
See #10236
Closes https://github.com/facebook/react-native/pull/10421

Differential Revision: D4045455

fbshipit-source-id: a4fd969b1ade5e1a44715c6aeebb12b58bbf8d0c
2016-11-04 07:58:37 -07:00
Andy Street 68aeffe01f Queue JS calls that come in before JS bundle has started loading instead of crashing
Summary: This mimics (some of) the behavior we have on iOS where if you call a JS module method before the JS bundle has started loading, we just queue up those calls and execute them after the bundle has started loading.

Reviewed By: javache

Differential Revision: D4117581

fbshipit-source-id: 58c5a6f87aeeb86083385334d92f2716a0574ba1
2016-11-03 09:44:58 -07:00
Ryan Gomba 9b4927c9c4 Implement NativeAnimated modulus node on Android
Summary:
This diff implements ModulusAnimatedNode on Android, bringing Android up to date with JS and iOS native animation APIs.
Closes https://github.com/facebook/react-native/pull/10681

Differential Revision: D4120162

fbshipit-source-id: 4e58e1b6309c1c7a12ef835547a3f3d321c20714
2016-11-02 14:58:52 -07:00
Ryan Gomba 8e81644f64 Implement NativeAnimated offsets on Android
Summary:
This diff implements NativeAnimation offsets on Android. Running the examples should show no change; however, calling `setOffset()` should offset the final value for any value node by that amount. This brings Android up to date with JS and iOS animation APIs.
Closes https://github.com/facebook/react-native/pull/10680

Differential Revision: D4119609

fbshipit-source-id: 96dccdf25f67c64c6787fd9ac762ec841cefc46a
2016-11-02 13:58:53 -07:00
Alexander Blom 788e2775f6 Add Java JNI bindings
Reviewed By: mhorowitz

Differential Revision: D4021520

fbshipit-source-id: dbaf2ebb7fa48f4efe6cf47a97c39bb079dda8d0
2016-11-02 12:29:15 -07:00
Andy Street f2d3113c1d Fix bug where ScrollView would stop overscrolled by a bit on fling
Summary: This bug was introduced with the bounce-back bug fix. We need to actually set the scroll position to the max scroll position if we've gone over otherwise it can get stuck.

Reviewed By: lexs

Differential Revision: D4118084

fbshipit-source-id: 41a927a40000c526414096c9385f8bd3cbd907f3
2016-11-02 10:58:34 -07:00
Andy Street 6a45f05872 Use whether react instance is accepting calls to determine whether instance is active
Summary:
There was previously a race condition where hasActiveCatalystInstance would return true, but calling a JS module call on it would result in a crash. Now, hasActivtyCatalystInstance will only return true once the instance is actually accepting calls.

I'll follow this up with a more risky diff that gets rid of hasActiveCatalystInstance and just queues JS calls until runJSBundle is called.

Reviewed By: javache

Differential Revision: D4117374

fbshipit-source-id: 60941f68b0906a8213571305c564bfe3d053f51b
2016-11-02 07:58:33 -07:00
Alexander Blom ddb8cb7cf0 Move JSCHelpers.h and Value.h into separate package
Reviewed By: javache

Differential Revision: D3950748

fbshipit-source-id: 6315ea07f3217b485aeb4374b5f6e36333957848
2016-11-01 11:44:10 -07:00
Ben Nham c089761f9b Use JSCExecutor to manage loading js script in JSContext
Reviewed By: jaegs

Differential Revision: D4021624

fbshipit-source-id: 8e46052ad246e842a88715d55059a233196a4a6b
2016-10-31 15:13:49 -07:00
Howard Yeh d4b8ae7a8a Android shouldn't dispatch onLayout if frame didn't change
Summary:
Fixes [#7202 Android Redundant onLayout event](https://github.com/facebook/react-native/issues/7202)
Closes https://github.com/facebook/react-native/pull/7250

Differential Revision: D4104066

Pulled By: mkonicek

fbshipit-source-id: 383efdb4b4881aa7d7e508d61c9c01165bcf7bb6
2016-10-31 10:58:49 -07:00
Michał Gregorczyk afe1619eb8 Do not block RN start path with fsync calls
Reviewed By: bnham

Differential Revision: D4097184

fbshipit-source-id: b3a7aeac7f4196a510efe650194eebdc797b5ec9
2016-10-28 19:43:34 -07:00
Fabian Köster 55ebb89916 Enable TLS 1.1 and TLS 1.2 on Android 4.1-4.4
Summary:
This is a proposed patch for issue #7192.

Android 4.1-4.4 has support for TLS 1.1 and 1.2 but it is disabled by default. Because of the known security issues and more and more servers switching to TLS 1.2 only, it would be nice for react-native to enable this support.

I demonstrated a demo application which showcases the problem and can be used to test this patch. All sources and documentation for it can be found here:

https://github.com/bringnow/react-native-tls-test

Credits to Alex Gotev (gotev) for the nice implementation.
Closes https://github.com/facebook/react-native/pull/9840

Differential Revision: D4099446

Pulled By: lacker

fbshipit-source-id: 94db320dce6d27f98169e63f834562360c00eef7
2016-10-28 17:14:00 -07:00
Ovidiu Viorel Iepure 4cff039d78 Circle CI releases now work with Java 8
Reviewed By: bestander

Differential Revision: D4095313

fbshipit-source-id: 1806db054bbca86f6394af077baeccac4e7efbe1
2016-10-28 07:58:52 -07:00
Emily Janzer 3580de541d fix notification task timeout crashing
Reviewed By: hedgerwang

Differential Revision: D4088570

fbshipit-source-id: e2a217564d9325815e396daafbef2b7f06e84b33
2016-10-27 17:28:40 -07:00
Emil Sjolander 844cafd883 Set layout outputs on java object from C
Reviewed By: lexs

Differential Revision: D4077968

fbshipit-source-id: bce86ba610cd5ae36cfb45d78b2609c63a14cfa3
2016-10-27 10:58:42 -07:00
Emil Sjolander 553f4371e0 BREAKING - Change measure() api to remove need for MeasureOutput allocation
Reviewed By: splhack

Differential Revision: D4081037

fbshipit-source-id: 28adbcdd160cbd3f59a0fdd4b9f1200ae18678f1
2016-10-27 10:58:42 -07:00
Martin Konicek b28c0bb7db Followup: Apply the User-Agent header correctly to Android WebView
Summary:
Followup for #5822, addressing nits.

**Test Plan**

Travis CI (the author of #5822 tested the change).
Closes https://github.com/facebook/react-native/pull/10563

Differential Revision: D4081826

fbshipit-source-id: f3a2e1996bf02f81fecea6e53fe1c522b8c85689
2016-10-26 10:13:40 -07:00
Giuseppe Ottaviano dc02907039 Fix a folly::dynamic deprecated pattern
Reviewed By: javache

Differential Revision: D4075622

fbshipit-source-id: 4a6b6c4068d762dce2b1535bfd9630e185f5489f
2016-10-26 09:43:56 -07:00
Emil Sjolander d8e77f0c76 Reset java state in jni reset method
Differential Revision: D4081049

fbshipit-source-id: 0b9ad70339ad906ad5219ad2679329cfe2fd7abc
2016-10-26 07:28:48 -07:00
Nikhilesh Sigatapu c67225818d Add a way to access the underlying JavaScriptCore context
Summary:
**Motivation**

I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.

(lexs you mentioned to tag you in this pull request)

**Test plan**

Modify the JavaScriptCore context through the `JSContextRef` returned (eg. add an object at global scope) and verify that it exists in JavaScript.
Closes https://github.com/facebook/react-native/pull/10399

Differential Revision: D4080945

Pulled By: lexs

fbshipit-source-id: 6659b7a01e09fd84475adde183c1d3aca2d4cf09
2016-10-26 03:43:44 -07:00
Emil Sjolander 2df4faaf15 Dont go down through JNI to figure out that no margin/padding/border/position was set
Differential Revision: D4080909

fbshipit-source-id: 7eb1885c615191055aa21e3435c6fbc652b883ae
2016-10-26 02:58:40 -07:00
Andrew Y. Chen 3af104fbd3 Fix memory leak in HeadlessJsTaskContext
Reviewed By: foghina, AaaChiuuu

Differential Revision: D4068078

fbshipit-source-id: a45ad83e9ecd8455558968089d80f94ec104c2ef
2016-10-25 07:13:51 -07:00
Michał Gregorczyk cfebad97b2 Synchronize before acquiring file lock
Reviewed By: dcaspi

Differential Revision: D4071662

fbshipit-source-id: 3458ff103fddb82a7588d7890f8bc931c0e19e14
2016-10-24 23:14:08 -07:00
Emil Sjolander 6664b816d7 Dont create a spacing object for returning margin, padding, border, and position
Differential Revision: D4050773

fbshipit-source-id: 3fd04c27f887a36875e455b5404a17154ac18f91
2016-10-24 10:43:43 -07:00
Emil Sjolander 58b5e28e71 Simplify memory model between managed and unmanaged memory
Differential Revision: D4051454

fbshipit-source-id: 8f5d010be520b3d1c981a7f85e5e6d95773ea6c1
2016-10-24 10:43:43 -07:00
Benoit Lemaire a7e333402d Add a few devsupport unit tests
Summary:
This PR adds a few unit tests to two devsupport classes, repectively

- JSDebuggerWebSocketClient
and
- JSPackagerWebSocketClient

Unit tests do not cover all methods / branches of the code. I solely focused on testing things having to do with JSON serialization as I am considering some quick refactoring to get rid of Jackson. Just prepping safety net with these few tests before starting.
Closes https://github.com/facebook/react-native/pull/10516

Differential Revision: D4067433

Pulled By: bestander

fbshipit-source-id: 97dc356c5eca5965914be074a7175cb48f038c4c
2016-10-24 03:58:33 -07:00
Emil Sjolander ea6458b63e Remove flex shorthand getter because it doesnt make a lot of sense
Reviewed By: gkassabli

Differential Revision: D4064674

fbshipit-source-id: 69935b85042020b4e8c61a393c1be8f4d42a6674
2016-10-24 03:44:22 -07:00
Aaron Chiu ed0e8f3360 Alphabetize CoreModulesPackage
Reviewed By: fkgozali

Differential Revision: D4058503

fbshipit-source-id: d0665b19ebf1d2991bcb13ee7d62311eed516946
2016-10-21 10:28:36 -07:00
Aaron Chiu c6330a2081 make HeadlessJsTaskSupportModule lazifiable
Reviewed By: achen1

Differential Revision: D4051137

fbshipit-source-id: 611b3cc36de040cf803b11a8a06ae13c0d9b044c
2016-10-21 05:28:41 -07:00
Kevin Gozali 150c522be9 allow fetching any resource under js folder via packager
Summary: This is a simple hook to allow native side to fetch any file under the js root folder via packager. Historically, only the `main.jsbundle` is fetched via the packager. This then allows fetching local file like a json file that lives under the same root js folder

Reviewed By: yungsters

Differential Revision: D4037730

fbshipit-source-id: a2d6eb5e30d148fee573d413fc4036d0189f4938
2016-10-20 11:43:44 -07:00
Aaron Chiu ffe06d3cfa annotate FB4A's view managers with @ReactModule
Reviewed By: achen1

Differential Revision: D4044730

fbshipit-source-id: c80c23c524b2d9366c51c52cbcdee8a2a4f26f75
2016-10-20 05:43:50 -07:00
Aaron Chiu e16251b46d don't allow fallback implementation when Lazy Native modules is enabled
Reviewed By: achen1

Differential Revision: D4019360

fbshipit-source-id: af5fffd1e80cdf99ff9af743eafff1412cac8e58
2016-10-20 05:43:50 -07:00
Yoshiya Hinosawa 71676809d6 Fix indent of .gradle files
Summary:
In most .gradle files, lines are indented with 4 spaces, but in some places they are indented with 2 spaces. This PR fixes them and enforce it by adding .editorconfig settings.
Closes https://github.com/facebook/react-native/pull/10267

Differential Revision: D4048335

Pulled By: lacker

fbshipit-source-id: df2f2556380f56672cf85690eb1c80e640a6aedf
2016-10-19 16:58:36 -07:00
Dmitry Petukhov d294e15c43 Two ReactART TODOs implemented on Android
Summary:
Implemented 2 TODOs from ReactART for Android:
- TODO(7255985): Use TextureView and pass Surface from the view to draw on it asynchronously instead of passing the bitmap (which is inefficient especially in terms of memory usage)
- TODO(6352067): Support dashes in ARTShape

We use ReactNativeART in our Android project.
1. Our app crashes sometimes on large screen smartphones with OutOfMemoryError. Crashes happen in ARTSurfaceShadowNode where TODO(7255985) was suggested in a comment in order to use memory more efficiently.
2. We needed dashes for drawing on ARTSurface.

**Test plan (required)**

I attach a screenshot of our app which shows dashed-lines and two ARTSurfaces on top of each other rendering exactly the same as in the pervious implementation of ARTSurface.
![screenshot_2016-08-19-16-45-43](https://cloud.githubusercontent.com/assets/18415611/17811741/cafc35c4-662c-11e6-8a63-7c35ef1c5ba9.png)
Closes https://github.com/facebook/react-native/pull/9486

Differential Revision: D4021303

Pulled By: foghina

fbshipit-source-id: 880175e841e3c598013982a7748b6fc691c7e8d6
2016-10-18 12:28:48 -07:00
Jacob Parker abb8ea3aea Implement a postMessage function and an onMessage event for webviews …
Summary:
JS API very similar to web workers and node's child process.

Work has been done by somebody else for the Android implementation over at #7020, so we'd need to have these in sync before anything gets merged.

I've made a prop `messagingEnabled` to be more explicit about creating globals—it might be sufficient to just check for an onMessage handler though.

![screen shot 2016-09-06 at 10 28 23](https://cloud.githubusercontent.com/assets/7275322/18268669/b1a12348-741c-11e6-91a1-ad39d5a8bc03.png)
Closes https://github.com/facebook/react-native/pull/9762

Differential Revision: D4008260

fbshipit-source-id: 84b1afafbc0ab1edc3dfbf1a8fb870218e171a4c
2016-10-16 06:43:46 -07:00
Tim Yung 331c13d4dc RN: Require {react/lib/ => }ReactNative
Reviewed By: sebmarkbage

Differential Revision: D4024375

fbshipit-source-id: cd2226a3580a7a4ff319d6a93b67b68f2942eb00
2016-10-14 18:59:10 -07:00
Felix Oghina 9df93c1071 Fix and re-enable TimingModuleTest
Summary:
For some reason the transitive dependency isn't picked up in OSS, so make it hard.

bestander
Closes https://github.com/facebook/react-native/pull/10397

Differential Revision: D4024350

Pulled By: bestander

fbshipit-source-id: 32182857dcc88744ebf6ce0e5cf8eaee390bf067
2016-10-14 15:28:43 -07:00
Konstantin Raev 82d6ac1a51 disabled broken test in jdk8
Summary:
Disabled test

cc kentaromiura
Closes https://github.com/facebook/react-native/pull/10395

Differential Revision: D4022410

Pulled By: kentaromiura

fbshipit-source-id: 9084badb457b18c146dca3853137e40c5b53b576
2016-10-14 11:13:54 -07:00
Connor McEwen 9c3bfe0cbb Prevent app from crashing when getCurrentActivity is null
Summary:
We're seeing a lot of crashes from `PermissionsModule` not being able to access the current activity, mentioned in #10009 and here: https://github.com/facebook/react-native/issues/9310#issuecomment-245657347

As far as I can tell, there is no way to ensure the Activity exists since the `ReactContext` holds a `WeakReference` to the current Activity and it appears that the lifecycle calls are happening in the right order (so not the same as #9310).

This will at least allow people to catch the error in JS and update the UI or try again as opposed to crashing the app.

I'm working on some bigger changes in #10221 but this is a smaller change and important to get fixed I think.
Closes https://github.com/facebook/react-native/pull/10351

Differential Revision: D4010242

fbshipit-source-id: 7a76973bb2b3e45817d4283917740c89a10ec0b0
2016-10-12 12:58:49 -07:00
Emil Sjolander 1f36d98874 Add tests for java jni bindings
Reviewed By: lucasr

Differential Revision: D4008411

fbshipit-source-id: c896a3925ff3f7fa368176a3d03c84eb7188ef60
2016-10-12 09:58:37 -07:00
Emil Sjolander fb245cca83 Rename init() -> reinit() to be more in line with what it now does
Reviewed By: lucasr

Differential Revision: D3992811

fbshipit-source-id: 61a10acc873ec028b2789007a400d89e62cf31d6
2016-10-12 03:58:45 -07:00
Emil Sjolander 64455ced5d Rename reset() -> free() to be more in line with what it now does
Reviewed By: lucasr

Differential Revision: D3992808

fbshipit-source-id: 8428ae33268d1417ce8642b741e47150a17bf077
2016-10-12 03:58:44 -07:00
Emil Sjolander 38bd937b40 Automatically init native memory when allocating java wrapper
Reviewed By: lucasr

Differential Revision: D3992802

fbshipit-source-id: 06d65821f1802ed8f2b2db651cef69f6851803f2
2016-10-12 03:58:44 -07:00
Emil Sjolander 6dae68306e JNI version is the default, its name should reflect that
Reviewed By: lucasr

Differential Revision: D3992777

fbshipit-source-id: cdd4cc58f3c15b5db1158f6f794394eb5c44a44d
2016-10-12 03:58:44 -07:00
Emil Sjolander 5c728a47b9 Clearly mark java CSSNode as deprecated. It will go away very soon
Reviewed By: lucasr

Differential Revision: D3992775

fbshipit-source-id: b3ceca277e5c7426eb51f8cbeacf5e2fe451c6ec
2016-10-12 02:59:18 -07:00
Satyajit Sahoo fa5ad85252 Remove deprecated APIs and modules
Summary:
We've deprecated these APIs for quite a few releases and we should be able to get rid of them now.

Remove following deprecated modules/components
 - AppStateIOS
 - ActivityIndicatorIOS
 - IntentAndroid
 - SliderIOS
 - SwitchAndroid
 - SwitchIOS
 - LinkingIOS

Update following modules to remove callback support
 - Clipboard
 - NetInfo

cc bestander
Closes https://github.com/facebook/react-native/pull/9891

Reviewed By: bestander

Differential Revision: D3974094

Pulled By: javache

fbshipit-source-id: 9abe32716bd85d0cea9933894f4447d53bdd5ee7
2016-10-11 07:43:52 -07:00
Pieter De Baets 9ed9bca0bf Lazily instantiate native modules
Summary: Instead of sending a list of modules over to JS on startup (and actually blocking script execution) instead provide a proxy object that constructs each of these lazily.

Reviewed By: lexs

Differential Revision: D3936979

fbshipit-source-id: 71bde822f01eb17a29f56c5e60e95e98e207d74d
2016-10-11 07:28:42 -07:00
Emil Sjolander 08e715bc9c Add finalizer to release any unreleased native memory
Reviewed By: lucasr

Differential Revision: D3992759

fbshipit-source-id: f648b72ead5bdb7257a5197496b19795f71f3788
2016-10-11 04:58:30 -07:00
Andrew Y. Chen 8e91843cc7 Fix crash when resolveView fails to find a view
Reviewed By: yungsters

Differential Revision: D3997107

fbshipit-source-id: 7bf03ff06a6b56d192bab7fa567a11a38148f076
2016-10-10 14:43:40 -07:00
Emil Sjolander b7ded130df Dont use explicit .so file name to support more platforms
Reviewed By: dreiss

Differential Revision: D3981166

fbshipit-source-id: 0b19f73e6de48a30613419ccc54735c968701532
2016-10-08 09:28:42 -07:00
Aaron Chiu 24a83fae2f make view managers native modules
Reviewed By: achen1

Differential Revision: D3973591

fbshipit-source-id: 44886f3bf045ed64585c92eb2e291627eed86c92
2016-10-07 05:43:45 -07:00
Aaron Chiu 1296cb29eb add flag to enable lazy view managers
Reviewed By: achen1

Differential Revision: D3981171

fbshipit-source-id: 2f6b8370064a5835e2e3636d4c1a7f42cc28ccaf
2016-10-07 05:43:45 -07:00
Emil Sjolander d89f59d94a Resolve some differences between CSSNode and CSSNodeJNI
Reviewed By: lucasr

Differential Revision: D3960755

fbshipit-source-id: 3e13a9435208851a96a619c07625ef2a5402f5ec
2016-10-07 05:28:37 -07:00
Aaron Chiu 8708c8bb82 make ViewManager extend BaseJavaModule
Reviewed By: achen1

Differential Revision: D3950323

fbshipit-source-id: 91fda89a9a457e0e5b6952b744eeba5e31c46a9a
2016-10-06 15:58:38 -07:00
Mike Lambert 1502e66c31 Allow code to check android permissions when run from a Service as well as Activity
Summary:
This allows the React JS code that's running from a Service (ie GcmListenerService) to check permissions (ie check for VIBRATE permissions before delivering notifications)

**Test plan (required)**

I've run this code from a GcmListenerService subclass, and it works correctly.
Closes https://github.com/facebook/react-native/pull/10229

Differential Revision: D3980853

fbshipit-source-id: 026b1f0c953d7093b5af2bec0b4a93ebd228f62e
2016-10-06 04:28:35 -07:00
Felix Oghina f7cbd56d8e pass EventDispatcher to UIImplementation constructor
Summary: This way `UIImplementation` can hold on to it and use it outside of calls from the `UIManagerModule`.

Reviewed By: lexs

Differential Revision: D3899774

fbshipit-source-id: 01e4956c4540bcdf30774a3f40a625e934714ee9
2016-10-04 12:29:13 -07:00
Konstantin Raev 20ef20591f fixed mockito version
Summary:
Gradle unit tests started failing, this PR fixes mockito to be one specific version instead of loose 1.+

**Explain the **motivation** for making this change. What existing problem does the pull request solve?**

Circle CI started failing without any specific reason https://circleci.com/gh/facebook/react-native/tree/master, looks like a dependency error.

Alas it is, I can reproduce the error on master with clean caches.

**Test plan (required)**

After the fix:

```
bestander-pro:react-native bestander$ ./gradlew :ReactAndroid:testDebugUnitTest
Incremental java compilation is an incubating feature.
:ReactAndroid:preBuild UP-TO-DATE
:ReactAndroid:preDebugBuild UP-TO-DATE
:ReactAndroid:checkDebugManifest
:ReactAndroid:preDebugAndroidTestBuild UP-TO-DATE
:ReactAndroid:preDebugUnitTestBuild UP-TO-DATE
:ReactAndroid:preReleaseBuild UP-TO-DATE
:ReactAndroid:preReleaseUnitTestBuild UP-TO-DATE
:ReactAndroid:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:ReactAndroid:prepareComAndro
Closes https://github.com/facebook/react-native/pull/10239

Differential Revision: D3968396

Pulled By: matryoshcow

fbshipit-source-id: 63374261303fb98dc252898dfd5d3b3346597e4f
2016-10-04 10:43:35 -07:00
Pieter De Baets d7d89172c2 Expose ModuleRegistry on ExecutorDelegate
Differential Revision: D3944588

fbshipit-source-id: f8450a6735e1f6283c3bfe9d2ce883327172621c
2016-10-03 05:13:38 -07:00
Felix Oghina 6d175f2c25 Android: enable foreground ripple
Reviewed By: astreet

Differential Revision: D3932066

fbshipit-source-id: ee2f019cb9ba41e32cbbd8c1cd07c9ed5263fddc
2016-10-03 04:28:46 -07:00
Andy a2aab625f3 Fix webview crash when trying to display local html files
Summary:
When using webview on android and trying to link to an html file located on device (using `file://`), the application would crash with an error specifying that nothing handles the fired intent. This is due to [`33a1f28`](33a1f28654) which attempts to intercept all non `http(s)` links.

This is a simple fix so hopefully it can make it into the next stable release.
Closes https://github.com/facebook/react-native/pull/9668

Differential Revision: D3956485

fbshipit-source-id: 5a752abc21802a44e3a26e88669ccb6852076992
2016-10-01 11:43:37 -07:00
Pieter De Baets 86c195b3d8 Upgrade OSS folly dependency
Reviewed By: bestander

Differential Revision: D3952605

fbshipit-source-id: 70146987c07b3c9917d19d7fbf844242343f9777
2016-09-30 15:28:38 -07:00
Hoa Dinh 5a24ea0b42 Create headers symlinks for FBReactKit
Reviewed By: javache, skotchvail

Differential Revision: D3946452

fbshipit-source-id: c6354f529bec2f9635a0ecf5f65e21dc4e17b1e4
2016-09-30 14:28:41 -07:00
Alexander Pantyuhov c4ac8b329c StatusBar: barStyle support for Android (API 23+)
Summary:
Android (starting from API 23) supports "light status bar", thus it is possible to extend StatusBar and make `barStyle` property work not only for iOS, but also for Android.

This PR introduces one more `barStyle` option `dark-content` in addition to two existing ones (`default` and `light-content`).
Why there are 3 options instead of 2?

Two simple reasons:
1) to make all existing applications fully compatible with these changes;
2) the default status bar on Android is dark with white text and icons, while on iOS it is light with black text and icons on it. Thus the `default` option means something like "I don't really care, just apply the default color for this platform", while two other options (`light-content` and `dark-content`) allow to accurately specify the required result.
Closes https://github.com/facebook/react-native/pull/10185

Differential Revision: D3952346

fbshipit-source-id: 999a67614abff52321fbeb06298ebf1946c3f1d1
2016-09-30 12:58:37 -07:00
Pieter De Baets 5b52dab781 Remove follySupport.h
Reviewed By: lexs

Differential Revision: D3944918

fbshipit-source-id: 702907a12e3916f9d6edde7362416188df909d70
2016-09-30 12:28:41 -07:00
Andrei Coman 9b261dbc94 Modal statusbar cleanup
Summary:
The hack for the status bar height is not necessary any longer, so we can remove
all code related to it

Reviewed By: lexs

Differential Revision: D3943770

fbshipit-source-id: 2d70f4ea10dd76ea6e6a73bb6edccae388bde1c0
2016-09-30 03:13:36 -07:00
Dave Pack 12a97e1ecd Fix Modal size on Android tablet
Summary:
On tablets, using Display.getRotation() returned ROTATION_0 or ROTATION_180 when it was in landscape, not portrait as it does on phones. This resulted in the Modal being sized incorrectly on tablets. Using size and comparing width and height is the only way I can think of to figure out the device orientation and give the modal the correct size. With this change, all issues listed in #7708 should be resolved.

**Test plan**
Modal should correctly fill screen on Android phone and tablet in both portrait and landscape.
Closes https://github.com/facebook/react-native/pull/10159

Differential Revision: D3950369

Pulled By: andreicoman11

fbshipit-source-id: 9488c4302a76cc48e4f8a4026eb5770d40b6e3d2
2016-09-30 02:44:09 -07:00
Nicolas Charpentier aa36adb116 Fix example in buck DEFS
Summary:
I noticed that the example doesn't match the definition below.

cc bestander
Closes https://github.com/facebook/react-native/pull/10175

Differential Revision: D3943967

Pulled By: bestander

fbshipit-source-id: 6941d4d663e1fd42f8723cd722eb8a5712a63dc8
2016-09-29 08:28:39 -07:00
Felix Oghina 3080b8d26c Android: add support for headless js tasks
Summary: Provide a base `HeadlessJsTaskService` class that can be extended to run JS in headless mode in response to some event. Added `HeadlessJsTaskEventListener` for modules that are interested in background lifecycle events, and `HeadlessJsTaskContext` that basically extends `ReactContext` without touching it. The react instance is shared with the rest of the app (e.g. activities) through the `ReactNativeHost`.

Reviewed By: astreet

Differential Revision: D3225753

fbshipit-source-id: 2c5e7679636f31e0e7842d8a67aeb95baf47c563
2016-09-29 03:58:33 -07:00
Chris Hopman eafd9b258f Use std=c++1y in xreact pertests
Reviewed By: mzlee

Differential Revision: D3935375

fbshipit-source-id: b477d865427ed56d5271477b198af633bba2f314
2016-09-28 16:29:01 -07:00
Andrei Coman 404b7cc069 BREAKING: Fix modal resizing on keyboard show
Summary:
This changes modal behavior to resize when the keyboard appears/disappears.
Previously, the modal would not react in any way, or it would pan above to bring the
TextInput into view. Resizing is the correct behavior for android.

This is not trivial, as in, setting the flag, because of the combination of
react native laying out all views and the system reacting to the keyboard
appearance in a weird way. Namely:
- if `windowTranslucentStatus` is not set, the system will just call
  `onSizeChanged` on the dialog's content view, and everything works nicely
- with `windowTranslucentStatus` set, the system will consider the dialog as a
  full screen view that doesn't resize. In order for it to resize, the base
  view of the layout needs to have
  `setFitsSystemWindows(true)` called on it. This is needed, so that the system
  can call layout on that base view with the new value of `paddingBottom` that
  coincides with the height of the keyboard. Neat.

We fix this by wrapping our existing content view (mHostView) in a simple
FrameLayout that has `setFitsSystemWindows` set. That way, `mHostView` will have
`onSizeChanged` called on itself with the correct new size of the dialog.

This has the fortunate consequence of our layout now also getting `paddingTop` as the size of the
status bar, which means that we can remove the JS `top` hack in Modal, which
was necessary for no view getting drawn under the status bar.

This behavior is set as default, since that is the default correct Android behavior.

Reviewed By: astreet

Differential Revision: D3913784

fbshipit-source-id: 4378ada21f466dc7ac6e357abeca10b88009ca3f
2016-09-28 02:58:37 -07:00
Marc Horowitz fc62b00880 Update tests to work better with async runJSBundle
Reviewed By: bestander

Differential Revision: D3932963

fbshipit-source-id: 16967987b3f777104ab3a41d5967ff1b2f4678db
2016-09-27 14:58:41 -07:00
Aaron Chiu d22a85211e remove CompositeLazyReactPackage in favor of ReactInstanceManager.Builder's existing ReactPackage list
Reviewed By: andreicoman11

Differential Revision: D3928330

fbshipit-source-id: aee8a7c31d80f5500744029676b9f2b8c87aa98a
2016-09-27 09:58:30 -07:00
Aaron Chiu 1f27dd6643 log into QPL time to create module for lazy native modules
Reviewed By: andreicoman11

Differential Revision: D3928797

fbshipit-source-id: d1c6c024c4994b237155f16e6a915b16f216d56d
2016-09-27 09:43:30 -07:00
Konstantin Raev 449c195941 Temporarily disabled CatalystUIManagerTestCase.testFlexWithTextViews test
Summary:
After D3876927 this test started failing on CI.
Locally we can't reproduce it, and it will take some time to understand what this test is intended for so that we could remove the variable part.
More investigation will follow, t13583009

Reviewed By: emilsjolander

Differential Revision: D3930334

fbshipit-source-id: 279f67eb5a77b5d4250afd48c8b94c828da6925c
2016-09-27 07:13:30 -07:00
Andrei Coman 30989dd24a Fix ReactSwipeRefreshLayout
Summary:
`ReactSwipeRefreshLayout` extends `SwipeRefreshLayout` which does not play nice with Android's touch handling system.
There are two problems:
1. `SwipeRefreshLayout` overrides and swallows `requestDisallowInterceptTouchEvent`, which means that Views underneath the `SwipeRefreshLayout` will not interact correctly with parent Views of
`SwipeRefreshLayout`. We've seen this in practice by H-ScrollViews having their touches intercepted by an enclosing ViewPager. This is fixed by passing `requestDisallowInterceptTouchEvent` up to the parents of `SwipeRefreshLayout`.
2. `SwipeRefreshLayout` overrides `onInterceptTouchEvent` and never calls `super.onInterceptTouchEvent`, therefore ignoring the value of `disallowIntercept`. That means that it will intercept some touches when it
shouldn't. One such case is again the H-ScrollView, which should receive all horizontal scrolls and stop `SwipeRefreshLayout` from intercepting any touch events after scrolling. Currently, after the H-ScrollView starts scrolling, it is still possible to get the `SwipeRefreshLayout` to detect and emit refresh events. This is fixed by checking and blocking on horizontal scrolls.

Reviewed By: foghina

Differential Revision: D3929893

fbshipit-source-id: e6f8050fb554e53318a7ca564c49c20cb5137df9
2016-09-27 04:28:34 -07:00
Kevin Gozali 0a0dd30c6a Introduced AnimatedDivision
Summary:
Combining 2 animated values via addition, multiplication, and modulo are already supported, and this adds another one: division.
There are some cases where an animated value needs to invert (1 / x) another animated value for calculation. An example is inverting a scale (2x --> 0.5x), e.g.:

```
const a = Animated.Value(1);
const b = Animated.divide(1, a);

Animated.spring(a, {
  toValue: 2,
}).start();
```

`b` will then follow `a`'s spring animation and produce the value of `1 / a`.

The basic usage is like this:

```
<Animated.View style={{transform: [{scale: a}]}}>
  <Animated.Image style={{transform: [{scale: b}]}} />
<Animated.View>
```

In this example, the inner image won't get stretched at all because the parent's scaling gets cancelled out.

Also added this to native animated implementation.

Reviewed By: foghina, mmmulani

Differential Revision: D3922891

fbshipit-source-id: 32508956c4b65b2deb7574d50a10c85b4809b961
2016-09-26 16:43:51 -07:00
Marc Horowitz 971cda8794 Move thread jump for js loading into NativeToJSBridge, out of platform code
Reviewed By: javache

Differential Revision: D3906009

fbshipit-source-id: b9782a6c209e3c1626899dac7fd50233cdef87f3
2016-09-26 16:14:10 -07:00
Emil Sjolander 0a9b6bedb3 BREAKING - Fix unconstraint sizing in main axis
Summary:
This fixes measuring of items in the main axis of a container. Previously items were in a lot of cases measured with UNSPECIFIED instead of AT_MOST. This was to support scrolling containers. The correct way to handle scrolling containers is to instead provide them with their own overflow value to activate this behavior. This is also similar to how the web works.

This is a breaking change. Most of your layouts will continue to function as before however some of them might not. Typically this is due to having a `flex: 1` style where it is currently a no-op due to being measured with an undefined size but after this change it may collapse your component to take zero size due to the implicit `flexBasis: 0` now being correctly treated. Removing the bad `flex: 1` style or changing it to `flexGrow: 1` should solve most if not all layout issues your see after this diff.

Reviewed By: majak

Differential Revision: D3876927

fbshipit-source-id: 81ea1c9d6574dd4564a3333f1b3617cf84b4022f
2016-09-26 06:13:56 -07:00
Andrei Coman 0abaaeead0 Modal: move style to xml
Summary:
The styles that get applied to the Dialogs that are created in RN are set in
`themes.xml`, so I'm moving `windowTranslucentStatus` there as well so that we
have all of them collocated.

Reviewed By: astreet

Differential Revision: D3913402

fbshipit-source-id: 8f23e84fb017c8810634ffe8279171061292b351
2016-09-26 03:59:09 -07:00
Aaron Chiu 1b2d9a858b add perf marker for create module
Reviewed By: andreicoman11

Differential Revision: D3910533

fbshipit-source-id: 645da63ac9fb0721f13eba05f52ae2c37a868f60
2016-09-23 16:58:30 -07:00
Aaron Chiu 797ca6c219 Add ability to lazy load Native Java Modules
Summary: Utilizes the build time annotation processor ReactModuleSpecProcessor that creates ReactModuleInfos for modules annotated with ReactModule and listed in the ReactModuleList annotation of LazyReactPackages. This way we don't have to instantiate the native modules to get the name, canOverrideExistingModule, and supportsWebWorkers values of the native modules. In the NativeModuleRegistry, we either store these ReactModuleInfos inside of a ModuleHolder or if we can't get the ReactModuleInfo for a specific module we instantiate that module to get the values (as we previously did) to store in a LegacyModuleInfo.

Reviewed By: astreet

Differential Revision: D3796561

fbshipit-source-id: f8fb9b4993f59b51ce595eb2f2c3425129b28ce5
2016-09-23 15:58:46 -07:00
Don Yu 17219720e4 Add support for image onLoad, onLoadEnd, onError events for IgReactImageView
Summary: Create separate buck library for image events so you can depend on that without depending on all of fresco

Reviewed By: brosenfeld

Differential Revision: D3907894

fbshipit-source-id: dca7a00d38b8b8bb5bab05b6883f6933fff3fa76
2016-09-23 04:43:54 -07:00
Aaron Chiu 826d7345ad Test diff CI fix: Update CoreModulesPackage.java
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

> **Unless you are a React Native release maintainer and cherry-picking an *existing* commit into a current release, ensure your pull request is targeting the `master` React Native branch.**

Explain the **motivation** for making this change. What existing problem does the pull request solve?

Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

**Test plan (required)**

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

Make sure tests pass on both Travis and Circle CI.

**Code formatting**

Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).

For more info, see
Closes https://github.com/facebook/react-native/pull/10057

Differential Revision: D3913431

Pulled By: bestander

fbshipit-source-id: c761640839ce0e85196ffd7fc1a4e1c615078b06
2016-09-23 04:43:53 -07:00
Aaron Chiu bdc47313e8 move some JS modules to debug only
Reviewed By: lexs

Differential Revision: D3893217

fbshipit-source-id: d84aea3391fea435ea1de39f7ce8cf08586b373f
2016-09-22 11:28:36 -07:00
Brad Daily 61eb3e8826 Reverted commit D3841122
Summary:
This commit brings Android in line with iOS WebSockets by sending along cookies from the shared CookieManager. See: https://github.com/facebook/react-native/pull/5630
Closes https://github.com/facebook/react-native/pull/6067

Differential Revision: D3841122

Pulled By: wutalman

fbshipit-source-id: 6dae03bdf1c4599f12c0b191fcc56a61952fb59e
2016-09-22 09:13:41 -07:00
Andrei Coman 3318483b31 Fix dev menu on top of modals
Summary:
The dialog intercepts all key events, we need to redirect some of them to the
activity so that it can display the dev menu.

Reviewed By: foghina

Differential Revision: D3894503

fbshipit-source-id: fb62346a4da783f28a73c5a9e20566a451177629
2016-09-22 04:49:58 -07:00
Andrei Coman 922cd6ddfc Fix Modal freeze
Summary:
In some cases, the size of the content view changes before we add views to the
Modal. That means that the size of that view will not be set through the
`onSizeChanged` method. This can result in some apps apparently freezing,
since the dialog is created, but there are no actual views in it.
For that reason, we still need the ModalHostShadowNode to set the size of the
initial view, so that by the time the view gets added it already has the correct
size.
There's a new helper class so that we can reuse the modal size computation.

Reviewed By: foghina

Differential Revision: D3892795

fbshipit-source-id: 6a32bd7680a74d9912a21bfebb4ebd7a3c3c3e38
2016-09-20 06:58:49 -07:00
Gant Laborde c6024f6391 - Add ability to detect if location was mocked
Summary:
Since API 18, Android locations have had the `isFromMockProvider()` function, to verify the validity of a provided location.  This was one of many methods one could verify location data, but as of Marshmallow, the other ways of detecting if "Mock Locations" is on in developer settings has been deprecated or defunct.

This means some devices can only detect location mocking by exposing the method on the location object.

This change provides that exposure.
Closes https://github.com/facebook/react-native/pull/9390

Differential Revision: D3858205

Pulled By: bestander

fbshipit-source-id: 3bae429cc0596ea01926c5be204f4403e4a2414f
2016-09-20 05:59:04 -07:00
Brad Daily 04392f2428 Android WebSocket: include cookies with request
Summary:
This commit brings Android in line with iOS WebSockets by sending along cookies from the shared CookieManager. See: https://github.com/facebook/react-native/pull/5630
Closes https://github.com/facebook/react-native/pull/6067

Differential Revision: D3841122

Pulled By: mkonicek

fbshipit-source-id: 6607424feeb31c9da4e370ebe4b33dbbedc0a446
2016-09-19 15:44:17 -07:00
Pieter De Baets 145109fc6d Remove additional JSON encoding for native->JS communication
Reviewed By: mhorowitz

Differential Revision: D3857323

fbshipit-source-id: 4386cc107b8a1425ecb7297b0f659f6c47f01a78
2016-09-19 04:44:12 -07:00
Andy Street 5deb528695 Don't crash if OEM has replaced OverScroller in ScrollView
Summary: Some OEMs have changed out the default scroller implementation in their ScrollView. We now check for that case and handle it gracefully instead of crashing.

Reviewed By: foghina

Differential Revision: D3876492

fbshipit-source-id: 4d03b88c4972e939c8352eeb9f30275e3ecf76e2
2016-09-19 04:14:01 -07:00
Janic Duplessis 6565929358 Add support for animated events
Summary:
This adds support for `Animated.event` driven natively. This is WIP and would like feedback on how this is implemented.

At the moment, it works by providing a mapping between a view tag, an event name, an event path and an animated value when a view has a prop with a `AnimatedEvent` object. Then we can hook into `EventDispatcher`, check for events that target our view + event name and update the animated value using the event path.

For now it works with the onScroll event but it should be generic enough to work with anything.
Closes https://github.com/facebook/react-native/pull/9253

Differential Revision: D3759844

Pulled By: foghina

fbshipit-source-id: 86989c705847955bd65e6cf5a7d572ec7ccd3eb4
2016-09-19 04:14:01 -07:00
Andrei Coman bdff10b4ea Fix text, textinput padding
Summary:
The issue here is that on some devices (ie. Nexus 5X), under certain
circumstances, the text gets trimmed. A simple example is P56651885, where the
text is at the end of the line and some padding is set. Digging further with
P56659346, I found that only the paddings that have integer pixel values work
correctly: these are the values P56656483, and this is the screenshot of that
test: {F63510378}.

It turns out that when we set the padding directly on the TextView, we have to
convert from float to int, and use `ceil` in the process. We lose some precision
here, since the csslayout will use the float values to compute the layout of the
views. The ideal solution would be to just set the float values on the TextView,
but since we can't do that, we should avoid using `ceil` instead of `floor`
since it can have bad side-effects in some scenarios.
Going way back to D1881202 and D1710471, we started using `ceil` because that
is how android handles non-integer
density ratios: "This figure is the factor by which you should multiply the dp
units on order to get the actual pixel count for the current screen. (Then add
0.5f to round the figure up to the nearest whole number, when converting to an
integer.)", see https://developer.android.com/guide/practices/screens_support.html.

Reviewed By: emilsjolander

Differential Revision: D3876310

fbshipit-source-id: 701c05a8b1a045d4e06fc89ffe79162c1eecb62c
2016-09-19 02:58:48 -07:00
Andrei Coman 4941cbcf1e Fix modal size
Summary:
With our previous fix to resize the Modal on orientation change, we broke the
computation of its size. The existing computation in `ModalHostShadowNode` was
in fact correct, and we were overriding it from `onSizeChanged`. By computing the
size of the Modal in `onSizeChanged` directly (and correctly), we fix this, and
simplify code by removing the `ModalHostShadowNode`.

Reviewed By: foghina

Differential Revision: D3863054

fbshipit-source-id: aaf4a8881798df4d2ab1dab882a9d9dfdc0a9342
2016-09-19 02:58:47 -07:00
ransj 44b0e6b91f optimize getNativeProps method
Summary:
The original method getNativeProps in ViewManagerPropertyUpdater.java create more HashMaps and putAll method need to re-hash the key again to avoid conflicts. This pull request pass the map as params to avoid the problem and update ReactPropertyProcessor.java to adapt the change.
Closes https://github.com/facebook/react-native/pull/9916

Differential Revision: D3873152

fbshipit-source-id: 089840e5272265662cdbf58d88580f9203153b69
2016-09-15 15:43:36 -07:00
Janic Duplessis d0d1712851 Reverted commit D3827366
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

Pulled By: fred2028

fbshipit-source-id: d346068734c5b987518794ab23e13914ed13b5c4
2016-09-15 12:13:39 -07:00
Fred Liu b7ee6adade Reverted commit D3870895
Reviewed By: foghina

Differential Revision: D3870895

fbshipit-source-id: 305534c752d1041bf03e27f28d6b5bf0a66a5a61
2016-09-15 11:58:36 -07:00
Andy Street 5c3f9547c6 Unbreak nodes that use ScrollViews
Reviewed By: foghina

Differential Revision: D3870895

fbshipit-source-id: e01130f19cca96ae1bcd0b8040e78552727fd6dc
2016-09-15 11:13:51 -07:00
Andy Street 6f42603d0e Add Dependency Injection, nodes support for RN/Components integration
Reviewed By: lexs, emilsjolander

Differential Revision: D3863226

fbshipit-source-id: f7528a9ff69697dd51fc7f7496a1c46110a42bed
2016-09-15 09:28:46 -07:00