Only show the schedule text for the night display and dark theme

In Android S design, night display and dark theme only show
schedule text for summary.

- Rmove redundant string resource.
- Remove redundant method in night display formatter.
- Refactor the code in dark mode preference and night display
controller.

Test: See the correct behavior in screen.
Fix: 174964139
Change-Id: I658b3073a0a6ed83f589103999c711e5430eaeb7
This commit is contained in:
Tsung-Mao Fang
2021-01-07 15:41:26 +08:00
parent cfedc19ab9
commit acab1a0364
4 changed files with 15 additions and 24 deletions

View File

@@ -74,10 +74,10 @@ public class DarkModePreference extends PrimarySwitchPreference {
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 @@ public class DarkModePreference extends PrimarySwitchPreference {
? 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);
}