Add dark theme custom type into the dark theme settings page

Also fix some test cases.

I'd prefer using Robolectric shadows rather than mocking Android
framework classes. However, I can't do that in this CL due to the
lack of multiple shadow classes support.

Test: make RunSettingsRoboTests -j56
      ROBOTEST_FILTER=com.android.settings.display.darkmode.*
Bug: 215182463
Change-Id: If557d2933927a5dd0fadd3f6db6bb6f0ab7dd5ee
This commit is contained in:
Steven Ng
2022-01-17 17:25:50 +00:00
parent 0128837312
commit 3859251be0
16 changed files with 698 additions and 108 deletions

View File

@@ -15,21 +15,20 @@
package com.android.settings.display.darkmode;
import android.app.Dialog;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM;
import android.app.TimePickerDialog;
import android.app.UiModeManager;
import android.content.Context;
import android.text.TextUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import static android.app.UiModeManager.MODE_NIGHT_CUSTOM;
/**
* Controller for custom mode night mode time settings
*/
@@ -89,7 +88,9 @@ public class DarkModeCustomPreferenceController extends BasePreferenceController
@Override
protected void refreshSummary(Preference preference) {
if (mUiModeManager.getNightMode() != MODE_NIGHT_CUSTOM) {
if (mUiModeManager.getNightMode() != MODE_NIGHT_CUSTOM
|| mUiModeManager.getNightModeCustomType()
!= UiModeManager.MODE_NIGHT_CUSTOM_TYPE_SCHEDULE) {
preference.setVisible(false);
return;
}