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

Commit 9836d6a6 authored by Yining Liu's avatar Yining Liu
Browse files

Add the new settings page for lock screen notifs

Add a new empty settings page, which is flag-guarded. When the flag
is disabled, show the original Notifications on lock screen
tri-state switch, otherwise show the new page.

Bug: 367455695
Flag: com.android.server.notification.notification_lock_screen_settings
Test: atest LockScreenNotificationsPreferenceControllerTest

Change-Id: I8a81ad651626f39380767b2c9cfa2f1c19d0e7c5
parent 226c6392
Loading
Loading
Loading
Loading
+22 −14
Original line number Original line Diff line number Diff line
@@ -92,23 +92,31 @@
            android:singleLineTitle="false"
            android:singleLineTitle="false"
            android:summary="@string/summary_placeholder" />
            android:summary="@string/summary_placeholder" />


        <Preference
            android:key="lock_screen_notifications_page"
            android:order="14"
            android:persistent="false"
            android:title="@string/lock_screen_notifs_title"
            android:fragment="com.android.settings.notification.LockScreenNotificationsPreferencePageFragment"
            settings:controller="com.android.settings.notification.LockScreenNotificationsPreferencePageController" />

        <com.android.settingslib.RestrictedSwitchPreference
        <com.android.settingslib.RestrictedSwitchPreference
            android:key="lock_screen_redact"
            android:key="lock_screen_redact"
            android:order="14"
            android:order="15"
            android:title="@string/lock_screen_notifs_redact"
            android:title="@string/lock_screen_notifs_redact"
            android:summary="@string/lock_screen_notifs_redact_summary"
            android:summary="@string/lock_screen_notifs_redact_summary"
            settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />
            settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />


        <com.android.settingslib.RestrictedSwitchPreference
        <com.android.settingslib.RestrictedSwitchPreference
            android:key="lock_screen_work_redact"
            android:key="lock_screen_work_redact"
            android:order="15"
            android:order="16"
            android:title="@string/lock_screen_notifs_redact_work"
            android:title="@string/lock_screen_notifs_redact_work"
            android:summary="@string/lock_screen_notifs_redact_work_summary"
            android:summary="@string/lock_screen_notifs_redact_work_summary"
            settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />
            settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />


        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="notification_lockscreen_bypass"
            android:key="notification_lockscreen_bypass"
            android:order="16"
            android:order="17"
            android:title="@string/lockscreen_bypass_title"
            android:title="@string/lockscreen_bypass_title"
            android:summary="@string/lockscreen_bypass_summary"
            android:summary="@string/lockscreen_bypass_summary"
            settings:searchable="false"
            settings:searchable="false"
@@ -129,14 +137,14 @@
        <Preference
        <Preference
            android:fragment="com.android.settings.notification.PoliteNotificationsPreferenceFragment"
            android:fragment="com.android.settings.notification.PoliteNotificationsPreferenceFragment"
            android:key="polite_notifications_preference"
            android:key="polite_notifications_preference"
            android:order="17"
            android:order="18"
            android:persistent="false"
            android:persistent="false"
            android:title="@string/notification_polite_title"
            android:title="@string/notification_polite_title"
            settings:controller="com.android.settings.notification.PoliteNotificationsPreferenceController" />
            settings:controller="com.android.settings.notification.PoliteNotificationsPreferenceController" />


        <com.android.settingslib.RestrictedPreference
        <com.android.settingslib.RestrictedPreference
            android:key="zen_mode_notifications"
            android:key="zen_mode_notifications"
            android:order="18"
            android:order="19"
            android:title="@string/zen_mode_settings_title"
            android:title="@string/zen_mode_settings_title"
            settings:useAdminDisabledSummary="true"
            settings:useAdminDisabledSummary="true"
            android:fragment="com.android.settings.notification.zen.ZenModeSettings"
            android:fragment="com.android.settings.notification.zen.ZenModeSettings"
@@ -145,7 +153,7 @@


        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="lock_screen_notif_minimalism"
            android:key="lock_screen_notif_minimalism"
            android:order="19"
            android:order="20"
            android:title="@string/lock_screen_notif_minimalism"
            android:title="@string/lock_screen_notif_minimalism"
            android:summary="@string/lock_screen_notif_minimalism_summary"
            android:summary="@string/lock_screen_notif_minimalism_summary"
            settings:controller="com.android.settings.notification.LockscreenNotificationMinimalismPreferenceController"
            settings:controller="com.android.settings.notification.LockscreenNotificationMinimalismPreferenceController"
@@ -153,7 +161,7 @@


        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="lock_screen_show_only_unseen_notifs"
            android:key="lock_screen_show_only_unseen_notifs"
            android:order="20"
            android:order="21"
            android:title="@string/unseen_notifs_lock_screen"
            android:title="@string/unseen_notifs_lock_screen"
            android:summary="@string/unseen_notifs_lock_screen_summary"
            android:summary="@string/unseen_notifs_lock_screen_summary"
            settings:controller="com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController"
            settings:controller="com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController"
