Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4127f14 authored by Julia Reynolds's avatar Julia Reynolds Committed by android-build-merger
Browse files

Collapse notification advanced settings

am: 5766d6e4

Change-Id: I99aca23639a2e9b1562942f4c37aad0aa7088c52
parents 60aa99a9 5766d6e4
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -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"/>

    <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:title="@string/app_settings_link"
        android:order="502" />
            android:order="1002"
            android:title="@string/app_settings_link" />

    </PreferenceCategory>

    <com.android.settings.notification.NotificationFooterPreference
        android:key="desc"
+65 −59
Original line number Diff line number Diff line
@@ -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,6 +28,10 @@
        android:key="block"
        android:layout="@layout/styled_switch_bar" />

    <PreferenceCategory
        android:key="channel_advanced"
        android:order="50"
        settings:initialExpandedChildrenCount="1">
        <!-- Importance -->
        <com.android.settings.RestrictedListPreference
            android:key="importance"
@@ -84,11 +87,14 @@
            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>
+25 −10
Original line number Diff line number Diff line
@@ -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());