Collapse notification advanced settings am: 5766d6e443
am: b4127f1481
Change-Id: Ifca9c55f412baf3a1636e89daab5d022e28d0dfd
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 3ddfac5..0056ef2 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -16,7 +16,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- settings:initialExpandedChildrenCount="500">
+ android:key="app_notifications">
<com.android.settings.applications.LayoutPreference
android:key="pref_app_header"
@@ -42,14 +42,6 @@
android:key="visibility_override"
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 -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="bypass_dnd"
@@ -57,10 +49,23 @@
android:summary="@string/app_notification_override_dnd_summary"
settings:useAdditionalSummary="true"/>
- <Preference
- android:key="app_link"
- android:title="@string/app_settings_link"
- android:order="502" />
+ <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
+ android:key="app_link"
+ android:order="1002"
+ android:title="@string/app_settings_link" />
+
+ </PreferenceCategory>
<com.android.settings.notification.NotificationFooterPreference
android:key="desc"
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 01001fa..e16a74f 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -18,8 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="channel_settings"
- android:title="@string/notification_channel_title"
- settings:initialExpandedChildrenCount="3" >
+ android:title="@string/notification_channel_title" >
<com.android.settings.applications.LayoutPreference
android:key="pref_app_header"
@@ -29,66 +28,73 @@
android:key="block"
android:layout="@layout/styled_switch_bar" />
- <!-- Importance -->
- <com.android.settings.RestrictedListPreference
- android:key="importance"
- android:title="@string/notification_importance_title" />
+ <PreferenceCategory
+ android:key="channel_advanced"
+ android:order="50"
+ settings:initialExpandedChildrenCount="1">
+ <!-- Importance -->
+ <com.android.settings.RestrictedListPreference
+ android:key="importance"
+ android:title="@string/notification_importance_title" />
- <!-- Importance toggle -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="allow_sound"
- android:title="@string/allow_interruption"
- android:summary="@string/allow_interruption_summary" />
+ <!-- Importance toggle -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="allow_sound"
+ android:title="@string/allow_interruption"
+ android:summary="@string/allow_interruption_summary" />
- <!-- Default ringtone -->
- <com.android.settings.notification.NotificationSoundPreference
- android:key="ringtone"
- android:title="@string/notification_channel_sound_title"
- android:dialogTitle="@string/notification_channel_sound_title"
- android:showSilent="true"
- android:showDefault="true"
- android:ringtoneType="notification" />
+ <!-- Default ringtone -->
+ <com.android.settings.notification.NotificationSoundPreference
+ android:key="ringtone"
+ android:title="@string/notification_channel_sound_title"
+ android:dialogTitle="@string/notification_channel_sound_title"
+ android:showSilent="true"
+ android:showDefault="true"
+ android:ringtoneType="notification" />
- <!-- Vibration -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="vibrate"
- android:title="@string/notification_vibrate_title"
- settings:useAdditionalSummary="true" />
+ <!-- Vibration -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="vibrate"
+ android:title="@string/notification_vibrate_title"
+ settings:useAdditionalSummary="true" />
- <!-- Visibility Override -->
- <com.android.settings.RestrictedListPreference
- android:key="visibility_override"
- android:title="@string/app_notification_visibility_override_title"/>
+ <!-- Visibility Override -->
+ <com.android.settings.RestrictedListPreference
+ android:key="visibility_override"
+ android:title="@string/app_notification_visibility_override_title"/>
- <!-- Lights -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="lights"
- android:title="@string/notification_show_lights_title"
- settings:useAdditionalSummary="true"/>
+ <!-- Lights -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="lights"
+ android:title="@string/notification_show_lights_title"
+ settings:useAdditionalSummary="true"/>
- <!-- Show badge -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="badge"
- android:title="@string/notification_channel_badge_title"
- settings:useAdditionalSummary="true"
- settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
+ <!-- Show badge -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="badge"
+ android:title="@string/notification_channel_badge_title"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
- <!-- Bypass DND -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="bypass_dnd"
- android:title="@string/app_notification_override_dnd_title"
- android:summary="@string/app_notification_override_dnd_summary"
- settings:useAdditionalSummary="true"/>
+ <!-- Bypass DND -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="bypass_dnd"
+ android:title="@string/app_notification_override_dnd_title"
+ android:summary="@string/app_notification_override_dnd_summary"
+ settings:useAdditionalSummary="true"/>
- <Preference
- android:key="app_link"
- android:title="@string/app_settings_link"
- settings:allowDividerAbove="true"/>
+ <Preference
+ android:key="app_link"
+ android:title="@string/app_settings_link"
+ settings:allowDividerAbove="true"/>
+ </PreferenceCategory>
<com.android.settings.notification.NotificationFooterPreference
- android:key="desc" />
+ android:key="desc"
+ android:order="100"/>
<com.android.settings.notification.NotificationFooterPreference
- android:key="block_desc" />
+ android:key="block_desc"
+ android:order="110"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 2bc2489..99e9458 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -20,10 +20,12 @@
import android.app.NotificationChannelGroup;
import android.content.Context;
import android.os.AsyncTask;
+import android.os.Bundle;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup;
+import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.util.Log;
@@ -45,6 +47,9 @@
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
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;
@@ -54,6 +59,25 @@
}
@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
public void onResume() {
super.onResume();
@@ -63,11 +87,6 @@
return;
}
- if (getPreferenceScreen() != null) {
- getPreferenceScreen().removeAll();
- mDynamicPreferences.clear();
- }
-
if (!mShowLegacyChannelConfig) {
// Load channel settings
new AsyncTask<Void, Void, Void>() {
@@ -87,7 +106,6 @@
}
}.execute();
}
- getPreferenceScreen().setOrderingAsAdded(true);
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
@@ -132,13 +150,10 @@
private void populateList() {
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) {
getPreferenceScreen().removePreference(p);
}
+ mDynamicPreferences.clear();
}
if (mChannelGroupList.isEmpty()) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());