Custom dark theme scheduling

allows the use to set the start and end automatic dark theme
activation within a day.

Test: run all settings tests
Change-Id: If96fc050159724d553acb09c2da4fab1d5ff519f
This commit is contained in:
Jay Aliomer
2020-01-02 19:24:25 -05:00
parent 76e22fcc42
commit c31c35fb19
12 changed files with 448 additions and 30 deletions

View File

@@ -63,8 +63,17 @@ public class DarkModeScheduleSelectorController extends BasePreferenceController
}
private int getCurrentMode() {
final int resId = mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_AUTO
? R.string.dark_ui_auto_mode_auto : R.string.dark_ui_auto_mode_never;
int resId;
switch (mUiModeManager.getNightMode()) {
case UiModeManager.MODE_NIGHT_AUTO:
resId = R.string.dark_ui_auto_mode_auto;
break;
case UiModeManager.MODE_NIGHT_CUSTOM:
resId = R.string.dark_ui_auto_mode_custom;
break;
default:
resId = R.string.dark_ui_auto_mode_never;
}
return mPreference.findIndexOfValue(mContext.getString(resId));
}
@@ -85,6 +94,9 @@ public class DarkModeScheduleSelectorController extends BasePreferenceController
} else if (mCurrentMode == mPreference.findIndexOfValue(
mContext.getString(R.string.dark_ui_auto_mode_auto))) {
mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);
} else if (mCurrentMode == mPreference.findIndexOfValue(
mContext.getString(R.string.dark_ui_auto_mode_custom))) {
mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
}
return true;
}