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

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

Merge "Move 'show hidden channels' option" into main

parents 49fc26ce 477ebd25
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8985,6 +8985,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