Fix TouchableNativeFeedback state propagating to children

Summary:For some reason Android propagates the the pressed state to all of the ViewGroup's children when calling `setPressed`. This caused the issue described in #3952. Luckily we can override the `dispatchSetPressed` method of ViewGroup to prevent it from doing so.

Had to dig in the Android source a bit to find this one, here's the relevant pieces :
https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/View.java#L7883
https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/ViewGroup.java#L3722

**Test plan (required)**
Reproduced the bug using [this gist](https://gist.github.com/janicduplessis/9f1d42c670aefd660afb4c96e8bb6a4f) in UIExplorer. Touching the parent should not trigger the ripple on the children.

I also made sure all the touchable still work properly.

Fixes #3952
Closes https://github.com/facebook/react-native/pull/6783

Differential Revision: D3133407

fb-gh-sync-id: 317e55de2652ea185a1082cd96b8fe3a8b807962
fbshipit-source-id: 317e55de2652ea185a1082cd96b8fe3a8b807962
This commit is contained in:
Janic Duplessis 2016-04-04 08:47:11 -07:00 committed by Facebook Github Bot 2
parent 5663ab4771
commit 114dde99ce
1 changed files with 6 additions and 0 deletions

View File

@ -377,6 +377,12 @@ public class ReactViewGroup extends ViewGroup implements
return mPointerEvents;
}
@Override
protected void dispatchSetPressed(boolean pressed) {
// Prevents the ViewGroup from dispatching the pressed state
// to it's children.
}
/*package*/ void setPointerEvents(PointerEvents pointerEvents) {
mPointerEvents = pointerEvents;
}