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

Commit e0f8db5d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Notification settings updates"

parents 2c0cee41 3527ef7c
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -6926,7 +6926,7 @@
    <string name="notification_group_title">Notification category group</string>
    <string name="notification_group_title">Notification category group</string>
    <!-- [CHAR LIMIT=100] Notification importance screen title -->
    <!-- [CHAR LIMIT=100] Notification importance screen title -->
    <string name="notification_importance_title">Importance</string>
    <string name="notification_importance_title">Behavior</string>
    <!-- [CHAR LIMIT=100 BACKUP_MESSAGE_ID=1820188704793497324] Notification Importance: unspecified importance level description -->
    <!-- [CHAR LIMIT=100 BACKUP_MESSAGE_ID=1820188704793497324] Notification Importance: unspecified importance level description -->
    <string name="notification_importance_unspecified">Allow sound</string>
    <string name="notification_importance_unspecified">Allow sound</string>
@@ -6991,6 +6991,9 @@
    <!-- [CHAR LIMIT=100] Notification Importance title: high importance level title -->
    <!-- [CHAR LIMIT=100] Notification Importance title: high importance level title -->
    <string name="notification_channel_summary_high">Urgent importance</string>
    <string name="notification_channel_summary_high">Urgent importance</string>
    <!-- [CHAR LIMIT=100] Label for on/off toggle -->
    <string name="notification_switch_label">Show notifications</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>
@@ -7087,13 +7090,13 @@
    <string name="loading_notification_apps">Loading apps...</string>
    <string name="loading_notification_apps">Loading apps...</string>
    <!-- [CHAR LIMIT=NONE] Text appearing when app notifications are off -->
    <!-- [CHAR LIMIT=NONE] Text appearing when app notifications are off -->
    <string name="app_notifications_off_desc">Android is blocking this app\'s notifications from appearing on this device</string>
    <string name="app_notifications_off_desc">At your request, Android is blocking this app\'s notifications from appearing on this device</string>
    <!-- [CHAR LIMIT=NONE] Text appearing when channel notifications are off -->
    <!-- [CHAR LIMIT=NONE] Text appearing when channel notifications are off -->
    <string name="channel_notifications_off_desc">Android is blocking this category of notifications from appearing on this device</string>
    <string name="channel_notifications_off_desc">At your request, Android is blocking this category of notifications from appearing on this device</string>
    <!-- [CHAR LIMIT=NONE] Text appearing when channel group notifications are off -->
    <!-- [CHAR LIMIT=NONE] Text appearing when channel group notifications are off -->
    <string name="channel_group_notifications_off_desc">Android is blocking this group of notifications from appearing on this device</string>
    <string name="channel_group_notifications_off_desc">At your request, Android is blocking this group of notifications from appearing on this device</string>
    <!-- [CHAR LIMIT=NONE] App notification settings: channels title -->
    <!-- [CHAR LIMIT=NONE] App notification settings: channels title -->
    <string name="notification_channels">Categories</string>
    <string name="notification_channels">Categories</string>
+2 −1
Original line number Original line Diff line number Diff line
@@ -15,7 +15,8 @@
-->
-->


<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="3">


    <com.android.settings.applications.LayoutPreference
    <com.android.settings.applications.LayoutPreference
        android:key="pref_app_header"
        android:key="pref_app_header"
+4 −9
Original line number Original line Diff line number Diff line
@@ -19,20 +19,15 @@


        <com.android.settings.widget.RadioButtonPreference
        <com.android.settings.widget.RadioButtonPreference
            android:key="importance_high"
            android:key="importance_high"
            android:title="@string/notification_importance_high_title"
            android:title="@string/notification_importance_high" />
            android:summary="@string/notification_importance_high"
        />
        <com.android.settings.widget.RadioButtonPreference
        <com.android.settings.widget.RadioButtonPreference
            android:key="importance_default"
            android:key="importance_default"
            android:title="@string/notification_importance_default_title"
            android:title="@string/notification_importance_default" />
            android:summary="@string/notification_importance_default" />
        <com.android.settings.widget.RadioButtonPreference
        <com.android.settings.widget.RadioButtonPreference
            android:key="importance_low"
            android:key="importance_low"
            android:title="@string/notification_importance_low_title"
            android:title="@string/notification_importance_low" />
            android:summary="@string/notification_importance_low" />
        <com.android.settings.widget.RadioButtonPreference
        <com.android.settings.widget.RadioButtonPreference
            android:key="importance_min"
            android:key="importance_min"
            android:title="@string/notification_importance_min_title"
            android:title="@string/notification_importance_min" />
            android:summary="@string/notification_importance_min" />


