Skip to content

Commit 9f4859d

Browse files
committed
UNC: added option for ignoring quiet hours during interactive mode
Now it is possible to choose whether notifications that normally make noise during quiet hours due to their ignoring rules should be muted during quiet hours interactive mode (user currently present and interacting with the device). Defaults to standard behavior which is that notifications matching ignoring rules make noise also during interactive mode. Based on suggestion in #1842
1 parent 1c6c679 commit 9f4859d

File tree

8 files changed

+48
-2
lines changed

8 files changed

+48
-2
lines changed

res/values-cs/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,4 +2028,9 @@
20282028
<!-- BatteryBar: only while charging -->
20292029
<string name="pref_battery_bar_show_charging_title">Jen během nabíjení</string>
20302030

2031+
<!-- UNC: ignore QH durine ginteractive mode -->
2032+
<string name="pref_lc_qh_ignore_interactive_title">Pro interaktivní režim</string>
2033+
<string name="pref_lc_qh_ignore_interactive_summary">Pokud povoleno, notifikace odpovídající pravidlům ignorování tichých hodin
2034+
nebudou utlumeny během interaktivního režimu</string>
2035+
20312036
</resources>

res/values-sk/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,4 +2033,9 @@
20332033
<!-- BatteryBar: only while charging -->
20342034
<string name="pref_battery_bar_show_charging_title">Len počas nabíjania</string>
20352035

2036+
<!-- UNC: ignore QH durine ginteractive mode -->
2037+
<string name="pref_lc_qh_ignore_interactive_title">Pre interaktívny režim</string>
2038+
<string name="pref_lc_qh_ignore_interactive_summary">Ak povolené, notifikácie zodpovedajúce pravidlám ignorovania tichých hodín
2039+
nebudú utlmené počas interaktívneho režimu</string>
2040+
20362041
</resources>

res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,4 +2104,9 @@
21042104
<string name="search_keyword_short">Keyword is too short</string>
21052105
<string name="search_no_match">No preferences found</string>
21062106

2107+
<!-- UNC: ignore QH durine ginteractive mode -->
2108+
<string name="pref_lc_qh_ignore_interactive_title">For interactive mode</string>
2109+
<string name="pref_lc_qh_ignore_interactive_summary">When enabled, notifications matching ignoring rules
2110+
won\'t be muted by quiet hours interactive mode</string>
2111+
21072112
</resources>

res/xml/led_control_settings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@
207207
android:defaultValue=""
208208
android:dependency="pref_lc_qh_ignore" />
209209

210+
<CheckBoxPreference
211+
android:key="pref_lc_qh_ignore_interactive"
212+
android:title="@string/pref_lc_qh_ignore_interactive_title"
213+
android:summary="@string/pref_lc_qh_ignore_interactive_summary"
214+
android:defaultValue="true"
215+
android:persistent="false"
216+
android:dependency="pref_lc_qh_ignore" />
217+
210218
</PreferenceCategory>
211219

212220
<PreferenceCategory

