Show deleted channels.
Test: run cts, verify manually in Settings ui Change-Id: Ib6376decaa4ae427bb706ea48608a5aa8924da2f
This commit is contained in:
@@ -6330,6 +6330,9 @@
|
||||
<!-- [CHAR LIMIT=NONE] App notification settings: channels title -->
|
||||
<string name="notification_channels">Channels</string>
|
||||
|
||||
<!-- [CHAR LIMIT=60] App notification settings: Text to display for deleted channels -->
|
||||
<string name="deleted_channel_name"><xliff:g id="channel_name" example="Promotions">%1$s</xliff:g> (deleted)</string>
|
||||
|
||||
<!-- [CHAR LIMIT=NONE] App notification settings: Block option title -->
|
||||
<string name="app_notification_block_title">Block all</string>
|
||||
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.notification;
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -42,7 +41,11 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/** These settings are per app, so should not be returned in global search results. */
|
||||
public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
@@ -94,6 +97,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
rows.put(mAppRow.pkg, mAppRow);
|
||||
collectConfigActivities(rows);
|
||||
mChannelList = mBackend.getChannels(mPkg, mUid).getList();
|
||||
Collections.sort(mChannelList, mChannelComparator);
|
||||
|
||||
if (mChannelList.isEmpty()) {
|
||||
setVisible(mChannels, false);
|
||||
@@ -105,16 +109,21 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
channelPref.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||
channelPref.setKey(channel.getId());
|
||||
channelPref.setTitle(channel.getName());
|
||||
Bundle channelArgs = new Bundle();
|
||||
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
|
||||
channelArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true);
|
||||
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
|
||||
channelArgs.putString(ARG_CHANNEL, channel.getId());
|
||||
|
||||
Intent topicIntent = Utils.onBuildStartFragmentIntent(getActivity(),
|
||||
ChannelNotificationSettings.class.getName(),
|
||||
channelArgs, null, 0, null, false);
|
||||
channelPref.setIntent(topicIntent);
|
||||
if (channel.isDeleted()) {
|
||||
channelPref.setTitle(
|
||||
getString(R.string.deleted_channel_name, channel.getName()));
|
||||
} else {
|
||||
Bundle channelArgs = new Bundle();
|
||||
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
|
||||
channelArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true);
|
||||
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
|
||||
channelArgs.putString(ARG_CHANNEL, channel.getId());
|
||||
Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(),
|
||||
ChannelNotificationSettings.class.getName(),
|
||||
channelArgs, null, 0, null, false);
|
||||
channelPref.setIntent(channelIntent);
|
||||
}
|
||||
mChannels.addPreference(channelPref);
|
||||
}
|
||||
}
|
||||
@@ -212,4 +221,20 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
.setClassName(activityInfo.packageName, activityInfo.name);
|
||||
}
|
||||
}
|
||||
|
||||
private Comparator<NotificationChannel> mChannelComparator =
|
||||
new Comparator<NotificationChannel>() {
|
||||
private final Collator sCollator = Collator.getInstance();
|
||||
|
||||
@Override
|
||||
public int compare(NotificationChannel left, NotificationChannel right) {
|
||||
if (left.isDeleted() != right.isDeleted()) {
|
||||
return Boolean.compare(left.isDeleted(), right.isDeleted());
|
||||
}
|
||||
if (!Objects.equals(left.getName(), right.getName())) {
|
||||
return sCollator.compare(left.getName().toString(), right.getName().toString());
|
||||
}
|
||||
return left.getId().compareTo(right.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -92,7 +92,7 @@ public class NotificationBackend {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return sINM.getNotificationChannelForPackage(pkg, uid, channelId);
|
||||
return sINM.getNotificationChannelForPackage(pkg, uid, channelId, true);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return null;
|
||||
@@ -101,7 +101,7 @@ public class NotificationBackend {
|
||||
|
||||
public ParceledListSlice<NotificationChannel> getChannels(String pkg, int uid) {
|
||||
try {
|
||||
return sINM.getNotificationChannelsForPackage(pkg, uid);
|
||||
return sINM.getNotificationChannelsForPackage(pkg, uid, true);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error calling NoMan", e);
|
||||
return ParceledListSlice.emptyList();
|
||||
|
Reference in New Issue
Block a user