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

Commit 821e37b4 authored by Tony Wickham's avatar Tony Wickham
Browse files

Stash taskbar when IME is present, including during gestures

- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).

Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
parent db5f5f05
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -46,16 +46,13 @@ public class FallbackTaskbarUIController extends TaskbarUIController {
                }
            };

    // Initialized in init.
    TaskbarControllers mControllers;

    public FallbackTaskbarUIController(RecentsActivity recentsActivity) {
        mRecentsActivity = recentsActivity;
    }

    @Override
    protected void init(TaskbarControllers taskbarControllers) {
        mControllers = taskbarControllers;
        super.init(taskbarControllers);

        mRecentsActivity.setTaskbarUIController(this);
        mRecentsActivity.getStateManager().addStateListener(mStateListener);
+9 −7
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.os.RemoteException;
import android.util.Log;
import android.view.MotionEvent;
import android.view.TaskTransitionSpec;
import android.view.View;
import android.view.WindowManagerGlobal;

import androidx.annotation.NonNull;
@@ -62,7 +61,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
            this::onStashedInAppChanged;

    // Initialized in init.
    private TaskbarControllers mControllers;
    private AnimatedFloat mTaskbarOverrideBackgroundAlpha;
    private TaskbarKeyguardController mKeyguardController;
    private final TaskbarLauncherStateController
@@ -83,7 +81,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {

    @Override
    protected void init(TaskbarControllers taskbarControllers) {
        mControllers = taskbarControllers;
        super.init(taskbarControllers);

        mTaskbarLauncherStateController.init(mControllers, mLauncher);
        mTaskbarOverrideBackgroundAlpha = mControllers.taskbarDragLayerController
@@ -168,10 +166,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        return mControllers.taskbarDragController.isDragging();
    }

    public View getRootView() {
        return mControllers.taskbarActivityContext.getDragLayer();
    }

    @Override
    protected void onStashedInAppChanged() {
        onStashedInAppChanged(mLauncher.getDeviceProfile());
@@ -251,4 +245,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        mLauncher.logAppLaunch(mControllers.taskbarActivityContext.getStatsLogManager(), item,
                instanceId);
    }

    @Override
    public void setSystemGestureInProgress(boolean inProgress) {
        super.setSystemGestureInProgress(inProgress);
        // Launcher's ScrimView will draw the background throughout the gesture. But once the
        // gesture ends, start drawing taskbar's background again since launcher might stop drawing.
        forceHideBackground(inProgress);
    }
}
+1 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BA
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_IME;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_KEYGUARD;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
@@ -140,11 +139,6 @@ public class NavbarButtonsViewController {
        mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;
        mNavButtonTranslationYMultiplier.value = 1;

        mPropertyHolders.add(new StatePropertyHolder(
                mControllers.taskbarViewController.getTaskbarIconAlpha()
                        .getProperty(ALPHA_INDEX_IME),
                flags -> (flags & FLAG_IME_VISIBLE) == 0, MultiValueAlpha.VALUE, 1, 0));

        boolean isThreeButtonNav = mContext.isThreeButtonNav();
        // IME switcher
        View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
@@ -196,7 +190,7 @@ public class NavbarButtonsViewController {
            }

            // Animate taskbar background when any of these flags are enabled
            int flagsToShowBg = FLAG_IME_VISIBLE | FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE
            int flagsToShowBg = FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE
                    | FLAG_NOTIFICATION_SHADE_EXPANDED;
            mPropertyHolders.add(new StatePropertyHolder(
                    mControllers.taskbarDragLayerController.getNavbarBackgroundAlpha(),
+24 −9
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
package com.android.launcher3.taskbar;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Outline;
@@ -23,8 +25,6 @@ import android.graphics.Rect;
import android.view.View;
import android.view.ViewOutlineProvider;

import androidx.annotation.Nullable;

import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.RevealOutlineAnimation;
@@ -66,7 +66,10 @@ public class StashedHandleViewController {
    private final Rect mStashedHandleBounds = new Rect();
    private float mStashedHandleRadius;

    private boolean mIsAtStashedRevealBounds = true;
    // When the reveal animation is cancelled, we can assume it's about to create a new animation,
    // which should start off at the same point the cancelled one left off.
    private float mStartProgressForNextRevealAnim;
    private boolean mWasLastRevealAnimReversed;

    public StashedHandleViewController(TaskbarActivityContext activity,
            StashedHandleView stashedHandleView) {
@@ -148,15 +151,27 @@ public class StashedHandleViewController {
     * shape and size. When stashed, the shape is a thin rounded pill. When unstashed, the shape
     * morphs into the size of where the taskbar icons will be.
     */
    public @Nullable Animator createRevealAnimToIsStashed(boolean isStashed) {
        if (mIsAtStashedRevealBounds == isStashed) {
            return null;
        }
        mIsAtStashedRevealBounds = isStashed;
    public Animator createRevealAnimToIsStashed(boolean isStashed) {
        final RevealOutlineAnimation handleRevealProvider = new RoundedRectRevealOutlineProvider(
                mStashedHandleRadius, mStashedHandleRadius,
                mControllers.taskbarViewController.getIconLayoutBounds(), mStashedHandleBounds);
        return handleRevealProvider.createRevealAnimator(mStashedHandleView, !isStashed);

        boolean isReversed = !isStashed;
        boolean changingDirection = mWasLastRevealAnimReversed != isReversed;
        mWasLastRevealAnimReversed = isReversed;
        if (changingDirection) {
            mStartProgressForNextRevealAnim = 1f - mStartProgressForNextRevealAnim;
        }

        ValueAnimator revealAnim = handleRevealProvider.createRevealAnimator(mStashedHandleView,
                isReversed, mStartProgressForNextRevealAnim);
        revealAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mStartProgressForNextRevealAnim = ((ValueAnimator) animation).getAnimatedFraction();
            }
        });
        return revealAnim;
    }

    public void onIsStashed(boolean isStashed) {
+7 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class TaskbarDragLayerController {
    private final AnimatedFloat mKeyguardBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
    private final AnimatedFloat mNotificationShadeBgTaskbar = new AnimatedFloat(
            this::updateBackgroundAlpha);
    private final AnimatedFloat mImeBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
    // Used to hide our background color when someone else (e.g. ScrimView) is handling it.
    private final AnimatedFloat mBgOverride = new AnimatedFloat(this::updateBackgroundAlpha);

@@ -74,6 +75,7 @@ public class TaskbarDragLayerController {
        mBgTaskbar.value = 1;
        mKeyguardBgTaskbar.value = 1;
        mNotificationShadeBgTaskbar.value = 1;
        mImeBgTaskbar.value = 1;
        mBgOverride.value = 1;
        updateBackgroundAlpha();
    }
@@ -108,6 +110,10 @@ public class TaskbarDragLayerController {
        return mNotificationShadeBgTaskbar;
    }

    public AnimatedFloat getImeBgTaskbar() {
        return mImeBgTaskbar;
    }

    public AnimatedFloat getOverrideBackgroundAlpha() {
        return mBgOverride;
    }
@@ -119,7 +125,7 @@ public class TaskbarDragLayerController {
    private void updateBackgroundAlpha() {
        final float bgNavbar = mBgNavbar.value;
        final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value
                * mNotificationShadeBgTaskbar.value;
                * mNotificationShadeBgTaskbar.value * mImeBgTaskbar.value;
        mLastSetBackgroundAlpha = mBgOverride.value * Math.max(bgNavbar, bgTaskbar);
        mTaskbarDragLayer.setTaskbarBackgroundAlpha(mLastSetBackgroundAlpha);

Loading