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

Commit 5059dbde authored by Tom Natan's avatar Tom Natan Committed by Android (Google) Code Review
Browse files

Merge "[18/n] Letterbox Education: start dialog enter animation after all...

Merge "[18/n] Letterbox Education: start dialog enter animation after all shell transitions have finished" into tm-dev
parents 840f3989 dc3dac34
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.annotations.ExternalThread;
import com.android.wm.shell.compatui.CompatUIWindowManager.CompatUIHintsState;
import com.android.wm.shell.compatui.letterboxedu.LetterboxEduWindowManager;
import com.android.wm.shell.transition.Transitions;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -50,6 +51,8 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;

import dagger.Lazy;

/**
 * Controller to show/update compat UI components on Tasks based on whether the foreground
 * activities are in compatibility mode.
@@ -102,6 +105,7 @@ public class CompatUIController implements OnDisplaysChangedListener,
    private final DisplayImeController mImeController;
    private final SyncTransactionQueue mSyncQueue;
    private final ShellExecutor mMainExecutor;
    private final Lazy<Transitions> mTransitionsLazy;
    private final CompatUIImpl mImpl = new CompatUIImpl();

    private CompatUICallback mCallback;
@@ -118,13 +122,15 @@ public class CompatUIController implements OnDisplaysChangedListener,
            DisplayInsetsController displayInsetsController,
            DisplayImeController imeController,
            SyncTransactionQueue syncQueue,
            ShellExecutor mainExecutor) {
            ShellExecutor mainExecutor,
            Lazy<Transitions> transitionsLazy) {
        mContext = context;
        mDisplayController = displayController;
        mDisplayInsetsController = displayInsetsController;
        mImeController = imeController;
        mSyncQueue = syncQueue;
        mMainExecutor = mainExecutor;
        mTransitionsLazy = transitionsLazy;
        mDisplayController.addDisplayWindowListener(this);
        mImeController.addPositionProcessor(this);
        mCompatUIHintsState = new CompatUIHintsState();
@@ -302,6 +308,7 @@ public class CompatUIController implements OnDisplaysChangedListener,
            ShellTaskOrganizer.TaskListener taskListener) {
        return new LetterboxEduWindowManager(context, taskInfo,
                mSyncQueue, taskListener, mDisplayController.getDisplayLayout(taskInfo.displayId),
                mTransitionsLazy.get(),
                this::onLetterboxEduDismissed);
    }

+4 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.compatui.letterboxedu;

import static com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation;
import static com.android.internal.R.styleable.WindowAnimation_windowExitAnimation;
import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -42,7 +43,9 @@ import com.android.internal.policy.TransitionAnimation;
class LetterboxEduAnimationController {
    private static final String TAG = "LetterboxEduAnimation";

    private static final int ENTER_ANIM_START_DELAY_MILLIS = 500;
    // If shell transitions are enabled, startEnterAnimation will be called after all transitions
    // have finished, and therefore the start delay should be shorter.
    private static final int ENTER_ANIM_START_DELAY_MILLIS = ENABLE_SHELL_TRANSITIONS ? 300 : 500;

    private final TransitionAnimation mTransitionAnimation;
    private final String mPackageName;
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ class LetterboxEduDialogLayout extends ConstraintLayout {
    // The alpha of a background is a number between 0 (fully transparent) to 255 (fully opaque).
    // 204 is simply 255 * 0.8.
    static final int BACKGROUND_DIM_ALPHA = 204;

    private View mDialogContainer;
    private TextView mDialogTitle;
    private Drawable mBackgroundDim;
+21 −6
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.compatui.CompatUIWindowManagerAbstract;
import com.android.wm.shell.transition.Transitions;

/**
 * Window manager for the Letterbox Education.
@@ -63,6 +64,8 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {

    private final LetterboxEduAnimationController mAnimationController;

    private final Transitions mTransitions;

    // Remember the last reported state in case visibility changes due to keyguard or IME updates.
    private boolean mEligibleForLetterboxEducation;

@@ -80,17 +83,19 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {

    public LetterboxEduWindowManager(Context context, TaskInfo taskInfo,
            SyncTransactionQueue syncQueue, ShellTaskOrganizer.TaskListener taskListener,
            DisplayLayout displayLayout, Runnable onDismissCallback) {
        this(context, taskInfo, syncQueue, taskListener, displayLayout, onDismissCallback,
                new LetterboxEduAnimationController(context));
            DisplayLayout displayLayout, Transitions transitions,
            Runnable onDismissCallback) {
        this(context, taskInfo, syncQueue, taskListener, displayLayout, transitions,
                onDismissCallback, new LetterboxEduAnimationController(context));
    }

    @VisibleForTesting
    LetterboxEduWindowManager(Context context, TaskInfo taskInfo,
            SyncTransactionQueue syncQueue, ShellTaskOrganizer.TaskListener taskListener,
            DisplayLayout displayLayout, Runnable onDismissCallback,
            DisplayLayout displayLayout, Transitions transitions, Runnable onDismissCallback,
            LetterboxEduAnimationController animationController) {
        super(context, taskInfo, syncQueue, taskListener, displayLayout);
        mTransitions = transitions;
        mOnDismissCallback = onDismissCallback;
        mAnimationController = animationController;
        mEligibleForLetterboxEducation = taskInfo.topActivityEligibleForLetterboxEducation;
@@ -132,8 +137,8 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {
        mLayout = inflateLayout();
        updateDialogMargins();

        mAnimationController.startEnterAnimation(mLayout, /* endCallback= */
                this::onDialogEnterAnimationEnded);
        // startEnterAnimation will be called immediately if shell-transitions are disabled.
        mTransitions.runOnIdle(this::startEnterAnimation);

        return mLayout;
    }
@@ -158,8 +163,18 @@ public class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {
                R.layout.letterbox_education_dialog_layout, null);
    }

    private void startEnterAnimation() {
        if (mLayout == null) {
            // Dialog has already been released.
            return;
        }
        mAnimationController.startEnterAnimation(mLayout, /* endCallback= */
                this::onDialogEnterAnimationEnded);
    }

    private void onDialogEnterAnimationEnded() {
        if (mLayout == null) {
            // Dialog has already been released.
            return;
        }
        mLayout.setDismissOnClickListener(this::onDismiss);
+3 −2
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ import com.android.wm.shell.unfold.ShellUnfoldProgressProvider;
import java.util.Optional;

import dagger.BindsOptionalOf;
import dagger.Lazy;
import dagger.Module;
import dagger.Provides;

@@ -210,9 +211,9 @@ public abstract class WMShellBaseModule {
    static CompatUIController provideCompatUIController(Context context,
            DisplayController displayController, DisplayInsetsController displayInsetsController,
            DisplayImeController imeController, SyncTransactionQueue syncQueue,
            @ShellMainThread ShellExecutor mainExecutor) {
            @ShellMainThread ShellExecutor mainExecutor, Lazy<Transitions> transitionsLazy) {
        return new CompatUIController(context, displayController, displayInsetsController,
                imeController, syncQueue, mainExecutor);
                imeController, syncQueue, mainExecutor, transitionsLazy);
    }

    @WMSingleton
Loading