From acd7bb77530d7267f1ff4a0ed5f2a56ca30c270b Mon Sep 17 00:00:00 2001 From: Nick0703 Date: Sat, 23 May 2020 14:40:33 +0530 Subject: [PATCH] Cherish: HeadsUp snooze function [2/2] 5.1 introduced a snooze feature which activates when swiping up. Default snooze time is 1 minute. Let's make it configurable! Change-Id: I1ec385bc03bde4671887ad568cbf59c0965f0a65 --- res/values-vi/cherish_strings.xml | 16 ++++++-- res/values/cherish_arrays.xml | 19 ++++++++++ res/values/cherish_strings.xml | 12 ++++++ res/xml/heads_up_settings.xml | 7 ++++ .../cherish/settings/fragments/HeadsUp.java | 38 +++++++++++++++++++ 5 files changed, 89 insertions(+), 3 deletions(-) diff --git a/res/values-vi/cherish_strings.xml b/res/values-vi/cherish_strings.xml index 52f0bdf..978e0d0 100644 --- a/res/values-vi/cherish_strings.xml +++ b/res/values-vi/cherish_strings.xml @@ -64,7 +64,7 @@ Mức độ mờ ảnh bìa Cài đặt nhanh - Cột (màn hình dọc) + Hàng (màn hình dọc) Hàng (ngang) Cột (màn hình dọc) Cột (màn hình ngang) @@ -123,8 +123,8 @@ Bình thường Nhỏ Ẩn - Hiển thị giây - Hiển thị giây trong đồng hồ trên thanh trạng thái + Hiển thị giây + Hiển thị giây trong đồng hồ trên thanh trạng thái Ngày Hiển thị ngày tùy chỉnh trước đồng hồ Ẩn @@ -444,4 +444,14 @@ 6 giây 8 giây 10 giây + + Hẹn giờ báo lại + Vuốt lên trên các thông báo nhìn nhanh sẽ báo lại từ ứng dụng đó cho 1 phút + Vuốt lên trên các thông báo nhìn nhanh sẽ báo lại từ ứng dụng đó cho %d phút + Hẹn giờ báo lại bị vô hiệu hóa + 1 phút + 5 phút + 10 phút + 15 phút + 20 phút diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml index e09ec67..93c71d1 100644 --- a/res/values/cherish_arrays.xml +++ b/res/values/cherish_arrays.xml @@ -419,4 +419,23 @@ 8000 10000 + + + + @string/disabled + @string/heads_up_snooze_1min + @string/heads_up_snooze_5min + @string/heads_up_snooze_10min + @string/heads_up_snooze_15min + @string/heads_up_snooze_20min + + + + 0 + 60000 + 300000 + 600000 + 900000 + 1200000 + diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index a6303b4..c1148f7 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -488,6 +488,7 @@ Heads Up + Headsup Pop up statusbar notifications Add app Stoplist @@ -497,5 +498,16 @@ Choose app Delete Remove selected item? + + + Snooze timer + Swiping up on peeking notifications will snooze heads up from that application for 1 minute + Swiping up on peeking notifications will snooze heads up from that application for %d minutes + Snooze timer is disabled + 1 minute + 5 minutes + 10 minutes + 15 minutes + 20 minutes diff --git a/res/xml/heads_up_settings.xml b/res/xml/heads_up_settings.xml index c0020a9..8f92741 100644 --- a/res/xml/heads_up_settings.xml +++ b/res/xml/heads_up_settings.xml @@ -23,6 +23,13 @@ android:entryValues="@array/heads_up_time_out_values" android:persistent="false" /> + + diff --git a/src/com/cherish/settings/fragments/HeadsUp.java b/src/com/cherish/settings/fragments/HeadsUp.java index bf93b2c..cba1123 100644 --- a/src/com/cherish/settings/fragments/HeadsUp.java +++ b/src/com/cherish/settings/fragments/HeadsUp.java @@ -55,6 +55,7 @@ public class HeadsUp extends SettingsPreferenceFragment private static final int DIALOG_STOPLIST_APPS = 0; private static final int DIALOG_BLACKLIST_APPS = 1; private static final String PREF_HEADS_UP_TIME_OUT = "heads_up_time_out"; + private static final String PREF_HEADS_UP_SNOOZE_TIME = "heads_up_snooze_time"; private PackageListAdapter mPackageAdapter; private PackageManager mPackageManager; @@ -63,6 +64,7 @@ public class HeadsUp extends SettingsPreferenceFragment private Preference mAddStoplistPref; private Preference mAddBlacklistPref; private ListPreference mHeadsUpTimeOut; + private ListPreference mHeadsUpSnoozeTime; private String mStoplistPackageList; private String mBlacklistPackageList; @@ -107,6 +109,24 @@ public class HeadsUp extends SettingsPreferenceFragment Settings.System.HEADS_UP_TIMEOUT, defaultTimeOut); mHeadsUpTimeOut.setValue(String.valueOf(headsUpTimeOut)); updateHeadsUpTimeOutSummary(headsUpTimeOut); + + int defaultSnooze = systemUiResources.getInteger(systemUiResources.getIdentifier( + "com.android.systemui:integer/heads_up_default_snooze_length_ms", null, null)); + mHeadsUpSnoozeTime = (ListPreference) findPreference(PREF_HEADS_UP_SNOOZE_TIME); + mHeadsUpSnoozeTime.setOnPreferenceChangeListener(this); + int headsUpSnooze = Settings.System.getInt(getContentResolver(), + Settings.System.HEADS_UP_NOTIFICATION_SNOOZE, defaultSnooze); + mHeadsUpSnoozeTime.setValue(String.valueOf(headsUpSnooze)); + updateHeadsUpSnoozeTimeSummary(headsUpSnooze); + + int defaultSnooze = systemUiResources.getInteger(systemUiResources.getIdentifier( + "com.android.systemui:integer/heads_up_default_snooze_length_ms", null, null)); + mHeadsUpSnoozeTime = (ListPreference) findPreference(PREF_HEADS_UP_SNOOZE_TIME); + mHeadsUpSnoozeTime.setOnPreferenceChangeListener(this); + int headsUpSnooze = Settings.System.getInt(getContentResolver(), + Settings.System.HEADS_UP_NOTIFICATION_SNOOZE, defaultSnooze); + mHeadsUpSnoozeTime.setValue(String.valueOf(headsUpSnooze)); + updateHeadsUpSnoozeTimeSummary(headsUpSnooze); } @Override @@ -118,6 +138,13 @@ public class HeadsUp extends SettingsPreferenceFragment headsUpTimeOut); updateHeadsUpTimeOutSummary(headsUpTimeOut); return true; + } else if (preference == mHeadsUpSnoozeTime) { + int headsUpSnooze = Integer.valueOf((String) newValue); + Settings.System.putInt(getContentResolver(), + Settings.System.HEADS_UP_NOTIFICATION_SNOOZE, + headsUpSnooze); + updateHeadsUpSnoozeTimeSummary(headsUpSnooze); + return true; } return false; } @@ -128,6 +155,17 @@ public class HeadsUp extends SettingsPreferenceFragment mHeadsUpTimeOut.setSummary(summary); } + private void updateHeadsUpSnoozeTimeSummary(int value) { + if (value == 0) { + mHeadsUpSnoozeTime.setSummary(getResources().getString(R.string.heads_up_snooze_disabled_summary)); + } else if (value == 60000) { + mHeadsUpSnoozeTime.setSummary(getResources().getString(R.string.heads_up_snooze_summary_one_minute)); + } else { + String summary = getResources().getString(R.string.heads_up_snooze_summary, value / 60 / 1000); + mHeadsUpSnoozeTime.setSummary(summary); + } + } + @Override public void onResume() { super.onResume();