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

Commit a59ecc34 authored by Selim Cinek's avatar Selim Cinek
Browse files

Handling a few more border cases with HUNs

Also does sorting correctly now.
The status bar now allows touches below when a
heads-up is on.
Also fixes a few flashes when a heads up was
dismissed or appeared.

Change-Id: I4d90a07333ad2e5ea2a13704cdc9d9184716681a
parent b8f09cf5
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1880,7 +1880,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
        boolean applyInPlace = shouldApplyInPlace(entry, n);
        final boolean shouldInterrupt = shouldInterrupt(notification);
        final boolean alertAgain = shouldInterrupt && alertAgain(entry, n);
        final boolean alertAgain = alertAgain(entry, n);
        boolean isHeadsUp = shouldInterrupt && alertAgain;

        entry.notification = notification;
@@ -1947,8 +1947,12 @@ public abstract class BaseStatusBar extends SystemUI implements
        if (wasHeadsUp) {
            mHeadsUpManager.updateNotification(entry, alertAgain);
            if (!shouldInterrupt) {
                // We don't want this to be interrupting anymore, lets remove it
                mHeadsUpManager.removeNotification(key);
            }
        } else if (shouldInterrupt && alertAgain) {
            // This notification was updated to be a heads-up, show it!
            mHeadsUpManager.showNotification(entry);
        }
    }

+5 −12
Original line number Diff line number Diff line
@@ -510,9 +510,6 @@ public class NotificationPanelView extends PanelView implements

    @Override
    protected void flingToHeight(float vel, boolean expand, float target) {
        if (!expand && mHeadsUpManager.hasPinnedHeadsUp()) {
            target = mHeadsUpManager.getHighestPinnedHeadsUp();
        }
        mHeadsUpTouchHelper.notifyFling(!expand);
        super.flingToHeight(vel, expand, target);
    }
@@ -722,7 +719,7 @@ public class NotificationPanelView extends PanelView implements
                || event.getActionMasked() == MotionEvent.ACTION_UP) {
            mConflictingQsExpansionGesture = false;
        }
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN && mExpandedHeight == 0
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isShadeCollapsed()
                && mQsExpansionEnabled) {
            mTwoFingerQsExpandPossible = true;
        }
@@ -1774,7 +1771,7 @@ public class NotificationPanelView extends PanelView implements
    }

    private void updateMaxHeadsUpTranslation() {
        mNotificationStackScroller.setMaxHeadsUpTranslation(getHeight() - mBottomBarHeight);
        mNotificationStackScroller.setHeadsUpBoundaries(getHeight(), mBottomBarHeight);
    }

    @Override
@@ -2151,16 +2148,12 @@ public class NotificationPanelView extends PanelView implements

    @Override
    public void OnHeadsUpStateChanged(NotificationData.Entry entry, boolean isHeadsUp) {
        // TODO: figure out the conditions when not to generate an animation
        mNotificationStackScroller.generateHeadsUpAnimation(entry.row, isHeadsUp);
        if (isShadeCollapsed()) {
            setExpandedHeight(mHeadsUpManager.getHighestPinnedHeadsUp());
        }
    }

    private boolean isShadeCollapsed() {
        // TODO: handle this cleaner
        return mHeader.getTranslationY() + mHeader.getCollapsedHeight() <= 0;
    @Override
    protected boolean isShadeCollapsed() {
        return mExpandedHeight == 0 || mHeadsUpManager.hasPinnedHeadsUp();
    }

    @Override
+4 −1
Original line number Diff line number Diff line
@@ -659,7 +659,7 @@ public abstract class PanelView extends FrameLayout {
        // If the user isn't actively poking us, let's update the height
        if ((!mTracking || isTrackingBlocked())
                && mHeightAnimator == null
                && mExpandedHeight > 0
                && !isShadeCollapsed()
                && currentMaxPanelHeight != mExpandedHeight
                && !mPeekPending
                && mPeekAnimator == null
@@ -730,6 +730,7 @@ public abstract class PanelView extends FrameLayout {
    }

    public boolean isFullyCollapsed() {
        // TODO: look into whether this is still correct with HUN's
        return mExpandedHeight <= 0;
    }

@@ -1019,6 +1020,8 @@ public abstract class PanelView extends FrameLayout {
     */
    protected abstract int getClearAllHeight();

    protected abstract boolean isShadeCollapsed();

    public void setHeadsUpManager(HeadsUpManager headsUpManager) {
        mHeadsUpManager = headsUpManager;
    }
+5 −6
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;

import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
@@ -615,7 +615,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    R.color.notification_panel_solid_background)));
        }

        mHeadsUpManager = new HeadsUpManager(context);
        mHeadsUpManager = new HeadsUpManager(context, mNotificationPanel.getViewTreeObserver());
        mHeadsUpManager.setBar(this);
        mHeadsUpManager.addListener(this);
        mHeadsUpManager.addListener(mNotificationPanel);
@@ -1880,10 +1880,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

    @Override
    public void escalateHeadsUp() {
        TreeMap<String, HeadsUpManager.HeadsUpEntry> entries = mHeadsUpManager.getEntries();
        for (String key : entries.keySet()) {
            Entry entry = entries.get(key).entry;
            final StatusBarNotification sbn = entry.notification;
        TreeSet<HeadsUpManager.HeadsUpEntry> entries = mHeadsUpManager.getSortedEntries();
        for (HeadsUpManager.HeadsUpEntry entry : entries) {
            final StatusBarNotification sbn = entry.entry.notification;
            final Notification notification = sbn.getNotification();
            if (notification.fullScreenIntent != null) {
                if (DEBUG) {
+9 −0
Original line number Diff line number Diff line
@@ -172,11 +172,20 @@ public class StatusBarWindowManager {
        applyUserActivityTimeout(state);
        applyInputFeatures(state);
        applyFitsSystemWindows(state);
        applyModalFlag(state);
        if (mLp.copyFrom(mLpChanged) != 0) {
            mWindowManager.updateViewLayout(mStatusBarView, mLp);
        }
    }

    private void applyModalFlag(State state) {
        if (state.headsUpShowing) {
            mLpChanged.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        } else {
            mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        }
    }

    public void setKeyguardShowing(boolean showing) {
        mCurrentState.keyguardShowing = showing;
        apply(mCurrentState);
Loading