Skip to content

Commit

Permalink
Remove experimental gating for LayoutAnimation on Android
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D14658087

fbshipit-source-id: 378ef4a5c5336d428b5045772d094a297b2767c7
  • Loading branch information
javache authored and facebook-github-bot committed Apr 3, 2019
1 parent f571c62 commit 9895d01
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 67 deletions.
4 changes: 0 additions & 4 deletions Libraries/LayoutAnimation/LayoutAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand Down
9 changes: 9 additions & 0 deletions Libraries/ReactNative/UIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions RNTester/js/RNTesterApp.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ 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');

const nativeImageSource = require('nativeImageSource');

import type {RNTesterNavigationState} from './RNTesterNavigationReducer';

UIManager.setLayoutAnimationEnabledExperimental(true);

const DRAWER_WIDTH_LEFT = 56;

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class NativeViewHierarchyManager {
private final LayoutAnimationController mLayoutAnimator = new LayoutAnimationController();
private final Map<Integer, SparseIntArray> mTagsToPendingIndicesToDelete = new HashMap<>();

private boolean mLayoutAnimationEnabled;
private PopupMenu mPopupMenu;

public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) {
Expand Down Expand Up @@ -106,10 +105,6 @@ public synchronized final ViewManager resolveViewManager(int tag) {
return viewManager;
}

public void setLayoutAnimationEnabled(boolean enabled) {
mLayoutAnimationEnabled = enabled;
}

public synchronized void updateInstanceHandle(int tag, long instanceHandle) {
UiThreadUtil.assertOnUiThread();

Expand Down Expand Up @@ -225,8 +220,7 @@ public long getInstanceHandle(int reactTag) {
}

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);
Expand Down Expand Up @@ -433,8 +427,7 @@ public synchronized void manageChildren(
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
Expand Down Expand Up @@ -483,8 +476,7 @@ public synchronized void manageChildren(
tagsToDelete));
}

if (mLayoutAnimationEnabled &&
mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) {
if (mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) {
int updatedCount = pendingIndicesToDelete.get(indexToDelete, 0) + 1;
pendingIndicesToDelete.put(indexToDelete, updatedCount);
mLayoutAnimator.deleteView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,21 +693,6 @@ protected void updateViewHierarchy() {
}
}

/**
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,22 +689,6 @@ public void dismissPopupMenu() {
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.
*
* <p>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.
*
* <p>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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,19 +354,6 @@ public AnimationOperation(int animationID) {
}
}

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;
Expand Down Expand Up @@ -736,11 +723,6 @@ public void enqueueSetChildren(
new SetChildrenOperation(reactTag, childrenTags));
}

public void enqueueSetLayoutAnimationEnabled(
final boolean enabled) {
mOperations.add(new SetLayoutAnimationEnabledOperation(enabled));
}

public void enqueueConfigureLayoutAnimation(
final ReadableMap config,
final Callback onAnimationComplete) {
Expand Down

0 comments on commit 9895d01

Please sign in to comment.