Cherish:Xtended Statusbar Clock Customization [2/2]
Add Clock size, color & font style. Port to Pie + Added Color for Clocks - SuperDroidBond Clock fonts and size - @temasek Port to Oreo by @varund7726 Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
committed by
Hưng Phan
parent
19f919964c
commit
561a6531a0
@@ -42,6 +42,8 @@ import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
||||
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -56,10 +58,15 @@ public class ClockSettings extends SettingsPreferenceFragment implements
|
||||
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_COLOR = "status_bar_clock_color";
|
||||
private static final String STATUS_BAR_CLOCK_SIZE = "status_bar_clock_size";
|
||||
private static final String STATUS_BAR_CLOCK_FONT_STYLE = "status_bar_clock_font_style";
|
||||
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;
|
||||
|
||||
static final int DEFAULT_STATUS_CLOCK_COLOR = 0xffffffff;
|
||||
|
||||
private SystemSettingSwitchPreference mStatusBarClockShow;
|
||||
private SystemSettingSwitchPreference mStatusBarSecondsShow;
|
||||
private ListPreference mStatusBarClock;
|
||||
@@ -67,6 +74,9 @@ public class ClockSettings extends SettingsPreferenceFragment implements
|
||||
private ListPreference mClockDateDisplay;
|
||||
private ListPreference mClockDateStyle;
|
||||
private ListPreference mClockDateFormat;
|
||||
private ColorPickerPreference mClockColor;
|
||||
private CustomSeekBarPreference mClockSize;
|
||||
private ListPreference mClockFontStyle;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -75,6 +85,9 @@ public class ClockSettings extends SettingsPreferenceFragment implements
|
||||
PreferenceScreen prefSet = getPreferenceScreen();
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
int intColor;
|
||||
String hexColor;
|
||||
|
||||
// clock settings
|
||||
mStatusBarClockShow = (SystemSettingSwitchPreference) findPreference(STATUS_BAR_CLOCK);
|
||||
mStatusBarSecondsShow = (SystemSettingSwitchPreference) findPreference(STATUS_BAR_CLOCK_SECONDS);
|
||||
@@ -97,6 +110,26 @@ public class ClockSettings extends SettingsPreferenceFragment implements
|
||||
mStatusBarClock.setSummary(mStatusBarClock.getEntry());
|
||||
mStatusBarClock.setOnPreferenceChangeListener(this);
|
||||
|
||||
mClockColor = (ColorPickerPreference) findPreference(STATUS_BAR_CLOCK_COLOR);
|
||||
mClockColor.setOnPreferenceChangeListener(this);
|
||||
intColor = Settings.System.getInt(resolver,
|
||||
Settings.System.STATUS_BAR_CLOCK_COLOR, DEFAULT_STATUS_CLOCK_COLOR);
|
||||
hexColor = String.format("#%08x", (0xffffffff & intColor));
|
||||
mClockColor.setSummary(hexColor);
|
||||
mClockColor.setNewPreviewColor(intColor);
|
||||
|
||||
mClockSize = (CustomSeekBarPreference) findPreference(STATUS_BAR_CLOCK_SIZE);
|
||||
int clockSize = Settings.System.getInt(resolver,
|
||||
Settings.System.STATUS_BAR_CLOCK_SIZE, 14);
|
||||
mClockSize.setValue(clockSize / 1);
|
||||
mClockSize.setOnPreferenceChangeListener(this);
|
||||
|
||||
mClockFontStyle = (ListPreference) findPreference(STATUS_BAR_CLOCK_FONT_STYLE);
|
||||
int showClockFont = Settings.System.getInt(resolver,
|
||||
Settings.System.STATUS_BAR_CLOCK_FONT_STYLE, 0);
|
||||
mClockFontStyle.setValue(String.valueOf(showClockFont));
|
||||
mClockFontStyle.setOnPreferenceChangeListener(this);
|
||||
|
||||
if (DateFormat.is24HourFormat(getActivity())) {
|
||||
mStatusBarAmPm.setEnabled(false);
|
||||
mStatusBarAmPm.setSummary(R.string.status_bar_am_pm_info);
|
||||
@@ -149,6 +182,8 @@ public class ClockSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
AlertDialog dialog;
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
if (preference == mStatusBarClockShow) {
|
||||
boolean value = (Boolean) newValue;
|
||||
Settings.System.putInt(getActivity().getContentResolver(),
|
||||
@@ -173,6 +208,26 @@ public class ClockSettings extends SettingsPreferenceFragment implements
|
||||
Settings.System.STATUSBAR_CLOCK_AM_PM_STYLE, statusBarAmPm);
|
||||
mStatusBarAmPm.setSummary(mStatusBarAmPm.getEntries()[index]);
|
||||
return true;
|
||||
} else if (preference == mClockColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
preference.setSummary(hex);
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putInt(resolver,
|
||||
Settings.System.STATUS_BAR_CLOCK_COLOR, intHex);
|
||||
return true;
|
||||
} else if (preference == mClockSize) {
|
||||
int width = ((Integer)newValue).intValue();
|
||||
Settings.System.putInt(resolver,
|
||||
Settings.System.STATUS_BAR_CLOCK_SIZE, width);
|
||||
return true;
|
||||
} else if (preference == mClockFontStyle) {
|
||||
int showClockFont = Integer.valueOf((String) newValue);
|
||||
int index = mClockFontStyle.findIndexOfValue((String) newValue);
|
||||
Settings.System.putInt(resolver, Settings.System.
|
||||
STATUS_BAR_CLOCK_FONT_STYLE, showClockFont);
|
||||
mClockFontStyle.setSummary(mClockFontStyle.getEntries()[index]);
|
||||
return true;
|
||||
} else if (preference == mClockDateDisplay) {
|
||||
int clockDateDisplay = Integer.valueOf((String) newValue);
|
||||
int index = mClockDateDisplay.findIndexOfValue((String) newValue);
|
||||
|
||||
Reference in New Issue
Block a user