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

Commit 45fe7840 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Pin HUNs while guts are visible

Test: NotificationGutsManagerTest
Test: long press HUN - verify that it does not time out
Test: Hit 'done' on Guts - verifiy that it times out now
that guts are closed
Test: post hun, verify that it times out if not touched
Test: post hun, open guts, open shade - guts still shown
Test: post hun, open guts, open shade, close guts, close shade:
notification unpinned on shade open
Test: post hun, open guts, open shade, post new HUN: ordering
is correct; both unpinned on shade close
Fixes: 194024962

Change-Id: I3e46932e38e40355f2add60ffc90ec65506688c3
parent c9e63145
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.notification.collection.render.NotifGutsVi
import com.android.systemui.statusbar.notification.collection.render.NotifGutsViewManager;
import com.android.systemui.statusbar.notification.collection.render.NotifGutsViewManager;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.wmshell.BubblesManager;
import com.android.systemui.wmshell.BubblesManager;


@@ -119,6 +120,7 @@ public class NotificationGutsManager implements NotifGutsViewManager {
    private final UiEventLogger mUiEventLogger;
    private final UiEventLogger mUiEventLogger;
    private final ShadeController mShadeController;
    private final ShadeController mShadeController;
    private NotifGutsViewListener mGutsListener;
    private NotifGutsViewListener mGutsListener;
    private final HeadsUpManagerPhone mHeadsUpManagerPhone;


    @Inject
    @Inject
    public NotificationGutsManager(Context context,
    public NotificationGutsManager(Context context,
@@ -141,7 +143,8 @@ public class NotificationGutsManager implements NotifGutsViewManager {
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            StatusBarStateController statusBarStateController,
            StatusBarStateController statusBarStateController,
            DeviceProvisionedController deviceProvisionedController,
            DeviceProvisionedController deviceProvisionedController,
            MetricsLogger metricsLogger) {
            MetricsLogger metricsLogger,
            HeadsUpManagerPhone headsUpManagerPhone) {
        mContext = context;
        mContext = context;
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mMainHandler = mainHandler;
        mMainHandler = mainHandler;
@@ -163,6 +166,7 @@ public class NotificationGutsManager implements NotifGutsViewManager {
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController = statusBarStateController;
        mDeviceProvisionedController = deviceProvisionedController;
        mDeviceProvisionedController = deviceProvisionedController;
        mMetricsLogger = metricsLogger;
        mMetricsLogger = metricsLogger;
        mHeadsUpManagerPhone = headsUpManagerPhone;
    }
    }


    public void setUpWithPresenter(NotificationPresenter presenter,
    public void setUpWithPresenter(NotificationPresenter presenter,
@@ -259,7 +263,7 @@ public class NotificationGutsManager implements NotifGutsViewManager {
            if (mGutsListener != null) {
            if (mGutsListener != null) {
                mGutsListener.onGutsClose(entry);
                mGutsListener.onGutsClose(entry);
            }
            }
            String key = entry.getKey();
            mHeadsUpManagerPhone.setGutsShown(row.getEntry(), false);
        });
        });


        View gutsView = item.getGutsView();
        View gutsView = item.getGutsView();
@@ -420,7 +424,7 @@ public class NotificationGutsManager implements NotifGutsViewManager {
    }
    }


    /**
    /**
     * Sets up the {@link ConversationInfo} inside the notification row's guts.
     * Sets up the {@link NotificationConversationInfo} inside the notification row's guts.
     * @param row view to set up the guts for
     * @param row view to set up the guts for
     * @param notificationInfoView view to set up/bind within {@code row}
     * @param notificationInfoView view to set up/bind within {@code row}
     */
     */
@@ -641,6 +645,7 @@ public class NotificationGutsManager implements NotifGutsViewManager {
                row.closeRemoteInput();
                row.closeRemoteInput();
                mListContainer.onHeightChanged(row, true /* needsAnimation */);
                mListContainer.onHeightChanged(row, true /* needsAnimation */);
                mGutsMenuItem = menuItem;
                mGutsMenuItem = menuItem;
                mHeadsUpManagerPhone.setGutsShown(row.getEntry(), true);
            }
            }
        };
        };
        guts.post(mOpenRunnable);
        guts.post(mOpenRunnable);
+0 −6
Original line number Original line Diff line number Diff line
@@ -370,11 +370,6 @@ public class NotificationStackScrollLayoutController {
            if (translatingParentView != null && row == translatingParentView) {
            if (translatingParentView != null && row == translatingParentView) {
                mSwipeHelper.clearExposedMenuView();
                mSwipeHelper.clearExposedMenuView();
                mSwipeHelper.clearTranslatingParentView();
                mSwipeHelper.clearTranslatingParentView();
                if (row instanceof ExpandableNotificationRow) {
                    mHeadsUpManager.setMenuShown(
                            ((ExpandableNotificationRow) row).getEntry(), false);

                }
            }
            }
        }
        }


