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

Commit 16ac3774 authored by Jason Monk's avatar Jason Monk
Browse files

Fix QS input handling

Remove the observable scroll view and put the qs container in its
place.  Also update the NotificationStackScrollerLayout to be aware
of the container and not eat up its touches as scroll events.

Change-Id: I8a56254bf8e76a7cdd63bd637a974c1f3aa49482
parent e1be3426
Loading
Loading
Loading
Loading
+4 −26
Original line number Diff line number Diff line
@@ -31,12 +31,6 @@
        android:layout_height="wrap_content"
        android:visibility="gone" />

    <include
        layout="@layout/qs_panel"
        android:layout_width="@dimen/notification_panel_width"
        android:layout_height="wrap_content"
        android:layout_gravity="@integer/notification_panel_layout_gravity" />

    <com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
        android:layout_width="match_parent"
        android:layout_height="match_parent"
@@ -45,27 +39,11 @@
        android:clipToPadding="false"
        android:clipChildren="false">

        <com.android.systemui.statusbar.phone.ObservableScrollView
            android:id="@+id/scroll_view"
        <include
            layout="@layout/qs_panel"
            android:layout_width="@dimen/notification_panel_width"
            android:layout_height="match_parent"
            android:layout_gravity="@integer/notification_panel_layout_gravity"
            android:scrollbars="none"
            android:overScrollMode="never"
            android:fillViewport="true">
            <LinearLayout
                android:layout_width="match_parent"
            android:layout_height="wrap_content"
                android:orientation="vertical">

                <!-- A view to reserve space for the collapsed stack -->
                <!-- Layout height: notification_min_height + bottom_stack_peek_amount -->
                <View
                    android:id="@+id/reserve_notification_space"
                    android:layout_height="@dimen/min_stack_height"
                    android:layout_width="match_parent" />
            </LinearLayout>
        </com.android.systemui.statusbar.phone.ObservableScrollView>
            android:layout_gravity="@integer/notification_panel_layout_gravity" />

        <com.android.systemui.statusbar.stack.NotificationStackScrollLayout
            android:id="@+id/notification_stack_scroller"
+0 −1
Original line number Diff line number Diff line
@@ -105,7 +105,6 @@ public class QSContainer extends FrameLayout {
        mHeader.setExpanded((mKeyguardShowing && !mHeaderAnimating)
                || (mQsExpanded && !mStackScrollerOverscrolling));
        mQSPanel.setVisibility(expandVisually ? View.VISIBLE : View.INVISIBLE);
        setVisibility(mKeyguardShowing && !expandVisually ? View.INVISIBLE : View.VISIBLE);
    }

    public BaseStatusBarHeader getHeader() {
+9 −66
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@ public class NotificationPanelView extends PanelView implements
    private KeyguardStatusBarView mKeyguardStatusBar;
    private QSContainer mQsContainer;
    private KeyguardStatusView mKeyguardStatusView;
    private ObservableScrollView mScrollView;
    private TextView mClockView;
    private View mReserveNotificationSpace;
    private View mQsNavbarScrim;
@@ -162,7 +161,6 @@ public class NotificationPanelView extends PanelView implements
     * If we are in a panel collapsing motion, we reset scrollY of our scroll view but still
     * need to take this into account in our panel height calculation.
     */
    private int mScrollYOverride = -1;
    private boolean mQsAnimatorExpand;
    private boolean mIsLaunchTransitionFinished;
    private boolean mIsLaunchTransitionRunning;
@@ -220,10 +218,6 @@ public class NotificationPanelView extends PanelView implements
        mQsContainer = (QSContainer) findViewById(R.id.quick_settings_container);
        mQsContainer.getHeader().setOnClickListener(this);
        mClockView = (TextView) findViewById(R.id.clock_view);
        mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
        mScrollView.setListener(this);
        mScrollView.setFocusable(false);
        mReserveNotificationSpace = findViewById(R.id.reserve_notification_space);
        mNotificationContainerParent = (NotificationsQuickSettingsContainer)
                findViewById(R.id.notification_container_parent);
        mNotificationStackScroller = (NotificationStackScrollLayout)
@@ -231,7 +225,7 @@ public class NotificationPanelView extends PanelView implements
        mNotificationStackScroller.setOnHeightChangedListener(this);
        mNotificationStackScroller.setOverscrollTopChangedListener(this);
        mNotificationStackScroller.setOnEmptySpaceClickListener(this);
        mNotificationStackScroller.setScrollView(mScrollView);
        mNotificationStackScroller.setQsContainer(mQsContainer);
        mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
        mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim);
        mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext());
@@ -287,13 +281,6 @@ public class NotificationPanelView extends PanelView implements
            lp.gravity = panelGravity;
            mNotificationStackScroller.setLayoutParams(lp);
        }

        lp = (FrameLayout.LayoutParams) mScrollView.getLayoutParams();
        if (lp.width != panelWidth) {
            lp.width = panelWidth;
            lp.gravity = panelGravity;
            mScrollView.setLayoutParams(lp);
        }
    }

    @Override
