String changes

- channel summaries
- Notification listener name
- notifications app page title

Change-Id: I0745c06aad44bfa7636ee2b10be9387313093fe3
Fixes: 36529184
Fixes: 38178073
Test: manual
This commit is contained in:
Julia Reynolds
2017-06-05 09:06:31 -04:00
parent 73fc34b780
commit d85ff59ce7
5 changed files with 52 additions and 16 deletions

View File

@@ -2614,7 +2614,6 @@
<!-- Show application-level notification settings (app passed in as extras) --> <!-- Show application-level notification settings (app passed in as extras) -->
<activity android:name="Settings$AppNotificationSettingsActivity" <activity android:name="Settings$AppNotificationSettingsActivity"
android:label="@string/app_notifications_title"
android:exported="true"> android:exported="true">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.settings.APP_NOTIFICATION_SETTINGS" /> <action android:name="android.settings.APP_NOTIFICATION_SETTINGS" />
@@ -2630,7 +2629,6 @@
<!-- Show channel-level notification settings (channel passed in as extras) --> <!-- Show channel-level notification settings (channel passed in as extras) -->
<activity android:name="Settings$ChannelNotificationSettingsActivity" <activity android:name="Settings$ChannelNotificationSettingsActivity"
android:label="@string/app_notifications_title"
android:exported="true"> android:exported="true">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" /> <action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />

View File

@@ -6723,8 +6723,11 @@
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=30] --> <!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=30] -->
<string name="lock_screen_notifications_interstitial_title_profile">Profile notifications</string> <string name="lock_screen_notifications_interstitial_title_profile">Profile notifications</string>
<!-- Notification Settings: Title for an individual app's notification settings. [CHAR LIMIT=30] -->
<string name="notifications_title">Notifications</string>
<!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] --> <!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
<string name="app_notifications_title">Notifications</string> <string name="app_notifications_title">App notifications</string>
<!-- [CHAR LIMIT=100] Notification channel title --> <!-- [CHAR LIMIT=100] Notification channel title -->
<string name="notification_channel_title">Notification category</string> <string name="notification_channel_title">Notification category</string>
@@ -6777,6 +6780,20 @@
<!-- [CHAR LIMIT=180] Notification importance summary --> <!-- [CHAR LIMIT=180] Notification importance summary -->
<string name="show_silently_summary">Don\'t make sound, vibrate, or peek these notifications into view on the current screen.</string> <string name="show_silently_summary">Don\'t make sound, vibrate, or peek these notifications into view on the current screen.</string>
<!-- Channel summaries for the app notification page -->
<!-- [CHAR LIMIT=100] Notification Importance title: min importance level title -->
<string name="notification_channel_summary_min">Low importance</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level title -->
<string name="notification_channel_summary_low">Medium importance</string>
<!-- [CHAR LIMIT=100] Notification Importance title: normal importance level title -->
<string name="notification_channel_summary_default">High importance</string>
<!-- [CHAR LIMIT=100] Notification Importance title: high importance level title -->
<string name="notification_channel_summary_high">Urgent importance</string>
<!-- Default Apps > Default notification assistant --> <!-- Default Apps > Default notification assistant -->
<string name="default_notification_assistant">Notification assistant</string> <string name="default_notification_assistant">Notification assistant</string>

View File

