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