Cherish: date right/left position [2/2]

This commit is contained in:
yank555-lu
2019-11-23 08:32:02 +07:00
committed by Hưng Phan
parent 63157ec6d9
commit 2e2089d6ee
4 changed files with 50 additions and 1 deletions

View File

@@ -59,6 +59,7 @@ public class ClockSettings extends SettingsPreferenceFragment
private static final String STATUS_BAR_CLOCK_DATE_DISPLAY = "clock_date_display";
private static final String STATUS_BAR_CLOCK_DATE_STYLE = "clock_date_style";
private static final String STATUS_BAR_CLOCK_DATE_FORMAT = "clock_date_format";
private static final String STATUS_BAR_CLOCK_DATE_POSITION = "statusbar_clock_date_position";
public static final int CLOCK_DATE_STYLE_LOWERCASE = 1;
public static final int CLOCK_DATE_STYLE_UPPERCASE = 2;
private static final int CUSTOM_CLOCK_DATE_FORMAT_INDEX = 18;
@@ -69,6 +70,7 @@ public class ClockSettings extends SettingsPreferenceFragment
private ListPreference mClockDateDisplay;
private ListPreference mClockDateStyle;
private ListPreference mClockDateFormat;
private ListPreference mClockDatePosition;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -82,6 +84,7 @@ public class ClockSettings extends SettingsPreferenceFragment
mStatusBarAmPm = (ListPreference) findPreference(STATUS_BAR_AM_PM);
mClockDateDisplay = (ListPreference) findPreference(STATUS_BAR_CLOCK_DATE_DISPLAY);
mClockDateStyle = (ListPreference) findPreference(STATUS_BAR_CLOCK_DATE_STYLE);
mClockDatePosition = (ListPreference) findPreference(STATUS_BAR_CLOCK_DATE_POSITION);
mStatusBarSecondsShow.setChecked((Settings.System.getInt(resolver,
Settings.System.STATUS_BAR_CLOCK_SECONDS, 0) == 1));
@@ -131,7 +134,15 @@ public class ClockSettings extends SettingsPreferenceFragment
}
parseClockDateFormats();
int clockDatePosition = Settings.System.getInt(resolver,
Settings.System.STATUSBAR_CLOCK_DATE_POSITION, 0);
mClockDatePosition.setValue(String.valueOf(clockDatePosition));
mClockDatePosition.setSummary(mClockDatePosition.getEntry());
mClockDatePosition.setOnPreferenceChangeListener(this);
setDateOptions();
}
@Override
@@ -227,6 +238,22 @@ public class ClockSettings extends SettingsPreferenceFragment
}
}
return true;
} else if (preference == mClockDatePosition) {
int val = Integer.parseInt((String) newValue);
int index = mClockDatePosition.findIndexOfValue((String) newValue);
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.STATUSBAR_CLOCK_DATE_POSITION, val);
mClockDatePosition.setSummary(mClockDatePosition.getEntries()[index]);
parseClockDateFormats();
return true;
} else if (preference == mClockDatePosition) {
int val = Integer.parseInt((String) newValue);
int index = mClockDatePosition.findIndexOfValue((String) newValue);
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.STATUSBAR_CLOCK_DATE_POSITION, val);
mClockDatePosition.setSummary(mClockDatePosition.getEntries()[index]);
parseClockDateFormats();
return true;
}
return false;
}
@@ -266,9 +293,11 @@ public class ClockSettings extends SettingsPreferenceFragment
if (enableDateOptions == 0) {
mClockDateStyle.setEnabled(false);
mClockDateFormat.setEnabled(false);
mClockDatePosition.setEnabled(false);
} else {
mClockDateStyle.setEnabled(true);
mClockDateFormat.setEnabled(true);
mClockDatePosition.setEnabled(true);
}
}
}