Merge "Only show the schedule text for the night display and dark theme"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2fa46d4..0275269 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2824,16 +2824,12 @@
<string name="night_display_status_title">Status</string>
<!-- Night display screen, setting the color temperature of the display. [CHAR LIMIT=30] -->
<string name="night_display_temperature_title">Intensity</string>
- <!-- Display settings screen, summary format of night display when off. [CHAR LIMIT=NONE] -->
- <string name="night_display_summary_off">Off / <xliff:g name="auto_mode_summary" example="Never turn on automatically">%1$s</xliff:g></string>
<!-- Display settings screen, summary of night display when off and will *never* turn on automatically. [CHAR LIMIT=NONE] -->
<string name="night_display_summary_off_auto_mode_never">Will never turn on automatically</string>
<!-- Display settings screen, summary format of night display when off and will turn on automatically at a user defined time. [CHAR LIMIT=NONE] -->
<string name="night_display_summary_off_auto_mode_custom">Will turn on automatically at <xliff:g name="time" example="6 AM">%1$s</xliff:g></string>
<!-- Display settings screen, summary of night display when off and will turn on automatically at sunset. [CHAR LIMIT=NONE] -->
<string name="night_display_summary_off_auto_mode_twilight">Will turn on automatically at sunset</string>
- <!-- Display settings screen, summary format of night display when on. [CHAR LIMIT=NONE] -->
- <string name="night_display_summary_on">On / <xliff:g name="auto_mode_summary" example="Never turn off automatically">%1$s</xliff:g></string>
<!-- Display settings screen, summary of night display when on and will *never* turn off automatically. [CHAR LIMIT=NONE] -->
<string name="night_display_summary_on_auto_mode_never">Will never turn off automatically</string>
<!-- Display settings screen, summary format of night display when on and will turn off automatically at a user defined time. [CHAR LIMIT=NONE] -->
@@ -2882,16 +2878,12 @@
<string name="dark_ui_auto_mode_custom">Turns on at custom time</string>
<!-- Dark UI screen, 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 night display when off and will turn on automatically at a user defined time. [CHAR LIMIT=NONE] -->
<string name="dark_ui_summary_off_auto_mode_custom">Will turn on automatically at <xliff:g name="time" example="6 AM">%1$s</xliff:g></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] -->
@@ -10870,7 +10862,7 @@
<string name="dark_ui_mode">Dark theme</string>
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is still on-->
- <string name="dark_ui_mode_disabled_summary_dark_theme_on">On / Temporarily disabled due to Battery Saver</string>
+ <string name="dark_ui_mode_disabled_summary_dark_theme_on">Temporarily disabled due to Battery Saver</string>
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is off-->
<string name="dark_ui_mode_disabled_summary_dark_theme_off">Temporarily turned on due to Battery Saver</string>
diff --git a/src/com/android/settings/display/NightDisplayPreferenceController.java b/src/com/android/settings/display/NightDisplayPreferenceController.java
index 0198007..003373c 100644
--- a/src/com/android/settings/display/NightDisplayPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayPreferenceController.java
@@ -17,6 +17,7 @@
import android.hardware.display.ColorDisplayManager;
import android.hardware.display.NightDisplayListener;
+import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -32,6 +33,7 @@
private final ColorDisplayManager mColorDisplayManager;
private final NightDisplayListener mNightDisplayListener;
+ private final NightDisplayTimeFormatter mTimeFormatter;
private PrimarySwitchPreference mPreference;
public NightDisplayPreferenceController(Context context, String key) {
@@ -39,6 +41,7 @@
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
mNightDisplayListener = new NightDisplayListener(context);
+ mTimeFormatter = new NightDisplayTimeFormatter(context);
}
public static boolean isSuggestionComplete(Context context) {
@@ -87,6 +90,12 @@
}
@Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setSummary(mTimeFormatter.getAutoModeSummary(mContext, mColorDisplayManager));
+ }
+
+ @Override
public void onActivated(boolean activated) {
updateState(mPreference);
}
diff --git a/src/com/android/settings/display/NightDisplayTimeFormatter.java b/src/com/android/settings/display/NightDisplayTimeFormatter.java
index 1449ac1..aa715de 100644
--- a/src/com/android/settings/display/NightDisplayTimeFormatter.java
+++ b/src/com/android/settings/display/NightDisplayTimeFormatter.java
@@ -17,8 +17,8 @@
package com.android.settings.display;
import android.content.Context;
-
import android.hardware.display.ColorDisplayManager;
+
import com.android.settings.R;
import java.text.DateFormat;
@@ -45,13 +45,6 @@
return mTimeFormatter.format(c.getTime());
}
- public String getAutoModeTimeSummary(Context context, ColorDisplayManager manager) {
- final int summaryFormatResId =
- manager.isNightDisplayActivated() ? R.string.night_display_summary_on
- : R.string.night_display_summary_off;
- return context.getString(summaryFormatResId, getAutoModeSummary(context, manager));
- }
-
public String getAutoModeSummary(Context context, ColorDisplayManager manager) {
final boolean isActivated = manager.isNightDisplayActivated();
final int autoMode = manager.getNightDisplayAutoMode();
diff --git a/src/com/android/settings/display/darkmode/DarkModePreference.java b/src/com/android/settings/display/darkmode/DarkModePreference.java
index baaa1f7..c69bb01 100644
--- a/src/com/android/settings/display/darkmode/DarkModePreference.java
+++ b/src/com/android/settings/display/darkmode/DarkModePreference.java
@@ -74,10 +74,10 @@
return;
}
final int mode = mUiModeManager.getNightMode();
- String detail;
+ String summary;
if (mode == UiModeManager.MODE_NIGHT_AUTO) {
- detail = getContext().getString(active
+ summary = getContext().getString(active
? R.string.dark_ui_summary_on_auto_mode_auto
: R.string.dark_ui_summary_off_auto_mode_auto);
} else if (mode == UiModeManager.MODE_NIGHT_CUSTOM) {
@@ -85,17 +85,14 @@
? mUiModeManager.getCustomNightModeEnd()
: mUiModeManager.getCustomNightModeStart();
final String timeStr = mFormat.of(time);
- detail = getContext().getString(active
+ summary = getContext().getString(active
? R.string.dark_ui_summary_on_auto_mode_custom
: R.string.dark_ui_summary_off_auto_mode_custom, timeStr);
} else {
- detail = getContext().getString(active
+ summary = getContext().getString(active
? R.string.dark_ui_summary_on_auto_mode_never
: R.string.dark_ui_summary_off_auto_mode_never);
}
- String summary = getContext().getString(active
- ? R.string.dark_ui_summary_on
- : R.string.dark_ui_summary_off, detail);
setSummary(summary);
}