• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.accessibility
18 
19 import android.content.Context
20 import android.hardware.display.ColorDisplayManager
21 import com.android.settings.R
22 import com.android.settings.Settings.ColorAndMotionActivity
23 import com.android.settings.display.darkmode.DarkModeScreen
24 import com.android.settings.flags.Flags
25 import com.android.settings.utils.makeLaunchIntent
26 import com.android.settingslib.metadata.PreferenceCategory
27 import com.android.settingslib.metadata.PreferenceGroup
28 import com.android.settingslib.metadata.PreferenceHierarchy
29 import com.android.settingslib.metadata.PreferenceMetadata
30 import com.android.settingslib.metadata.ProvidePreferenceScreen
31 import com.android.settingslib.metadata.preferenceHierarchy
32 import com.android.settingslib.preference.PreferenceScreenCreator
33 
34 @ProvidePreferenceScreen(ColorAndMotionScreen.KEY)
35 class ColorAndMotionScreen : PreferenceScreenCreator {
36     override val key: String
37         get() = KEY
38 
39     override val title: Int
40         get() = R.string.accessibility_color_and_motion_title
41 
42     override val icon: Int
43         get() = R.drawable.ic_color_and_motion
44 
isFlagEnablednull45     override fun isFlagEnabled(context: Context) = Flags.catalystAccessibilityColorAndMotion()
46 
47     override fun hasCompleteHierarchy(): Boolean = true
48 
49     override fun fragmentClass() = ColorAndMotionFragment::class.java
50 
51     override fun getPreferenceHierarchy(context: Context): PreferenceHierarchy {
52         // LINT.IfChange(ui_hierarchy)
53         if (ColorDisplayManager.isColorTransformAccelerated(context)) {
54             return preferenceHierarchy(context, this) {
55                 +DaltonizerPreference()
56                 +ColorInversionPreference()
57                 +DarkModeScreen.KEY
58                 +RemoveAnimationsPreference()
59             }
60         } else {
61             return preferenceHierarchy(context, this) {
62                 +ColorInversionPreference()
63                 +DarkModeScreen.KEY
64                 +PreferenceCategory(
65                     "experimental_category",
66                     R.string.experimental_category_title
67                 ) += {
68                     +DaltonizerPreference()
69                     +RemoveAnimationsPreference()
70                 }
71             }
72         }
73         // LINT.ThenChange(/res/xml/accessibility_color_and_motion.xml, /src/com/android/settings/accessibility/ColorAndMotionFragment.java:ui_hierarchy)
74     }
75 
getLaunchIntentnull76     override fun getLaunchIntent(context: Context, metadata: PreferenceMetadata?) =
77         makeLaunchIntent(context, ColorAndMotionActivity::class.java, metadata?.key)
78 
79     companion object {
80         const val KEY = "accessibility_color_and_motion"
81     }
82 }
83