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

Commit 8bf00024 authored by Justin Weir's avatar Justin Weir Committed by Automerger Merge Worker
Browse files

Merge "Replace NPVC with an interface in HeadsUpTouchHelper" into udc-dev am:...

Merge "Replace NPVC with an interface in HeadsUpTouchHelper" into udc-dev am: 5895ed66 am: dddff1b5

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



Change-Id: I67e772a762c30a3ca3f8d1dc93a5b01bb148bd4d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 523b1adf dddff1b5
Loading
Loading
Loading
Loading
+30 −14
Original line number Diff line number Diff line
@@ -2897,15 +2897,7 @@ public final class NotificationPanelViewController implements Dumpable {
        mHeadsUpManager.addListener(mOnHeadsUpChangedListener);
        mHeadsUpTouchHelper = new HeadsUpTouchHelper(headsUpManager,
                mNotificationStackScrollLayoutController.getHeadsUpCallback(),
                NotificationPanelViewController.this);
    }

    public void setTrackedHeadsUp(ExpandableNotificationRow pickedChild) {
        if (pickedChild != null) {
            updateTrackingHeadsUp(pickedChild);
            mExpandingFromHeadsUp = true;
        }
        // otherwise we update the state when the expansion is finished
                new HeadsUpNotificationViewControllerImpl());
    }

    private void onClosingFinished() {
@@ -2953,7 +2945,8 @@ public final class NotificationPanelViewController implements Dumpable {
    }

    /** Called when a HUN is dragged up or down to indicate the starting height for shade motion. */
    public void setHeadsUpDraggingStartingHeight(int startHeight) {
    @VisibleForTesting
    void setHeadsUpDraggingStartingHeight(int startHeight) {
        mHeadsUpStartHeight = startHeight;
        float scrimMinFraction;
        if (mSplitShadeEnabled) {
@@ -2987,10 +2980,6 @@ public final class NotificationPanelViewController implements Dumpable {
        mScrimController.setPanelScrimMinFraction(mMinFraction);
    }

    public void clearNotificationEffects() {
        mCentralSurfaces.clearNotificationEffects();
    }

    private boolean isPanelVisibleBecauseOfHeadsUp() {
        return (mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway)
                && mBarState == StatusBarState.SHADE;
@@ -5143,6 +5132,33 @@ public final class NotificationPanelViewController implements Dumpable {
        }
    }

    private final class HeadsUpNotificationViewControllerImpl implements
            HeadsUpTouchHelper.HeadsUpNotificationViewController {
        @Override
        public void setHeadsUpDraggingStartingHeight(int startHeight) {
            NotificationPanelViewController.this.setHeadsUpDraggingStartingHeight(startHeight);
        }

        @Override
        public void setTrackedHeadsUp(ExpandableNotificationRow pickedChild) {
            if (pickedChild != null) {
                updateTrackingHeadsUp(pickedChild);
                mExpandingFromHeadsUp = true;
            }
            // otherwise we update the state when the expansion is finished
        }

        @Override
        public void startExpand(float x, float y, boolean startTracking, float expandedHeight) {
            startExpandMotion(x, y, startTracking, expandedHeight);
        }

        @Override
        public void clearNotificationEffects() {
            mCentralSurfaces.clearNotificationEffects();
        }
    }

    private final class ShadeAccessibilityDelegate extends AccessibilityDelegate {
        @Override
        public void onInitializeAccessibilityNodeInfo(View host,
+21 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.view.MotionEvent;
import android.view.ViewConfiguration;

import com.android.systemui.Gefingerpoken;
import com.android.systemui.shade.NotificationPanelViewController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
@@ -31,21 +30,21 @@ import com.android.systemui.statusbar.notification.row.ExpandableView;
 */
public class HeadsUpTouchHelper implements Gefingerpoken {

    private HeadsUpManagerPhone mHeadsUpManager;
    private Callback mCallback;
    private final HeadsUpManagerPhone mHeadsUpManager;
    private final Callback mCallback;
    private int mTrackingPointer;
    private float mTouchSlop;
    private final float mTouchSlop;
    private float mInitialTouchX;
    private float mInitialTouchY;
    private boolean mTouchingHeadsUpView;
    private boolean mTrackingHeadsUp;
    private boolean mCollapseSnoozes;
    private NotificationPanelViewController mPanel;
    private final HeadsUpNotificationViewController mPanel;
    private ExpandableNotificationRow mPickedChild;

    public HeadsUpTouchHelper(HeadsUpManagerPhone headsUpManager,
            Callback callback,
            NotificationPanelViewController notificationPanelView) {
            HeadsUpNotificationViewController notificationPanelView) {
        mHeadsUpManager = headsUpManager;
        mCallback = callback;
        mPanel = notificationPanelView;
@@ -116,7 +115,7 @@ public class HeadsUpTouchHelper implements Gefingerpoken {
                    int startHeight = (int) (mPickedChild.getActualHeight()
                                                + mPickedChild.getTranslationY());
                    mPanel.setHeadsUpDraggingStartingHeight(startHeight);
                    mPanel.startExpandMotion(x, y, true /* startTracking */, startHeight);
                    mPanel.startExpand(x, y, true /* startTracking */, startHeight);
                    // This call needs to be after the expansion start otherwise we will get a
                    // flicker of one frame as it's not expanded yet.
                    mHeadsUpManager.unpinAll(true);
@@ -181,4 +180,19 @@ public class HeadsUpTouchHelper implements Gefingerpoken {
        boolean isExpanded();
        Context getContext();
    }

    /** The controller for a view that houses heads up notifications. */
    public interface HeadsUpNotificationViewController {
        /** Called when a HUN is dragged to indicate the starting height for shade motion. */
        void setHeadsUpDraggingStartingHeight(int startHeight);

        /** Sets notification that is being expanded. */
        void setTrackedHeadsUp(ExpandableNotificationRow expandableNotificationRow);

        /** Called when a MotionEvent is about to trigger expansion. */
        void startExpand(float newX, float newY, boolean startTracking, float expandedHeight);

        /** Clear any effects that were added for the expansion. */
        void clearNotificationEffects();
    }
}