Fix Master: Add settings for scheduling dark theme

Adding a settings page similar to night light for Dark theme. it will allow the user to schedule
dark mode from sunrise to sunset

Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.display.DarkUIPreferenceControllerTest" && \
make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.display.darkmode.DarkModeActivationPreferenceControllerTest" && \
make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.display.darkmode.DarkModeObserverTest" && \
make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.display.darkmode.DarkModeScheduleSelectorControllerTest"

Fixes: 141567787
Change-Id: Iee5d020ac6ea093be712a4f191d4601c9d4617fa
This commit is contained in:
Jay Aliomer
2019-10-24 13:42:38 -04:00
parent 01cf29b958
commit a377b5c4aa
17 changed files with 904 additions and 48 deletions

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight">
<Button
android:id="@+id/dark_ui_turn_on_button"
style="@style/ActionPrimaryButton"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<Button
android:id="@+id/dark_ui_turn_off_button"
style="@style/ActionSecondaryButton"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>

View File

@@ -100,6 +100,14 @@
<item>1800000</item>
</string-array>
<!-- Dark theme scheduling preferences [CHAR LIMIT=NONE] -->
<string-array name="dark_ui_scheduler_preference_titles">
<!-- 1: None -->
<item>@string/dark_ui_auto_mode_never</item>
<!-- 2: Auto -->
<item>@string/dark_ui_auto_mode_auto</item>
</string-array>
<!-- Security settings. The delay after screen is turned off until device locks.
These are shown in a list dialog. -->
<string-array name="lock_after_timeout_entries">

View File