@@ -162,7 +170,7 @@
        <Preference
        <Preference
            android:fragment="com.android.settings.accessibility.FlashNotificationsPreferenceFragment"
            android:fragment="com.android.settings.accessibility.FlashNotificationsPreferenceFragment"
            android:key="flash_notifications_preference"
            android:key="flash_notifications_preference"
            android:order="21"
            android:order="22"
            android:persistent="false"
            android:persistent="false"
            android:title="@string/flash_notifications_title"
            android:title="@string/flash_notifications_title"
            settings:searchable="false"
            settings:searchable="false"
@@ -170,7 +178,7 @@


        <com.android.settingslib.RestrictedPreference
        <com.android.settingslib.RestrictedPreference
            android:key="app_and_notif_cell_broadcast_settings"
            android:key="app_and_notif_cell_broadcast_settings"
            android:order="22"
            android:order="23"
            android:title="@string/cell_broadcast_settings"
            android:title="@string/cell_broadcast_settings"
            settings:useAdminDisabledSummary="true">
            settings:useAdminDisabledSummary="true">
            <intent
            <intent
@@ -181,33 +189,33 @@


        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
             android:key="silent_icons"
             android:key="silent_icons"
             android:order="23"
             android:order="24"
             android:title="@string/silent_notifications_status_bar"
             android:title="@string/silent_notifications_status_bar"
             settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController"/>
             settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController"/>


        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="show_snooze_options"
            android:key="show_snooze_options"
            android:order="24"
            android:order="25"
            android:title="@string/snooze_options_title"
            android:title="@string/snooze_options_title"
            settings:controller="com.android.settings.notification.SnoozeNotificationPreferenceController" />
            settings:controller="com.android.settings.notification.SnoozeNotificationPreferenceController" />


        <!-- Notification badging -->
        <!-- Notification badging -->
        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="notification_badging"
            android:key="notification_badging"
            android:order="25"
            android:order="26"
            android:title="@string/notification_badging_title"
            android:title="@string/notification_badging_title"
            settings:controller="com.android.settings.notification.BadgingNotificationPreferenceController"/>
            settings:controller="com.android.settings.notification.BadgingNotificationPreferenceController"/>


        <!-- Pulse notification light, on devices that support it -->
        <!-- Pulse notification light, on devices that support it -->
        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="notification_pulse"
            android:key="notification_pulse"
            android:order="26"
            android:order="27"
            android:title="@string/notification_pulse_title"
            android:title="@string/notification_pulse_title"
            settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/>
            settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/>


        <SwitchPreferenceCompat
        <SwitchPreferenceCompat
            android:key="notification_assistant"
            android:key="notification_assistant"
            android:order="27"
            android:order="28"
            android:title="@string/notification_assistant_title"
            android:title="@string/notification_assistant_title"
            android:summary="@string/notification_assistant_summary"
            android:summary="@string/notification_assistant_summary"
            settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
            settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
+24 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2024 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:title="@string/lock_screen_notifs_title"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto">


</PreferenceScreen>
+40 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.notification;

import android.content.Context;

import com.android.server.notification.Flags;
import com.android.settings.core.BasePreferenceController;

// TODO(b/367455695): remove controller when the feature flag is removed!

/**
 * Controller for lock screen notifications settings page.
 */
public class LockScreenNotificationsPreferencePageController extends BasePreferenceController {

    public LockScreenNotificationsPreferencePageController(Context context, String preferenceKey) {
        super(context, preferenceKey);
    }

    @Override
    public int getAvailabilityStatus() {
        return Flags.notificationLockScreenSettings() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }

}
+56 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.notification;

import android.app.settings.SettingsEnums;
import android.content.Context;

import com.android.server.notification.Flags;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;

/**
 * Fragment for notifications on lock screen preference page.
 */
@SearchIndexable
public class LockScreenNotificationsPreferencePageFragment extends DashboardFragment {

    @Override
    public int getMetricsCategory() {
        //TODO(b/367455695): create a new metrics category
        return SettingsEnums.SETTINGS_LOCK_SCREEN_PREFERENCES;
    }

    @Override
    protected int getPreferenceScreenResId() {
        return R.xml.lock_screen_notifications_settings;
    }
    @Override
    protected String getLogTag() {
        return "LockScreenNotificationsPreferenceFragment";
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider(R.xml.lock_screen_notifications_settings) {
                @Override
                protected boolean isPageSearchEnabled(Context context) {
                    return Flags.notificationLockScreenSettings();
                }
            };
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -56,6 +56,10 @@ public class LockscreenNotificationMinimalismPreferenceController


    @Override
    @Override
    public int getAvailabilityStatus() {
    public int getAvailabilityStatus() {
        // Hide when the notifications on lock screen settings page flag is enabled.
        if (Flags.notificationLockScreenSettings()) {
            return CONDITIONALLY_UNAVAILABLE;
        }
        if (!Flags.notificationMinimalism()) {
        if (!Flags.notificationMinimalism()) {
            return CONDITIONALLY_UNAVAILABLE;
            return CONDITIONALLY_UNAVAILABLE;
        }
        }
Loading