From 0fd0dbe361b14e7fd3af0fe63f0fb4b4bcc306f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C6=B0ng=20Phan?= Date: Wed, 7 Sep 2022 21:57:16 +0700 Subject: [PATCH] Cherish:Cherish:[SQUASH]Add tunables for clock position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherish: Add tunables for clock position Author: Hendrik Hagendorn Date: Sun Jan 15 10:00:12 2017 +0100 Tuner: Move clock seconds option to status bar settings Change-Id: I532c179f06b934009d48433e50b69660247ee295 Author: Luca Stefani Date: Sun Jul 29 14:19:08 2018 +0200 SystemUI: Fix default clock blacklist value Change-Id: Ibdc4f6a707569ddb417854760cf579daca989ebb Author: LuK1337 Date: Wed Aug 1 18:10:39 2018 +0200 SystemUI: Initialize mClockVisibleByUser to android:visibility * Fixes ~ triple clock ~ after leaving from Google SUW. Change-Id: I3ceea4400b3057e2b6b1f221f9074b1d451133ea Author: LuK1337 Date: Thu Sep 27 12:24:19 2018 +0200 SystemUI: Fix clock icon blacklist handling * This makes sure clock isn't on blacklist before calling showClock(animate); Change-Id: I7f77a83aa6c109e1682d764fb22701375ae5ba1e Author: LuK1337 Date: Tue Apr 2 20:56:25 2019 +0200 SystemUI: Don't hide right clock when heads up is visible * https://gitlab.com/LineageOS/issues/android/issues/436 Change-Id: I85a6cd2dff79e6b97d8a7db552c22d611bf25dbd Author: LuK1337 Date: Wed Oct 30 15:48:38 2019 +0100 SystemUI: Fix up right clock handling when showing heads up * Oops, we somehow forgot to import this code from 16.0 ;-; Change-Id: Ic4195a30da2870f569f07fc323e4b939320ab6c8 Author: Michael W Date: Mon Jun 1 14:43:31 2020 +0200 SystemUI: Make clock truly invisible * When the clock is set to left and then hidden, the notification icons, which would appear on the left first transition to the right to make place for the clock then finally snap into place * The same happens when the clock was set to show right and then is hidden: The battery, wifi, etc. icons do leave space for the (not displayed) clock and then snap to the right * This patch fixes the behavior Change-Id: Ic68b1001becb91da6f1aeaca95a7312b36e1d2a1 Author: LuK1337 Date: Sat Apr 10 22:52:25 2021 +0200 SystemUI: Make center clock layout safe insets aware This effectively fixes wrongly centered clock layout on devices with side notch / hole punch. Change-Id: I7cb8cbbe628397c50d37e23ba1853368e61a1fc9 Author: LuK1337 Date: Sun Apr 11 09:47:17 2021 +0200 SystemUI: Move network traffic monitor under same layout as clock This effectively fixes wrongly network monitor layout on devices with side notch / hole punch. Change-Id: I217b886d8da75eab7636066f4822f5fd6dbc9aff Author: Volodymyr Zhdanov Date: Tue Nov 9 20:53:56 2021 +0200 SystemUI: fix clock dark/light mode switching * move ClockController init to PhoneStatusBarView * move add/remove dark receiver logic to ClockController Change-Id: I6464af6e8aa130ea54fe7bfa19858c8930a29b1e Change-Id: Icdc039d13fd2676c1eb979a81fb77f9a6ec59b4a Signed-off-by: Volodymyr Zhdanov Signed-off-by: Hưng Phan Cherish:Add tunables for clock AM/PM style Conflicts: packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java Cherish: Add support for clock auto-hiding Hide statusbar clock when launcher is visible. Useful when you already have a clock as widget. Change-Id: I03dfc81bc055f2f865ac704e3bf9d9d104fac272 Signed-off-by: Hưng Phan CherishAdd separate tunable for clock seconds Signed-off-by: Pranav Vashi Signed-off-by: Hưng Phan Co-authored-by: LuK1337 Co-authored-by: Michael Bestas Signed-off-by: Hưng Phan --- res/values/cherish_arrays.xml | 113 +++++++++ res/values/cherish_strings.xml | 54 +++++ res/xml/cherish_settings_quicksettings.xml | 15 ++ res/xml/cherish_settings_status_bar_clock.xml | 95 ++++++++ res/xml/cherish_settings_statusbar.xml | 15 ++ src/com/cherish/settings/fragments/Clock.java | 229 ++++++++++++++++++ 6 files changed, 521 insertions(+) create mode 100644 res/xml/cherish_settings_status_bar_clock.xml create mode 100644 src/com/cherish/settings/fragments/Clock.java diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml index b40dbb8..bad7ba5 100644 --- a/res/values/cherish_arrays.xml +++ b/res/values/cherish_arrays.xml @@ -249,4 +249,117 @@ 4 2 + + + + @string/status_bar_clock_position_right + @string/status_bar_clock_position_center + @string/status_bar_clock_position_left + + + + 0 + 1 + 2 + + + + @string/status_bar_clock_position_left + @string/status_bar_clock_position_center + @string/status_bar_clock_position_right + + + + 2 + 1 + 0 + + + + @string/status_bar_clock_position_right + @string/status_bar_clock_position_left + + + + 0 + 2 + + + + @string/status_bar_clock_position_left + @string/status_bar_clock_position_right + + + + 2 + 0 + + + + @string/status_bar_am_pm_hidden + @string/status_bar_am_pm_normal + @string/status_bar_am_pm_small + + + + 2 + 0 + 1 + + + + @string/clock_date_left + @string/clock_date_right + + + + 0 + 1 + + + + @string/status_bar_date_none + @string/status_bar_date_small + @string/status_bar_date_normal + + + + 0 + 1 + 2 + + + + @string/status_bar_date_style_normal + @string/status_bar_date_style_lowercase + @string/status_bar_date_style_uppercase + + + + 0 + 1 + 2 + + + + dd/MM/yy + MM/dd/yy + yyyy-MM-dd + yyyy-dd-MM + dd-MM-yyyy + MM-dd-yyyy + MMM dd + MMM dd, yyyy + MMMM dd, yyyy + EEE + EEE dd + EEE dd/MM + EEE MM/dd + EEE dd MMM + EEE MMM dd + EEE MMMM dd + EEEE dd/MM + EEEE MM/dd + @string/status_bar_date_format_custom + diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index bd6e78b..84d923c 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -75,6 +75,13 @@ Choose app Delete Remove selected item? + + + milliseconds + \u0025 + dp + seconds + x1000 ms Quick settings @@ -509,5 +516,52 @@ Sunrise Turns on from sunset till a time Turns on from a time till sunrise + + + Clock & date + Customize clock & date + Clock seconds + Display seconds next to clock in status bar + Clock style + Right + Left + Center + Hidden + Auto hide + Hide clock if launcher is visible + Hide clock at regular interval + Hide duration + Number of seconds to hide clock + Show duration + Number of seconds to wait before hiding clock + AM/PM style + 24-hour clock is enabled + Normal + Small + Hidden + Date + Hidden + Small + Normal + Date format + Date style + Normal + Lowercase + Uppercase + Custom java format + Must be in DateFormat eg. MM/dd/yy + Enter string + Date position + Right of time + Left of time + Clock font size + + + Clock + Display clock in quick status bar header + + + Date + Display date in quick status bar header diff --git a/res/xml/cherish_settings_quicksettings.xml b/res/xml/cherish_settings_quicksettings.xml index e1003c4..c7fb933 100644 --- a/res/xml/cherish_settings_quicksettings.xml +++ b/res/xml/cherish_settings_quicksettings.xml @@ -43,6 +43,21 @@ android:entries="@array/quick_pulldown_entries" android:entryValues="@array/quick_pulldown_values" android:defaultValue="0" /> + + + + diff --git a/res/xml/cherish_settings_status_bar_clock.xml b/res/xml/cherish_settings_status_bar_clock.xml new file mode 100644 index 0000000..1cdcc2e --- /dev/null +++ b/res/xml/cherish_settings_status_bar_clock.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/xml/cherish_settings_statusbar.xml b/res/xml/cherish_settings_statusbar.xml index 8c48cc0..db08bb3 100644 --- a/res/xml/cherish_settings_statusbar.xml +++ b/res/xml/cherish_settings_statusbar.xml @@ -48,6 +48,21 @@ + + + + 0); + mClockDatePosition.setOnPreferenceChangeListener(this); + + mClockDateStyle = (SystemSettingListPreference) findPreference(CLOCK_DATE_STYLE); + mClockDateStyle.setEnabled(dateDisplay > 0); + mClockDateStyle.setOnPreferenceChangeListener(this); + + mClockDateFormat = (ListPreference) findPreference(CLOCK_DATE_FORMAT); + if (mClockDateFormat.getValue() == null) { + mClockDateFormat.setValue("EEE"); + } + parseClockDateFormats(); + mClockDateFormat.setEnabled(dateDisplay > 0); + mClockDateFormat.setOnPreferenceChangeListener(this); + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + AlertDialog dialog; + ContentResolver resolver = getActivity().getContentResolver(); + if (preference == mClockDateDisplay) { + int val = Integer.parseInt((String) newValue); + if (val == 0) { + mClockDatePosition.setEnabled(false); + mClockDateStyle.setEnabled(false); + mClockDateFormat.setEnabled(false); + } else { + mClockDatePosition.setEnabled(true); + mClockDateStyle.setEnabled(true); + mClockDateFormat.setEnabled(true); + } + return true; + } else if (preference == mClockDatePosition) { + parseClockDateFormats(); + return true; + } else if (preference == mClockDateStyle) { + parseClockDateFormats(); + return true; + } else if (preference == mClockDateFormat) { + int index = mClockDateFormat.findIndexOfValue((String) newValue); + + if (index == CUSTOM_CLOCK_DATE_FORMAT_INDEX) { + AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); + alert.setTitle(R.string.status_bar_date_string_edittext_title); + alert.setMessage(R.string.status_bar_date_string_edittext_summary); + + final EditText input = new EditText(getActivity()); + String oldText = Settings.System.getString( + resolver, + Settings.System.STATUS_BAR_CLOCK_DATE_FORMAT); + if (oldText != null) { + input.setText(oldText); + } + alert.setView(input); + + alert.setPositiveButton(R.string.menu_save, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialogInterface, int whichButton) { + String value = input.getText().toString(); + if (value.equals("")) { + return; + } + Settings.System.putString(resolver, + Settings.System.STATUS_BAR_CLOCK_DATE_FORMAT, value); + + return; + } + }); + + alert.setNegativeButton(R.string.menu_cancel, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialogInterface, int which) { + return; + } + }); + dialog = alert.create(); + dialog.show(); + } else { + if ((String) newValue != null) { + Settings.System.putString(resolver, + Settings.System.STATUS_BAR_CLOCK_DATE_FORMAT, (String) newValue); + } + } + return true; + } + return false; + } + + private void parseClockDateFormats() { + String[] dateEntries = getResources().getStringArray( + R.array.status_bar_date_format_entries_values); + CharSequence parsedDateEntries[]; + parsedDateEntries = new String[dateEntries.length]; + Date now = new Date(); + + int lastEntry = dateEntries.length - 1; + int dateFormat = Settings.System.getIntForUser(getActivity() + .getContentResolver(), Settings.System.STATUS_BAR_CLOCK_DATE_STYLE, 0, UserHandle.USER_CURRENT); + for (int i = 0; i < dateEntries.length; i++) { + if (i == lastEntry) { + parsedDateEntries[i] = dateEntries[i]; + } else { + String newDate; + CharSequence dateString = DateFormat.format(dateEntries[i], now); + if (dateFormat == CLOCK_DATE_STYLE_LOWERCASE) { + newDate = dateString.toString().toLowerCase(); + } else if (dateFormat == CLOCK_DATE_STYLE_UPPERCASE) { + newDate = dateString.toString().toUpperCase(); + } else { + newDate = dateString.toString(); + } + + parsedDateEntries[i] = newDate; + } + } + mClockDateFormat.setEntries(parsedDateEntries); + } + + @Override + public int getMetricsCategory() { + return MetricsEvent.CHERISH_SETTINGS; + } + + /** + * For Search. + */ + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider(R.xml.cherish_settings_status_bar_clock); +} \ No newline at end of file