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

Commit 091a463c authored by Alex Florescu's avatar Alex Florescu Committed by Automerger Merge Worker
Browse files

Merge "Cache value of shouldUseSplitNotificationShade" into sc-dev am: 85789d59

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

Change-Id: I7a76a1461713bc0f6de082bb90e72ff152b0c19e
parents 6dd6a582 85789d59
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
    private final DumpManager mDumpManager;
    private final FeatureFlags mFeatureFlags;
    protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
    private boolean mShouldUseSplitNotificationShade;

    private int mLastOrientation;
    private String mCachedSpecs = "";
@@ -81,6 +82,8 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
            new QSPanel.OnConfigurationChangedListener() {
                @Override
                public void onConfigurationChange(Configuration newConfig) {
                    mShouldUseSplitNotificationShade =
                            Utils.shouldUseSplitNotificationShade(mFeatureFlags, getResources());
                    if (newConfig.orientation != mLastOrientation) {
                        mLastOrientation = newConfig.orientation;
                        switchTileLayout(false);
@@ -119,6 +122,8 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
        mDumpManager = dumpManager;
        mFeatureFlags = featureFlags;
        mQSLabelFlag = featureFlags.isQSLabelsEnabled();
        mShouldUseSplitNotificationShade =
                Utils.shouldUseSplitNotificationShade(mFeatureFlags, getResources());
    }

    @Override
@@ -345,7 +350,7 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
    }

    boolean shouldUseHorizontalLayout() {
        if (Utils.shouldUseSplitNotificationShade(mFeatureFlags, getResources()))  {
        if (mShouldUseSplitNotificationShade)  {
            return false;
        }
        return mUsingMediaPlayer && mMediaHost.getVisible()
+8 −5
Original line number Diff line number Diff line
@@ -456,6 +456,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private long mNumHeadsUp;
    private NotificationStackScrollLayoutController.TouchHandler mTouchHandler;
    private final FeatureFlags mFeatureFlags;
    private boolean mShouldUseSplitNotificationShade;

    private final ExpandableView.OnHeightChangedListener mOnChildHeightChangedListener =
            new ExpandableView.OnHeightChangedListener() {
@@ -500,7 +501,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        super(context, attrs, 0, 0);
        Resources res = getResources();
        mSectionsManager = notificationSectionsManager;

        mFeatureFlags = featureFlags;
        mShouldUseSplitNotificationShade = shouldUseSplitNotificationShade(mFeatureFlags, res);
        mSectionsManager.initialize(this, LayoutInflater.from(context));
        mSections = mSectionsManager.createSectionsForBuckets();

@@ -533,7 +535,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mGroupMembershipManager = groupMembershipManager;
        mGroupExpansionManager = groupExpansionManager;
        mStatusbarStateController = statusbarStateController;
        mFeatureFlags = featureFlags;
    }

    void initializeForegroundServiceSection(ForegroundServiceDungeonView fgsSectionView) {
@@ -1164,7 +1165,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                if (stackStartPosition <= stackEndPosition) {
                    stackHeight = stackEndPosition;
                } else {
                    if (shouldUseSplitNotificationShade(mFeatureFlags, getResources())) {
                    if (mShouldUseSplitNotificationShade) {
                        // This prevents notifications from being collapsed when QS is expanded.
                        stackHeight = (int) height;
                    } else {
@@ -1552,8 +1553,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mStatusBarHeight = getResources().getDimensionPixelOffset(R.dimen.status_bar_height);
        float densityScale = getResources().getDisplayMetrics().density;
        Resources res = getResources();
        mShouldUseSplitNotificationShade = shouldUseSplitNotificationShade(mFeatureFlags, res);
        mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height);
        float densityScale = res.getDisplayMetrics().density;
        mSwipeHelper.setDensityScale(densityScale);
        float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
        mSwipeHelper.setPagingTouchSlop(pagingTouchSlop);
+13 −10
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ public class NotificationPanelViewController extends PanelViewController {
    // Maximum # notifications to show on Keyguard; extras will be collapsed in an overflow card.
    // If there are exactly 1 + mMaxKeyguardNotifications, then still shows all notifications
    private final int mMaxKeyguardNotifications;
    private boolean mShouldUseSplitNotificationShade;
    // Current max allowed keyguard notifications determined by measuring the panel
    private int mMaxAllowedKeyguardNotifications;

@@ -598,6 +599,8 @@ public class NotificationPanelViewController extends PanelViewController {
                mKeyguardUserSwitcherEnabled && mResources.getBoolean(
                        R.bool.config_keyguard_user_switch_opens_qs_details);
        keyguardUpdateMonitor.setKeyguardQsUserSwitchEnabled(mKeyguardQsUserSwitchEnabled);
        mShouldUseSplitNotificationShade =
                Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources);
        mView.setWillNotDraw(!DEBUG);
        mLayoutInflater = layoutInflater;
        mFalsingManager = falsingManager;
@@ -736,7 +739,7 @@ public class NotificationPanelViewController extends PanelViewController {

        mView.setAccessibilityDelegate(mAccessibilityDelegate);
        // dynamically apply the split shade value overrides.
        if (Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)) {
        if (mShouldUseSplitNotificationShade) {
            updateResources();
        }
    }
@@ -835,12 +838,13 @@ public class NotificationPanelViewController extends PanelViewController {
    public void updateResources() {
        int qsWidth = mResources.getDimensionPixelSize(R.dimen.qs_panel_width);
        int panelWidth = mResources.getDimensionPixelSize(R.dimen.notification_panel_width);

        mShouldUseSplitNotificationShade =
                Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources);
        // To change the constraints at runtime, all children of the ConstraintLayout must have ids
        ensureAllViewsHaveIds(mNotificationContainerParent);
        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(mNotificationContainerParent);
        if (Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)) {
        if (mShouldUseSplitNotificationShade) {
            // width = 0 to take up all available space within constraints
            qsWidth = 0;
            panelWidth = 0;
@@ -1915,7 +1919,7 @@ public class NotificationPanelViewController extends PanelViewController {
                mBarState != KEYGUARD
                        && (!mQsExpanded
                            || mQsExpansionFromOverscroll
                            || Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)));
                            || mShouldUseSplitNotificationShade));

        if (mKeyguardUserSwitcherController != null && mQsExpanded
                && !mStackScrollerOverscrolling) {
@@ -1987,7 +1991,7 @@ public class NotificationPanelViewController extends PanelViewController {

    private float calculateQsTopPadding() {
        // in split shade mode we want notifications to be directly below status bar
        if (Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources) && !mKeyguardShowing) {
        if (mShouldUseSplitNotificationShade && !mKeyguardShowing) {
            return 0f;
        }
        if (mKeyguardShowing && (mQsExpandImmediate
@@ -2203,8 +2207,7 @@ public class NotificationPanelViewController extends PanelViewController {
            return true;
        }

        return !Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)
                && (isInSettings() || mIsPanelCollapseOnQQS);
        return !mShouldUseSplitNotificationShade && (isInSettings() || mIsPanelCollapseOnQQS);
    }

    @Override
@@ -2631,7 +2634,7 @@ public class NotificationPanelViewController extends PanelViewController {
        super.onTrackingStarted();
        if (mQsFullyExpanded) {
            mQsExpandImmediate = true;
            if (!Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)) {
            if (!mShouldUseSplitNotificationShade) {
                mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
            }
        }
@@ -2882,7 +2885,7 @@ public class NotificationPanelViewController extends PanelViewController {
     */
    protected void updateHorizontalPanelPosition(float x) {
        if (mNotificationStackScrollLayoutController.getWidth() * 1.75f > mView.getWidth()
                || Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)) {
                || mShouldUseSplitNotificationShade) {
            resetHorizontalPanelPosition();
            return;
        }
@@ -3573,7 +3576,7 @@ public class NotificationPanelViewController extends PanelViewController {
        @Override
        public void onOverscrollTopChanged(float amount, boolean isRubberbanded) {
            // When in split shade, overscroll shouldn't carry through to QS
            if (Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)) {
            if (mShouldUseSplitNotificationShade) {
                return;
            }
            cancelQsAnimation();
+8 −0
Original line number Diff line number Diff line
@@ -242,10 +242,18 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
        when(mMediaHost.getVisible()).thenReturn(true);

        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(false);
        mController = new TestableQSPanelControllerBase(mQSPanel, mQSTileHost,
                mQSCustomizerController, mMediaHost,
                mMetricsLogger, mUiEventLogger, mQSLogger, mDumpManager, mFeatureFlags);

        assertThat(mController.shouldUseHorizontalLayout()).isTrue();

        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(true);
        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true);
        mController = new TestableQSPanelControllerBase(mQSPanel, mQSTileHost,
                mQSCustomizerController, mMediaHost,
                mMetricsLogger, mUiEventLogger, mQSLogger, mDumpManager, mFeatureFlags);

        assertThat(mController.shouldUseHorizontalLayout()).isFalse();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -536,8 +536,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
    @Test
    public void testCanCollapsePanelOnTouch_falseInDualPaneShade() {
        mStatusBarStateController.setState(SHADE);
        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true);
        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(true);
        enableSplitShade();
        mNotificationPanelViewController.setQsExpanded(true);

        assertThat(mNotificationPanelViewController.canCollapsePanelOnTouch()).isFalse();
@@ -562,6 +561,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
    private void enableSplitShade() {
        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true);
        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(true);
        mNotificationPanelViewController.updateResources();
    }

    private void onTouchEvent(MotionEvent ev) {