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

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

Merge "Add dismiss state to entry adapter" into main

parents 09558664 60110c9b
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito
import org.mockito.Mockito.mock
import org.mockito.Mockito.verify

@SmallTest
@@ -380,4 +381,36 @@ class NotificationEntryAdapterTest : SysuiTestCase() {
        underTest.onNotificationActionClicked()
        verify(kosmos.mockNotificationActionClickManager).onNotificationActionClicked(entry)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getDismissState() {
        val notification: Notification =
            Notification.Builder(mContext, "").setSmallIcon(R.drawable.ic_person).build()

        val entry = NotificationEntryBuilder().setNotification(notification).build()
        entry.dismissState = NotificationEntry.DismissState.PARENT_DISMISSED

        underTest = factory.create(entry) as NotificationEntryAdapter

        assertThat(underTest.dismissState).isEqualTo(entry.dismissState)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun onEntryClicked() {
        val notification: Notification =
            Notification.Builder(mContext, "")
                .setSmallIcon(R.drawable.ic_person)
                .addAction(mock(Notification.Action::class.java))
                .build()
        val entry = NotificationEntryBuilder().setNotification(notification).build()
        val row = mock(ExpandableNotificationRow::class.java)

        underTest = factory.create(entry) as NotificationEntryAdapter


        underTest.onEntryClicked(row)
        verify(kosmos.mockNotificationActivityStarter).onNotificationClicked(entry, row)
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -130,6 +130,16 @@ class BundleEntryAdapter(val entry: BundleEntry) : EntryAdapter {
        // do nothing. these have no actions
        Log.wtf(TAG, "onNotificationActionClicked() called")
    }

    override fun getDismissState(): NotificationEntry.DismissState {
        // TODO(b/394483200): setDismissState is only called in NotifCollection so it does not
        // work on bundles yet
        return NotificationEntry.DismissState.NOT_DISMISSED
    }

    override fun onEntryClicked(row: ExpandableNotificationRow) {
        // TODO(b/396446620): should anything happen when you click on a bundle?
    }
}

private const val TAG = "BundleEntryAdapter"
+4 −0
Original line number Diff line number Diff line
@@ -150,5 +150,9 @@ public interface EntryAdapter {
     * Processes a click on a notification action
     */
    void onNotificationActionClicked();

    NotificationEntry.DismissState getDismissState();

    void onEntryClicked(ExpandableNotificationRow row);
}
+8 −0
Original line number Diff line number Diff line
@@ -152,4 +152,12 @@ class NotificationEntryAdapter(
    override fun onNotificationActionClicked() {
        notificationActionClickManager.onNotificationActionClicked(entry)
    }

    override fun getDismissState(): NotificationEntry.DismissState {
        return entry.dismissState
    }

    override fun onEntryClicked(row: ExpandableNotificationRow) {
        notificationActivityStarter.onNotificationClicked(entry, row)
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -1786,7 +1786,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    /** @return true if the User has dismissed this notif's parent */
    public boolean isParentDismissed() {
        return getEntry().getDismissState() == PARENT_DISMISSED;
        if (NotificationBundleUi.isEnabled()) {
            return getEntryAdapter().getDismissState() == PARENT_DISMISSED;
        } else {
            return getEntryLegacy().getDismissState() == PARENT_DISMISSED;
        }
    }

    @Override