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

Commit b898a3c8 authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix bubbles taskbar scrim showing when notification panel is shown

TaskbarScrimViewController was previously unaware of visibility
changes that happened to taskbar outside of when the sysui state
flags changed. Additionally, isTaskbarVisibileAndNotStashing is not
a reliable signal as the visibility might be GONE even though taskbar
is about to animate to be visible (i.e. shade is showing and then
you swipe it back up -- taskbar scrim wouldn't appear because when
the sysuiStateFlags changed, taskbar visibility would still be 'gone'
at that point so the taskbar scrim wouldn't animate back when
the shade is swiped up).

To resolve this, I've added a callback to notify the scrim
controller of visibility changes and it'll update if needed.

Bug: 270634233
Test: manual - enable 3 button nav
             - have a bubble
             - go to overview
             - expand bubbles
             => observe that scrim appears over taskbar
             - swipe down shade
             => observe that scrim fades out
             - swipe shade up
             => observe that scrim fades in

Change-Id: Ibaae8efb90b4558d30795298570208a52b31efb4
parent 9ea209b8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ public class TaskbarScrimView extends View {
        invalidate();
    }

    protected float getScrimAlpha() {
        return mRenderer.getPaint().getAlpha() / 255f;
    }

    /**
     * Sets the roundness of the round corner above Taskbar.
     * @param cornerRoundness 0 has no round corner, 1 has complete round corner.
+41 −12
Original line number Diff line number Diff line
@@ -15,10 +15,13 @@
 */
package com.android.launcher3.taskbar;

import static android.view.View.VISIBLE;

import static com.android.launcher3.taskbar.bubbles.BubbleBarController.BUBBLE_BAR_ENABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED;
import static com.android.wm.shell.common.bubbles.BubbleConstants.BUBBLE_EXPANDED_SCRIM_ALPHA;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE;

import android.animation.ObjectAnimator;
import android.view.animation.Interpolator;
@@ -41,6 +44,8 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa

    private final TaskbarActivityContext mActivity;
    private final TaskbarScrimView mScrimView;
    private boolean mTaskbarVisible;
    private int mSysUiStateFlags;

    // Alpha property for the scrim.
    private final AnimatedFloat mScrimAlpha = new AnimatedFloat(this::updateScrimAlpha);
@@ -60,6 +65,20 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
        mControllers = controllers;
    }

    /**
     * Called when the taskbar visibility changes.
     *
     * @param visibility the current visibility of {@link TaskbarView}.
     */
    public void onTaskbarVisibilityChanged(int visibility) {
        mTaskbarVisible = visibility == VISIBLE;
        if (shouldShowScrim()) {
            showScrim(true, getScrimAlpha(), false /* skipAnim */);
        } else if (mScrimView.getScrimAlpha() > 0f) {
            showScrim(false, 0, false /* skipAnim */);
        }
    }

    /**
     * Updates the scrim state based on the flags.
     */
@@ -68,29 +87,39 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
            // These scrims aren't used if bubble bar & transient taskbar are active.
            return;
        }
        final boolean bubblesExpanded = (stateFlags & SYSUI_STATE_BUBBLES_EXPANDED) != 0;
        mSysUiStateFlags = stateFlags;
        showScrim(shouldShowScrim(), getScrimAlpha(), skipAnim);
    }

    private boolean shouldShowScrim() {
        final boolean bubblesExpanded = (mSysUiStateFlags & SYSUI_STATE_BUBBLES_EXPANDED) != 0;
        boolean isShadeVisible = (mSysUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE) != 0;
        return bubblesExpanded && !mControllers.navbarButtonsViewController.isImeVisible()
                && !isShadeVisible
                && !mControllers.taskbarStashController.isStashed()
                && mTaskbarVisible;
    }

    private float getScrimAlpha() {
        final boolean manageMenuExpanded =
                (stateFlags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
        final boolean showScrim = !mControllers.navbarButtonsViewController.isImeVisible()
                && bubblesExpanded
                && mControllers.taskbarStashController.isTaskbarVisibleAndNotStashing();
        final float scrimAlpha = manageMenuExpanded
                (mSysUiStateFlags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
        return manageMenuExpanded
                // When manage menu shows there's the first scrim and second scrim so figure out
                // what the total transparency would be.
                ? (BUBBLE_EXPANDED_SCRIM_ALPHA + (BUBBLE_EXPANDED_SCRIM_ALPHA
                * (1 - BUBBLE_EXPANDED_SCRIM_ALPHA)))
                : showScrim ? BUBBLE_EXPANDED_SCRIM_ALPHA : 0;
        showScrim(showScrim, scrimAlpha, skipAnim);
                : shouldShowScrim() ? BUBBLE_EXPANDED_SCRIM_ALPHA : 0;
    }

    private void showScrim(boolean showScrim, float alpha, boolean skipAnim) {
        mScrimView.setOnClickListener(showScrim ? (view) -> onClick() : null);
        mScrimView.setClickable(showScrim);
        if (skipAnim) {
            mScrimView.setScrimAlpha(alpha);
        } else {
            ObjectAnimator anim = mScrimAlpha.animateToValue(showScrim ? alpha : 0);
            anim.setInterpolator(showScrim ? SCRIM_ALPHA_IN : SCRIM_ALPHA_OUT);
            anim.start();
        if (skipAnim) {
            anim.end();
        }
    }

+9 −0
Original line number Diff line number Diff line
@@ -194,6 +194,15 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
        }
    }

    @Override
    public void setVisibility(int visibility) {
        boolean changed = getVisibility() != visibility;
        super.setVisibility(visibility);
        if (changed && mControllerCallbacks != null) {
            mControllerCallbacks.notifyVisibilityChanged();
        }
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
+8 −0
Original line number Diff line number Diff line
@@ -756,5 +756,13 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
        public void notifyIconLayoutBoundsChanged() {
            mControllers.uiController.onIconLayoutBoundsChanged();
        }

        /**
         * Notifies the taskbar scrim when the visibility of taskbar changes.
         */
        public void notifyVisibilityChanged() {
            mControllers.taskbarScrimViewController.onTaskbarVisibilityChanged(
                    mTaskbarView.getVisibility());
        }
    }
}