Collapse notification advanced settings

am: 5766d6e443

Change-Id: I99aca23639a2e9b1562942f4c37aad0aa7088c52
This commit is contained in:
Julia Reynolds
2018-04-20 12:27:20 -07:00
committed by android-build-merger
3 changed files with 100 additions and 74 deletions

View File

@@ -16,7 +16,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
settings:initialExpandedChildrenCount="500"> android:key="app_notifications">
<com.android.settings.applications.LayoutPreference <com.android.settings.applications.LayoutPreference
android:key="pref_app_header" android:key="pref_app_header"
@@ -42,14 +42,6 @@
android:key="visibility_override" android:key="visibility_override"
android:title="@string/app_notification_visibility_override_title"/> android:title="@string/app_notification_visibility_override_title"/>
<!-- Show badge -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="badge"
android:title="@string/notification_badge_title"
android:order="501"
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
<!-- Bypass DND --> <!-- Bypass DND -->
<com.android.settingslib.RestrictedSwitchPreference <com.android.settingslib.RestrictedSwitchPreference
android:key="bypass_dnd" android:key="bypass_dnd"
@@ -57,10 +49,23 @@
android:summary="@string/app_notification_override_dnd_summary" android:summary="@string/app_notification_override_dnd_summary"
settings:useAdditionalSummary="true"/> settings:useAdditionalSummary="true"/>
<PreferenceCategory
android:key="app_advanced"
android:order="1000"
settings:initialExpandedChildrenCount="0">
<!-- Show badge -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="badge"
android:title="@string/notification_badge_title"
settings:useAdditionalSummary="true"
android:order="1001"
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
<Preference <Preference
android:key="app_link" android:key="app_link"
android:title="@string/app_settings_link" android:order="1002"
android:order="502" /> android:title="@string/app_settings_link" />
</PreferenceCategory>
<com.android.settings.notification.NotificationFooterPreference <com.android.settings.notification.NotificationFooterPreference
android:key="desc" android:key="desc"

View File

@@ -18,8 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="channel_settings" android:key="channel_settings"
android:title="@string/notification_channel_title" android:title="@string/notification_channel_title" >
settings:initialExpandedChildrenCount="3" >
<com.android.settings.applications.LayoutPreference <com.android.settings.applications.LayoutPreference
android:key="pref_app_header" android:key="pref_app_header"
@@ -29,6 +28,10 @@
android:key="block" android:key="block"
android:layout="@layout/styled_switch_bar" /> android:layout="@layout/styled_switch_bar" />
<PreferenceCategory
android:key="channel_advanced"
android:order="50"
settings:initialExpandedChildrenCount="1">
<!-- Importance --> <!-- Importance -->
<com.android.settings.RestrictedListPreference <com.android.settings.RestrictedListPreference
android:key="importance" android:key="importance"
@@ -84,11 +87,14 @@
android:key="app_link" android:key="app_link"
android:title="@string/app_settings_link" android:title="@string/app_settings_link"
settings:allowDividerAbove="true"/> settings:allowDividerAbove="true"/>
</PreferenceCategory>
<com.android.settings.notification.NotificationFooterPreference <com.android.settings.notification.NotificationFooterPreference
android:key="desc" /> android:key="desc"
android:order="100"/>
<com.android.settings.notification.NotificationFooterPreference <com.android.settings.notification.NotificationFooterPreference
android:key="block_desc" /> android:key="block_desc"
android:order="110"/>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -20,10 +20,12 @@ import android.app.NotificationChannel;
import android.app.NotificationChannelGroup; import android.app.NotificationChannelGroup;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@@ -45,6 +47,9 @@ public class AppNotificationSettings extends NotificationSettingsBase {
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static String KEY_GENERAL_CATEGORY = "categories"; private static String KEY_GENERAL_CATEGORY = "categories";
private static String KEY_ADVANCED_CATEGORY = "app_advanced";
private static String KEY_BADGE = "badge";
private static String KEY_APP_LINK = "app_link";
private List<NotificationChannelGroup> mChannelGroupList; private List<NotificationChannelGroup> mChannelGroupList;
@@ -53,6 +58,25 @@ public class AppNotificationSettings extends NotificationSettingsBase {
return MetricsEvent.NOTIFICATION_APP_NOTIFICATION; return MetricsEvent.NOTIFICATION_APP_NOTIFICATION;
} }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PreferenceScreen screen = getPreferenceScreen();
if (mShowLegacyChannelConfig && screen != null) {
// if showing legacy settings, pull advanced settings out of the advanced category
Preference badge = findPreference(KEY_BADGE);
Preference appLink = findPreference(KEY_APP_LINK);
removePreference(KEY_ADVANCED_CATEGORY);
if (badge != null) {
screen.addPreference(badge);
}
if (appLink != null) {
screen.addPreference(appLink);
}
}
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@@ -63,11 +87,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
return; return;
} }
if (getPreferenceScreen() != null) {
getPreferenceScreen().removeAll();
mDynamicPreferences.clear();
}
if (!mShowLegacyChannelConfig) { if (!mShowLegacyChannelConfig) {
// Load channel settings // Load channel settings
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@@ -87,7 +106,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
} }
}.execute(); }.execute();
} }
getPreferenceScreen().setOrderingAsAdded(true);
for (NotificationPreferenceController controller : mControllers) { for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin); controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
@@ -132,13 +150,10 @@ public class AppNotificationSettings extends NotificationSettingsBase {
private void populateList() { private void populateList() {
if (!mDynamicPreferences.isEmpty()) { if (!mDynamicPreferences.isEmpty()) {
// If there's anything in mChannelGroups, we've called populateChannelList twice.
// Clear out existing channels and log.
Log.w(TAG, "Notification channel group posted twice to settings - old size " +
mDynamicPreferences.size() + ", new size " + mChannelGroupList.size());
for (Preference p : mDynamicPreferences) { for (Preference p : mDynamicPreferences) {
getPreferenceScreen().removePreference(p); getPreferenceScreen().removePreference(p);
} }
mDynamicPreferences.clear();
} }
if (mChannelGroupList.isEmpty()) { if (mChannelGroupList.isEmpty()) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext()); PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());