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

Commit 35b49cff authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Migrate NotificationClick to EntryAdapter" into main

parents 158797c6 9c4dfaa7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ class BundleEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isBubble() {
        assertThat(underTest.isBubbleCapable).isFalse()
        assertThat(underTest.isBubble).isFalse()
    }

    @Test
+9 −9
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getRow_adapter() {
        val row = Mockito.mock(ExpandableNotificationRow::class.java)
        val row = mock(ExpandableNotificationRow::class.java)
        val notification: Notification =
            Notification.Builder(mContext, "").setSmallIcon(R.drawable.ic_person).build()

@@ -128,7 +128,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isGroupRoot_adapter_groupSummary() {
        val row = Mockito.mock(ExpandableNotificationRow::class.java)
        val row = mock(ExpandableNotificationRow::class.java)
        val notification: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
@@ -175,7 +175,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isClearable_adapter() {
        val row = Mockito.mock(ExpandableNotificationRow::class.java)
        val row = mock(ExpandableNotificationRow::class.java)
        val notification: Notification =
            Notification.Builder(mContext, "").setSmallIcon(R.drawable.ic_person).build()

@@ -193,7 +193,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getSummarization_adapter() {
        val row = Mockito.mock(ExpandableNotificationRow::class.java)
        val row = mock(ExpandableNotificationRow::class.java)
        val notification: Notification =
            Notification.Builder(mContext, "").setSmallIcon(R.drawable.ic_person).build()

@@ -213,7 +213,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getIcons_adapter() {
        val row = Mockito.mock(ExpandableNotificationRow::class.java)
        val row = mock(ExpandableNotificationRow::class.java)
        val notification: Notification =
            Notification.Builder(mContext, "").setSmallIcon(R.drawable.ic_person).build()

@@ -258,7 +258,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun canDragAndDrop() {
        val pi = Mockito.mock(PendingIntent::class.java)
        val pi = mock(PendingIntent::class.java)
        Mockito.`when`(pi.isActivity).thenReturn(true)
        val notification: Notification =
            Notification.Builder(mContext, "")
@@ -284,7 +284,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
        val entry = NotificationEntryBuilder().setNotification(notification).build()

        underTest = factory.create(entry) as NotificationEntryAdapter
        assertThat(underTest.isBubbleCapable).isEqualTo(entry.isBubble)
        assertThat(underTest.isBubble).isEqualTo(entry.isBubble)
    }

    @Test
@@ -350,7 +350,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
        val notification: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .setFullScreenIntent(Mockito.mock(PendingIntent::class.java), true)
                .setFullScreenIntent(mock(PendingIntent::class.java), true)
                .build()

        val entry =
@@ -399,7 +399,7 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
        val notification: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .addAction(Mockito.mock(Notification.Action::class.java))
                .addAction(mock(Notification.Action::class.java))
                .build()

        val entry = NotificationEntryBuilder().setNotification(notification).build()
+7 −5
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ public final class NotificationClicker implements View.OnClickListener {
        mPowerInteractor.wakeUpIfDozing("NOTIFICATION_CLICK", PowerManager.WAKE_REASON_GESTURE);

        final ExpandableNotificationRow row = (ExpandableNotificationRow) v;
        final NotificationEntry entry = row.getEntry();
        mLogger.logOnClick(row.getLoggingKey());

        // Check if the notification is displaying the menu, if so slide notification back
@@ -109,16 +108,16 @@ public final class NotificationClicker implements View.OnClickListener {
        DejankUtils.postAfterTraversal(() -> row.setJustClicked(false));

        if (NotificationBundleUi.isEnabled()) {
            if (!row.getEntryAdapter().isBubbleCapable() && mBubblesOptional.isPresent()) {
            if (!row.getEntryAdapter().isBubble() && mBubblesOptional.isPresent()) {
                mBubblesOptional.get().collapseStack();
            }
            row.getEntryAdapter().onEntryClicked(row);
        } else {
            if (!row.getEntryLegacy().isBubble() && mBubblesOptional.isPresent()) {
                mBubblesOptional.get().collapseStack();
            }
            mNotificationActivityStarter.onNotificationClicked(row.getEntryLegacy(), row);
        }

        mNotificationActivityStarter.onNotificationClicked(entry, row);
    }

    private boolean isMenuVisible(ExpandableNotificationRow row) {
@@ -129,9 +128,12 @@ public final class NotificationClicker implements View.OnClickListener {
     * Attaches the click listener to the row if appropriate.
     */
    public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {
        boolean isBubble = NotificationBundleUi.isEnabled()
                ? row.getEntryAdapter().isBubble()
                : row.getEntryLegacy().isBubble();
        Notification notification = sbn.getNotification();
        if (notification.contentIntent != null || notification.fullScreenIntent != null
                || row.getEntry().isBubble()) {
                || isBubble) {
            if (NotificationBundleUi.isEnabled()) {
                row.setBubbleClickListener(
                        v -> row.getEntryAdapter().onNotificationBubbleIconClicked());
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ class BundleEntryAdapter(val entry: BundleEntry) : EntryAdapter {
        return false
    }

    override fun isBubbleCapable(): Boolean {
    override fun isBubble(): Boolean {
        return false
    }

+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ public interface EntryAdapter {

    boolean canDragAndDrop();

    boolean isBubbleCapable();
    boolean isBubble();

    @Nullable String getStyle();

Loading