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

Commit 0bc260dc authored by Caitlin Cassidy's avatar Caitlin Cassidy
Browse files

[Status Bar Refactor] Move some PanelView setters + getters into...

[Status Bar Refactor] Move some PanelView setters + getters into PanelViewController and out of PanelBar.

PanelBar and PanelView are unrelated (despite their names): PanelBar
represents the status bar view, and PanelView represents the
notification panel. So, methods regarding PanelView shouldn't live in
PanelBar. This CL moves some of those methods out of PanelBar and into
to PanelView's controller.

Note: These methods are all intertwined, so they all need to be in 1 CL.

Specific changes:
- #shouldPanelBeVisible moved out of PanelBar into PanelViewController.
- #setBouncerShowing moved out of PanelBar into StatusBar. That
 method adjusts visibility and accessibility for both PanelBar and
 PanelView, so it shouldn't live in PanelViewController (which is
 specific to PanelView only). StatusBar seemed like a semi-logical place
 for it.
- #setHeadsUpVisible is no longer needed in PanelBar since it was only
 used to determine PanelView's visibility. Logic is moved to
 PanelViewController instead.
- StatusBar uses PanelViewController to get expansionFraction and
 isExpanded values, instead of PanelBar.

Test: 1) Modify display size while a heads up notification is showing and verify that the HUN remains visible
and the status bar updates appropriately. 2) Rotate device while
HUN is showing, same verification steps. (This tests no regression of
b/80224819.)
Test: Modify font size while the shade is open using `adb shell settings
put system font_scale 0.8`. (This approximately tests no
regression of b/110530608, since the repro steps in that bug are no
longer applicable.)
Test: atest SystemUITests

Bug: 200063118
Change-Id: Idd9715992792b20002716332ccd7c15369183b5c
parent 3e68fa49
Loading
Loading
Loading
Loading
+19 −5
Original line number Original line Diff line number Diff line
@@ -334,6 +334,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private boolean mKeyguardUserSwitcherEnabled;
    private boolean mKeyguardUserSwitcherEnabled;
    private boolean mDozing;
    private boolean mDozing;
    private boolean mDozingOnDown;
    private boolean mDozingOnDown;
    private boolean mBouncerShowing;
    private int mBarState;
    private int mBarState;
    private float mInitialHeightOnTouch;
    private float mInitialHeightOnTouch;
    private float mInitialTouchX;
    private float mInitialTouchX;
@@ -404,7 +405,7 @@ public class NotificationPanelViewController extends PanelViewController {


    private Runnable mHeadsUpExistenceChangedRunnable = () -> {
    private Runnable mHeadsUpExistenceChangedRunnable = () -> {
        setHeadsUpAnimatingAway(false);
        setHeadsUpAnimatingAway(false);
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();
    };
    };
    // TODO (b/162832756): once migrated to the new pipeline, delete legacy group manager
    // TODO (b/162832756): once migrated to the new pipeline, delete legacy group manager
    private NotificationGroupManagerLegacy mGroupManager;
    private NotificationGroupManagerLegacy mGroupManager;
@@ -3228,11 +3229,19 @@ public class NotificationPanelViewController extends PanelViewController {
    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
        mHeadsUpAnimatingAway = headsUpAnimatingAway;
        mHeadsUpAnimatingAway = headsUpAnimatingAway;
        mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway);
        mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway);
        updateHeadsUpVisibility();
        updateVisibility();
    }
    }


    private void updateHeadsUpVisibility() {
    /** Set whether the bouncer is showing. */
        ((PhoneStatusBarView) mBar).setHeadsUpVisible(mHeadsUpAnimatingAway || mHeadsUpPinnedMode);
    public void setBouncerShowing(boolean bouncerShowing) {
        mBouncerShowing = bouncerShowing;
        updateVisibility();
    }

    @Override
    protected boolean shouldPanelBeVisible() {
        boolean headsUpVisible = mHeadsUpAnimatingAway || mHeadsUpPinnedMode;
        return headsUpVisible || isExpanded() || mBouncerShowing;
    }
    }


    @Override
    @Override
