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

Commit 38537f81 authored by Yining Liu's avatar Yining Liu
Browse files

Inverse toggles on the notifications on locks screen settings page

Inverse the toggles on the notifications on locks screen settings page
to consistently make ON = SHOW.

Bug: 367455695
Flag: com.android.server.notification.notification_lock_screen_settings
Test: manual, atest LockScreenNotificationShowSensitiveControllerTest
Change-Id: I6e34ef9b89f4c0ad058bf740bafb3c83790201c0
parent b5fa953d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -8931,17 +8931,17 @@
    <!-- Notification Settings > Notifications on lock screen > Title for showing notifications on the lock screen. [CHAR LIMIT=100] -->
    <string name="lockscreen_notification_what_to_show_title">What to show on lock screen</string>
    <!-- Notification Settings > Notifications on lock screen > Summary for hiding seen notifications toggle. [CHAR LIMIT=100] -->
    <string name="lock_screen_notification_hide_seen_summary">Seen notifications are removed from the lock screen.</string>
    <!-- Notification Settings > Notifications on lock screen > Title for showing seen notifications toggle. [CHAR LIMIT=60] -->
    <string name="lock_screen_notification_show_seen_title">Show seen notifications</string>
    <!-- Notification Settings > Notifications on lock screen > Title for hiding silent notifications toggle. [CHAR LIMIT=60] -->
    <string name="lock_screen_notification_hide_silent_title">Hide silent notifications</string>
    <string name="lock_screen_notification_show_silent_title">Show silent notifications</string>
    <!-- Notification Settings > Notifications on lock screen > Title for hiding sensitive notification content on lock screen. [CHAR LIMIT=60] -->
    <string name="lock_screen_notification_hide_sensitive_content_title">Hide sensitive content</string>
    <string name="lock_screen_notification_show_sensitive_content_title">Show sensitive content</string>
    <!-- Notification Settings > Notifications on lock screen > Title for hiding sensitive work profile notification content on lock screen. [CHAR LIMIT=100] -->
    <string name="lock_screen_notification_hide_sensitive_work_content_title">Hide sensitive work profile content</string>
    <string name="lock_screen_notification_show_sensitive_work_content_title">Show sensitive work profile content</string>
    <!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Title for the screen asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=30] -->
    <string name="lock_screen_notifications_interstitial_title_profile">Profile notifications</string>
+10 −10
Original line number Diff line number Diff line
@@ -49,24 +49,24 @@
        android:title="@string/lockscreen_notification_what_to_show_title">

        <SwitchPreferenceCompat
            android:key="lock_screen_notification_hide_seen_toggle"
            android:title="@string/lock_screen_notification_hide_seen_summary"
            settings:controller="com.android.settings.notification.LockScreenNotificationHideSeenToggleController" />
            android:key="lock_screen_notification_show_seen_toggle"
            android:title="@string/lock_screen_notification_show_seen_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationShowSeenController" />

        <SwitchPreferenceCompat
            android:key="lock_screen_notification_hide_silent_toggle"
            android:title="@string/lock_screen_notification_hide_silent_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationHideSilentToggleController" />
            android:key="lock_screen_notification_show_silent_toggle"
            android:title="@string/lock_screen_notification_show_silent_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationShowSilentController" />

        <com.android.settingslib.RestrictedSwitchPreference
            android:key="lock_screen_notification_show_sensitive_toggle"
            android:title="@string/lock_screen_notification_hide_sensitive_content_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveToggleController" />
            android:title="@string/lock_screen_notification_show_sensitive_content_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveController" />

        <com.android.settingslib.RestrictedSwitchPreference
            android:key="work_profile_show_sensitive_notif_toggle"
            android:title="@string/lock_screen_notification_hide_sensitive_work_content_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveToggleController" />
            android:title="@string/lock_screen_notification_show_sensitive_work_content_title"
            settings:controller="com.android.settings.notification.LockScreenNotificationShowSensitiveController" />

    </PreferenceCategory>

+7 −7
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import com.android.settings.core.TogglePreferenceController;
 * Controls the toggle that determines whether to hide seen notifications from the lock screen.
 * Toggle for setting: Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS
 */
