Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b64e777f authored by Chet Haase's avatar Chet Haase
Browse files

Add methods to query animation state

Testing utilities want the ability to know whether things in the UI
are in flux and they need to wait before testing on-screen values.
These changes (a subset of what's needed, but will have to do for
a start) allow querying of ActivityTransitions and ProgressBar, two
common/difficult pieces in the puzzle.

Test: CTS tests at ag/1835467
Bug: 30978257 Provide view transition Api to prevent flaky tests

Change-Id: If63b3d0dde2178d826ac1dbfad0fc50e5ed9a780
parent b3231029
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3553,6 +3553,7 @@ package android.app {
    method public android.view.WindowManager getWindowManager();
    method public boolean hasWindowFocus();
    method public void invalidateOptionsMenu();
    method public boolean isActivityTransitionRunning();
    method public boolean isChangingConfigurations();
    method public final boolean isChild();
    method public boolean isDestroyed();
@@ -49235,6 +49236,7 @@ package android.widget {
    method public android.graphics.PorterDuff.Mode getSecondaryProgressTintMode();
    method public final synchronized void incrementProgressBy(int);
    method public final synchronized void incrementSecondaryProgressBy(int);
    method public boolean isAnimating();
    method public synchronized boolean isIndeterminate();
    method public void onRestoreInstanceState(android.os.Parcelable);
    method public android.os.Parcelable onSaveInstanceState();
+2 −0
Original line number Diff line number Diff line
@@ -3675,6 +3675,7 @@ package android.app {
    method public android.view.WindowManager getWindowManager();
    method public boolean hasWindowFocus();
    method public void invalidateOptionsMenu();
    method public boolean isActivityTransitionRunning();
    method public boolean isBackgroundVisibleBehind();
    method public boolean isChangingConfigurations();
    method public final boolean isChild();
@@ -53001,6 +53002,7 @@ package android.widget {
    method public android.graphics.PorterDuff.Mode getSecondaryProgressTintMode();
    method public final synchronized void incrementProgressBy(int);
    method public final synchronized void incrementSecondaryProgressBy(int);
    method public boolean isAnimating();
    method public synchronized boolean isIndeterminate();
    method public void onRestoreInstanceState(android.os.Parcelable);
    method public android.os.Parcelable onSaveInstanceState();
+2 −0
Original line number Diff line number Diff line
@@ -3555,6 +3555,7 @@ package android.app {
    method public android.view.WindowManager getWindowManager();
    method public boolean hasWindowFocus();
    method public void invalidateOptionsMenu();
    method public boolean isActivityTransitionRunning();
    method public boolean isChangingConfigurations();
    method public final boolean isChild();
    method public boolean isDestroyed();
@@ -49554,6 +49555,7 @@ package android.widget {
    method public android.graphics.PorterDuff.Mode getSecondaryProgressTintMode();
    method public final synchronized void incrementProgressBy(int);
    method public final synchronized void incrementSecondaryProgressBy(int);
    method public boolean isAnimating();
    method public synchronized boolean isIndeterminate();
    method public void onRestoreInstanceState(android.os.Parcelable);
    method public android.os.Parcelable onSaveInstanceState();
+12 −0
Original line number Diff line number Diff line
@@ -4326,6 +4326,18 @@ public class Activity extends ContextThemeWrapper
        }
    }

    /**
     * Returns whether there are any activity transitions currently running on this
     * activity. A return value of {@code true} can mean that either an enter or
     * exit transition is running, including whether the background of the activity
     * is animating as a part of that transition.
     *
     * @return true if a transition is currently running on this activity, false otherwise.
     */
    public boolean isActivityTransitionRunning() {
        return mActivityTransitionState.isTransitionRunning();
    }

    private Bundle transferSpringboardActivityOptions(Bundle options) {
        if (options == null && (mWindow != null && !mWindow.isActive())) {
            final ActivityOptions activityOptions = getActivityOptions();
+10 −0
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
    private ArrayList<Matrix> mSharedElementParentMatrices;
    private boolean mSharedElementTransitionComplete;
    private boolean mViewsTransitionComplete;
    private boolean mBackgroundAnimatorComplete;
    private ArrayList<View> mStrippedTransitioningViews = new ArrayList<>();

    public ActivityTransitionCoordinator(Window window,
@@ -884,6 +885,10 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
        startInputWhenTransitionsComplete();
    }

    protected void backgroundAnimatorComplete() {
        mBackgroundAnimatorComplete = true;
    }

    protected void sharedElementTransitionComplete() {
        mSharedElementTransitionComplete = true;
        startInputWhenTransitionsComplete();
@@ -966,6 +971,11 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
        }
    }

    public boolean isTransitionRunning() {
        return !(mViewsTransitionComplete && mSharedElementTransitionComplete &&
                mBackgroundAnimatorComplete);
    }

    private static class FixedEpicenterCallback extends Transition.EpicenterCallback {
        private Rect mEpicenter;

Loading