From abc483a653e40889d8a04078369b786bce5fe4d9 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 8 Mar 2017 06:39:39 -0800 Subject: [PATCH] BREAKING - Remove LayoutAnimation experimental flag on Android Summary: I don't remember exactly where we talked about this but LayoutAnimation on Android is pretty stable now so there's no reason to keep it behind an experimental flag anymore. The only part that is not really stable is delete animations, so what I did is remove the default delete animation that we provide in presets. **Test plan** Tested that layout animations work properly without any config. Closes https://github.com/facebook/react-native/pull/12141 Differential Revision: D4494386 Pulled By: mkonicek fbshipit-source-id: 5dd025584e35f9bff25dc299cc9ca5c5bf5f17a3 --- .../UIExplorer/js/ListViewPagingExample.js | 5 ----- .../UIExplorer/js/UIExplorerApp.android.js | 2 -- Libraries/LayoutAnimation/LayoutAnimation.js | 12 ------------ .../uimanager/NativeViewHierarchyManager.java | 15 +++------------ .../react/uimanager/UIImplementation.java | 15 --------------- .../react/uimanager/UIManagerModule.java | 16 ---------------- .../react/uimanager/UIViewOperationQueue.java | 18 ------------------ docs/Animations.md | 6 ------ 8 files changed, 3 insertions(+), 86 deletions(-) diff --git a/Examples/UIExplorer/js/ListViewPagingExample.js b/Examples/UIExplorer/js/ListViewPagingExample.js index 58d7359e5b7..07d8f802c3d 100644 --- a/Examples/UIExplorer/js/ListViewPagingExample.js +++ b/Examples/UIExplorer/js/ListViewPagingExample.js @@ -58,11 +58,6 @@ var NUM_SECTIONS = 100; var NUM_ROWS_PER_SECTION = 10; class Thumb extends React.Component { - componentWillMount() { - UIManager.setLayoutAnimationEnabledExperimental && - UIManager.setLayoutAnimationEnabledExperimental(true); - } - _getThumbIdx = () => { return Math.floor(Math.random() * THUMB_URLS.length); }; diff --git a/Examples/UIExplorer/js/UIExplorerApp.android.js b/Examples/UIExplorer/js/UIExplorerApp.android.js index 1e13a212ceb..a6ca080e199 100644 --- a/Examples/UIExplorer/js/UIExplorerApp.android.js +++ b/Examples/UIExplorer/js/UIExplorerApp.android.js @@ -46,8 +46,6 @@ const nativeImageSource = require('nativeImageSource'); import type { UIExplorerNavigationState } from './UIExplorerNavigationReducer'; -UIManager.setLayoutAnimationEnabledExperimental(true); - const DRAWER_WIDTH_LEFT = 56; type Props = { diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index 61d62601d71..b1d8e6e87c9 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -88,10 +88,6 @@ function create(duration: number, type, creationProp): Config { update: { type, }, - delete: { - type, - property: creationProp, - }, }; } @@ -112,10 +108,6 @@ var Presets = { type: Types.spring, springDamping: 0.4, }, - delete: { - type: Types.linear, - property: Properties.opacity, - }, }, }; @@ -124,10 +116,6 @@ var Presets = { * next layout happens. * * A common way to use this API is to call it before calling `setState`. - * - * Note that in order to get this to work on **Android** you need to set the following flags via `UIManager`: - * - * UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true); */ var LayoutAnimation = { /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index a5b157d0f10..29f8f17cf5b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -76,8 +76,6 @@ public class NativeViewHierarchyManager { private final RootViewManager mRootViewManager; private final LayoutAnimationController mLayoutAnimator = new LayoutAnimationController(); - private boolean mLayoutAnimationEnabled; - public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) { this(viewManagers, new RootViewManager()); } @@ -112,10 +110,6 @@ public class NativeViewHierarchyManager { return mAnimationRegistry; } - public void setLayoutAnimationEnabled(boolean enabled) { - mLayoutAnimationEnabled = enabled; - } - public void updateProperties(int tag, ReactStylesDiffMap props) { UiThreadUtil.assertOnUiThread(); @@ -192,8 +186,7 @@ public class NativeViewHierarchyManager { } private void updateLayout(View viewToUpdate, int x, int y, int width, int height) { - if (mLayoutAnimationEnabled && - mLayoutAnimator.shouldAnimateLayout(viewToUpdate)) { + if (mLayoutAnimator.shouldAnimateLayout(viewToUpdate)) { mLayoutAnimator.applyLayoutUpdate(viewToUpdate, x, y, width, height); } else { viewToUpdate.layout(x, y, x + width, y + height); @@ -363,8 +356,7 @@ public class NativeViewHierarchyManager { View viewToRemove = viewManager.getChildAt(viewToManage, indexToRemove); - if (mLayoutAnimationEnabled && - mLayoutAnimator.shouldAnimateLayout(viewToRemove) && + if (mLayoutAnimator.shouldAnimateLayout(viewToRemove) && arrayContains(tagsToDelete, viewToRemove.getId())) { // The view will be removed and dropped by the 'delete' layout animation // instead, so do nothing @@ -411,8 +403,7 @@ public class NativeViewHierarchyManager { tagsToDelete)); } - if (mLayoutAnimationEnabled && - mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) { + if (mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) { mLayoutAnimator.deleteView(viewToDestroy, new LayoutAnimationListener() { @Override public void onAnimationEnd() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index e6499c43def..78a03fa262d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -569,21 +569,6 @@ public class UIImplementation { mOperationsQueue.enqueueRemoveAnimation(animationID); } - /** - * LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabled - * explicitly in order to avoid regression in existing application written for iOS using this API. - * - * Warning : This method will be removed in future version of React Native, and layout animation - * will be enabled by default, so always check for its existence before invoking it. - * - * TODO(9139831) : remove this method once layout animation is fully stable. - * - * @param enabled whether layout animation is enabled or not - */ - public void setLayoutAnimationEnabledExperimental(boolean enabled) { - mOperationsQueue.enqueueSetLayoutAnimationEnabled(enabled); - } - /** * Configure an animation to be used for the native layout changes, and native views * creation. The animation will only apply during the current batch operations. diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 1d05aa26793..b33b3b59810 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -474,22 +474,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mUIImplementation.showPopupMenu(reactTag, items, error, success); } - /** - * LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabled - * explicitly in order to avoid regression in existing application written for iOS using this API. - * - * Warning : This method will be removed in future version of React Native, and layout animation - * will be enabled by default, so always check for its existence before invoking it. - * - * TODO(9139831) : remove this method once layout animation is fully stable. - * - * @param enabled whether layout animation is enabled or not - */ - @ReactMethod - public void setLayoutAnimationEnabledExperimental(boolean enabled) { - mUIImplementation.setLayoutAnimationEnabledExperimental(enabled); - } - /** * Configure an animation to be used for the native layout changes, and native views * creation. The animation will only apply during the current batch operations. diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 7098bf057d4..a11766cdf59 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -351,19 +351,6 @@ public class UIViewOperationQueue { } } - private class SetLayoutAnimationEnabledOperation implements UIOperation { - private final boolean mEnabled; - - private SetLayoutAnimationEnabledOperation(final boolean enabled) { - mEnabled = enabled; - } - - @Override - public void execute() { - mNativeViewHierarchyManager.setLayoutAnimationEnabled(mEnabled); - } - } - private class ConfigureLayoutAnimationOperation implements UIOperation { private final ReadableMap mConfig; @@ -699,11 +686,6 @@ public class UIViewOperationQueue { mOperations.add(new RemoveAnimationOperation(animationID)); } - public void enqueueSetLayoutAnimationEnabled( - final boolean enabled) { - mOperations.add(new SetLayoutAnimationEnabledOperation(enabled)); - } - public void enqueueConfigureLayoutAnimation( final ReadableMap config, final Callback onSuccess, diff --git a/docs/Animations.md b/docs/Animations.md index c97fe2b460b..30514f3156c 100644 --- a/docs/Animations.md +++ b/docs/Animations.md @@ -387,12 +387,6 @@ it provides much less control than `Animated` and other animation libraries, so you may need to use another approach if you can't get `LayoutAnimation` to do what you want. -Note that in order to get this to work on **Android** you need to set the following flags via `UIManager`: - -```javascript -UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true); -``` - ![](img/LayoutAnimationExample.gif) ```javascript