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