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 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 19 | import android.content.Context; |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 20 | import android.os.UserHandle; |
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 | |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 23 | import com.android.internal.hardware.AmbientDisplayConfiguration; |
Tamas Berghammer | 265d3c2 | 2016-06-22 15:34:45 +0100 | [diff] [blame] | 24 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 25 | import com.android.settings.core.PreferenceController; |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 26 | import com.android.settings.core.lifecycle.Lifecycle; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 27 | import com.android.settings.dashboard.DashboardFragment; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 28 | import com.android.settings.display.AutoBrightnessPreferenceController; |
| 29 | import com.android.settings.display.AutoRotatePreferenceController; |
Doris Ling | 03ee253 | 2017-04-03 15:21:18 -0700 | [diff] [blame] | 30 | import com.android.settings.display.BrightnessLevelPreferenceController; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 31 | import com.android.settings.display.CameraGesturePreferenceController; |
| 32 | import com.android.settings.display.DozePreferenceController; |
| 33 | import com.android.settings.display.FontSizePreferenceController; |
| 34 | import com.android.settings.display.LiftToWakePreferenceController; |
| 35 | import com.android.settings.display.NightDisplayPreferenceController; |
| 36 | import com.android.settings.display.NightModePreferenceController; |
| 37 | import com.android.settings.display.ScreenSaverPreferenceController; |
| 38 | import com.android.settings.display.TapToWakePreferenceController; |
Jason Monk | 6324cff | 2017-01-25 10:34:29 -0500 | [diff] [blame] | 39 | import com.android.settings.display.ThemePreferenceController; |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 40 | import com.android.settings.display.TimeoutPreferenceController; |
| 41 | import com.android.settings.display.VrDisplayPreferenceController; |
| 42 | import com.android.settings.display.WallpaperPreferenceController; |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 43 | import com.android.settings.gestures.DoubleTapScreenPreferenceController; |
| 44 | import com.android.settings.gestures.PickupGesturePreferenceController; |
Jason Monk | 49b6103 | 2015-08-12 11:31:29 -0400 | [diff] [blame] | 45 | import com.android.settings.search.BaseSearchIndexProvider; |
| 46 | import com.android.settings.search.Indexable; |
| 47 | |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 48 | import java.util.ArrayList; |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 49 | import java.util.List; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 50 | |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 51 | public class DisplaySettings extends DashboardFragment { |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 52 | private static final String TAG = "DisplaySettings"; |
| 53 | |
Matthew Fritze | c6f2638 | 2017-04-11 13:22:40 -0700 | [diff] [blame^] | 54 | public static final String KEY_AUTO_BRIGHTNESS = "auto_brightness"; |
| 55 | private static final String KEY_SCREEN_TIMEOUT = "screen_timeout"; |
| 56 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 57 | @Override |
Fan Zhang | 6507613 | 2016-08-08 10:25:13 -0700 | [diff] [blame] | 58 | public int getMetricsCategory() { |
Chris Wren | 9d1bfd1 | 2016-01-26 18:04:01 -0500 | [diff] [blame] | 59 | return MetricsEvent.DISPLAY; |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | @Override |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 63 | protected String getLogTag() { |
| 64 | return TAG; |
Stephen Chen | 2b98ffa | 2016-09-20 13:15:11 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 67 | @Override |
Fan Zhang | d916dae | 2017-01-06 16:10:28 -0800 | [diff] [blame] | 68 | public void onAttach(Context context) { |
| 69 | super.onAttach(context); |
| 70 | mProgressiveDisclosureMixin.setTileLimit(4); |
| 71 | } |
| 72 | |
| 73 | @Override |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 74 | protected int getPreferenceScreenResId() { |
Fan Zhang | dc9a82f | 2017-03-16 11:08:59 -0700 | [diff] [blame] | 75 | return R.xml.display_settings; |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 76 | } |
Jeff Brown | 9e143f5 | 2012-09-19 20:46:07 -0700 | [diff] [blame] | 77 | |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 78 | @Override |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 79 | protected List<PreferenceController> getPreferenceControllers(Context context) { |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 80 | return buildPreferenceControllers(context, getLifecycle()); |
Fan Zhang | b00811d | 2017-02-28 10:52:46 -0800 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | @Override |
| 84 | protected int getHelpResource() { |
| 85 | return R.string.help_uri_display; |
| 86 | } |
| 87 | |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 88 | private static List<PreferenceController> buildPreferenceControllers( |
| 89 | Context context, Lifecycle lifecycle) { |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 90 | final List<PreferenceController> controllers = new ArrayList<>(); |
Matthew Fritze | c6f2638 | 2017-04-11 13:22:40 -0700 | [diff] [blame^] | 91 | controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS)); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 92 | controllers.add(new AutoRotatePreferenceController(context)); |
| 93 | controllers.add(new CameraGesturePreferenceController(context)); |
| 94 | controllers.add(new DozePreferenceController(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)); |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 100 | AmbientDisplayConfiguration ambientDisplayConfig = new AmbientDisplayConfiguration(context); |
| 101 | controllers.add(new PickupGesturePreferenceController( |
| 102 | context, lifecycle, ambientDisplayConfig, UserHandle.myUserId())); |
| 103 | controllers.add(new DoubleTapScreenPreferenceController( |
| 104 | context, lifecycle, ambientDisplayConfig, UserHandle.myUserId())); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 105 | controllers.add(new TapToWakePreferenceController(context)); |
Matthew Fritze | c6f2638 | 2017-04-11 13:22:40 -0700 | [diff] [blame^] | 106 | controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 107 | controllers.add(new VrDisplayPreferenceController(context)); |
| 108 | controllers.add(new WallpaperPreferenceController(context)); |
Jason Monk | 6324cff | 2017-01-25 10:34:29 -0500 | [diff] [blame] | 109 | controllers.add(new ThemePreferenceController(context)); |
Doris Ling | 03ee253 | 2017-04-03 15:21:18 -0700 | [diff] [blame] | 110 | controllers.add(new BrightnessLevelPreferenceController(context)); |
Fan Zhang | 66b573a | 2016-10-06 16:33:13 -0700 | [diff] [blame] | 111 | return controllers; |
Doris Ling | b727e9c | 2016-08-01 14:56:26 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 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) { |
Fan Zhang | 99abc02 | 2016-10-11 14:23:13 -0700 | [diff] [blame] | 119 | final ArrayList<SearchIndexableResource> result = new ArrayList<>(); |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 120 | |
Fan Zhang | 99abc02 | 2016-10-11 14:23:13 -0700 | [diff] [blame] | 121 | final SearchIndexableResource sir = new SearchIndexableResource(context); |
Fan Zhang | dc9a82f | 2017-03-16 11:08:59 -0700 | [diff] [blame] | 122 | sir.xmlResId = R.xml.display_settings; |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 123 | result.add(sir); |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 124 | return result; |
| 125 | } |
| 126 | |
| 127 | @Override |
Matthew Fritze | 516b0f1 | 2017-01-26 14:37:48 -0800 | [diff] [blame] | 128 | public List<PreferenceController> getPreferenceControllers(Context context) { |
Andrew Sapperstein | 6138f1a | 2017-03-22 18:00:47 -0700 | [diff] [blame] | 129 | return buildPreferenceControllers(context, null); |
Matthew Fritze | 516b0f1 | 2017-01-26 14:37:48 -0800 | [diff] [blame] | 130 | } |
Adrian Roos | 8ab0954 | 2014-06-02 20:33:56 +0200 | [diff] [blame] | 131 | }; |
Amith Yamasani | 992f102 | 2010-01-25 09:17:53 -0800 | [diff] [blame] | 132 | } |