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

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

Merge "Create "on lock screen notifications" in Privacy"

parents d25f37bc e541def5
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
    android:key="privacy_dashboard_page"
    android:title="@string/privacy_dashboard_title">

    <!-- App permissions -->
    <Preference
        android:key="privacy_manage_perms"
        android:title="@string/app_permissions"
@@ -29,6 +30,14 @@
        <intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
    </Preference>

    <!-- On lock screen notifications -->
    <com.android.settings.RestrictedListPreference
        android:key="privacy_lock_screen_notifications"
        android:title="@string/lock_screen_notifications_title"
        android:summary="@string/summary_placeholder"
        settings:searchable="false"/>

    <!-- Show passwords -->
    <SwitchPreference
        android:key="show_password"
        android:title="@string/show_password"
@@ -42,4 +51,20 @@
    <PreferenceCategory
        android:key="dashboard_tile_placeholder"/>

    <!-- Work profile settings are at the bottom with high order value to avoid users thinking that
         any of the above settings (including dynamic) are specific to the work profile. -->
    <PreferenceCategory
        android:key="privacy_work_profile_notifications_category"
        android:title="@string/profile_section_header"
        android:order="998"
        settings:searchable="false">

        <com.android.settings.RestrictedListPreference
            android:key="privacy_lock_screen_work_profile_notifications"
            android:title="@string/locked_work_profile_notification_title"
            android:summary="@string/summary_placeholder"
            android:order="999"
            settings:searchable="false"/>
    </PreferenceCategory>

</PreferenceScreen>
 No newline at end of file
+36 −0
Original line number Diff line number Diff line
@@ -22,7 +22,10 @@ import android.provider.SearchIndexableResource;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;

import java.util.ArrayList;
@@ -31,6 +34,11 @@ import java.util.List;
@SearchIndexable
public class PrivacyDashboardFragment extends DashboardFragment {
    private static final String TAG = "PrivacyDashboardFragment";
    private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "privacy_lock_screen_notifications";
    private static final String KEY_WORK_PROFILE_CATEGORY =
            "privacy_work_profile_notifications_category";
    private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
            "privacy_lock_screen_work_profile_notifications";

    @Override
    public int getMetricsCategory() {
@@ -52,6 +60,28 @@ public class PrivacyDashboardFragment extends DashboardFragment {
        return R.string.help_url_privacy_dashboard;
    }

    @Override
    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
        return buildPreferenceControllers(context, getSettingsLifecycle());
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(
            Context context, Lifecycle lifecycle) {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
        final LockScreenNotificationPreferenceController notificationController =
                new LockScreenNotificationPreferenceController(context,
                        KEY_LOCK_SCREEN_NOTIFICATIONS,
                        KEY_WORK_PROFILE_CATEGORY,
                        KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS);
        if (lifecycle != null) {
            lifecycle.addObserver(notificationController);
        }
        controllers.add(notificationController);

        return controllers;

    }

    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {
                @Override
@@ -64,5 +94,11 @@ public class PrivacyDashboardFragment extends DashboardFragment {
                    result.add(sir);
                    return result;
                }

                @Override
                public List<AbstractPreferenceController> createPreferenceControllers(
                        Context context) {
                    return buildPreferenceControllers(context, null);
                }
            };
}