@@ -385,7 +380,6 @@ public class NotificationStackScrollLayoutController {
                mMetricsLogger.write(notificationRow.getEntry().getSbn().getLogMaker()
                mMetricsLogger.write(notificationRow.getEntry().getSbn().getLogMaker()
                        .setCategory(MetricsEvent.ACTION_REVEAL_GEAR)
                        .setCategory(MetricsEvent.ACTION_REVEAL_GEAR)
                        .setType(MetricsEvent.TYPE_ACTION));
                        .setType(MetricsEvent.TYPE_ACTION));
                mHeadsUpManager.setMenuShown(notificationRow.getEntry(), true);
                mSwipeHelper.onMenuShown(row);
                mSwipeHelper.onMenuShown(row);
                mNotificationGutsManager.closeAndSaveGuts(true /* removeLeavebehind */,
                mNotificationGutsManager.closeAndSaveGuts(true /* removeLeavebehind */,
                        false /* force */, false /* removeControls */, -1 /* x */, -1 /* y */,
                        false /* force */, false /* removeControls */, -1 /* x */, -1 /* y */,
+13 −11
Original line number Original line Diff line number Diff line
@@ -271,13 +271,15 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
    }
    }


    /**
    /**
     * Sets whether an entry's menu row is exposed and therefore it should stick in the heads up
     * Sets whether an entry's guts are exposed and therefore it should stick in the heads up
     * area if it's pinned until it's hidden again.
     * area if it's pinned until it's hidden again.
     */
     */
    public void setMenuShown(@NonNull NotificationEntry entry, boolean menuShown) {
    public void setGutsShown(@NonNull NotificationEntry entry, boolean gutsShown) {
        HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey());
        HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey());
        if (headsUpEntry instanceof HeadsUpEntryPhone && entry.isRowPinned()) {
        if (!(headsUpEntry instanceof HeadsUpEntryPhone)) return;
            ((HeadsUpEntryPhone) headsUpEntry).setMenuShownPinned(menuShown);
        HeadsUpEntryPhone headsUpEntryPhone = (HeadsUpEntryPhone)headsUpEntry;
        if (entry.isRowPinned() || !gutsShown) {
            headsUpEntryPhone.setGutsShownPinned(gutsShown);
        }
        }
    }
    }


@@ -411,7 +413,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,


    protected class HeadsUpEntryPhone extends HeadsUpManager.HeadsUpEntry {
    protected class HeadsUpEntryPhone extends HeadsUpManager.HeadsUpEntry {


        private boolean mMenuShownPinned;
        private boolean mGutsShownPinned;


        /**
        /**
         * If the time this entry has been on was extended
         * If the time this entry has been on was extended
@@ -421,7 +423,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,


        @Override
        @Override
        public boolean isSticky() {
        public boolean isSticky() {
            return super.isSticky() || mMenuShownPinned;
            return super.isSticky() || mGutsShownPinned;
        }
        }


        public void setEntry(@NonNull final NotificationEntry entry) {
        public void setEntry(@NonNull final NotificationEntry entry) {
@@ -469,13 +471,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
            }
            }
        }
        }


        public void setMenuShownPinned(boolean menuShownPinned) {
        public void setGutsShownPinned(boolean gutsShownPinned) {
            if (mMenuShownPinned == menuShownPinned) {
            if (mGutsShownPinned == gutsShownPinned) {
                return;
                return;
            }
            }


            mMenuShownPinned = menuShownPinned;
            mGutsShownPinned = gutsShownPinned;
            if (menuShownPinned) {
            if (gutsShownPinned) {
                removeAutoRemovalCallbacks();
                removeAutoRemovalCallbacks();
            } else {
            } else {
                updateEntry(false /* updatePostTime */);
                updateEntry(false /* updatePostTime */);
@@ -485,7 +487,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
        @Override
        @Override
        public void reset() {
        public void reset() {
            super.reset();
            super.reset();
            mMenuShownPinned = false;
            mGutsShownPinned = false;
            extended = false;
            extended = false;
        }
        }


+8 −2
Original line number Original line Diff line number Diff line
@@ -81,6 +81,7 @@ import com.android.systemui.statusbar.notification.people.PeopleNotificationIden
import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.wmshell.BubblesManager;
import com.android.systemui.wmshell.BubblesManager;


@@ -134,6 +135,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
    @Mock private AssistantFeedbackController mAssistantFeedbackController;
    @Mock private AssistantFeedbackController mAssistantFeedbackController;
    @Mock private NotificationLockscreenUserManager mNotificationLockscreenUserManager;
    @Mock private NotificationLockscreenUserManager mNotificationLockscreenUserManager;
    @Mock private StatusBarStateController mStatusBarStateController;
    @Mock private StatusBarStateController mStatusBarStateController;
    @Mock private HeadsUpManagerPhone mHeadsUpManagerPhone;


    @Before
    @Before
    public void setUp() {
    public void setUp() {
@@ -153,7 +155,8 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
                mNotificationLockscreenUserManager,
                mNotificationLockscreenUserManager,
                mStatusBarStateController,
                mStatusBarStateController,
                mDeviceProvisionedController,
                mDeviceProvisionedController,
                mMetricsLogger);
                mMetricsLogger,
                mHeadsUpManagerPhone);
        mGutsManager.setUpWithPresenter(mPresenter, mNotificationListContainer,
        mGutsManager.setUpWithPresenter(mPresenter, mNotificationListContainer,
                mOnSettingsClickListener);
                mOnSettingsClickListener);
        mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter);
        mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter);
@@ -192,12 +195,15 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
                anyInt(),
                anyInt(),
                anyBoolean(),
                anyBoolean(),
                any(Runnable.class));
                any(Runnable.class));
        verify(mHeadsUpManagerPhone).setGutsShown(realRow.getEntry(), true);


        assertEquals(View.VISIBLE, guts.getVisibility());
        assertEquals(View.VISIBLE, guts.getVisibility());
        mGutsManager.closeAndSaveGuts(false, false, false, 0, 0, false);
        mGutsManager.closeAndSaveGuts(false, false, true, 0, 0, false);


        verify(guts).closeControls(anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyBoolean());
        verify(guts).closeControls(anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyBoolean());
        verify(row, times(1)).setGutsView(any());
        verify(row, times(1)).setGutsView(any());
        mTestableLooper.processAllMessages();
        verify(mHeadsUpManagerPhone).setGutsShown(realRow.getEntry(), false);
    }
    }


    @Test
    @Test