src/com/ceco/oreo/gravitybox/ledcontrol/LedSettings.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public enum VisibilityLs { DEFAULT, CLEARABLE, PERSISTENT, ALL };
8080
private LedMode mLedMode;
8181
private boolean mQhIgnore;
8282
private String mQhIgnoreList;
83+
private boolean mQhIgnoreInteractive;
8384
private HeadsUpMode mHeadsUpMode;
8485
private boolean mHeadsUpDnd;
8586
private int mHeadsUpTimeout;
@@ -162,6 +163,8 @@ private static LedSettings deserialize(Context context, String packageName, Set<
162163
ls.setQhIgnore(Boolean.valueOf(data[1]));
163164
} else if (data[0].equals("qhIgnoreList")) {
164165
ls.setQhIgnoreList(data[1]);
166+
} else if (data[0].equals("qhIgnoreInteractive")) {
167+
ls.setQhIgnoreInteractive(Boolean.valueOf(data[1]));
165168
} else if (data[0].equals("headsUpMode")) {
166169
ls.setHeadsUpMode(data[1]);
167170
} else if (data[0].equals("headsUpDnd")) {
@@ -214,6 +217,7 @@ private LedSettings(Context context, String packageName) {
214217
mLedMode = LedMode.OVERRIDE;
215218
mQhIgnore = false;
216219
mQhIgnoreList = null;
220+
mQhIgnoreInteractive = true;
217221
mHeadsUpMode = HeadsUpMode.DEFAULT;
218222
mHeadsUpDnd = false;
219223
mHeadsUpTimeout = 5;
@@ -412,6 +416,10 @@ protected void setQhIgnoreList(String ignoreList) {
412416
mQhIgnoreList = ignoreList;
413417
}
414418

419+
protected void setQhIgnoreInteractive (boolean ignore) {
420+
mQhIgnoreInteractive = ignore;
421+
}
422+
415423
protected void setHeadsUpMode(HeadsUpMode mode) {
416424
mHeadsUpMode = mode;
417425
}
@@ -560,6 +568,10 @@ public String getQhIgnoreList() {
560568
return mQhIgnoreList;
561569
}
562570

571+
public boolean getQhIgnoreInteractive() {
572+
return mQhIgnoreInteractive;
573+
}
574+
563575
public HeadsUpMode getHeadsUpMode() {
564576
return mHeadsUpMode;
565577
}
@@ -626,6 +638,7 @@ private Set<String> createDataSet() {
626638
if (mQhIgnoreList != null) {
627639
dataSet.add("qhIgnoreList:" + mQhIgnoreList);
628640
}
641+
dataSet.add("qhIgnoreInteractive:" + mQhIgnoreInteractive);
629642
dataSet.add("headsUpMode:" + mHeadsUpMode.toString());
630643
dataSet.add("headsUpDnd:" + mHeadsUpDnd);
631644
dataSet.add("headsUpTimeout:" + mHeadsUpTimeout);

src/com/ceco/oreo/gravitybox/ledcontrol/LedSettingsActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ private void applyPrefsToSettings(LedSettings settings) {
140140
settings.setLedMode(mPrefsFragment.getLedMode());
141141
settings.setQhIgnore(mPrefsFragment.getQhIgnore());
142142
settings.setQhIgnoreList(mPrefsFragment.getQhIgnoreList());
143+
settings.setQhIgnoreInteractive(mPrefsFragment.getQhIgnoreInteractive());
143144
settings.setHeadsUpMode(mPrefsFragment.getHeadsUpMode());
144145
settings.setHeadsUpDnd(mPrefsFragment.getHeadsUpDnd());
145146
settings.setHeadsUpTimeout(mPrefsFragment.getHeadsUpTimeout());

src/com/ceco/oreo/gravitybox/ledcontrol/LedSettingsFragment.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class LedSettingsFragment extends PreferenceFragment implements OnPrefere
7171
private static final String PREF_CAT_KEY_QH = "pref_cat_lc_quiet_hours";
7272
private static final String PREF_KEY_QH_IGNORE = "pref_lc_qh_ignore";
7373
private static final String PREF_KEY_QH_IGNORE_LIST = "pref_lc_qh_ignore_list";
74+
private static final String PREF_KEY_QH_IGNORE_INTERACTIVE = "pref_lc_qh_ignore_interactive";
7475
private static final String PREF_CAT_KEY_HEADS_UP = "pref_cat_lc_heads_up";
7576
private static final String PREF_KEY_HEADS_UP_MODE = "pref_lc_headsup_mode";
7677
private static final String PREF_KEY_HEADS_UP_DND = "pref_lc_headsup_dnd";
@@ -108,6 +109,7 @@ public class LedSettingsFragment extends PreferenceFragment implements OnPrefere
108109
private PreferenceCategory mQhCat;
109110
private CheckBoxPreference mQhIgnorePref;
110111
private EditTextPreference mQhIgnoreListPref;
112+
private CheckBoxPreference mQhIgnoreInteractivePref;
111113
private PreferenceCategory mHeadsUpCat;
112114
private ListPreference mHeadsUpModePref;
113115
private CheckBoxPreference mHeadsUpDndPref;
@@ -153,6 +155,7 @@ public void onCreate(Bundle savedInstanceState) {
153155
mQhCat = (PreferenceCategory) findPreference(PREF_CAT_KEY_QH);
154156
mQhIgnorePref = (CheckBoxPreference) findPreference(PREF_KEY_QH_IGNORE);
155157
mQhIgnoreListPref = (EditTextPreference) findPreference(PREF_KEY_QH_IGNORE_LIST);
158+
mQhIgnoreInteractivePref = (CheckBoxPreference) findPreference(PREF_KEY_QH_IGNORE_INTERACTIVE);
156159
mHeadsUpCat = (PreferenceCategory) findPreference(PREF_CAT_KEY_HEADS_UP);
157160
mHeadsUpModePref = (ListPreference) findPreference(PREF_KEY_HEADS_UP_MODE);
158161
mHeadsUpModePref.setOnPreferenceChangeListener(this);
@@ -208,6 +211,7 @@ protected void initialize(LedSettings ledSettings) {
208211
} else {
209212
mQhIgnorePref.setChecked(ledSettings.getQhIgnore());
210213
mQhIgnoreListPref.setText(ledSettings.getQhIgnoreList());
214+
mQhIgnoreInteractivePref.setChecked(ledSettings.getQhIgnoreInteractive());
211215
}
212216
if (!LedSettings.isHeadsUpEnabled(getActivity())) {
213217
getPreferenceScreen().removePreference(mHeadsUpCat);
@@ -331,6 +335,10 @@ protected String getQhIgnoreList() {
331335
return mQhIgnoreListPref.getText();
332336
}
333337

338+
protected boolean getQhIgnoreInteractive() {
339+
return mQhIgnoreInteractivePref.isChecked();
340+
}
341+
334342
protected String getHeadsUpMode() {
335343
return mHeadsUpModePref.getValue();
336344
}

src/com/ceco/oreo/gravitybox/ledcontrol/QuietHours.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ public boolean quietHoursActive(LedSettings ls, Notification n, boolean userPres
105105
}
106106

107107
if (ls.getEnabled() && ls.getQhIgnore()) {
108+
boolean defaultIgnoreResult = (interactive && userPresent) ? !ls.getQhIgnoreInteractive() : false;
108109
if (ls.getQhIgnoreList() == null || ls.getQhIgnoreList().trim().isEmpty()) {
109110
if (ModLedControl.DEBUG) ModLedControl.log("QH ignored for all notifications");
110-
return false;
111+
return defaultIgnoreResult;
111112
} else {
112113
List<CharSequence> notifTexts = getNotificationTexts(n);
113114
String[] keywords = ls.getQhIgnoreList().trim().split(",");
@@ -121,7 +122,7 @@ public boolean quietHoursActive(LedSettings ls, Notification n, boolean userPres
121122
}
122123
}
123124
if (ModLedControl.DEBUG) ModLedControl.log("QH ignore list contains keyword?: " + ignore);
124-
return (ignore ? false : (quietHoursActive() || (interactive && userPresent)));
125+
return (ignore ? defaultIgnoreResult : (quietHoursActive() || (interactive && userPresent)));
125126
}
126127
} else {
127128
return (quietHoursActive() || (interactive && userPresent));

0 commit comments

Comments
 (0)