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

Commit 7dc8245e authored by Adrian Roos's avatar Adrian Roos Committed by Automerger Merge Worker
Browse files

Merge "WindowInsetsAnimationController: Add state callback and getters" into rvc-dev am: 269b1626

Change-Id: I3a52c334c8acaa907eeaf94c49058578ce56deac
parents f580578e 269b1626
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -55573,7 +55573,8 @@ package android.view {
  }
  public interface WindowInsetsAnimationControlListener {
    method public void onCancelled();
    method public void onCancelled(@Nullable android.view.WindowInsetsAnimationController);
    method public void onFinished(@NonNull android.view.WindowInsetsAnimationController);
    method public void onReady(@NonNull android.view.WindowInsetsAnimationController, int);
  }
@@ -55585,6 +55586,9 @@ package android.view {
    method @NonNull public android.graphics.Insets getHiddenStateInsets();
    method @NonNull public android.graphics.Insets getShownStateInsets();
    method public int getTypes();
    method public boolean isCancelled();
    method public boolean isFinished();
    method public default boolean isReady();
    method public void setInsetsAndAlpha(@Nullable android.graphics.Insets, @FloatRange(from=0.0f, to=1.0f) float, @FloatRange(from=0.0f, to=1.0f) float);
  }
+8 −1
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        }
        setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, 1f /* alpha */, 1f /* fraction */);
        mFinished = true;
        mListener.onFinished(this);

        mShownOnFinish = shown;
    }
@@ -216,11 +217,17 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            return;
        }
        mCancelled = true;
        mListener.onCancelled();
        mListener.onCancelled(this);

        releaseLeashes();
    }

    @Override
    public boolean isFinished() {
        return mFinished;
    }

    @Override
    public boolean isCancelled() {
        return mCancelled;
    }
+9 −5
Original line number Diff line number Diff line
@@ -213,7 +213,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        }

        @Override
        public void onCancelled() {
        public void onFinished(WindowInsetsAnimationController controller) {
        }

        @Override
        public void onCancelled(WindowInsetsAnimationController controller) {
            // Animator can be null when it is cancelled before onReady() completes.
            if (mAnimator != null) {
                mAnimator.cancel();
@@ -583,7 +587,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            boolean fromIme, long durationMs, @Nullable Interpolator interpolator,
            @AnimationType int animationType) {
        if (!checkDisplayFramesForControlling()) {
            listener.onCancelled();
            listener.onCancelled(null);
            return;
        }
        controlAnimationUnchecked(types, cancellationSignal, listener, mFrame, fromIme, durationMs,
@@ -608,7 +612,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            boolean useInsetsAnimationThread) {
        if (types == 0) {
            // nothing to animate.
            listener.onCancelled();
            listener.onCancelled(null);
            return;
        }
        cancelExistingControllers(types);
@@ -641,7 +645,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        }

        if (typesReady == 0) {
            listener.onCancelled();
            listener.onCancelled(null);
            return;
        }

@@ -756,7 +760,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    private void abortPendingImeControlRequest() {
        if (mPendingImeControlRequest != null) {
            mPendingImeControlRequest.listener.onCancelled();
            mPendingImeControlRequest.listener.onCancelled(null);
            mPendingImeControlRequest = null;
            mHandler.removeCallbacks(mPendingControlTimeout);
        }
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class PendingInsetsController implements WindowInsetsController {
            mReplayedInsetsController.controlWindowInsetsAnimation(types, durationMillis,
                    interpolator, cancellationSignal, listener);
        } else {
            listener.onCancelled();
            listener.onCancelled(null);
        }
    }

+48 −12
Original line number Diff line number Diff line
@@ -17,20 +17,30 @@
package android.view;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.view.WindowInsets.Type.InsetsType;
import android.view.inputmethod.EditorInfo;

/**
 * Interface that informs the client about {@link WindowInsetsAnimationController} state changes.
 * Listener that encapsulates a request to
 * {@link WindowInsetsController#controlWindowInsetsAnimation}.
 *
 * <p>
 * Insets can be controlled with the supplied {@link WindowInsetsAnimationController} from
 * {@link #onReady} until either {@link #onFinished} or {@link #onCancelled}.
 *
 * <p>
 * Once the control over insets is finished or cancelled, it will not be regained until a new
 * request to {@link WindowInsetsController#controlWindowInsetsAnimation} is made.
 *
 * <p>
 * The request to control insets can fail immediately. In that case {@link #onCancelled} will be
 * invoked without a preceding {@link #onReady}.
 *
 * @see WindowInsetsController#controlWindowInsetsAnimation
 */
public interface WindowInsetsAnimationControlListener {

    /**
     * @hide
     */
    default void onPrepare(int types) {
    }

    /**
     * Called when the animation is ready to be controlled. This may be delayed when the IME needs
     * to redraw because of an {@link EditorInfo} change, or when the window is starting up.
@@ -41,14 +51,40 @@ public interface WindowInsetsAnimationControlListener {
     *              {@link WindowInsetsController#controlWindowInsetsAnimation} in case the window
     *              wasn't able to gain the controls because it wasn't the IME target or not
     *              currently the window that's controlling the system bars.
     * @see WindowInsetsAnimationController#isReady
     */
    void onReady(@NonNull WindowInsetsAnimationController controller, @InsetsType int types);

    /**
     * Called when the window no longer has control over the requested types. If it loses control
     * over one type, the whole control will be cancelled. If none of the requested types were
     * available when requesting the control, the animation control will be cancelled immediately
     * without {@link #onReady} being called.
     * Called when the request for control over the insets has
     * {@link WindowInsetsAnimationController#finish finished}.
     *
     * Once this callback is invoked, the supplied {@link WindowInsetsAnimationController}
     * is no longer {@link WindowInsetsAnimationController#isReady() ready}.
     *
     * Control will not be regained until a new request
     * to {@link WindowInsetsController#controlWindowInsetsAnimation} is made.
     *
     * @param controller the controller which has finished.
     * @see WindowInsetsAnimationController#isFinished
     */
    void onFinished(@NonNull WindowInsetsAnimationController controller);

    /**
     * Called when the request for control over the insets has been cancelled, either
     * because the {@link android.os.CancellationSignal} associated with the
     * {@link WindowInsetsController#controlWindowInsetsAnimation request} has been invoked, or
     * the window has lost control over the insets (e.g. because it lost focus).
     *
     * Once this callback is invoked, the supplied {@link WindowInsetsAnimationController}
     * is no longer {@link WindowInsetsAnimationController#isReady() ready}.
     *
     * Control will not be regained until a new request
     * to {@link WindowInsetsController#controlWindowInsetsAnimation} is made.
     *
     * @param controller the controller which has been cancelled, or null if the request
     *                   was cancelled before {@link #onReady} was invoked.
     * @see WindowInsetsAnimationController#isCancelled
     */
    void onCancelled();
    void onCancelled(@Nullable WindowInsetsAnimationController controller);
}
Loading