@@ -664,17 +651,6 @@ public class NotificationPanelView extends PanelView implements
        }
    }

    @Override
    public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {

        // Block request when interacting with the scroll view so we can still intercept the
        // scrolling when QS is expanded.
        if (mScrollView.isHandlingTouchEvent()) {
            return;
        }
        super.requestDisallowInterceptTouchEvent(disallowIntercept);
    }

    private void flingQsWithCurrentVelocity(float y, boolean isCancelMotionEvent) {
        float vel = getCurrentVelocity();
        final boolean expandsQs = flingExpandsQs(vel);
@@ -796,7 +772,7 @@ public class NotificationPanelView extends PanelView implements
    }

    private boolean isInQsArea(float x, float y) {
        return (x >= mScrollView.getX() && x <= mScrollView.getX() + mScrollView.getWidth()) &&
        return (x >= mQsContainer.getX() && x <= mQsContainer.getX() + mQsContainer.getWidth()) &&
                (y <= mNotificationStackScroller.getBottomMostNotificationBottom()
                || y <= mQsContainer.getY() + mQsContainer.getHeight());
    }
@@ -972,11 +948,7 @@ public class NotificationPanelView extends PanelView implements
        cancelHeightAnimator();

        // Reset scroll position and apply that position to the expanded height.
        float height = mQsExpansionHeight - mScrollView.getScrollY() - overscrollAmount;
        if (mScrollView.getScrollY() != 0) {
            mScrollYOverride = mScrollView.getScrollY();
        }
        mScrollView.scrollTo(0, 0);
        float height = mQsExpansionHeight - overscrollAmount;
        setQsExpansion(height);
        requestPanelHeightUpdate();
    }
@@ -988,7 +960,6 @@ public class NotificationPanelView extends PanelView implements
            updateQsState();
            requestPanelHeightUpdate();
            mFalsingManager.setQsExpanded(expanded);
            mNotificationStackScroller.setInterceptDelegateEnabled(expanded);
            mStatusBar.setQsExpanded(expanded);
            mNotificationContainerParent.setQsExpanded(expanded);
        }
@@ -1172,7 +1143,6 @@ public class NotificationPanelView extends PanelView implements
        mNotificationStackScroller.setScrollingEnabled(
                mStatusBarState != StatusBarState.KEYGUARD && (!mQsExpanded
                        || mQsExpansionFromOverscroll));
        mScrollView.setTouchEnabled(mQsExpanded);
        updateEmptyShadeView();
        mQsNavbarScrim.setVisibility(mStatusBarState == StatusBarState.SHADE && mQsExpanded
                && !mStackScrollerOverscrolling && mQsScrimEnabled
@@ -1256,7 +1226,7 @@ public class NotificationPanelView extends PanelView implements
                    mQsMinExpansionHeight, max);
        } else if (mQsSizeChangeAnimator != null) {
            return (int) mQsSizeChangeAnimator.getAnimatedValue();
        } else if (mKeyguardShowing && mScrollYOverride == -1) {
        } else if (mKeyguardShowing) {

            // We can only do the smoother transition on Keyguard when we also are not collapsing
            // from a scrolled quick settings.
@@ -1270,7 +1240,6 @@ public class NotificationPanelView extends PanelView implements

    private void requestScrollerTopPaddingUpdate(boolean animate) {
        mNotificationStackScroller.updateTopPadding(calculateQsTopPadding(),
                mScrollView.getScrollY(),
                mAnimateNextTopPaddingChange || animate,
                mKeyguardShowing
                        && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted));
@@ -1312,7 +1281,6 @@ public class NotificationPanelView extends PanelView implements
            boolean isClick) {
        float target = expand ? mQsMaxExpansionHeight : mQsMinExpansionHeight;
        if (target == mQsExpansionHeight) {
            mScrollYOverride = -1;
            if (onFinishRunnable != null) {
                onFinishRunnable.run();
            }
@@ -1322,7 +1290,6 @@ public class NotificationPanelView extends PanelView implements
        if (belowFalsingThreshold) {
            vel = 0;
        }
        mScrollView.setBlockFlinging(true);
        ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target);
        if (isClick) {
            animator.setInterpolator(Interpolators.TOUCH_RESPONSE);
@@ -1342,8 +1309,6 @@ public class NotificationPanelView extends PanelView implements
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mScrollView.setBlockFlinging(false);
                mScrollYOverride = -1;
                mQsExpansionAnimator = null;
                if (onFinishRunnable != null) {
                    onFinishRunnable.run();
@@ -1362,11 +1327,11 @@ public class NotificationPanelView extends PanelView implements
        if (!mQsExpansionEnabled || mCollapsedOnDown) {
            return false;
        }
        View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer;
        View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer.getHeader();
        boolean onHeader = x >= header.getX() && x <= header.getX() + header.getWidth()
                && y >= header.getTop() && y <= header.getBottom();
        if (mQsExpanded) {
            return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0) && isInQsArea(x, y);
            return onHeader || (yDiff < 0 && isInQsArea(x, y));
        } else {
            return onHeader;
        }
@@ -1378,7 +1343,7 @@ public class NotificationPanelView extends PanelView implements
            return mStatusBar.getBarState() == StatusBarState.KEYGUARD
                    || mNotificationStackScroller.isScrolledToBottom();
        } else {
            return mScrollView.isScrolledToBottom();
            return true;
        }
    }

