1 /*
2  * Copyright (C) 2010 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 
17 package com.android.settings;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.os.Bundle;
22 
23 import com.android.settings.dashboard.DashboardFragment;
24 import com.android.settings.display.BrightnessLevelPreferenceController;
25 import com.android.settings.display.CameraGesturePreferenceController;
26 import com.android.settings.display.LiftToWakePreferenceController;
27 import com.android.settings.display.NightDisplayPreferenceController;
28 import com.android.settings.display.NightModePreferenceController;
29 import com.android.settings.display.ScreenSaverPreferenceController;
30 import com.android.settings.display.ShowOperatorNamePreferenceController;
31 import com.android.settings.display.TapToWakePreferenceController;
32 import com.android.settings.display.ThemePreferenceController;
33 import com.android.settings.display.TimeoutPreferenceController;
34 import com.android.settings.display.VrDisplayPreferenceController;
35 import com.android.settings.search.BaseSearchIndexProvider;
36 import com.android.settingslib.core.AbstractPreferenceController;
37 import com.android.settingslib.core.lifecycle.Lifecycle;
38 import com.android.settingslib.search.SearchIndexable;
39 
40 import java.util.ArrayList;
41 import java.util.List;
42 
43 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
44 public class DisplaySettings extends DashboardFragment {
45     private static final String TAG = "DisplaySettings";
46 
47     private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
48 
49     @Override
getMetricsCategory()50     public int getMetricsCategory() {
51         return SettingsEnums.DISPLAY;
52     }
53 
54     @Override
getLogTag()55     protected String getLogTag() {
56         return TAG;
57     }
58 
59     @Override
getPreferenceScreenResId()60     protected int getPreferenceScreenResId() {
61         return R.xml.display_settings;
62     }
63 
64     @Override
onCreate(Bundle icicle)65     public void onCreate(Bundle icicle) {
66         super.onCreate(icicle);
67     }
68 
69     @Override
createPreferenceControllers(Context context)70     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
71         return buildPreferenceControllers(context, getSettingsLifecycle());
72     }
73 
74     @Override
getHelpResource()75     public int getHelpResource() {
76         return R.string.help_uri_display;
77     }
78 
buildPreferenceControllers( Context context, Lifecycle lifecycle)79     private static List<AbstractPreferenceController> buildPreferenceControllers(
80             Context context, Lifecycle lifecycle) {
81         final List<AbstractPreferenceController> controllers = new ArrayList<>();
82         controllers.add(new CameraGesturePreferenceController(context));
83         controllers.add(new LiftToWakePreferenceController(context));
84         controllers.add(new NightDisplayPreferenceController(context));
85         controllers.add(new NightModePreferenceController(context));
86         controllers.add(new ScreenSaverPreferenceController(context));
87         controllers.add(new TapToWakePreferenceController(context));
88         controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
89         controllers.add(new VrDisplayPreferenceController(context));
90         controllers.add(new ShowOperatorNamePreferenceController(context));
91         controllers.add(new ThemePreferenceController(context));
92         controllers.add(new BrightnessLevelPreferenceController(context, lifecycle));
93         return controllers;
94     }
95 
96     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
97             new BaseSearchIndexProvider(R.xml.display_settings) {
98 
99                 @Override
100                 public List<AbstractPreferenceController> createPreferenceControllers(
101                         Context context) {
102                     return buildPreferenceControllers(context, null);
103                 }
104             };
105 }
106