Cherish: Allow scheduling always on display [2/2]

From sunset to sunrise or at a custom time

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
idoybh
2021-12-11 00:13:54 +00:00
committed by Hưng Phan
parent 6bc14947d6
commit 9d7a94864c
6 changed files with 269 additions and 0 deletions

View File

@@ -57,6 +57,10 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class LockScreenSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String AOD_SCHEDULE_KEY = "always_on_display_schedule";
Preference mAODPref;
@Override
public void onCreate(Bundle icicle) {
@@ -76,11 +80,32 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
} catch (NameNotFoundException e) {
e.printStackTrace();
}
mAODPref = findPreference(AOD_SCHEDULE_KEY);
updateAlwaysOnSummary();
}
@Override
public void onResume() {
super.onResume();
updateAlwaysOnSummary();
}
private void updateAlwaysOnSummary() {
if (mAODPref == null) return;
int mode = Settings.Secure.getIntForUser(getActivity().getContentResolver(),
Settings.Secure.DOZE_ALWAYS_ON_AUTO_MODE, 0, UserHandle.USER_CURRENT);
switch (mode) {
case 0:
mAODPref.setSummary(R.string.disabled);
break;
case 1:
mAODPref.setSummary(R.string.night_display_auto_mode_twilight);
break;
case 2:
mAODPref.setSummary(R.string.night_display_auto_mode_custom);
break;
}
}
public boolean onPreferenceChange(Preference preference, Object newValue) {