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