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

Commit 51ec535c authored by Selim Cinek's avatar Selim Cinek Committed by Android Git Automerger
Browse files

am 131c1e29: Made sure that HUNS with full screen intents stay pinned

* commit '131c1e29':
  Made sure that HUNS with full screen intents stay pinned
parents 12aa8471 131c1e29
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -95,13 +95,15 @@ public class HeadsUpTouchHelper implements Gefingerpoken {

            case MotionEvent.ACTION_MOVE:
                final float h = y - mInitialTouchY;
                if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
                if (mTouchingHeadsUpView && Math.abs(h) > mTouchSlop
                        && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
                    setTrackingHeadsUp(true);
                    mCollapseSnoozes = h < 0;
                    mInitialTouchX = x;
                    mInitialTouchY = y;
                    int expandedHeight = mPickedChild.getActualHeight();
                    mPanel.startExpandMotion(x, y, true /* startTracking */, expandedHeight);
                    mHeadsUpManager.unpinAll();
                    return true;
                }
                break;
+22 −16
Original line number Diff line number Diff line
@@ -1872,13 +1872,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    @Override
    public void onHeadsUpPinnedModeChanged(boolean inPinnedMode) {
        if (inPinnedMode) {
            mStatusBarWindowManager.setHeadsUpShowing(true);
            mStatusBarWindowManager.setForceStatusBarVisible(true);
            if (mNotificationPanel.isFullyCollapsed()) {
                // We need to ensure that the touchable region is updated before the window will be
                // resized, in order to not catch any touches. A layout will ensure that
                // onComputeInternalInsets will be called and after that we can resize the layout. Let's
                // make sure that the window stays small for one frame until the touchableRegion is set.
                mNotificationPanel.requestLayout();
            mStatusBarWindowManager.setHeadsUpShowing(true);
            mStatusBarWindowManager.setForceStatusBarVisible(true);
                mStatusBarWindowManager.setForceWindowCollapsed(true);
                mNotificationPanel.post(new Runnable() {
                    @Override
@@ -1886,10 +1887,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                        mStatusBarWindowManager.setForceWindowCollapsed(false);
                    }
                });
            }
        } else {
            if (!mNotificationPanel.isFullyCollapsed()) {
            if (!mNotificationPanel.isFullyCollapsed() || mNotificationPanel.isTracking()) {
                // We are currently tracking or is open and the shade doesn't need to be kept
                // open artificially.
                mStatusBarWindowManager.setHeadsUpShowing(false);
            } else {
                // we need to keep the panel open artificially, let's wait until the animation
                // is finished.
                mHeadsUpManager.setHeadsUpGoingAway(true);
                mStackScroller.runAfterAnimationFinished(new Runnable() {
                    @Override
+10 −3
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
        if (mFraction != fraction) {
            mFraction = fraction;
            scheduleUpdate();
            if (mPinnedHeadsUpCount != 0) {
                updateHeadsUpScrim(false);
            }
        }
    }

@@ -425,12 +428,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
    }

    private float calculateHeadsUpAlpha() {
        float alpha;
        if (mPinnedHeadsUpCount >= 2) {
            return 1.0f;
            alpha = 1.0f;
        } else if (mPinnedHeadsUpCount == 0) {
            return 0.0f;
            alpha = 0.0f;
        } else {
            return 1.0f - mTopHeadsUpDragAmount;
            alpha = 1.0f - mTopHeadsUpDragAmount;
        }
        float expandFactor = (1.0f - mFraction);
        expandFactor = Math.max(expandFactor, 0.0f);
        return alpha * expandFactor;
    }
}
+15 −8
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
        if (alert) {
            HeadsUpEntry headsUpEntry = mHeadsUpEntries.get(headsUp.key);
            headsUpEntry.updateEntry();
            setEntryPinned(headsUpEntry, !mIsExpanded /* isPinned */);
            setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUp));
        }
    }

