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

Commit 97da9d91 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Show the feedback icon on all notifications

With no adjustment extras if no adjustment was active on
the notification

Test: NotificationInfoTest
Test: NotificationConversationInfoTest
Test: PartialConversationInfoTest
Fixes: 428671193
Flag: android.app.notification_classification_ui

Change-Id: I7b0ad3cbc9c133e720c6927b2566c33aeb16da29
parent 110501cc
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -905,15 +905,6 @@ class NotificationInfoTest : SysuiTestCase() {
        assertThat(latch.count).isEqualTo(0)
    }

    @Test
    @EnableFlags(Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI)
    @Throws(Exception::class)
    fun testBindNotification_hidesFeedbackLink_notReservedChannel() {
        bindNotification()

        assertThat(underTest.findViewById<View>(R.id.feedback).visibility).isEqualTo(GONE)
    }

    @Test
    @Throws(RemoteException::class)
    fun testDismissListenerBound() {
+4 −41
Original line number Diff line number Diff line
@@ -311,52 +311,15 @@ public class NotificationConversationInfo extends LinearLayout implements
        bindDelegate();
    }
    private boolean showSummarizationFeedback() {
        return NmSummarizationUiFlag.isEnabled()
                && !TextUtils.isEmpty(mRanking.getSummarization());
    }
    private static boolean isAnimatedReply(CharSequence choice) {
        if (choice instanceof Spanned) {
            Spanned spanned = (Spanned) choice;
            Annotation[] annotations = spanned.getSpans(0, choice.length(), Annotation.class);
            if (annotations != null) { // Add null check
                for (Annotation annotation : annotations) {
                    if ("isAnimatedReply".equals(annotation.getKey())
                            && "1".equals(annotation.getValue())) {
                        return true;
                    }
                }
            }
        }
        return false;
        return NmSummarizationUiFlag.isEnabled();
    }

    private boolean showAnimatedFeedback() {
        boolean hasAnimatedSmartReplies = false;
        boolean hasAnimatedSmartActions = false;
        // Check for animated smart replies
        List<CharSequence> smartReplies = mRanking.getSmartReplies();
            for (CharSequence reply : smartReplies) {
                if (isAnimatedReply(reply)) {
                    hasAnimatedSmartReplies = true;
                    break;
                }
            }
        // Check for animated actions
        List<Notification.Action> smartActions = mRanking.getSmartActions();
            for (Notification.Action action : smartActions) {
                if (action != null && action.getExtras() != null &&
                        action.getExtras().getBoolean(Notification.Action.EXTRA_IS_ANIMATED,
                                false)) {
                    hasAnimatedSmartActions = true;
                    break;
                }
            }
        return com.android.systemui.Flags.notificationAnimatedActionsTreatment() &&
                (hasAnimatedSmartActions || hasAnimatedSmartReplies);
        return com.android.systemui.Flags.notificationAnimatedActionsTreatment();
    }

    private boolean showClassificationFeedback() {
        return Flags.notificationClassificationUi() &&
                SYSTEM_RESERVED_IDS.contains(mNotificationChannel.getId());
        return Flags.notificationClassificationUi();
    }

    private void bindFeedback() {
+11 −4
Original line number Diff line number Diff line
@@ -365,8 +365,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        bindDelegate();


        if (Flags.notificationClassificationUi() &&
                SYSTEM_RESERVED_IDS.contains(mSingleNotificationChannel.getId())) {
        if (Flags.notificationClassificationUi()) {
            bindFeedback();
        } else {
            // Set up app settings link (i.e. Customize)
@@ -393,6 +392,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G

    private void bindFeedback() {
        View feedbackButton = findViewById(R.id.feedback);
        if (feedbackButton == null) {
            return;
        }
        Intent intent = getAssistantFeedbackIntent(
                mINotificationManager, mPm, mSbn.getKey(), mRanking);
        if ((!android.app.Flags.notificationClassificationUi() &&
@@ -444,8 +446,13 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
            intent.setClassName(activityInfo.packageName, activityInfo.name);

            intent.putExtra(NotificationAssistantService.EXTRA_NOTIFICATION_KEY, key);
            if (ranking.getSummarization() != null ||
                    SYSTEM_RESERVED_IDS.contains(ranking.getChannel().getId())) {
                intent.putExtra(NotificationAssistantService.EXTRA_NOTIFICATION_ADJUSTMENT,
                    ranking.getSummarization() != null ? KEY_SUMMARIZATION : KEY_TYPE);
                        ranking.getSummarization() != null
                        ? KEY_SUMMARIZATION
                        : KEY_TYPE);
            }
            ArrayList<String> keys = new ArrayList<>();
            NotificationChannel channel = ranking.getChannel(); // Get channel from ranking

+2 −4
Original line number Diff line number Diff line
@@ -278,13 +278,11 @@ public class PartialConversationInfo extends LinearLayout implements
    }

    private boolean showSummarizationFeedback() {
        return NmSummarizationUiFlag.isEnabled()
                && !TextUtils.isEmpty(mRanking.getSummarization());
        return NmSummarizationUiFlag.isEnabled();
    }

    private boolean showClassificationFeedback() {
        return Flags.notificationClassificationUi() &&
                SYSTEM_RESERVED_IDS.contains(mNotificationChannel.getId());
        return Flags.notificationClassificationUi();
    }

    private void bindFeedback() {
+0 −12
Original line number Diff line number Diff line
@@ -522,18 +522,6 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
        assertEquals(0, latch.getCount());
    }

    @Test
    @EnableFlags({
            Flags.FLAG_NM_SUMMARIZATION,
            Flags.FLAG_NM_SUMMARIZATION_UI,
            FLAG_NOTIFICATION_ANIMATED_ACTIONS_TREATMENT
    })
    public void testBindNotification_hidesFeedbackLink_ifSummaryNotInRanking() {
        doStandardBind();

        assertEquals(GONE, mNotificationInfo.findViewById(R.id.feedback).getVisibility());
    }

    @Test
    public void testBindNotification_SetsOnClickListenerForSettings() {
        final CountDownLatch latch = new CountDownLatch(1);