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

Commit e41d00bc authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Automerger Merge Worker
Browse files

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

Merge "[Status Bar Refactor] Move some PanelView setters + getters into PanelViewController and out of PanelBar." into sc-v2-dev am: 837ed2be

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15854191

Change-Id: Ib84e1eb5224f02d4835ea8f420aba8d19729b70a
parents 58091ed3 837ed2be
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private boolean mKeyguardUserSwitcherEnabled;
    private boolean mDozing;
    private boolean mDozingOnDown;
    private boolean mBouncerShowing;
    private int mBarState;
    private float mInitialHeightOnTouch;
    private float mInitialTouchX;
@@ -404,7 +405,7 @@ public class NotificationPanelViewController extends PanelViewController {

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

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

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

    @Override
@@ -3639,6 +3648,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.
     * This is necessary to avoid shade expansion while/after the bouncer is dismissed.
@@ -4211,7 +4225,7 @@ public class NotificationPanelViewController extends PanelViewController {
            }
            updateGestureExclusionRect();
            mHeadsUpPinnedMode = inPinnedMode;
            updateHeadsUpVisibility();
            updateVisibility();
            mKeyguardStatusBarViewController.updateForHeadsUp();
        }

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

    public static final void LOG(String fmt, Object... args) {
@@ -99,33 +97,6 @@ public abstract class PanelBar extends FrameLayout {
        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() {
        return true;
    }
@@ -183,9 +154,7 @@ public abstract class PanelBar extends FrameLayout {
        boolean fullyClosed = true;
        boolean fullyOpened = false;
        if (SPEW) LOG("panelExpansionChanged: start state=%d, f=%.1f", mState, frac);
        mExpanded = expanded;
        mPanelFraction = frac;
        updateVisibility();
        // adjust any other panels that may be partially visible
        if (expanded) {
            if (mState == STATE_CLOSED) {
+37 −14
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

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.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.GENERIC;
@@ -315,7 +318,7 @@ public abstract class PanelViewController {
    }

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

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

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

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

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

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

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

@@ -1022,7 +1025,7 @@ public abstract class PanelViewController {
            public void onAnimationEnd(Animator animation) {
                setAnimator(null);
                onAnimationFinished.run();
                notifyBarPanelExpansionChanged();
                updatePanelExpansionAndVisibility();
            }
        });
        animator.start();
@@ -1059,19 +1062,39 @@ public abstract class PanelViewController {
        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) {
            mBar.panelExpansionChanged(
                    mExpandedFraction,
                    mExpandedFraction > 0f || mInstantExpanding
                            || isPanelVisibleBecauseOfHeadsUp() || mTracking
                            || mHeightAnimator != null && !mIsSpringBackAnimation);
            mBar.panelExpansionChanged(mExpandedFraction, isExpanded());
        }
        updateVisibility();
        for (int i = 0; i < mExpansionListeners.size(); i++) {
            mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking);
        }
    }

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

    public void addExpansionListener(PanelExpansionListener panelExpansionListener) {
        mExpansionListeners.add(panelExpansionListener);
    }
+0 −10
Original line number Diff line number Diff line
@@ -402,16 +402,6 @@ public class PhoneStatusBarView extends PanelBar {
                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. */
    interface PanelEnabledProvider {
        /** Returns true if the panel is enabled and false otherwise. */
+4 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@ class PhoneStatusBarViewController(
        }
    }

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

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