@@ -1455,11 +1420,7 @@ public class NotificationPanelView extends PanelView implements
     *         collapsing QS / the panel when QS was scrolled
     */
    private int getTempQsMaxExpansion() {
        int qsTempMaxExpansion = mQsMaxExpansionHeight;
        if (mScrollYOverride != -1) {
            qsTempMaxExpansion -= mScrollYOverride;
        }
        return qsTempMaxExpansion;
        return mQsMaxExpansionHeight;
    }

    private int calculatePanelHeightShade() {
@@ -1497,20 +1458,12 @@ public class NotificationPanelView extends PanelView implements
                + notificationHeight;
        if (totalHeight > mNotificationStackScroller.getHeight()) {
            float fullyCollapsedHeight = maxQsHeight
                    + mNotificationStackScroller.getMinStackHeight()
                    - getScrollViewScrollY();
                    + mNotificationStackScroller.getMinStackHeight();
            totalHeight = Math.max(fullyCollapsedHeight, mNotificationStackScroller.getHeight());
        }
        return (int) totalHeight;
    }

    private int getScrollViewScrollY() {
        if (mScrollYOverride != -1 && !mQsTracking) {
            return mScrollYOverride;
        } else {
            return mScrollView.getScrollY();
        }
    }
    private void updateNotificationTranslucency() {
        float alpha = 1f;
        if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp && !mHeadsUpManager.hasPinnedHeadsUp()) {
@@ -1651,7 +1604,6 @@ public class NotificationPanelView extends PanelView implements
        mNotificationStackScroller.onExpansionStopped();
        mHeadsUpManager.onExpandingFinished();
        mIsExpanding = false;
        mScrollYOverride = -1;
        if (isFullyCollapsed()) {
            DejankUtils.postAfterTraversal(new Runnable() {
                @Override
@@ -2018,14 +1970,6 @@ public class NotificationPanelView extends PanelView implements
        return mConflictingQsExpansionGesture && mQsExpanded;
    }

    public void notifyVisibleChildrenChanged() {
        if (mNotificationStackScroller.getNotGoneChildCount() != 0) {
            mReserveNotificationSpace.setVisibility(View.VISIBLE);
        } else {
            mReserveNotificationSpace.setVisibility(View.GONE);
        }
    }

    public boolean isQsExpanded() {
        return mQsExpanded;
    }
@@ -2269,7 +2213,6 @@ public class NotificationPanelView extends PanelView implements

    protected void setVerticalPanelTranslation(float translation) {
        mNotificationStackScroller.setTranslationX(translation);
        mScrollView.setTranslationX(translation);
        mQsContainer.setTranslationX(translation);
    }

+7 −7
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import com.android.systemui.R;
public class NotificationsQuickSettingsContainer extends FrameLayout
        implements ViewStub.OnInflateListener {

    private View mScrollView;
    private View mQsContainer;
    private View mUserSwitcher;
    private View mStackScroller;
    private View mKeyguardStatusBar;
@@ -47,7 +47,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mScrollView = findViewById(R.id.scroll_view);
        mQsContainer = findViewById(R.id.quick_settings_container);
        mStackScroller = findViewById(R.id.notification_stack_scroller);
        mKeyguardStatusBar = findViewById(R.id.keyguard_header);
        ViewStub userSwitcher = (ViewStub) findViewById(R.id.keyguard_user_switcher);
@@ -58,7 +58,7 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        reloadWidth(mScrollView);
        reloadWidth(mQsContainer);
        reloadWidth(mStackScroller);
    }

@@ -80,11 +80,11 @@ public class NotificationsQuickSettingsContainer extends FrameLayout
        boolean userSwitcherVisible = mInflated && mUserSwitcher.getVisibility() == View.VISIBLE;
        boolean statusBarVisible = mKeyguardStatusBar.getVisibility() == View.VISIBLE;

        View stackQsTop = mQsExpanded ? mStackScroller : mScrollView;
        View stackQsBottom = !mQsExpanded ? mStackScroller : mScrollView;
        View stackQsTop = mQsExpanded ? mStackScroller : mQsContainer;
        View stackQsBottom = !mQsExpanded ? mStackScroller : mQsContainer;
        // Invert the order of the scroll view and user switcher such that the notifications receive
        // touches first but the panel gets drawn above.
        if (child == mScrollView) {
        if (child == mQsContainer) {
            return super.drawChild(canvas, userSwitcherVisible && statusBarVisible ? mUserSwitcher
                    : statusBarVisible ? mKeyguardStatusBar
                    : userSwitcherVisible ? mUserSwitcher
+0 −6
Original line number Diff line number Diff line
@@ -1599,12 +1599,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        updateNotifications();
    }

    @Override
    protected void updateRowStates() {
        super.updateRowStates();
        mNotificationPanel.notifyVisibleChildrenChanged();
    }

    @Override
    protected void setAreThereNotifications() {

Loading