@@ -3642,6 +3651,11 @@ public class NotificationPanelViewController extends PanelViewController {
        }
        }
    }
    }


    /** */
    public void setImportantForAccessibility(int mode) {
        mView.setImportantForAccessibility(mode);
    }

    /**
    /**
     * Do not let the user drag the shade up and down for the current touch session.
     * Do not let the user drag the shade up and down for the current touch session.
     * This is necessary to avoid shade expansion while/after the bouncer is dismissed.
     * This is necessary to avoid shade expansion while/after the bouncer is dismissed.
@@ -4216,7 +4230,7 @@ public class NotificationPanelViewController extends PanelViewController {
            }
            }
            updateGestureExclusionRect();
            updateGestureExclusionRect();
            mHeadsUpPinnedMode = inPinnedMode;
            mHeadsUpPinnedMode = inPinnedMode;
            updateHeadsUpVisibility();
            updateVisibility();
            mKeyguardStatusBarViewController.updateForHeadsUp();
            mKeyguardStatusBarViewController.updateForHeadsUp();
        }
        }


+0 −31
Original line number Original line Diff line number Diff line
@@ -33,8 +33,6 @@ public abstract class PanelBar extends FrameLayout {
    private static final boolean SPEW = false;
    private static final boolean SPEW = false;
    private static final String PANEL_BAR_SUPER_PARCELABLE = "panel_bar_super_parcelable";
    private static final String PANEL_BAR_SUPER_PARCELABLE = "panel_bar_super_parcelable";
    private static final String STATE = "state";
    private static final String STATE = "state";
    private boolean mBouncerShowing;
    private boolean mExpanded;
    protected float mPanelFraction;
    protected float mPanelFraction;


    public static final void LOG(String fmt, Object... args) {
    public static final void LOG(String fmt, Object... args) {
@@ -99,33 +97,6 @@ public abstract class PanelBar extends FrameLayout {
        pv.setBar(this);
        pv.setBar(this);
    }
    }


    public void setBouncerShowing(boolean showing) {
        mBouncerShowing = showing;
        int important = showing ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                : IMPORTANT_FOR_ACCESSIBILITY_AUTO;

        setImportantForAccessibility(important);
        updateVisibility();

        if (mPanel != null) mPanel.getView().setImportantForAccessibility(important);
    }

    public float getExpansionFraction() {
        return mPanelFraction;
    }

    public boolean isExpanded() {
        return mExpanded;
    }

    protected void updateVisibility() {
        mPanel.getView().setVisibility(shouldPanelBeVisible() ? VISIBLE : INVISIBLE);
    }

    protected boolean shouldPanelBeVisible() {
        return mExpanded || mBouncerShowing;
    }

    public boolean panelEnabled() {
    public boolean panelEnabled() {
        return true;
        return true;
    }
    }
@@ -183,9 +154,7 @@ public abstract class PanelBar extends FrameLayout {
        boolean fullyClosed = true;
        boolean fullyClosed = true;
        boolean fullyOpened = false;
        boolean fullyOpened = false;
        if (SPEW) LOG("panelExpansionChanged: start state=%d, f=%.1f", mState, frac);
        if (SPEW) LOG("panelExpansionChanged: start state=%d, f=%.1f", mState, frac);
        mExpanded = expanded;
        mPanelFraction = frac;
        mPanelFraction = frac;
        updateVisibility();
        // adjust any other panels that may be partially visible
        // adjust any other panels that may be partially visible
        if (expanded) {
        if (expanded) {
            if (mState == STATE_CLOSED) {
            if (mState == STATE_CLOSED) {
+37 −14
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package com.android.systemui.statusbar.phone;
package com.android.systemui.statusbar.phone;


import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE;
import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.GENERIC;
import static com.android.systemui.classifier.Classifier.GENERIC;
@@ -315,7 +318,7 @@ public abstract class PanelViewController {
    }
    }


    private void startOpening(MotionEvent event) {
    private void startOpening(MotionEvent event) {
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();
        maybeVibrateOnOpening();
        maybeVibrateOnOpening();


        //TODO: keyguard opens QS a different way; log that too?
        //TODO: keyguard opens QS a different way; log that too?
@@ -447,7 +450,7 @@ public abstract class PanelViewController {
    protected void onTrackingStopped(boolean expand) {
    protected void onTrackingStopped(boolean expand) {
        mTracking = false;
        mTracking = false;
        mBar.onTrackingStopped(expand);
        mBar.onTrackingStopped(expand);
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();
    }
    }


    protected void onTrackingStarted() {
    protected void onTrackingStarted() {
@@ -455,7 +458,7 @@ public abstract class PanelViewController {
        mTracking = true;
        mTracking = true;
        mBar.onTrackingStarted();
        mBar.onTrackingStarted();
        notifyExpandingStarted();
        notifyExpandingStarted();
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();
    }
    }


    /**
    /**
@@ -685,7 +688,7 @@ public abstract class PanelViewController {
        } else {
        } else {
            cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
            cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
        }
        }
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();
    }
    }


    protected abstract boolean shouldUseDismissingAnimation();
    protected abstract boolean shouldUseDismissingAnimation();
@@ -760,7 +763,7 @@ public abstract class PanelViewController {
        mExpandedFraction = Math.min(1f,
        mExpandedFraction = Math.min(1f,
                maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
                maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
        onHeightUpdated(mExpandedHeight);
        onHeightUpdated(mExpandedHeight);
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();
    }
    }


    /**
    /**
@@ -878,7 +881,7 @@ public abstract class PanelViewController {
        if (mExpanding) {
        if (mExpanding) {
            notifyExpandingFinished();
            notifyExpandingFinished();
        }
        }
        notifyBarPanelExpansionChanged();
        updatePanelExpansionAndVisibility();


        // Wait for window manager to pickup the change, so we know the maximum height of the panel
        // Wait for window manager to pickup the change, so we know the maximum height of the panel
        // then.
        // then.
@@ -916,7 +919,7 @@ public abstract class PanelViewController {
        }
        }
        if (mInstantExpanding) {
        if (mInstantExpanding) {
            mInstantExpanding = false;
            mInstantExpanding = false;
            notifyBarPanelExpansionChanged();
            updatePanelExpansionAndVisibility();
        }
        }
    }
    }


@@ -1022,7 +1025,7 @@ public abstract class PanelViewController {
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                setAnimator(null);
                setAnimator(null);
                onAnimationFinished.run();
                onAnimationFinished.run();
                notifyBarPanelExpansionChanged();
                updatePanelExpansionAndVisibility();
            }
            }
        });
        });
        animator.start();
        animator.start();
@@ -1059,19 +1062,39 @@ public abstract class PanelViewController {
        return animator;
        return animator;
    }
    }


    protected void notifyBarPanelExpansionChanged() {
    /** Update the visibility of {@link PanelView} if necessary. */
    public void updateVisibility() {
        mView.setVisibility(shouldPanelBeVisible() ? VISIBLE : INVISIBLE);
    }

    /** Returns true if {@link PanelView} should be visible. */
    abstract boolean shouldPanelBeVisible();

    /**
     * Updates the panel expansion and {@link PanelView} visibility if necessary.
     *
     * TODO(b/200063118): Could public calls to this method be replaced with calls to
     *   {@link #updateVisibility()}? That would allow us to make this method private.
     */
    public void updatePanelExpansionAndVisibility() {
        if (mBar != null) {
        if (mBar != null) {
            mBar.panelExpansionChanged(
            mBar.panelExpansionChanged(mExpandedFraction, isExpanded());
                    mExpandedFraction,
                    mExpandedFraction > 0f || mInstantExpanding
                            || isPanelVisibleBecauseOfHeadsUp() || mTracking
                            || mHeightAnimator != null && !mIsSpringBackAnimation);
        }
        }
        updateVisibility();
        for (int i = 0; i < mExpansionListeners.size(); i++) {
        for (int i = 0; i < mExpansionListeners.size(); i++) {
            mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking);
            mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking);
        }
        }
    }
    }


    public boolean isExpanded() {
        return mExpandedFraction > 0f
                || mInstantExpanding
                || isPanelVisibleBecauseOfHeadsUp()
                || mTracking
                || mHeightAnimator != null
                && !mIsSpringBackAnimation;
    }

    public void addExpansionListener(PanelExpansionListener panelExpansionListener) {
    public void addExpansionListener(PanelExpansionListener panelExpansionListener) {
        mExpansionListeners.add(panelExpansionListener);
        mExpansionListeners.add(panelExpansionListener);
    }
    }
