Experiment: hide unused channels in settings
behind a 3-dot menu. "unused" in this case means a channel that is not blocked but also hasn't sent a notification in the last 2 weeks Test: manual Flag: com.android.server.notification.notification_hide_unused_channels Bug: 322536537 Change-Id: I99f5a61411c9b3a567fd7517f0bf7ea33bb7637c
This commit is contained in:
@@ -16,10 +16,16 @@
|
||||
|
||||
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;
|
||||
@@ -33,6 +39,8 @@ public class AppNotificationSettings extends NotificationSettings {
|
||||
private static final String TAG = "AppNotificationSettings";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
boolean mShowAll = false;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.NOTIFICATION_APP_NOTIFICATION;
|
||||
@@ -101,4 +109,36 @@ public class AppNotificationSettings extends NotificationSettings {
|
||||
mControllers.add(new DeletedChannelsPreferenceController(context, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user