• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.settings.system;
17 
18 import android.content.Context;
19 import android.os.UserManager;
20 import android.provider.SearchIndexableResource;
21 
22 import com.android.internal.logging.nano.MetricsProto;
23 import com.android.settings.R;
24 import com.android.settings.backup.BackupSettingsActivityPreferenceController;
25 import com.android.settings.core.PreferenceController;
26 import com.android.settings.dashboard.DashboardFragment;
27 import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
28 import com.android.settings.deviceinfo.SystemUpdatePreferenceController;
29 import com.android.settings.search.BaseSearchIndexProvider;
30 import com.android.settings.search.Indexable;
31 
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.List;
35 
36 public class SystemDashboardFragment extends DashboardFragment {
37 
38     private static final String TAG = "SystemDashboardFrag";
39 
40     private static final String KEY_RESET = "reset_dashboard";
41 
42     @Override
getMetricsCategory()43     public int getMetricsCategory() {
44         return MetricsProto.MetricsEvent.SETTINGS_SYSTEM_CATEGORY;
45     }
46 
47     @Override
getLogTag()48     protected String getLogTag() {
49         return TAG;
50     }
51 
52     @Override
getPreferenceScreenResId()53     protected int getPreferenceScreenResId() {
54         return R.xml.system_dashboard_fragment;
55     }
56 
57     @Override
getPreferenceControllers(Context context)58     protected List<PreferenceController> getPreferenceControllers(Context context) {
59         return buildPreferenceControllers(context);
60     }
61 
buildPreferenceControllers(Context context)62     private static List<PreferenceController> buildPreferenceControllers(Context context) {
63         final List<PreferenceController> controllers = new ArrayList<>();
64         controllers.add(new SystemUpdatePreferenceController(context, UserManager.get(context)));
65         controllers.add(new AdditionalSystemUpdatePreferenceController(context));
66         controllers.add(new BackupSettingsActivityPreferenceController(context));
67         return controllers;
68     }
69 
70     /**
71      * For Search.
72      */
73     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
74             new BaseSearchIndexProvider() {
75                 @Override
76                 public List<SearchIndexableResource> getXmlResourcesToIndex(
77                         Context context, boolean enabled) {
78                     final SearchIndexableResource sir = new SearchIndexableResource(context);
79                     sir.xmlResId = R.xml.system_dashboard_fragment;
80                     return Arrays.asList(sir);
81                 }
82 
83                 @Override
84                 public List<PreferenceController> getPreferenceControllers(Context context) {
85                     return buildPreferenceControllers(context);
86                 }
87 
88                 @Override
89                 public List<String> getNonIndexableKeys(Context context) {
90                     List<String> keys = super.getNonIndexableKeys(context);
91                     keys.add((new BackupSettingsActivityPreferenceController(context)
92                             .getPreferenceKey()));
93                     keys.add(KEY_RESET);
94                     return keys;
95                 }
96             };
97 }
98