+0 −10
Original line number Original line Diff line number Diff line
@@ -402,16 +402,6 @@ public class PhoneStatusBarView extends PanelBar {
                getPaddingBottom());
                getPaddingBottom());
    }
    }


    public void setHeadsUpVisible(boolean headsUpVisible) {
        mHeadsUpVisible = headsUpVisible;
        updateVisibility();
    }

    @Override
    protected boolean shouldPanelBeVisible() {
        return mHeadsUpVisible || super.shouldPanelBeVisible();
    }

    /** An interface that will provide whether panel is enabled. */
    /** An interface that will provide whether panel is enabled. */
    interface PanelEnabledProvider {
    interface PanelEnabledProvider {
        /** Returns true if the panel is enabled and false otherwise. */
        /** Returns true if the panel is enabled and false otherwise. */
+4 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,10 @@ class PhoneStatusBarViewController(
        }
        }
    }
    }


    fun setImportantForAccessibility(mode: Int) {
        mView.importantForAccessibility = mode
    }

    private class StatusBarViewsCenterProvider : UnfoldMoveFromCenterAnimator.ViewCenterProvider {
    private class StatusBarViewsCenterProvider : UnfoldMoveFromCenterAnimator.ViewCenterProvider {
        override fun getViewCenter(view: View, outPoint: Point) =
        override fun getViewCenter(view: View, outPoint: Point) =
            when (view.id) {
            when (view.id) {
Loading