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.content.Context; 20 import android.provider.SearchIndexableResource; 21 22 import com.android.internal.hardware.AmbientDisplayConfiguration; 23 import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 24 import com.android.settings.dashboard.DashboardFragment; 25 import com.android.settings.display.AmbientDisplayPreferenceController; 26 import com.android.settings.display.AutoBrightnessPreferenceController; 27 import com.android.settings.display.AutoRotatePreferenceController; 28 import com.android.settings.display.BrightnessLevelPreferenceController; 29 import com.android.settings.display.CameraGesturePreferenceController; 30 import com.android.settings.display.ColorModePreferenceController; 31 import com.android.settings.display.FontSizePreferenceController; 32 import com.android.settings.display.LiftToWakePreferenceController; 33 import com.android.settings.display.NightDisplayPreferenceController; 34 import com.android.settings.display.NightModePreferenceController; 35 import com.android.settings.display.ScreenSaverPreferenceController; 36 import com.android.settings.display.TapToWakePreferenceController; 37 import com.android.settings.display.ThemePreferenceController; 38 import com.android.settings.display.TimeoutPreferenceController; 39 import com.android.settings.display.VrDisplayPreferenceController; 40 import com.android.settings.display.WallpaperPreferenceController; 41 import com.android.settings.search.BaseSearchIndexProvider; 42 import com.android.settings.search.Indexable; 43 import com.android.settingslib.core.AbstractPreferenceController; 44 import com.android.settingslib.core.lifecycle.Lifecycle; 45 46 import java.util.ArrayList; 47 import java.util.List; 48 49 public class DisplaySettings extends DashboardFragment { 50 private static final String TAG = "DisplaySettings"; 51 52 public static final String KEY_AUTO_BRIGHTNESS = "auto_brightness"; 53 public static final String KEY_DISPLAY_SIZE = "screen_zoom"; 54 55 private static final String KEY_SCREEN_TIMEOUT = "screen_timeout"; 56 private static final String KEY_AMBIENT_DISPLAY = "ambient_display"; 57 58 @Override getMetricsCategory()59 public int getMetricsCategory() { 60 return MetricsEvent.DISPLAY; 61 } 62 63 @Override getLogTag()64 protected String getLogTag() { 65 return TAG; 66 } 67 68 @Override onAttach(Context context)69 public void onAttach(Context context) { 70 super.onAttach(context); 71 mProgressiveDisclosureMixin.setTileLimit(4); 72 } 73 74 @Override getPreferenceScreenResId()75 protected int getPreferenceScreenResId() { 76 return R.xml.display_settings; 77 } 78 79 @Override getPreferenceControllers(Context context)80 protected List<AbstractPreferenceController> getPreferenceControllers(Context context) { 81 return buildPreferenceControllers(context, getLifecycle()); 82 } 83 84 @Override getHelpResource()85 protected int getHelpResource() { 86 return R.string.help_uri_display; 87 } 88 buildPreferenceControllers( Context context, Lifecycle lifecycle)89 private static List<AbstractPreferenceController> buildPreferenceControllers( 90 Context context, Lifecycle lifecycle) { 91 final List<AbstractPreferenceController> controllers = new ArrayList<>(); 92 controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS)); 93 controllers.add(new AutoRotatePreferenceController(context, lifecycle)); 94 controllers.add(new CameraGesturePreferenceController(context)); 95 controllers.add(new FontSizePreferenceController(context)); 96 controllers.add(new LiftToWakePreferenceController(context)); 97 controllers.add(new NightDisplayPreferenceController(context)); 98 controllers.add(new NightModePreferenceController(context)); 99 controllers.add(new ScreenSaverPreferenceController(context)); 100 controllers.add(new AmbientDisplayPreferenceController( 101 context, 102 new AmbientDisplayConfiguration(context), 103 KEY_AMBIENT_DISPLAY)); 104 controllers.add(new TapToWakePreferenceController(context)); 105 controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); 106 controllers.add(new VrDisplayPreferenceController(context)); 107 controllers.add(new WallpaperPreferenceController(context)); 108 controllers.add(new ThemePreferenceController(context)); 109 controllers.add(new BrightnessLevelPreferenceController(context, lifecycle)); 110 controllers.add(new ColorModePreferenceController(context)); 111 return controllers; 112 } 113 114 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 115 new BaseSearchIndexProvider() { 116 @Override 117 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 118 boolean enabled) { 119 final ArrayList<SearchIndexableResource> result = new ArrayList<>(); 120 121 final SearchIndexableResource sir = new SearchIndexableResource(context); 122 sir.xmlResId = R.xml.display_settings; 123 result.add(sir); 124 return result; 125 } 126 127 @Override 128 public List<String> getNonIndexableKeys(Context context) { 129 List<String> keys = super.getNonIndexableKeys(context); 130 keys.add(KEY_DISPLAY_SIZE); 131 keys.add(WallpaperPreferenceController.KEY_WALLPAPER); 132 keys.add(KEY_AMBIENT_DISPLAY); 133 return keys; 134 } 135 136 @Override 137 public List<AbstractPreferenceController> getPreferenceControllers(Context context) { 138 return buildPreferenceControllers(context, null); 139 } 140 }; 141 } 142