From a333c2b202d56da49c922a8e607659506fdfa524 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 3 Apr 2019 04:38:50 -0700 Subject: [PATCH] Remove legacy AnimationManagerModule Summary: This code was shipped as part of the initial open-source release but was never used. Reviewed By: sahrens Differential Revision: D14649389 fbshipit-source-id: 0c068ca69b91d275008f4a7af77a23a4f1470c18 --- .../AbstractFloatPairPropertyUpdater.java | 62 ----------- .../AbstractSingleFloatProperyUpdater.java | 52 --------- .../facebook/react/animation/Animation.java | 105 ------------------ .../react/animation/AnimationListener.java | 25 ----- .../animation/AnimationPropertyUpdater.java | 44 -------- .../react/animation/AnimationRegistry.java | 41 ------- .../java/com/facebook/react/animation/BUCK | 14 --- .../react/animation/ImmediateAnimation.java | 26 ----- .../NoopAnimationPropertyUpdater.java | 28 ----- .../OpacityAnimationPropertyUpdater.java | 34 ------ .../PositionAnimationPairPropertyUpdater.java | 40 ------- .../RotationAnimationPropertyUpdater.java | 30 ----- .../ScaleXAnimationPropertyUpdater.java | 34 ------ .../ScaleXYAnimationPairPropertyUpdater.java | 40 ------- .../ScaleYAnimationPropertyUpdater.java | 34 ------ .../java/com/facebook/react/uimanager/BUCK | 1 - .../uimanager/NativeViewHierarchyManager.java | 48 -------- .../react/uimanager/UIImplementation.java | 24 ---- .../react/uimanager/UIManagerModule.java | 18 --- .../react/uimanager/UIViewOperationQueue.java | 82 +------------- .../src/test/java/com/facebook/react/BUCK | 4 +- .../test/java/com/facebook/react/modules/BUCK | 4 +- .../java/com/facebook/react/uimanager/BUCK | 1 - 23 files changed, 5 insertions(+), 786 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/AbstractFloatPairPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/AbstractSingleFloatProperyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/Animation.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/AnimationListener.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/AnimationPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/AnimationRegistry.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/BUCK delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/ImmediateAnimation.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/NoopAnimationPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/OpacityAnimationPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/PositionAnimationPairPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/RotationAnimationPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXAnimationPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXYAnimationPairPropertyUpdater.java delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/animation/ScaleYAnimationPropertyUpdater.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/AbstractFloatPairPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/AbstractFloatPairPropertyUpdater.java deleted file mode 100644 index b086f8fdcc9..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/AbstractFloatPairPropertyUpdater.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Base class for {@link AnimationPropertyUpdater} subclasses that updates a pair of float property - * values. It helps to handle conversion from animation progress to the actual values as - * well as the quite common case when no starting value is provided. - */ -public abstract class AbstractFloatPairPropertyUpdater implements AnimationPropertyUpdater { - - private final float[] mFromValues = new float[2]; - private final float[] mToValues = new float[2]; - private final float[] mUpdateValues = new float[2]; - private boolean mFromSource; - - protected AbstractFloatPairPropertyUpdater(float toFirst, float toSecond) { - mToValues[0] = toFirst; - mToValues[1] = toSecond; - mFromSource = true; - } - - protected AbstractFloatPairPropertyUpdater( - float fromFirst, - float fromSecond, - float toFirst, - float toSecond) { - this(toFirst, toSecond); - mFromValues[0] = fromFirst; - mFromValues[1] = fromSecond; - mFromSource = false; - } - - protected abstract void getProperty(View view, float[] returnValues); - protected abstract void setProperty(View view, float[] propertyValues); - - @Override - public void prepare(View view) { - if (mFromSource) { - getProperty(view, mFromValues); - } - } - - @Override - public void onUpdate(View view, float progress) { - mUpdateValues[0] = mFromValues[0] + (mToValues[0] - mFromValues[0]) * progress; - mUpdateValues[1] = mFromValues[1] + (mToValues[1] - mFromValues[1]) * progress; - setProperty(view, mUpdateValues); - } - - @Override - public void onFinish(View view) { - setProperty(view, mToValues); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/AbstractSingleFloatProperyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/AbstractSingleFloatProperyUpdater.java deleted file mode 100644 index cfa24177eca..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/AbstractSingleFloatProperyUpdater.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Base class for {@link AnimationPropertyUpdater} subclasses that updates a single float property - * value. It helps to handle conversion from animation progress to the actual value as well as the - * quite common case when no starting value is provided. - */ -public abstract class AbstractSingleFloatProperyUpdater implements AnimationPropertyUpdater { - - private float mFromValue, mToValue; - private boolean mFromSource; - - protected AbstractSingleFloatProperyUpdater(float toValue) { - mToValue = toValue; - mFromSource = true; - } - - protected AbstractSingleFloatProperyUpdater(float fromValue, float toValue) { - this(toValue); - mFromValue = fromValue; - mFromSource = false; - } - - protected abstract float getProperty(View view); - protected abstract void setProperty(View view, float propertyValue); - - @Override - public final void prepare(View view) { - if (mFromSource) { - mFromValue = getProperty(view); - } - } - - @Override - public final void onUpdate(View view, float progress) { - setProperty(view, mFromValue + (mToValue - mFromValue) * progress); - } - - @Override - public void onFinish(View view) { - setProperty(view, mToValue); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/Animation.java b/ReactAndroid/src/main/java/com/facebook/react/animation/Animation.java deleted file mode 100644 index af29fdeaae0..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/Animation.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import javax.annotation.Nullable; - -import android.view.View; - -import com.facebook.infer.annotation.Assertions; - -/** - * Base class for various catalyst animation engines. Subclasses of this class should implement - * {@link #run} method which should bootstrap the animation. Then in each animation frame we expect - * animation engine to call {@link #onUpdate} with a float progress which then will be transferred - * to the underlying {@link AnimationPropertyUpdater} instance. - * - * Animation engine should support animation cancelling by monitoring the returned value of - * {@link #onUpdate}. In case of returning false, animation should be considered cancelled and - * engine should not attempt to call {@link #onUpdate} again. - */ -public abstract class Animation { - - private final int mAnimationID; - private final AnimationPropertyUpdater mPropertyUpdater; - private volatile boolean mCancelled = false; - private volatile boolean mIsFinished = false; - private @Nullable AnimationListener mAnimationListener; - private @Nullable View mAnimatedView; - - public Animation(int animationID, AnimationPropertyUpdater propertyUpdater) { - mAnimationID = animationID; - mPropertyUpdater = propertyUpdater; - } - - public void setAnimationListener(AnimationListener animationListener) { - mAnimationListener = animationListener; - } - - public final void start(View view) { - mAnimatedView = view; - mPropertyUpdater.prepare(view); - run(); - } - - public abstract void run(); - - /** - * Animation engine should call this method for every animation frame passing animation progress - * value as a parameter. Animation progress should be within the range 0..1 (the exception here - * would be a spring animation engine which may slightly exceed start and end progress values). - * - * This method will return false if the animation has been cancelled. In that case animation - * engine should not attempt to call this method again. Otherwise this method will return true - */ - protected final boolean onUpdate(float value) { - Assertions.assertCondition(!mIsFinished, "Animation must not already be finished!"); - if (!mCancelled) { - mPropertyUpdater.onUpdate(Assertions.assertNotNull(mAnimatedView), value); - } - return !mCancelled; - } - - /** - * Animation engine should call this method when the animation is finished. Should be called only - * once - */ - protected final void finish() { - Assertions.assertCondition(!mIsFinished, "Animation must not already be finished!"); - mIsFinished = true; - if (!mCancelled) { - if (mAnimatedView != null) { - mPropertyUpdater.onFinish(mAnimatedView); - } - if (mAnimationListener != null) { - mAnimationListener.onFinished(); - } - } - } - - /** - * Cancels the animation. - * - * It is possible for this to be called after finish() and should handle that gracefully. - */ - public final void cancel() { - if (mIsFinished || mCancelled) { - // If we were already finished, ignore - return; - } - - mCancelled = true; - if (mAnimationListener != null) { - mAnimationListener.onCancel(); - } - } - - public int getAnimationID() { - return mAnimationID; - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationListener.java b/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationListener.java deleted file mode 100644 index bc4b9e29168..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -/** - * Interface for getting animation lifecycle updates. It is guaranteed that for a given animation, - * only one of onFinished and onCancel will be called, and it will be called exactly once. - */ -public interface AnimationListener { - - /** - * Called once animation is finished - */ - public void onFinished(); - - /** - * Called in case when animation was cancelled - */ - public void onCancel(); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationPropertyUpdater.java deleted file mode 100644 index b815210be58..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationPropertyUpdater.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Interface used to update particular property types during animation. While animation is in - * progress {@link Animation} instance will call {@link #onUpdate} several times with a value - * representing animation progress. Normally value will be from 0..1 range, but for spring animation - * it can slightly exceed that limit due to bounce effect at the start/end of animation. - */ -public interface AnimationPropertyUpdater { - - /** - * This method will be called before animation starts. - * - * @param view view that will be animated - */ - public void prepare(View view); - - /** - * This method will be called for each animation frame - * - * @param view view to update property - * @param progress animation progress from 0..1 range (may slightly exceed that limit in case of - * spring engine) retrieved from {@link Animation} engine. - */ - public void onUpdate(View view, float progress); - - /** - * This method will be called at the end of animation. It should be used to set the final values - * for animated properties in order to avoid floating point inaccuracy calculated in - * {@link #onUpdate} by passing value close to 1.0 or in a case some frames got dropped. - * - * @param view view to update property - */ - public void onFinish(View view); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationRegistry.java b/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationRegistry.java deleted file mode 100644 index 58b9518801c..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/AnimationRegistry.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.util.SparseArray; - -import com.facebook.react.bridge.UiThreadUtil; - -/** - * Coordinates catalyst animations driven by {@link UIManagerModule} and - * {@link AnimationManagerModule} - */ -public class AnimationRegistry { - - private final SparseArray mRegistry = new SparseArray(); - - public void registerAnimation(Animation animation) { - UiThreadUtil.assertOnUiThread(); - mRegistry.put(animation.getAnimationID(), animation); - } - - public Animation getAnimation(int animationID) { - UiThreadUtil.assertOnUiThread(); - return mRegistry.get(animationID); - } - - public Animation removeAnimation(int animationID) { - UiThreadUtil.assertOnUiThread(); - Animation animation = mRegistry.get(animationID); - if (animation != null) { - mRegistry.delete(animationID); - } - return animation; - } - -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/BUCK b/ReactAndroid/src/main/java/com/facebook/react/animation/BUCK deleted file mode 100644 index 1c2781c23b4..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/BUCK +++ /dev/null @@ -1,14 +0,0 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_android_library") - -rn_android_library( - name = "animation", - srcs = glob(["**/*.java"]), - visibility = [ - "PUBLIC", - ], - deps = [ - react_native_dep("third-party/java/infer-annotations:infer-annotations"), - react_native_dep("third-party/java/jsr-305:jsr-305"), - react_native_target("java/com/facebook/react/bridge:bridge"), - ], -) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/ImmediateAnimation.java b/ReactAndroid/src/main/java/com/facebook/react/animation/ImmediateAnimation.java deleted file mode 100644 index 4949d68dfe2..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/ImmediateAnimation.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -/** - * Ignores duration and immediately jump to the end of animation. This is a temporal solution for - * the lack of real animation engines implemented. - */ -public class ImmediateAnimation extends Animation { - - public ImmediateAnimation(int animationID, AnimationPropertyUpdater propertyUpdater) { - super(animationID, propertyUpdater); - } - - @Override - public void run() { - onUpdate(1.0f); - finish(); - } - -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/NoopAnimationPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/NoopAnimationPropertyUpdater.java deleted file mode 100644 index 04a5ee9ee4b..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/NoopAnimationPropertyUpdater.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Empty {@link AnimationPropertyUpdater} that can be used as a stub for unsupported property types - */ -public class NoopAnimationPropertyUpdater implements AnimationPropertyUpdater { - - @Override - public void prepare(View view) { - } - - @Override - public void onUpdate(View view, float value) { - } - - @Override - public void onFinish(View view) { - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/OpacityAnimationPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/OpacityAnimationPropertyUpdater.java deleted file mode 100644 index 7ca1af8a30a..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/OpacityAnimationPropertyUpdater.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Subclass of {@link AnimationPropertyUpdater} for animating view's opacity - */ -public class OpacityAnimationPropertyUpdater extends AbstractSingleFloatProperyUpdater { - - public OpacityAnimationPropertyUpdater(float toOpacity) { - super(toOpacity); - } - - public OpacityAnimationPropertyUpdater(float fromOpacity, float toOpacity) { - super(fromOpacity, toOpacity); - } - - @Override - protected float getProperty(View view) { - return view.getAlpha(); - } - - @Override - protected void setProperty(View view, float propertyValue) { - view.setAlpha(propertyValue); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/PositionAnimationPairPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/PositionAnimationPairPropertyUpdater.java deleted file mode 100644 index 9d2e9737106..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/PositionAnimationPairPropertyUpdater.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Subclass of {@link AnimationPropertyUpdater} for animating center position of a view - */ -public class PositionAnimationPairPropertyUpdater extends AbstractFloatPairPropertyUpdater { - - public PositionAnimationPairPropertyUpdater(float toFirst, float toSecond) { - super(toFirst, toSecond); - } - - public PositionAnimationPairPropertyUpdater( - float fromFirst, - float fromSecond, - float toFirst, - float toSecond) { - super(fromFirst, fromSecond, toFirst, toSecond); - } - - @Override - protected void getProperty(View view, float[] returnValues) { - returnValues[0] = view.getX() + 0.5f * view.getWidth(); - returnValues[1] = view.getY() + 0.5f * view.getHeight(); - } - - @Override - protected void setProperty(View view, float[] propertyValues) { - view.setX(propertyValues[0] - 0.5f * view.getWidth()); - view.setY(propertyValues[1] - 0.5f * view.getHeight()); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/RotationAnimationPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/RotationAnimationPropertyUpdater.java deleted file mode 100644 index 772fa09a236..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/RotationAnimationPropertyUpdater.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Subclass of {@link AnimationPropertyUpdater} for animating view's rotation - */ -public class RotationAnimationPropertyUpdater extends AbstractSingleFloatProperyUpdater { - - public RotationAnimationPropertyUpdater(float toValue) { - super(toValue); - } - - @Override - protected float getProperty(View view) { - return view.getRotation(); - } - - @Override - protected void setProperty(View view, float propertyValue) { - view.setRotation((float) Math.toDegrees(propertyValue)); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXAnimationPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXAnimationPropertyUpdater.java deleted file mode 100644 index dd8bb4c24c4..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXAnimationPropertyUpdater.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Subclass of {@link AnimationPropertyUpdater} for animating view's X scale - */ -public class ScaleXAnimationPropertyUpdater extends AbstractSingleFloatProperyUpdater { - - public ScaleXAnimationPropertyUpdater(float toValue) { - super(toValue); - } - - public ScaleXAnimationPropertyUpdater(float fromValue, float toValue) { - super(fromValue, toValue); - } - - @Override - protected float getProperty(View view) { - return view.getScaleX(); - } - - @Override - protected void setProperty(View view, float propertyValue) { - view.setScaleX(propertyValue); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXYAnimationPairPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXYAnimationPairPropertyUpdater.java deleted file mode 100644 index 779527b1a86..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleXYAnimationPairPropertyUpdater.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Subclass of {@link AnimationPropertyUpdater} for animating view's X and Y scale - */ -public class ScaleXYAnimationPairPropertyUpdater extends AbstractFloatPairPropertyUpdater { - - public ScaleXYAnimationPairPropertyUpdater(float toFirst, float toSecond) { - super(toFirst, toSecond); - } - - public ScaleXYAnimationPairPropertyUpdater( - float fromFirst, - float fromSecond, - float toFirst, - float toSecond) { - super(fromFirst, fromSecond, toFirst, toSecond); - } - - @Override - protected void getProperty(View view, float[] returnValues) { - returnValues[0] = view.getScaleX(); - returnValues[1] = view.getScaleY(); - } - - @Override - protected void setProperty(View view, float[] propertyValues) { - view.setScaleX(propertyValues[0]); - view.setScaleY(propertyValues[1]); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleYAnimationPropertyUpdater.java b/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleYAnimationPropertyUpdater.java deleted file mode 100644 index e3bf36cfb6c..00000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/animation/ScaleYAnimationPropertyUpdater.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.animation; - -import android.view.View; - -/** - * Subclass of {@link AnimationPropertyUpdater} for animating view's Y scale - */ -public class ScaleYAnimationPropertyUpdater extends AbstractSingleFloatProperyUpdater { - - public ScaleYAnimationPropertyUpdater(float toValue) { - super(toValue); - } - - public ScaleYAnimationPropertyUpdater(float fromValue, float toValue) { - super(fromValue, toValue); - } - - @Override - protected float getProperty(View view) { - return view.getScaleY(); - } - - @Override - protected void setProperty(View view, float propertyValue) { - view.setScaleY(propertyValue); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK index 63f3e09cd5a..0b91cc60729 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK @@ -29,7 +29,6 @@ rn_android_library( react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_target("java/com/facebook/debug/tags:tags"), react_native_target("java/com/facebook/debug/holder:holder"), - react_native_target("java/com/facebook/react/animation:animation"), react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/config:config"), 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 b4321252de9..8cabf9ad6ef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -21,9 +21,6 @@ import android.widget.PopupMenu; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.R; -import com.facebook.react.animation.Animation; -import com.facebook.react.animation.AnimationListener; -import com.facebook.react.animation.AnimationRegistry; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReactContext; @@ -68,7 +65,6 @@ public class NativeViewHierarchyManager { private static final String TAG = NativeViewHierarchyManager.class.getSimpleName(); - private final AnimationRegistry mAnimationRegistry; private final SparseArray mTagsToViews; private final SparseArray mTagsToViewManagers; private final SparseBooleanArray mRootTags; @@ -86,7 +82,6 @@ public class NativeViewHierarchyManager { } public NativeViewHierarchyManager(ViewManagerRegistry viewManagers, RootViewManager manager) { - mAnimationRegistry = new AnimationRegistry(); mViewManagers = viewManagers; mTagsToViews = new SparseArray<>(); mTagsToViewManagers = new SparseArray<>(); @@ -111,10 +106,6 @@ public class NativeViewHierarchyManager { return viewManager; } - public AnimationRegistry getAnimationRegistry() { - return mAnimationRegistry; - } - public void setLayoutAnimationEnabled(boolean enabled) { mLayoutAnimationEnabled = enabled; } @@ -746,45 +737,6 @@ public class NativeViewHierarchyManager { mLayoutAnimator.reset(); } - /* package */ synchronized void startAnimationForNativeView( - int reactTag, - Animation animation, - @Nullable final Callback animationCallback) { - UiThreadUtil.assertOnUiThread(); - View view = mTagsToViews.get(reactTag); - final int animationId = animation.getAnimationID(); - if (view != null) { - animation.setAnimationListener(new AnimationListener() { - @Override - public void onFinished() { - Animation removedAnimation = mAnimationRegistry.removeAnimation(animationId); - - // There's a chance that there was already a removeAnimation call enqueued on the main - // thread when this callback got enqueued on the main thread, but the Animation class - // should handle only calling one of onFinished and onCancel exactly once. - Assertions.assertNotNull(removedAnimation, "Animation was already removed somehow!"); - if (animationCallback != null) { - animationCallback.invoke(true); - } - } - - @Override - public void onCancel() { - Animation removedAnimation = mAnimationRegistry.removeAnimation(animationId); - - Assertions.assertNotNull(removedAnimation, "Animation was already removed somehow!"); - if (animationCallback != null) { - animationCallback.invoke(false); - } - } - }); - animation.start(view); - } else { - // TODO(5712813): cleanup callback in JS callbacks table in case of an error - throw new IllegalViewOperationException("View with tag " + reactTag + " not found"); - } - } - public synchronized void dispatchCommand( int reactTag, int commandId, 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 c013a55e455..24512031ff3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -11,7 +11,6 @@ import android.view.View; import android.view.View.MeasureSpec; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; -import com.facebook.react.animation.Animation; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; @@ -694,29 +693,6 @@ public class UIImplementation { } } - /** - * Registers a new Animation that can then be added to a View using {@link #addAnimation}. - */ - public void registerAnimation(Animation animation) { - mOperationsQueue.enqueueRegisterAnimation(animation); - } - - /** - * Adds an Animation previously registered with {@link #registerAnimation} to a View and starts it - */ - public void addAnimation(int reactTag, int animationID, Callback onSuccess) { - assertViewExists(reactTag, "addAnimation"); - mOperationsQueue.enqueueAddAnimation(reactTag, animationID, onSuccess); - } - - /** - * Removes an existing Animation, canceling it if it was in progress. - */ - public void removeAnimation(int reactTag, int animationID) { - assertViewExists(reactTag, "removeAnimation"); - 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. 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 0de24d15ecf..ec94a1abec6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -20,7 +20,6 @@ import android.view.View; import com.facebook.common.logging.FLog; import com.facebook.debug.holder.PrinterHolder; import com.facebook.debug.tags.ReactDebugOverlayTags; -import com.facebook.react.animation.Animation; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.GuardedRunnable; @@ -635,23 +634,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule mUIImplementation.viewIsDescendantOf(reactTag, ancestorReactTag, callback); } - /** Registers a new Animation that can then be added to a View using {@link #addAnimation}. */ - public void registerAnimation(Animation animation) { - mUIImplementation.registerAnimation(animation); - } - - /** - * Adds an Animation previously registered with {@link #registerAnimation} to a View and starts it - */ - public void addAnimation(int reactTag, int animationID, Callback onSuccess) { - mUIImplementation.addAnimation(reactTag, animationID, onSuccess); - } - - /** Removes an existing Animation, canceling it if it was in progress. */ - public void removeAnimation(int reactTag, int animationID) { - mUIImplementation.removeAnimation(reactTag, animationID); - } - @Override @ReactMethod public void setJSResponder(int reactTag, boolean blockNativeResponder) { 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 4d84d7545c0..cf366322ef7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -10,8 +10,6 @@ package com.facebook.react.uimanager; import android.os.SystemClock; import android.view.View; import com.facebook.common.logging.FLog; -import com.facebook.react.animation.Animation; -import com.facebook.react.animation.AnimationRegistry; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.GuardedRunnable; import com.facebook.react.bridge.ReactApplicationContext; @@ -33,9 +31,9 @@ import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; /** - * This class acts as a buffer for command executed on {@link NativeViewHierarchyManager} or on - * {@link AnimationRegistry}. It expose similar methods as mentioned classes but instead of - * executing commands immediately it enqueues those operations in a queue that is then flushed from + * This class acts as a buffer for command executed on {@link NativeViewHierarchyManager}. + * It expose similar methods as mentioned classes but instead of executing commands + * immediately it enqueues those operations in a queue that is then flushed from * {@link UIManagerModule} once JS batch of ui operations is finished. This is to make sure that we * execute all the JS operation coming from a single batch a single loop of the main (UI) android * looper. @@ -356,63 +354,6 @@ public class UIViewOperationQueue { } } - private class RegisterAnimationOperation extends AnimationOperation { - - private final Animation mAnimation; - - private RegisterAnimationOperation(Animation animation) { - super(animation.getAnimationID()); - mAnimation = animation; - } - - @Override - public void execute() { - mAnimationRegistry.registerAnimation(mAnimation); - } - } - - private class AddAnimationOperation extends AnimationOperation { - private final int mReactTag; - private final Callback mSuccessCallback; - - private AddAnimationOperation(int reactTag, int animationID, Callback successCallback) { - super(animationID); - mReactTag = reactTag; - mSuccessCallback = successCallback; - } - - @Override - public void execute() { - Animation animation = mAnimationRegistry.getAnimation(mAnimationID); - if (animation != null) { - mNativeViewHierarchyManager.startAnimationForNativeView( - mReactTag, - animation, - mSuccessCallback); - } else { - // node or animation not found - // TODO(5712813): cleanup callback in JS callbacks table in case of an error - throw new IllegalViewOperationException("Animation with id " + mAnimationID - + " was not found"); - } - } - } - - private final class RemoveAnimationOperation extends AnimationOperation { - - private RemoveAnimationOperation(int animationID) { - super(animationID); - } - - @Override - public void execute() { - Animation animation = mAnimationRegistry.getAnimation(mAnimationID); - if (animation != null) { - animation.cancel(); - } - } - } - private class SetLayoutAnimationEnabledOperation implements UIOperation { private final boolean mEnabled; @@ -604,7 +545,6 @@ public class UIViewOperationQueue { } private final NativeViewHierarchyManager mNativeViewHierarchyManager; - private final AnimationRegistry mAnimationRegistry; private final Object mDispatchRunnablesLock = new Object(); private final Object mNonBatchedOperationsLock = new Object(); private final DispatchUIFrameCallback mDispatchUIFrameCallback; @@ -637,7 +577,6 @@ public class UIViewOperationQueue { NativeViewHierarchyManager nativeViewHierarchyManager, int minTimeLeftInFrameForNonBatchedOperationMs) { mNativeViewHierarchyManager = nativeViewHierarchyManager; - mAnimationRegistry = nativeViewHierarchyManager.getAnimationRegistry(); mDispatchUIFrameCallback = new DispatchUIFrameCallback( reactContext, @@ -795,21 +734,6 @@ public class UIViewOperationQueue { new SetChildrenOperation(reactTag, childrenTags)); } - public void enqueueRegisterAnimation(Animation animation) { - mOperations.add(new RegisterAnimationOperation(animation)); - } - - public void enqueueAddAnimation( - final int reactTag, - final int animationID, - final Callback onSuccess) { - mOperations.add(new AddAnimationOperation(reactTag, animationID, onSuccess)); - } - - public void enqueueRemoveAnimation(int animationID) { - mOperations.add(new RemoveAnimationOperation(animationID)); - } - public void enqueueSetLayoutAnimationEnabled( final boolean enabled) { mOperations.add(new SetLayoutAnimationEnabledOperation(enabled)); diff --git a/ReactAndroid/src/test/java/com/facebook/react/BUCK b/ReactAndroid/src/test/java/com/facebook/react/BUCK index 3eecaae58b7..8cdeff023e2 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/BUCK @@ -3,8 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_robolectric_test( name = "react", srcs = glob(["*.java"]), - # Please change the contact to the oncall of your team - contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], + contacts = ["oncall+react_native@xmail.facebook.com"], deps = [ YOGA_TARGET, react_native_dep("libraries/fbcore/src/test/java/com/facebook/powermock:powermock"), @@ -17,7 +16,6 @@ rn_robolectric_test( react_native_dep("third-party/java/okio:okio"), react_native_dep("third-party/java/robolectric3/robolectric:robolectric"), react_native_target("java/com/facebook/react:react"), - react_native_target("java/com/facebook/react/animation:animation"), react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/touch:touch"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK b/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK index 2206284f930..8319a30de31 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/BUCK @@ -3,8 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "r rn_robolectric_test( name = "modules", srcs = glob(["**/*.java"]), - # Please change the contact to the oncall of your team - contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"], + contacts = ["oncall+react_native@xmail.facebook.com"], visibility = [ "PUBLIC", ], @@ -20,7 +19,6 @@ rn_robolectric_test( react_native_dep("third-party/java/okio:okio"), react_native_dep("third-party/java/robolectric3/robolectric:robolectric"), react_native_target("java/com/facebook/react:react"), - react_native_target("java/com/facebook/react/animation:animation"), react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/common/network:network"), diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK index 8d49aa5e259..b9df6bf62a3 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/BUCK @@ -27,7 +27,6 @@ rn_robolectric_test( react_native_dep("third-party/java/okio:okio"), react_native_dep("third-party/java/robolectric3/robolectric:robolectric"), react_native_target("java/com/facebook/react:react"), - react_native_target("java/com/facebook/react/animation:animation"), react_native_target("java/com/facebook/react/bridge:bridge"), react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/touch:touch"),