@@ -190,13 +190,21 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
        headsUpEntry.setEntry(entry);
        mHeadsUpEntries.put(entry.key, headsUpEntry);
        entry.row.setHeadsUp(true);
        setEntryPinned(headsUpEntry, !mIsExpanded /* isPinned */);
        setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(entry));
        for (OnHeadsUpChangedListener listener : mListeners) {
            listener.onHeadsUpStateChanged(entry, true);
        }
        entry.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
    }

    private boolean shouldHeadsUpBecomePinned(NotificationData.Entry entry) {
        return !mIsExpanded || hasFullScreenIntent(entry);
    }

    private boolean hasFullScreenIntent(NotificationData.Entry entry) {
        return entry.notification.getNotification().fullScreenIntent != null;
    }

    private void setEntryPinned(HeadsUpEntry headsUpEntry, boolean isPinned) {
        ExpandableNotificationRow row = headsUpEntry.entry.row;
        if (row.isPinned() != isPinned) {
@@ -350,6 +358,10 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
    }

    public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
        if (mIsExpanded) {
            // The touchable region is always the full area when expanded
            return;
        }
        if (mHasPinnedNotification) {
            int minX = Integer.MAX_VALUE;
            int maxX = 0;
@@ -445,7 +457,6 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
        if (isExpanded != mIsExpanded) {
            mIsExpanded = isExpanded;
            if (isExpanded) {
                unpinAll();
                // make sure our state is sane
                mWaitingOnCollapseWhenGoingAway = false;
                mHeadsUpGoingAway = false;
@@ -542,7 +553,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
            earliestRemovaltime = currentTime + mMinimumDisplayTime;
            postTime = Math.max(postTime, currentTime);
            removeAutoRemovalCallbacks();
            if (canEntryDecay()) {
            if (!hasFullScreenIntent(entry)) {
                long finishTime = postTime + mHeadsUpNotificationDecay;
                long removeDelay = Math.max(finishTime - currentTime, mMinimumDisplayTime);
                mHandler.postDelayed(mRemoveHeadsUpRunnable, removeDelay);
@@ -550,10 +561,6 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
            updateSortOrder(HeadsUpEntry.this);
        }

        private boolean canEntryDecay() {
            return entry.notification.getNotification().fullScreenIntent == null;
        }

        @Override
        public int compareTo(HeadsUpEntry o) {
            return postTime < o.postTime ? 1
+8 −7
Original line number Diff line number Diff line
@@ -485,7 +485,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        int minStackHeight = getMinStackHeight();
        int stackHeight;
        float paddingOffset;
        boolean trackingHeadsUp = mTrackingHeadsUp;
        boolean trackingHeadsUp = mTrackingHeadsUp || mHeadsUpManager.hasPinnedHeadsUp();
        int normalUnfoldPositionStart = trackingHeadsUp ? mHeadsUpManager.getTopHeadsUpHeight()
                : minStackHeight;
        if (newStackHeight - mTopPadding - mTopPaddingOverflow >= normalUnfoldPositionStart
@@ -608,7 +608,7 @@ public class NotificationStackScrollLayout extends ViewGroup

    @Override
    public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) {
        if (isPinnedHeadsUp(animView) && canChildBeDismissed(animView)) {
        if (!mIsExpanded && isPinnedHeadsUp(animView) && canChildBeDismissed(animView)) {
            mScrimController.setTopHeadsUpDragAmount(animView,
                    Math.min(Math.abs(swipeProgress - 1.0f), 1.0f));
        }
@@ -618,7 +618,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    public void onBeginDrag(View v) {
        setSwipingInProgress(true);
        mAmbientState.onBeginDrag(v);
        if (mAnimationsEnabled && !isPinnedHeadsUp(v)) {
        if (mAnimationsEnabled && (mIsExpanded || !isPinnedHeadsUp(v))) {
            mDragAnimPendingChildren.add(v);
            mNeedsAnimation = true;
        }
@@ -710,7 +710,7 @@ public class NotificationStackScrollLayout extends ViewGroup
            if (touchY >= top && touchY <= bottom && touchX >= left && touchX <= right) {
                if (slidingChild instanceof ExpandableNotificationRow) {
                    ExpandableNotificationRow row = (ExpandableNotificationRow) slidingChild;
                    if (row.isHeadsUp() && row.isPinned()
                    if (!mIsExpanded && row.isHeadsUp() && row.isPinned()
                            && mHeadsUpManager.getTopEntry().entry.row != row) {
                        continue;
                    }
@@ -1871,17 +1871,18 @@ public class NotificationStackScrollLayout extends ViewGroup
            boolean isHeadsUp = eventPair.second;
            int type = AnimationEvent.ANIMATION_TYPE_HEADS_UP_OTHER;
            boolean onBottom = false;
            boolean pinnedAndClosed = row.isPinned() && !mIsExpanded;
            if (!mIsExpanded && !isHeadsUp) {
                type = AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR;
            } else if (mAddedHeadsUpChildren.contains(row) || (row.isPinned() && !mIsExpanded)) {
                if (row.isPinned() || shouldHunAppearFromBottom(row)) {
            } else if (isHeadsUp && (mAddedHeadsUpChildren.contains(row) || pinnedAndClosed)) {
                if (pinnedAndClosed || shouldHunAppearFromBottom(row)) {
                    // Our custom add animation
                    type = AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR;
                } else {
                    // Normal add animation
                    type = AnimationEvent.ANIMATION_TYPE_ADD;
                }
                onBottom = !row.isPinned();
                onBottom = !pinnedAndClosed;
            }
            AnimationEvent event = new AnimationEvent(row, type);
            event.headsUpFromBottom = onBottom;
Loading