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

Commit 68fe9164 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Specify explicit actions for bubble / unbubble"

parents 55a32151 d7fcf05d
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.systemui.statusbar.notification.row.NotificationConver
import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_HOME;
import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_MUTE;
import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_SNOOZE;
import static com.android.systemui.statusbar.notification.row.NotificationConversationInfo.UpdateChannelRunnable.ACTION_UNBUBBLE;

import static java.lang.annotation.RetentionPolicy.SOURCE;

@@ -121,7 +122,7 @@ public class NotificationConversationInfo extends LinearLayout implements
    boolean mSkipPost = false;

    private OnClickListener mOnBubbleClick = v -> {
        mSelectedAction = ACTION_BUBBLE;
        mSelectedAction = mStartedAsBubble ? ACTION_UNBUBBLE : ACTION_BUBBLE;
        if (mStartedAsBubble) {
            mBubbleController.onUserDemotedBubbleFromNotification(mEntry);
        } else {
@@ -586,6 +587,7 @@ public class NotificationConversationInfo extends LinearLayout implements
        static final int ACTION_SNOOZE = 3;
        static final int ACTION_MUTE = 4;
        static final int ACTION_DEMOTE = 5;
        static final int ACTION_UNBUBBLE = 6;

        private final INotificationManager mINotificationManager;
        private final String mAppPkg;
@@ -606,9 +608,17 @@ public class NotificationConversationInfo extends LinearLayout implements
        @Override
        public void run() {
            try {
                boolean channelSettingChanged = mAction != ACTION_HOME && mAction != ACTION_SNOOZE;
                switch (mAction) {
                    case ACTION_BUBBLE:
                        mChannelToUpdate.setAllowBubbles(!mChannelToUpdate.canBubble());
                    case ACTION_UNBUBBLE:
                        boolean canBubble = mAction == ACTION_BUBBLE;
                        if (mChannelToUpdate.canBubble() != canBubble) {
                            channelSettingChanged = true;
                            mChannelToUpdate.setAllowBubbles(canBubble);
                        } else {
                            channelSettingChanged = false;
                        }
                        break;
                    case ACTION_FAVORITE:
                        // TODO: extend beyond DND
@@ -629,7 +639,7 @@ public class NotificationConversationInfo extends LinearLayout implements

                }

                if (mAction != ACTION_HOME && mAction != ACTION_SNOOZE) {
                if (channelSettingChanged) {
                    mINotificationManager.updateNotificationChannelForPackage(
                            mAppPkg, mAppUid, mChannelToUpdate);
                }
+28 −1
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import android.service.notification.StatusBarNotification;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -600,6 +599,34 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
        assertFalse(captor.getValue().canBubble());
    }

    @Test
    public void testBubble_noChannelChange() throws Exception {
        mNotificationInfo.bindNotification(
                mShortcutManager,
                mLauncherApps,
                mMockPackageManager,
                mMockINotificationManager,
                mVisualStabilityManager,
                TEST_PACKAGE_NAME,
                mNotificationChannel,
                mBubbleEntry,
                null,
                null,
                null,
                true);

        assertFalse(mBubbleEntry.isBubble());
        assertTrue(mNotificationChannel.canBubble());

        // Promote it
        mNotificationInfo.findViewById(R.id.bubble).performClick();
        mTestableLooper.processAllMessages();

        verify(mBubbleController, times(1)).onUserCreatedBubbleFromNotification(mBubbleEntry);
        verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
                anyString(), anyInt(), any());
    }

    @Test
    public void testFavorite_favorite() throws Exception {
        mNotificationInfo.bindNotification(