Display channel/group names only.

Test: manual
Change-Id: I7da68f71ddb78f3150ebc64af40310de65cd010c
This commit is contained in:
Julia Reynolds
2017-03-13 15:06:28 -04:00
parent 8ba1bf34b4
commit 2194f3db37
3 changed files with 8 additions and 29 deletions

View File

@@ -145,7 +145,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
? R.string.notification_channels_other ? R.string.notification_channels_other
: R.string.notification_channels); : R.string.notification_channels);
} else { } else {
groupCategory.setTitle(getNotificationGroupLabel(group)); groupCategory.setTitle(group.getName());
} }
groupCategory.setKey(group.getId()); groupCategory.setKey(group.getId());
groupCategory.setOrderingAsAdded(true); groupCategory.setOrderingAsAdded(true);
@@ -161,13 +161,13 @@ public class AppNotificationSettings extends NotificationSettingsBase {
getPrefContext()); getPrefContext());
channelPref.setDisabledByAdmin(mSuspendedAppsAdmin); channelPref.setDisabledByAdmin(mSuspendedAppsAdmin);
channelPref.setKey(channel.getId()); channelPref.setKey(channel.getId());
channelPref.setTitle(getNotificationChannelLabel(channel)); channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE); channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
channelPref.setMultiLine(true); channelPref.setMultiLine(true);
if (channel.isDeleted()) { if (channel.isDeleted()) {
channelPref.setTitle(getString(R.string.deleted_channel_name, channelPref.setTitle(getString(R.string.deleted_channel_name,
getNotificationChannelLabel(channel))); channel.getName()));
channelPref.setEnabled(false); channelPref.setEnabled(false);
} else { } else {
channelPref.setSummary(getImportanceSummary(channel.getImportance())); channelPref.setSummary(getImportanceSummary(channel.getImportance()));
@@ -257,8 +257,8 @@ public class AppNotificationSettings extends NotificationSettingsBase {
if (left.isDeleted() != right.isDeleted()) { if (left.isDeleted() != right.isDeleted()) {
return Boolean.compare(left.isDeleted(), right.isDeleted()); return Boolean.compare(left.isDeleted(), right.isDeleted());
} }
CharSequence leftName = getNotificationChannelLabel(left); CharSequence leftName = left.getName();
CharSequence rightName = getNotificationChannelLabel(right); CharSequence rightName = right.getName();
if (!Objects.equals(leftName, rightName)) { if (!Objects.equals(leftName, rightName)) {
return sCollator.compare(leftName.toString(), rightName.toString()); return sCollator.compare(leftName.toString(), rightName.toString());
} }
@@ -278,8 +278,8 @@ public class AppNotificationSettings extends NotificationSettingsBase {
} else if (right.getId() == null && left.getId() != null) { } else if (right.getId() == null && left.getId() != null) {
return -1; return -1;
} }
CharSequence leftName = getNotificationGroupLabel(left); CharSequence leftName = left.getName();
CharSequence rightName = getNotificationGroupLabel(right); CharSequence rightName = right.getName();
// sort rest of the groups by name // sort rest of the groups by name
if (!Objects.equals(leftName, rightName)) { if (!Objects.equals(leftName, rightName)) {
return sCollator.compare(leftName.toString(), rightName.toString()); return sCollator.compare(leftName.toString(), rightName.toString());

View File

@@ -113,7 +113,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
.getApplicationFeatureProvider(activity) .getApplicationFeatureProvider(activity)
.newAppHeaderController(this /* fragment */, null /* appHeader */) .newAppHeaderController(this /* fragment */, null /* appHeader */)
.setIcon(mAppRow.icon) .setIcon(mAppRow.icon)
.setLabel(getNotificationChannelLabel(mChannel)) .setLabel(mChannel.getName())
.setSummary(mAppRow.label) .setSummary(mAppRow.label)
.setPackageName(mAppRow.pkg) .setPackageName(mAppRow.pkg)
.setUid(mAppRow.uid) .setUid(mAppRow.uid)

View File

@@ -251,25 +251,4 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
return getContext().getString(R.string.notification_importance_high); return getContext().getString(R.string.notification_importance_high);
} }
} }
protected CharSequence getNotificationGroupLabel(NotificationChannelGroup group) {
return getLabel(group.getName(), group.getNameResId());
}
protected CharSequence getNotificationChannelLabel(NotificationChannel channel) {
return getLabel(channel.getName(), channel.getNameResId());
}
private CharSequence getLabel(CharSequence name, int nameResId) {
if (!TextUtils.isEmpty(name)) {
return name;
}
try {
ApplicationInfo info = mPm.getApplicationInfoAsUser(mAppRow.pkg, 0, mAppRow.userId);
return mPm.getText(mAppRow.pkg, nameResId, info);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return null;
}
} }