</PreferenceScreen>
</PreferenceScreen>
+28 −49
Original line number Original line Diff line number Diff line
@@ -135,7 +135,6 @@ public class AppNotificationSettings extends NotificationSettingsBase {
        return new ArrayList<>(mControllers);
        return new ArrayList<>(mControllers);
    }
    }



    private void populateList() {
    private void populateList() {
        if (!mDynamicPreferences.isEmpty()) {
        if (!mDynamicPreferences.isEmpty()) {
            // If there's anything in mChannelGroups, we've called populateChannelList twice.
            // If there's anything in mChannelGroups, we've called populateChannelList twice.
@@ -164,59 +163,39 @@ public class AppNotificationSettings extends NotificationSettingsBase {
    }
    }


    private void populateGroupList() {
    private void populateGroupList() {
        for (NotificationChannelGroup group : mChannelGroupList) {
            PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
            PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
        groupCategory.setTitle(R.string.notification_channels);
        groupCategory.setKey(KEY_GENERAL_CATEGORY);
            groupCategory.setOrderingAsAdded(true);
            groupCategory.setOrderingAsAdded(true);
            getPreferenceScreen().addPreference(groupCategory);
            getPreferenceScreen().addPreference(groupCategory);
            mDynamicPreferences.add(groupCategory);
            mDynamicPreferences.add(groupCategory);
        for (NotificationChannelGroup group : mChannelGroupList) {
            if (group.getId() == null) {
            final List<NotificationChannel> channels = group.getChannels();
                groupCategory.setTitle(mChannelGroupList.size() > 1
            int N = channels.size();
                        ? R.string.notification_channels_other
            // app defined groups with one channel and channels with no group display the channel
                        : R.string.notification_channels);
            // name and no summary and link directly to the channel page unless the group is blocked
                groupCategory.setKey(KEY_GENERAL_CATEGORY);
            if ((group.getId() == null || N < 2) && !group.isBlocked()) {
                Collections.sort(channels, mChannelComparator);
                for (int i = 0; i < N; i++) {
                    final NotificationChannel channel = channels.get(i);
                    populateSingleChannelPrefs(groupCategory, channel, "");
                }
            } else {
            } else {
                populateGroupPreference(groupCategory, group, N);
                groupCategory.setTitle(group.getName());
            }
                groupCategory.setKey(group.getId());
        }
    }

    void populateGroupPreference(PreferenceGroup parent,
            final NotificationChannelGroup group, int channelCount) {
        MasterSwitchPreference groupPref = new MasterSwitchPreference(
                getPrefContext());
        groupPref.setSwitchEnabled(mSuspendedAppsAdmin == null
                && isChannelGroupBlockable(group));
        groupPref.setKey(group.getId());
        groupPref.setTitle(group.getName());
        groupPref.setChecked(!group.isBlocked());
        groupPref.setSummary(getResources().getQuantityString(
                R.plurals.notification_group_summary, channelCount, channelCount));
                Bundle groupArgs = new Bundle();
                Bundle groupArgs = new Bundle();
                groupArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
                groupArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
                groupArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
                groupArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
                groupArgs.putString(Settings.EXTRA_CHANNEL_GROUP_ID, group.getId());
                groupArgs.putString(Settings.EXTRA_CHANNEL_GROUP_ID, group.getId());
        Intent groupIntent = Utils.onBuildStartFragmentIntent(getActivity(),
                Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(),
                        ChannelGroupNotificationSettings.class.getName(),
                        ChannelGroupNotificationSettings.class.getName(),
                groupArgs, null, R.string.notification_group_title, null, false,
                        groupArgs, null, R.string.notification_group_title,
                getMetricsCategory());
                        null, false, getMetricsCategory());
        groupPref.setIntent(groupIntent);
                groupCategory.setIntent(channelIntent);

                populateGroupToggle(groupCategory, group);
        groupPref.setOnPreferenceChangeListener(
            }
                (preference, o) -> {

                    boolean value = (Boolean) o;
            final List<NotificationChannel> channels = group.getChannels();
                    group.setBlocked(!value);
            Collections.sort(channels, mChannelComparator);
                    mBackend.updateChannelGroup(mPkg, mUid, group);
            int N = channels.size();

            for (int i = 0; i < N; i++) {
                    return true;
                final NotificationChannel channel = channels.get(i);
                });
                populateSingleChannelPrefs(groupCategory, channel, group.isBlocked());
        parent.addPreference(groupPref);
            }
        }
    }
    }


    private Comparator<NotificationChannelGroup> mChannelGroupComparator =
    private Comparator<NotificationChannelGroup> mChannelGroupComparator =
+2 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,8 @@ public class BlockPreferenceController extends NotificationPreferenceController
        LayoutPreference pref = (LayoutPreference) preference;
        LayoutPreference pref = (LayoutPreference) preference;
        SwitchBar bar = pref.findViewById(R.id.switch_bar);
        SwitchBar bar = pref.findViewById(R.id.switch_bar);
        if (bar != null) {
        if (bar != null) {
            bar.setSwitchBarText(R.string.notification_switch_label,
                    R.string.notification_switch_label);
            bar.show();
            bar.show();
            try {
            try {
                bar.addOnSwitchChangeListener(this);
                bar.addOnSwitchChangeListener(this);
Loading