@@ -566,8 +566,7 @@ public class ManageApplications extends InstrumentedPreferenceFragment
private void startApplicationDetailsActivity() { private void startApplicationDetailsActivity() {
switch (mListType) { switch (mListType) {
case LIST_TYPE_NOTIFICATION: case LIST_TYPE_NOTIFICATION:
startAppInfoFragment(AppNotificationSettings.class, startAppInfoFragment(AppNotificationSettings.class, R.string.notifications_title);
R.string.app_notifications_title);
break; break;
case LIST_TYPE_USAGE_ACCESS: case LIST_TYPE_USAGE_ACCESS:
startAppInfoFragment(UsageAccessDetails.class, R.string.usage_access); startAppInfoFragment(UsageAccessDetails.class, R.string.usage_access);

View File

@@ -328,15 +328,15 @@ public class AppNotificationSettings extends NotificationSettingsBase {
case NotificationManager.IMPORTANCE_NONE: case NotificationManager.IMPORTANCE_NONE:
return getContext().getString(R.string.notification_toggle_off); return getContext().getString(R.string.notification_toggle_off);
case NotificationManager.IMPORTANCE_MIN: case NotificationManager.IMPORTANCE_MIN:
return getContext().getString(R.string.notification_importance_min_title); return getContext().getString(R.string.notification_channel_summary_min);
case NotificationManager.IMPORTANCE_LOW: case NotificationManager.IMPORTANCE_LOW:
return getContext().getString(R.string.notification_importance_low_title); return getContext().getString(R.string.notification_channel_summary_low);
case NotificationManager.IMPORTANCE_DEFAULT: case NotificationManager.IMPORTANCE_DEFAULT:
return getContext().getString(R.string.notification_importance_default_title); return getContext().getString(R.string.notification_channel_summary_default);
case NotificationManager.IMPORTANCE_HIGH: case NotificationManager.IMPORTANCE_HIGH:
case NotificationManager.IMPORTANCE_MAX: case NotificationManager.IMPORTANCE_MAX:
default: default:
return getContext().getString(R.string.notification_importance_high_title); return getContext().getString(R.string.notification_channel_summary_high);
} }
} }

View File

@@ -34,6 +34,7 @@ import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener; import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import android.view.View; import android.view.View;
import com.android.internal.logging.nano.MetricsProto; import com.android.internal.logging.nano.MetricsProto;
@@ -46,10 +47,11 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public abstract class ManagedServiceSettings extends EmptyTextSettings { public abstract class ManagedServiceSettings extends EmptyTextSettings {
private static final String TAG = "ManagedServiceSettings";
private final Config mConfig; private final Config mConfig;
protected Context mContext; protected Context mContext;
private PackageManager mPM; private PackageManager mPm;
private DevicePolicyManager mDpm; private DevicePolicyManager mDpm;
protected ServiceListing mServiceListing; protected ServiceListing mServiceListing;
@@ -64,7 +66,7 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
super.onCreate(icicle); super.onCreate(icicle);
mContext = getActivity(); mContext = getActivity();
mPM = mContext.getPackageManager(); mPm = mContext.getPackageManager();
mDpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); mDpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
mServiceListing = new ServiceListing(mContext, mConfig); mServiceListing = new ServiceListing(mContext, mConfig);
mServiceListing.addCallback(new ServiceListing.Callback() { mServiceListing.addCallback(new ServiceListing.Callback() {
@@ -101,14 +103,27 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
final PreferenceScreen screen = getPreferenceScreen(); final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll(); screen.removeAll();
Collections.sort(services, new PackageItemInfo.DisplayNameComparator(mPM)); Collections.sort(services, new PackageItemInfo.DisplayNameComparator(mPm));
for (ServiceInfo service : services) { for (ServiceInfo service : services) {
final ComponentName cn = new ComponentName(service.packageName, service.name); final ComponentName cn = new ComponentName(service.packageName, service.name);
final String title = service.loadLabel(mPM).toString(); CharSequence title = null;
try {
title = mPm.getApplicationInfoAsUser(
service.packageName, 0, getCurrentUser(managedProfileId)).loadLabel(mPm);
} catch (PackageManager.NameNotFoundException e) {
// unlikely, as we are iterating over live services.
Log.e(TAG, "can't find package name", e);
}
final String summary = service.loadLabel(mPm).toString();
final SwitchPreference pref = new SwitchPreference(getPrefContext()); final SwitchPreference pref = new SwitchPreference(getPrefContext());
pref.setPersistent(false); pref.setPersistent(false);
pref.setIcon(service.loadIcon(mPM)); pref.setIcon(service.loadIcon(mPm));
pref.setTitle(title); if (title != null && !title.equals(summary)) {
pref.setTitle(title);
pref.setSummary(summary);
} else {
pref.setTitle(summary);
}
pref.setChecked(mServiceListing.isEnabled(cn)); pref.setChecked(mServiceListing.isEnabled(cn));
if (managedProfileId != UserHandle.USER_NULL if (managedProfileId != UserHandle.USER_NULL
&& !mDpm.isNotificationListenerServicePermitted( && !mDpm.isNotificationListenerServicePermitted(
@@ -119,13 +134,20 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean enable = (boolean) newValue; final boolean enable = (boolean) newValue;
return setEnabled(cn, title, enable); return setEnabled(cn, summary, enable);
} }
}); });
screen.addPreference(pref); screen.addPreference(pref);
} }
} }
private int getCurrentUser(int managedProfileId) {
if (managedProfileId != UserHandle.USER_NULL) {
return managedProfileId;
}
return UserHandle.myUserId();
}
protected boolean setEnabled(ComponentName service, String title, boolean enable) { protected boolean setEnabled(ComponentName service, String title, boolean enable) {
if (!enable) { if (!enable) {
// the simple version: disabling // the simple version: disabling