public class LockScreenNotificationHideSeenToggleController extends TogglePreferenceController
public class LockScreenNotificationShowSeenController extends TogglePreferenceController
        implements LifecycleEventObserver {

    private static final int UNSET = 0;
@@ -57,7 +57,7 @@ public class LockScreenNotificationHideSeenToggleController extends TogglePrefer
        }
    };

    public LockScreenNotificationHideSeenToggleController(@NonNull Context context,
    public LockScreenNotificationShowSeenController(@NonNull Context context,
            @NonNull String preferenceKey) {
        super(context, preferenceKey);
        mContentResolver = context.getContentResolver();
@@ -90,7 +90,7 @@ public class LockScreenNotificationHideSeenToggleController extends TogglePrefer
    @Override
    public void updateState(@NonNull Preference preference) {
        super.updateState(preference);
        setChecked(lockScreenShowOnlyUnseenNotifications());
        setChecked(lockScreenShowSeenNotifications());
        preference.setVisible(isAvailable());
    }

@@ -115,18 +115,18 @@ public class LockScreenNotificationHideSeenToggleController extends TogglePrefer

    @Override
    public boolean isChecked() {
        return lockScreenShowOnlyUnseenNotifications();
        return lockScreenShowSeenNotifications();
    }

    private boolean lockScreenShowOnlyUnseenNotifications() {
    private boolean lockScreenShowSeenNotifications() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET) == ON;
                Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET) == OFF;
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        return Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, (isChecked ? ON : OFF));
                Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, (isChecked ? OFF : ON));
    }

    @Override
+9 −9
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ import java.util.List;
 * when locked.
 * Toggle for: Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
 */
public class LockScreenNotificationShowSensitiveToggleController
public class LockScreenNotificationShowSensitiveController
        extends TogglePreferenceController implements LifecycleEventObserver {

    private static final int ON = 1;
@@ -78,7 +78,7 @@ public class LockScreenNotificationShowSensitiveToggleController
        }
    };

    public LockScreenNotificationShowSensitiveToggleController(@NonNull Context context,
    public LockScreenNotificationShowSensitiveController(@NonNull Context context,
            @NonNull String preferenceKey) {
        super(context, preferenceKey);
        mContentResolver = context.getContentResolver();
@@ -145,7 +145,7 @@ public class LockScreenNotificationShowSensitiveToggleController
    @Override
    public void updateState(@Nullable Preference preference) {
        if (preference == null) return;
        setChecked(showSensitiveContentOnlyWhenUnlocked());
        setChecked(showSensitiveContentWhenLocked());
        preference.setVisible(isAvailable());
    }

@@ -187,15 +187,15 @@ public class LockScreenNotificationShowSensitiveToggleController

    @Override
    public boolean isChecked() {
        return showSensitiveContentOnlyWhenUnlocked();
        return showSensitiveContentWhenLocked();
    }

    private boolean showSensitiveContentOnlyWhenUnlocked() {
    private boolean showSensitiveContentWhenLocked() {
        int userId = getUserId();
        if (!isLockScreenSecure()) return false;
        if (getEnforcedAdmin(userId) != null) return true;
        if (!isLockScreenSecure()) return true;
        if (getEnforcedAdmin(userId) != null) return false;
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, ON, userId) == OFF;
                Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, ON, userId) == ON;
    }

    @Override
@@ -203,7 +203,7 @@ public class LockScreenNotificationShowSensitiveToggleController
        return Settings.Secure.putIntForUser(
                mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
                (isChecked ? OFF : ON), getUserId()
                (isChecked ? ON : OFF), getUserId()
        );
    }

+7 −7
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import com.android.settings.core.TogglePreferenceController;
 * Controls the toggle that determines whether to show silent notifications when screen locked.
 * Toggle for: Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS
 */
public class LockScreenNotificationHideSilentToggleController extends TogglePreferenceController
public class LockScreenNotificationShowSilentController extends TogglePreferenceController
        implements LifecycleEventObserver {

    private static final int ON = 1;
@@ -56,7 +56,7 @@ public class LockScreenNotificationHideSilentToggleController extends TogglePref
        }
    };

    public LockScreenNotificationHideSilentToggleController(@NonNull Context context,
    public LockScreenNotificationShowSilentController(@NonNull Context context,
            @NonNull String preferenceKey) {
        super(context, preferenceKey);
        mContentResolver = context.getContentResolver();
@@ -89,13 +89,13 @@ public class LockScreenNotificationHideSilentToggleController extends TogglePref
    @Override
    public void updateState(@NonNull Preference preference) {
        super.updateState(preference);
        setChecked(hideSilentNotificationsWhenLocked());
        setChecked(showSilentNotificationsWhenLocked());
        preference.setVisible(isAvailable());
    }

    private boolean hideSilentNotificationsWhenLocked() {
    private boolean showSilentNotificationsWhenLocked() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, OFF) == OFF;
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, OFF) == ON;
    }

    @Override
@@ -116,13 +116,13 @@ public class LockScreenNotificationHideSilentToggleController extends TogglePref

    @Override
    public boolean isChecked() {
        return hideSilentNotificationsWhenLocked();
        return showSilentNotificationsWhenLocked();
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        return Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, (isChecked ? OFF : ON));
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, (isChecked ? ON : OFF));
    }

    @Override
Loading