OSDN Git Service

Create "on lock screen notifications" in Privacy
authortmfang <tmfang@google.com>
Tue, 20 Nov 2018 09:53:41 +0000 (17:53 +0800)
committertmfang <tmfang@google.com>
Tue, 20 Nov 2018 12:09:46 +0000 (20:09 +0800)
Test: visual, robotest
Bug: 116628158
Change-Id: I056f3734c591f8b300ae1003364ed4c1c2b2f9e3

res/xml/privacy_dashboard_settings.xml
src/com/android/settings/privacy/PrivacyDashboardFragment.java

index 5d11936..79e2e71 100644 (file)
@@ -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"
         <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"
     <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
index dd4c8fa..91e85b3 100644 (file)
@@ -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);
+                }
             };
 }