Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 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 | |
Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame^] | 19 | import android.app.settings.SettingsEnums; |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 21 | import android.provider.SearchIndexableResource; |
Jason Monk | 1230ac8 | 2015-12-11 20:14:43 -0500 | [diff] [blame] | 22 | |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 23 | import com.android.settings.dashboard.DashboardFragment; |
Doris Ling | 2e4ff90 | 2017-04-13 15:06:36 -0700 | [diff] [blame] | 24 | import com.android.settings.display.BrightnessLevelPreferenceController; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 25 | import com.android.settings.display.CameraGesturePreferenceController; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 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; |
Yoshinori Hirano | 53cfd11 | 2017-10-10 13:57:07 +0900 | [diff] [blame] | 30 | import com.android.settings.display.ShowOperatorNamePreferenceController; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 31 | import com.android.settings.display.TapToWakePreferenceController; |
Jason Monk | 6324cff | 2017-01-25 10:34:29 -0500 | [diff] [blame] | 32 | import com.android.settings.display.ThemePreferenceController; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 33 | import com.android.settings.display.TimeoutPreferenceController; |
| 34 | import com.android.settings.display.VrDisplayPreferenceController; |
Jason Monk | 49b6103 | 2015-08-12 11:31:29 -0400 | [diff] [blame] | 35 | import com.android.settings.search.BaseSearchIndexProvider; |
| 36 | import com.android.settings.search.Indexable; |
Tony Mantler | 1d583e1 | 2017-06-13 13:09:25 -0700 | [diff] [blame] | 37 | import com.android.settingslib.core.AbstractPreferenceController; |
Juan Lang | 777ed25 | 2017-05-09 15:42:36 -0700 | [diff] [blame] | 38 | import com.android.settingslib.core.lifecycle.Lifecycle; |
Tony Mantler | 0fcd6cb | 2018-03-26 15:17:25 -0700 | [diff] [blame] | 39 | import com.android.settingslib.search.SearchIndexable; |
Jason Monk | 49b6103 | 2015-08-12 11:31:29 -0400 | [diff] [blame] | 40 | |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 41 | import java.util.ArrayList; |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 42 | import java.util.List; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 43 | |
Tony Mantler | 0fcd6cb | 2018-03-26 15:17:25 -0700 | [diff] [blame] | 44 | @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 45 | public class DisplaySettings extends DashboardFragment { |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 46 | private static final String TAG = "DisplaySettings"; |
| 47 | |
Matthew Fritze | c6f2638 | 2017-04-11 13:22:40 -0700 | [diff] [blame] | 48 | private static final String KEY_SCREEN_TIMEOUT = "screen_timeout"; |
Matthew Fritze | c448863 | 2017-11-28 14:36:35 -0800 | [diff] [blame] | 49 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 50 | @Override |
Fan Zhang | 6507613 | 2016-08-08 10:25:13 -0700 | [diff] [blame] | 51 | public int getMetricsCategory() { |
Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame^] | 52 | return SettingsEnums.DISPLAY; |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | @Override |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 56 | protected String getLogTag() { |
| 57 | return TAG; |
Stephen Chen | 2b98ffa | 2016-09-20 13:15:11 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 60 | @Override |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 61 | protected int getPreferenceScreenResId() { |
Doris Ling | 8b14a1a | 2017-08-17 14:45:12 -0700 | [diff] [blame] | 62 | return R.xml.display_settings; |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 63 | } |
Jeff Brown | 9e143f5 | 2012-09-19 20:46:07 -0700 | [diff] [blame] | 64 | |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 65 | @Override |
Fan Zhang | f7843ad | 2018-02-22 13:51:41 -0800 | [diff] [blame] | 66 | protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { |
tmfang | 27c84de | 2018-06-28 11:39:05 +0800 | [diff] [blame] | 67 | return buildPreferenceControllers(context, getSettingsLifecycle()); |
Fan Zhang | b00811d | 2017-02-28 10:52:46 -0800 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | @Override |
Fan Zhang | e0b0e9f | 2017-11-29 14:55:59 -0800 | [diff] [blame] | 71 | public int getHelpResource() { |
Fan Zhang | b00811d | 2017-02-28 10:52:46 -0800 | [diff] [blame] | 72 | return R.string.help_uri_display; |
| 73 | } |
| 74 | |
Tony Mantler | 1d583e1 | 2017-06-13 13:09:25 -0700 | [diff] [blame] | 75 | private static List<AbstractPreferenceController> buildPreferenceControllers( |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 76 | Context context, Lifecycle lifecycle) { |
Tony Mantler | 1d583e1 | 2017-06-13 13:09:25 -0700 | [diff] [blame] | 77 | final List<AbstractPreferenceController> controllers = new ArrayList<>(); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 78 | controllers.add(new CameraGesturePreferenceController(context)); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 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)); |
Matthew Fritze | c6f2638 | 2017-04-11 13:22:40 -0700 | [diff] [blame] | 84 | controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 85 | controllers.add(new VrDisplayPreferenceController(context)); |
Yoshinori Hirano | 53cfd11 | 2017-10-10 13:57:07 +0900 | [diff] [blame] | 86 | controllers.add(new ShowOperatorNamePreferenceController(context)); |
Jason Monk | 6324cff | 2017-01-25 10:34:29 -0500 | [diff] [blame] | 87 | controllers.add(new ThemePreferenceController(context)); |
Doris Ling | 2e4ff90 | 2017-04-13 15:06:36 -0700 | [diff] [blame] | 88 | controllers.add(new BrightnessLevelPreferenceController(context, lifecycle)); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 89 | return controllers; |
Doris Ling | b727e9c | 2016-08-01 14:56:26 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 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) { |
Fan Zhang | 99abc02 | 2016-10-11 14:23:13 -0700 | [diff] [blame] | 97 | final ArrayList<SearchIndexableResource> result = new ArrayList<>(); |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 98 | |
Fan Zhang | 99abc02 | 2016-10-11 14:23:13 -0700 | [diff] [blame] | 99 | final SearchIndexableResource sir = new SearchIndexableResource(context); |
Fan Zhang | dc9a82f | 2017-03-16 11:08:59 -0700 | [diff] [blame] | 100 | sir.xmlResId = R.xml.display_settings; |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 101 | result.add(sir); |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 102 | return result; |
| 103 | } |
| 104 | |
| 105 | @Override |
Fan Zhang | aed8994 | 2018-02-22 13:32:32 -0800 | [diff] [blame] | 106 | public List<AbstractPreferenceController> createPreferenceControllers( |
| 107 | Context context) { |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 108 | return buildPreferenceControllers(context, null); |
Matthew Fritze | 516b0f1 | 2017-01-26 14:37:48 -0800 | [diff] [blame] | 109 | } |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 110 | }; |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 111 | } |