@@ -2762,6 +2762,40 @@
<!-- Night display slice screen, subtitle of intensity setting when night light is off. [CHAR LIMIT=30] -->
<string name="night_display_not_currently_on">Night Light not currently on</string>
<!-- Dark ui screen-->
<!-- Display settings screen, activation button action for manual mode. [CHAR LIMIT=40] -->
<string name="dark_ui_activation_on_manual">Turn on now</string>
<!-- Display settings screen, deactivation button action for manual mode. [CHAR LIMIT=40] -->
<string name="dark_ui_activation_off_manual">Turn off now</string>
<!-- Display settings screen, activation button action for sunset-to-sunrise schedule [CHAR LIMIT=40] -->
<string name="dark_ui_activation_on_auto">Turn on until sunrise</string>
<!-- Display settings screen, deactivation button action for sunset-to-sunrise schedule [CHAR LIMIT=40] -->
<string name="dark_ui_activation_off_auto">Turn off until sunset</string>
<!-- Dark UI screen, setting option name to enable Dark UI [CHAR LIMIT=30] -->
<string name="dark_ui_title">Dark Mode</string>
<!-- Dark UI screen, setting option name to configure whether Dark UI turn on/off automatically. [CHAR LIMIT=30] -->
<string name="dark_ui_auto_mode_title">Schedule</string>
<!-- Dark UI screen, setting option value for Dark UI to *never* turn on/off automatically. [CHAR LIMIT=30] -->
<string name="dark_ui_auto_mode_never">None</string>
<!-- Dark UIscreen, setting option value for Dark UI to turn on/off automatically at sunset/sunrise. [CHAR LIMIT=32] -->
<string name="dark_ui_auto_mode_auto">Turns on from sunset to sunrise</string>
<!-- Dark UIscreen, setting option name controlling the current activation status. [CHAR LIMIT=30] -->
<string name="dark_ui_status_title">Status</string>
<!-- Display settings screen, summary format of Dark UI when off. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_off">Off / <xliff:g name="auto_mode_summary" example="Never turn on automatically">%1$s</xliff:g></string>
<!-- Display settings screen, summary of Dark UI when off and will *never* turn on automatically. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_off_auto_mode_never">Will never turn on automatically</string>
<!-- Display settings screen, summary of Dark UI when off and will turn on automatically at sunset. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_off_auto_mode_auto">Will turn on automatically at sunset</string>
<!-- Display settings screen, summary format of Dark UI when on. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_on">On / <xliff:g name="auto_mode_summary" example="Never turn off automatically">%1$s</xliff:g></string>
<!-- Display settings screen, summary of Dark UI when on and will *never* turn off automatically. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_on_auto_mode_never">Will never turn off automatically</string>
<!-- Display settings screen, summary of Dark UI when on and will turn off automatically at sunrise. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_on_auto_mode_auto">Will turn off automatically at sunrise</string>
<!-- Dark theme screen, description of Dark theme feature. [CHAR LIMIT=NONE] -->
<string name="dark_ui_text">Dark theme uses true black to help keep your battery alive longer. Dark theme schedules wait to turn on until your screen is off.</string>
<!-- Sound & display settings screen, setting option name to change screen timeout -->
<string name="screen_timeout">Screen timeout</string>
<!-- Sound & display settings screen, setting option name to change screen timeout [CHAR LIMIT=30] -->
@@ -6879,6 +6913,7 @@
<string name="help_url_connected_devices" translatable="false"></string>
<string name="help_url_apps_and_notifications" translatable="false"></string>
<string name="help_url_night_display" translatable="false"></string>
<string name="help_url_dark_theme" translatable="false"></string>
<string name="help_url_screen_saver" translatable="false"></string>
<string name="help_url_pickup_gesture" translatable="false"></string>
<string name="help_url_storage_dashboard" translatable="false"></string>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/dark_ui_mode"
android:key="dark_ui_mode_screen"
settings:keywords="@string/keywords_dark_ui_mode">
<DropDownPreference
android:key="dark_ui_auto_mode"
android:title="@string/dark_ui_auto_mode_title"
android:summary="%s"
android:entries="@array/dark_ui_scheduler_preference_titles"
android:entryValues="@array/dark_ui_scheduler_preference_titles"
settings:controller="com.android.settings.display.darkmode.DarkModeScheduleSelectorController"
settings:keywords="@string/keywords_dark_ui_mode"/>
<com.android.settingslib.widget.LayoutPreference
android:key="dark_ui_activated"
android:title="@string/dark_ui_title"
android:selectable="false"
android:layout="@layout/dark_ui_activation_button"
settings:allowDividerBelow="true"
settings:controller="com.android.settings.display.darkmode.DarkModeActivationPreferenceController"
settings:keywords="@string/keywords_dark_ui_mode"/>
<com.android.settingslib.widget.FooterPreference
android:key="dark_ui_footer"
android:title="@string/dark_ui_text"
android:selectable="false"
settings:searchable="false"
settings:allowDividerAbove="true"/>
</PreferenceScreen>

View File

@@ -21,4 +21,4 @@
android:key="dark_ui_mode_screen"
settings:staticPreferenceLocation="append"
settings:keywords="@string/keywords_dark_ui_mode">
</PreferenceScreen >
</PreferenceScreen >

View File

@@ -31,6 +31,15 @@
<intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
</com.android.settingslib.RestrictedPreference>
<com.android.settings.display.darkmode.DarkModePreference
android:key="dark_ui_mode"
android:title="@string/dark_ui_mode"
android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
android:widgetLayout="@null"
settings:widgetLayout="@null"
settings:controller="com.android.settings.display.DarkUIPreferenceController"
settings:searchable="false"/>
<com.android.settings.display.NightDisplayPreference
android:key="night_display"
android:title="@string/night_display_title"
@@ -54,13 +63,6 @@
settings:controller="com.android.settings.display.WallpaperPreferenceController">
</com.android.settingslib.RestrictedPreference>
<SwitchPreference
android:key="dark_ui_mode"
android:title="@string/dark_ui_mode"
settings:keywords="@string/keywords_dark_ui_mode"
settings:controller="com.android.settings.display.DarkUIPreferenceController"/>
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
<com.android.settings.display.TimeoutListPreference
android:key="screen_timeout"