Collapse notification advanced settings am: 5766d6e443

am: b4127f1481

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

View File

@@ -20,10 +20,12 @@ import android.app.NotificationChannel;
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 @@ public class AppNotificationSettings extends NotificationSettingsBase {
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;
@@ -53,6 +58,25 @@ public class AppNotificationSettings extends NotificationSettingsBase {
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
public void onResume() {
super.onResume();
@@ -63,11 +87,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
return;
}
if (getPreferenceScreen() != null) {
getPreferenceScreen().removeAll();
mDynamicPreferences.clear();
}
if (!mShowLegacyChannelConfig) {
// Load channel settings
new AsyncTask<Void, Void, Void>() {
@@ -87,7 +106,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
}
}.execute();
}
getPreferenceScreen().setOrderingAsAdded(true);
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
@@ -132,13 +150,10 @@ public class AppNotificationSettings extends NotificationSettingsBase {
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());