Loading AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2785,6 +2785,7 @@ </intent-filter> <intent-filter> <action android:name="com.android.settings.action.SETTINGS" /> <action android:name="com.android.intent.action.SHOW_CONTRAST_DIALOG" /> </intent-filter> <meta-data android:name="com.android.settings.order" android:value="-40"/> <meta-data android:name="com.android.settings.category" Loading res/values/strings.xml +11 −0 Original line number Diff line number Diff line Loading @@ -4946,6 +4946,8 @@ <string name="keywords_color_correction">adjust color </string> <!-- List of synonyms used in the settings search bar to find the “Color inversion”. [CHAR LIMIT=NONE] --> <string name="keywords_color_inversion">turn screen dark, turn screen light</string> <!-- List of synonyms used in the settings search bar to find the “Contrast”. [CHAR LIMIT=NONE] --> <string name="keywords_contrast">color contrast</string> <!-- List of synonyms used in the settings search bar to find the “Accessibility Menu”. [CHAR LIMIT=NONE] --> <string name="keywords_accessibility_menu"></string> <!-- List of synonyms used in the settings search bar to find the “Switch Access”. [CHAR LIMIT=NONE] --> Loading Loading @@ -12021,6 +12023,15 @@ <!-- Button to close the dialog without saving in screen flash color selection dialog. [CHAR LIMIT=20] --> <string name="color_selector_dialog_cancel">Cancel</string> <!-- Title for the contrast preference fragment [CHAR LIMIT=35] --> <string name="contrast_title">Contrast</string> <!-- 'Standard' contrast option [CHAR LIMIT=20] --> <string name="contrast_standard">Standard</string> <!-- 'Medium' contrast option [CHAR LIMIT=20] --> <string name="contrast_medium">Medium</string> <!-- 'High' contrast option [CHAR LIMIT=20] --> <string name="contrast_high">High</string> <!-- Warning message when we try to dock an app not supporting multiple instances split into multiple sides [CHAR LIMIT=NONE] --> <string name="dock_multi_instances_not_supported_text">"This app can only be opened in 1 window"</string> </resources> res/xml/development_settings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -515,6 +515,12 @@ android:title="@string/transparent_navigation_bar" android:summary="@string/transparent_navigation_bar_summary" /> <Preference android:key="contrast_preference" android:title="@string/contrast_title" android:persistent="false" settings:keywords="@string/keywords_contrast" /> </PreferenceCategory> <PreferenceCategory Loading src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.settings.development; import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES; import android.app.Activity; import android.app.UiModeManager; import android.app.settings.SettingsEnums; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothAdapter; Loading Loading @@ -63,6 +64,7 @@ import com.android.settings.development.storage.SharedDataPreferenceController; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.actionbar.SearchMenuController; import com.android.settings.theme.ContrastPreferenceController; import com.android.settings.widget.SettingsMainSwitchBar; import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.lifecycle.Lifecycle; Loading Loading @@ -685,6 +687,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new IngressRateLimitPreferenceController((context))); controllers.add(new BackAnimationPreferenceController(context, fragment)); controllers.add(new PhantomProcessPreferenceController(context)); controllers.add(new ContrastPreferenceController( context, context.getSystemService(UiModeManager.class))); return controllers; } Loading src/com/android/settings/theme/ContrastPreferenceController.kt 0 → 100644 +66 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.theme import android.app.UiModeManager import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_HIGH import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_MEDIUM import android.app.UiModeManager.ContrastUtils.toContrastLevel import android.content.Context import android.content.Intent import android.os.UserHandle import android.text.TextUtils import androidx.preference.Preference import com.android.internal.annotations.VisibleForTesting import com.android.settings.R import com.android.settings.core.BasePreferenceController /** * Controller that opens the contrast dialog and updates the text describing the current contrast */ class ContrastPreferenceController( private val context: Context, private val uiModeManager: UiModeManager) : BasePreferenceController(context, KEY) { companion object { @VisibleForTesting const val KEY = "contrast_preference" } override fun getAvailabilityStatus(): Int { return AVAILABLE } override fun handlePreferenceTreeClick(preference: Preference): Boolean { if (TextUtils.equals(preference.key, preferenceKey)) { val intent = Intent(Intent.ACTION_SHOW_CONTRAST_DIALOG) context.startActivityAsUser(intent, UserHandle(UserHandle.USER_CURRENT)) return true } return false } override fun getSummary(): CharSequence = getSummary(toContrastLevel(uiModeManager.contrast)) @VisibleForTesting fun getSummary(contrast: Int): String { return when (contrast) { CONTRAST_LEVEL_HIGH -> context.getString(R.string.contrast_high) CONTRAST_LEVEL_MEDIUM -> context.getString(R.string.contrast_medium) else -> context.getString(R.string.contrast_standard) } } } No newline at end of file Loading
AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2785,6 +2785,7 @@ </intent-filter> <intent-filter> <action android:name="com.android.settings.action.SETTINGS" /> <action android:name="com.android.intent.action.SHOW_CONTRAST_DIALOG" /> </intent-filter> <meta-data android:name="com.android.settings.order" android:value="-40"/> <meta-data android:name="com.android.settings.category" Loading
res/values/strings.xml +11 −0 Original line number Diff line number Diff line Loading @@ -4946,6 +4946,8 @@ <string name="keywords_color_correction">adjust color </string> <!-- List of synonyms used in the settings search bar to find the “Color inversion”. [CHAR LIMIT=NONE] --> <string name="keywords_color_inversion">turn screen dark, turn screen light</string> <!-- List of synonyms used in the settings search bar to find the “Contrast”. [CHAR LIMIT=NONE] --> <string name="keywords_contrast">color contrast</string> <!-- List of synonyms used in the settings search bar to find the “Accessibility Menu”. [CHAR LIMIT=NONE] --> <string name="keywords_accessibility_menu"></string> <!-- List of synonyms used in the settings search bar to find the “Switch Access”. [CHAR LIMIT=NONE] --> Loading Loading @@ -12021,6 +12023,15 @@ <!-- Button to close the dialog without saving in screen flash color selection dialog. [CHAR LIMIT=20] --> <string name="color_selector_dialog_cancel">Cancel</string> <!-- Title for the contrast preference fragment [CHAR LIMIT=35] --> <string name="contrast_title">Contrast</string> <!-- 'Standard' contrast option [CHAR LIMIT=20] --> <string name="contrast_standard">Standard</string> <!-- 'Medium' contrast option [CHAR LIMIT=20] --> <string name="contrast_medium">Medium</string> <!-- 'High' contrast option [CHAR LIMIT=20] --> <string name="contrast_high">High</string> <!-- Warning message when we try to dock an app not supporting multiple instances split into multiple sides [CHAR LIMIT=NONE] --> <string name="dock_multi_instances_not_supported_text">"This app can only be opened in 1 window"</string> </resources>
res/xml/development_settings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -515,6 +515,12 @@ android:title="@string/transparent_navigation_bar" android:summary="@string/transparent_navigation_bar_summary" /> <Preference android:key="contrast_preference" android:title="@string/contrast_title" android:persistent="false" settings:keywords="@string/keywords_contrast" /> </PreferenceCategory> <PreferenceCategory Loading
src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.settings.development; import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES; import android.app.Activity; import android.app.UiModeManager; import android.app.settings.SettingsEnums; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothAdapter; Loading Loading @@ -63,6 +64,7 @@ import com.android.settings.development.storage.SharedDataPreferenceController; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.actionbar.SearchMenuController; import com.android.settings.theme.ContrastPreferenceController; import com.android.settings.widget.SettingsMainSwitchBar; import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.lifecycle.Lifecycle; Loading Loading @@ -685,6 +687,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new IngressRateLimitPreferenceController((context))); controllers.add(new BackAnimationPreferenceController(context, fragment)); controllers.add(new PhantomProcessPreferenceController(context)); controllers.add(new ContrastPreferenceController( context, context.getSystemService(UiModeManager.class))); return controllers; } Loading
src/com/android/settings/theme/ContrastPreferenceController.kt 0 → 100644 +66 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.theme import android.app.UiModeManager import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_HIGH import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_MEDIUM import android.app.UiModeManager.ContrastUtils.toContrastLevel import android.content.Context import android.content.Intent import android.os.UserHandle import android.text.TextUtils import androidx.preference.Preference import com.android.internal.annotations.VisibleForTesting import com.android.settings.R import com.android.settings.core.BasePreferenceController /** * Controller that opens the contrast dialog and updates the text describing the current contrast */ class ContrastPreferenceController( private val context: Context, private val uiModeManager: UiModeManager) : BasePreferenceController(context, KEY) { companion object { @VisibleForTesting const val KEY = "contrast_preference" } override fun getAvailabilityStatus(): Int { return AVAILABLE } override fun handlePreferenceTreeClick(preference: Preference): Boolean { if (TextUtils.equals(preference.key, preferenceKey)) { val intent = Intent(Intent.ACTION_SHOW_CONTRAST_DIALOG) context.startActivityAsUser(intent, UserHandle(UserHandle.USER_CURRENT)) return true } return false } override fun getSummary(): CharSequence = getSummary(toContrastLevel(uiModeManager.contrast)) @VisibleForTesting fun getSummary(contrast: Int): String { return when (contrast) { CONTRAST_LEVEL_HIGH -> context.getString(R.string.contrast_high) CONTRAST_LEVEL_MEDIUM -> context.getString(R.string.contrast_medium) else -> context.getString(R.string.contrast_standard) } } } No newline at end of file