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

Commit 0ef7d842 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Display proper block text for blocking helper

Test: runtest systemui
Bug: 63095540
Change-Id: Ifa86744e2ddbb0170f61d15750a2e5453107988d
parent 6692b47d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1496,6 +1496,10 @@
    <!-- Notification Inline Controls: Shown when a channel's notifications are currently blocked -->
    <string name="notification_channel_disabled">You won\'t see these notifications anymore</string>

    <!-- Notification Inline controls: continue receiving notifications prompt, channel level -->
    <string name="inline_blocking_helper">You usually dismiss these notifications.
    \nKeep showing them?</string>

    <!-- Notification Inline controls: continue receiving notifications prompt, channel level -->
    <string name="inline_keep_showing">Keep showing these notifications?</string>

+5 −1
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */
package com.android.systemui.statusbar;

import static android.service.notification.NotificationListenerService.Ranking
        .USER_SENTIMENT_NEGATIVE;

import android.app.INotificationManager;
import android.app.NotificationChannel;
import android.content.Context;
@@ -231,7 +234,8 @@ public class NotificationGutsManager implements Dumpable {
            try {
                info.bindNotification(pmUser, iNotificationManager, pkg, row.getEntry().channel,
                        channels.size(), sbn, mCheckSaveListener, onSettingsClick,
                        onAppSettingsClick, mNonBlockablePkgs);
                        onAppSettingsClick, mNonBlockablePkgs,
                        row.getEntry().userSentiment == USER_SENTIMENT_NEGATIVE);
            } catch (RemoteException e) {
                Log.e(TAG, e.toString());
            }
+31 −10
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
    private OnSettingsClickListener mOnSettingsClickListener;
    private OnAppSettingsClickListener mAppSettingsClickListener;
    private NotificationGuts mGutsContainer;
    private boolean mNegativeUserSentiment;

    private OnClickListener mOnKeepShowing = v -> {
        closeControls(v);
@@ -122,6 +123,22 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
            final OnAppSettingsClickListener onAppSettingsClick,
            final Set<String> nonBlockablePkgs)
            throws RemoteException {
        bindNotification(pm, iNotificationManager, pkg, notificationChannel, numChannels, sbn,
                checkSaveListener, onSettingsClick, onAppSettingsClick, nonBlockablePkgs,
                false /* negative sentiment */);
    }

    public void bindNotification(final PackageManager pm,
            final INotificationManager iNotificationManager,
            final String pkg,
            final NotificationChannel notificationChannel,
            final int numChannels,
            final StatusBarNotification sbn,
            final CheckSaveListener checkSaveListener,
            final OnSettingsClickListener onSettingsClick,
            final OnAppSettingsClickListener onAppSettingsClick,
            final Set<String> nonBlockablePkgs,
            boolean negativeUserSentiment)  throws RemoteException {
        mINotificationManager = iNotificationManager;
        mPkg = pkg;
        mNumNotificationChannels = numChannels;
@@ -133,6 +150,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        mOnSettingsClickListener = onSettingsClick;
        mSingleNotificationChannel = notificationChannel;
        mStartingUserImportance = mChosenImportance = mSingleNotificationChannel.getImportance();
        mNegativeUserSentiment = negativeUserSentiment;

        int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage(
                pkg, mAppUid, false /* includeDeleted */);
@@ -227,24 +245,27 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
    }

    private void bindPrompt() {
        final TextView channelName = findViewById(R.id.channel_name);
        final TextView blockPrompt = findViewById(R.id.block_prompt);
        bindName();
        if (mNonblockable) {
            if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) {
                channelName.setVisibility(View.GONE);
            blockPrompt.setText(R.string.notification_unblockable_desc);
        } else {
                channelName.setText(mSingleNotificationChannel.getName());
            if (mNegativeUserSentiment) {
                blockPrompt.setText(R.string.inline_blocking_helper);
            }  else if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) {
                blockPrompt.setText(R.string.inline_keep_showing_app);
            } else {
                blockPrompt.setText(R.string.inline_keep_showing);
            }
        }
    }

            blockPrompt.setText(R.string.notification_unblockable_desc);
        } else {
    private void bindName() {
        final TextView channelName = findViewById(R.id.channel_name);
        if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) {
            channelName.setVisibility(View.GONE);
                blockPrompt.setText(R.string.inline_keep_showing_app);
        } else {
            channelName.setText(mSingleNotificationChannel.getName());
                blockPrompt.setText(R.string.inline_keep_showing);
            }
        }
    }

+10 −0
Original line number Diff line number Diff line
@@ -280,6 +280,16 @@ public class NotificationInfoTest extends SysuiTestCase {
        assertEquals(GONE, blockView.getVisibility());
    }

    @Test
    public void testbindNotification_BlockingHelper() throws Exception {
        mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
                TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null,
                null, null, true);
        final TextView view = mNotificationInfo.findViewById(R.id.block_prompt);
        assertEquals(View.VISIBLE, view.getVisibility());
        assertEquals(mContext.getString(R.string.inline_blocking_helper), view.getText());
    }

    @Test
    public void testbindNotification_UnblockableTextVisibleWhenAppUnblockable() throws Exception {
        mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,