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

Commit 477ebd25 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Move 'show hidden channels' option

Make it more prominent to make it more clear what's happening
when you unblock an app

Test: DeletedChannelsPreferenceControllerTest
Test: ShowMorePreferenceControllerTest
Flag: com.android.server.notification.notification_hide_unused_channels
Bug: 322536537
Change-Id: I745b2037b4dc907a4307fa7f70ecc3a4c9db2dd2
parent add6f2d2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8935,6 +8935,9 @@
    <!-- [CHAR LIMIT=NONE] App notification settings: no channels -->
    <string name="no_channels">This app has not posted any notifications</string>
    <!-- [CHAR LIMIT=NONE] App notification settings: has channels, but hasn't sent notifications recently -->
    <string name="no_recent_channels">Show unused categories</string>
    <!-- [CHAR LIMIT=NONE] App notification settings: link to app notification settings-->
    <string name="app_settings_link">Additional settings in the app</string>
+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,11 @@
        android:key="channels"
        android:layout="@layout/empty_view" />

    <Preference
        android:key="more"
        android:title="@string/no_recent_channels"
        android:icon="@drawable/ic_expand"/>

    <!-- Importance toggle -->
    <com.android.settingslib.RestrictedSwitchPreference
        android:key="allow_sound"
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_CACHED;
import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC;
import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED_BY_ANY_LAUNCHER;

import static com.android.server.notification.Flags.notificationHideUnusedChannels;

import android.app.INotificationManager;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -78,6 +80,9 @@ public class NotificationBackend {

    public AppRow loadAppRow(Context context, PackageManager pm, ApplicationInfo app) {
        final AppRow row = new AppRow();
        if (notificationHideUnusedChannels()) {
            row.showAllChannels = false;
        }
        row.pkg = app.packageName;
        row.uid = app.uid;
        try {
@@ -686,5 +691,6 @@ public class NotificationBackend {
        public int channelCount;
        public Map<String, NotificationsSentState> sentByChannel;
        public NotificationsSentState sentByApp;
        public boolean showAllChannels = true;
    }
}
+2 −38
Original line number Diff line number Diff line
@@ -16,16 +16,10 @@

package com.android.settings.notification.app;

import static com.android.server.notification.Flags.notificationHideUnusedChannels;


import android.app.settings.SettingsEnums;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
@@ -107,38 +101,8 @@ public class AppNotificationSettings extends NotificationSettings {
        mControllers.add(new BubbleSummaryPreferenceController(context, mBackend));
        mControllers.add(new NotificationsOffPreferenceController(context));
        mControllers.add(new DeletedChannelsPreferenceController(context, mBackend));
        mControllers.add(new ShowMorePreferenceController(
                context, mDependentFieldListener, mBackend));
        return new ArrayList<>(mControllers);
    }

    private final int SHOW_ALL_CHANNELS = 1;

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        if (notificationHideUnusedChannels()) {
            menu.add(Menu.NONE, SHOW_ALL_CHANNELS, Menu.NONE,
                    mShowAll ? R.string.hide_unused_channels : R.string.show_unused_channels);
        }
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (!notificationHideUnusedChannels()) {
            return super.onOptionsItemSelected(item);
        }
        switch (item.getItemId()) {
            case SHOW_ALL_CHANNELS:
                mShowAll = !mShowAll;
                item.setTitle(mShowAll
                        ? R.string.hide_unused_channels
                        : R.string.show_unused_channels);
                ChannelListPreferenceController list =
                        use(ChannelListPreferenceController.class);
                list.setShowAll(mShowAll);
                list.updateState(findPreference(list.getPreferenceKey()));
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}
+1 −7
Original line number Diff line number Diff line
@@ -59,8 +59,6 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
    private List<NotificationChannelGroup> mChannelGroupList;
    private PreferenceCategory mPreference;

    private boolean mShowAll;

    public ChannelListPreferenceController(Context context, NotificationBackend backend) {
        super(context, backend);
    }
@@ -100,7 +98,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
            @Override
            protected Void doInBackground(Void... unused) {
                if (notificationHideUnusedChannels()) {
                    if (mShowAll) {
                    if (mAppRow.showAllChannels) {
                        mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList();
                    } else {
                        mChannelGroupList = mBackend.getGroupsWithRecentBlockedFilter(mAppRow.pkg,
@@ -123,10 +121,6 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
        }.execute();
    }

    protected void setShowAll(boolean showAll) {
        mShowAll = showAll;
    }

    /**
     * Update the preferences group to match the
     * @param groupPrefsList
Loading