diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index ef92d99cec6..74b3eb10308 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -90,10 +90,6 @@ const 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); */ const LayoutAnimation = { /** diff --git a/Libraries/ReactNative/UIManager.js b/Libraries/ReactNative/UIManager.js index 833005dbe92..dfbece03f91 100644 --- a/Libraries/ReactNative/UIManager.js +++ b/Libraries/ReactNative/UIManager.js @@ -100,6 +100,15 @@ function lazifyViewManagerConfig(viewName) { } } +if (Platform.OS === 'android') { + UIManager.setLayoutAnimationEnabledExperimental = () => { + console.warn( + 'setLayoutAnimationEnabledExperimental is deprecated. ' + + 'Layout animations are enabled by default', + ); + }; +} + /** * Copies the ViewManager constants and commands into UIManager. This is * only needed for iOS, which puts the constants in the ViewManager diff --git a/RNTester/js/RNTesterApp.android.js b/RNTester/js/RNTesterApp.android.js index 16c6660e074..1f8e00a40cc 100644 --- a/RNTester/js/RNTesterApp.android.js +++ b/RNTester/js/RNTesterApp.android.js @@ -27,7 +27,6 @@ const RNTesterExampleList = require('./RNTesterExampleList'); * making Flow check .android.js files. */ const RNTesterList = require('./RNTesterList'); const RNTesterNavigationReducer = require('./RNTesterNavigationReducer'); -const UIManager = require('UIManager'); const URIActionMap = require('./URIActionMap'); const View = require('View'); @@ -35,8 +34,6 @@ const nativeImageSource = require('nativeImageSource'); import type {RNTesterNavigationState} from './RNTesterNavigationReducer'; -UIManager.setLayoutAnimationEnabledExperimental(true); - const DRAWER_WIDTH_LEFT = 56; type Props = { 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 f5953bacdc4..469dbb7c19a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -74,7 +74,6 @@ public class NativeViewHierarchyManager { private final LayoutAnimationController mLayoutAnimator = new LayoutAnimationController(); private final Map mTagsToPendingIndicesToDelete = new HashMap<>(); - private boolean mLayoutAnimationEnabled; private PopupMenu mPopupMenu; public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) { @@ -106,10 +105,6 @@ public class NativeViewHierarchyManager { return viewManager; } - public void setLayoutAnimationEnabled(boolean enabled) { - mLayoutAnimationEnabled = enabled; - } - public synchronized void updateInstanceHandle(int tag, long instanceHandle) { UiThreadUtil.assertOnUiThread(); @@ -225,8 +220,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); @@ -433,8 +427,7 @@ public class NativeViewHierarchyManager { int normalizedIndexToRemove = normalizeIndex(indexToRemove, pendingIndicesToDelete); View viewToRemove = viewManager.getChildAt(viewToManage, normalizedIndexToRemove); - 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 @@ -483,8 +476,7 @@ public class NativeViewHierarchyManager { tagsToDelete)); } - if (mLayoutAnimationEnabled && - mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) { + if (mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) { int updatedCount = pendingIndicesToDelete.get(indexToDelete, 0) + 1; pendingIndicesToDelete.put(indexToDelete, updatedCount); mLayoutAnimator.deleteView( 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 dfa310b76d4..36c19b70d99 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -693,21 +693,6 @@ public class UIImplementation { } } - /** - * 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 51a229f73ae..73a8cda51e8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -689,22 +689,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule mUIImplementation.dismissPopupMenu(); } - /** - * 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 cf66d2a5c50..2c87a999dda 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -354,19 +354,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; private final Callback mAnimationComplete; @@ -736,11 +723,6 @@ public class UIViewOperationQueue { new SetChildrenOperation(reactTag, childrenTags)); } - public void enqueueSetLayoutAnimationEnabled( - final boolean enabled) { - mOperations.add(new SetLayoutAnimationEnabledOperation(enabled)); - } - public void enqueueConfigureLayoutAnimation( final ReadableMap config, final Callback onAnimationComplete) {