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! Signed-off-by: Arghya Chanda <arghyac35@gmail.com> Change-Id: Ieac7f6182597c2285c1ddf40e2e75cce680682e7 Signed-off-by: SagarMakhar <sagarmakhar@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
committed by
Hưng Phan
parent
5ddc665991
commit
eae80f6e34
@@ -42,4 +42,22 @@
|
|||||||
<item>8000</item>
|
<item>8000</item>
|
||||||
<item>10000</item>
|
<item>10000</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Heads up snooze -->
|
||||||
|
<string-array name="heads_up_snooze_entries">
|
||||||
|
<item>@string/disabled</item>
|
||||||
|
<item>@string/heads_up_snooze_1min</item>
|
||||||
|
<item>@string/heads_up_snooze_5min</item>
|
||||||
|
<item>@string/heads_up_snooze_10min</item>
|
||||||
|
<item>@string/heads_up_snooze_15min</item>
|
||||||
|
<item>@string/heads_up_snooze_20min</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="heads_up_snooze_values" translatable="false">
|
||||||
|
<item>0</item>
|
||||||
|
<item>60000</item>
|
||||||
|
<item>300000</item>
|
||||||
|
<item>600000</item>
|
||||||
|
<item>900000</item>
|
||||||
|
<item>1200000</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -214,4 +214,15 @@
|
|||||||
<string name="heads_up_time_out_8sec">8 seconds</string>
|
<string name="heads_up_time_out_8sec">8 seconds</string>
|
||||||
<string name="heads_up_time_out_10sec">10 seconds</string>
|
<string name="heads_up_time_out_10sec">10 seconds</string>
|
||||||
|
|
||||||
|
<!-- Heads up snooze -->
|
||||||
|
<string name="heads_up_snooze_title">Snooze timer</string>
|
||||||
|
<string name="heads_up_snooze_summary_one_minute">Swiping up on peeking notifications will snooze heads up from that application for 1 minute</string>
|
||||||
|
<string name="heads_up_snooze_summary">Swiping up on peeking notifications will snooze heads up from that application for <xliff:g id="number">%d</xliff:g> minutes</string>
|
||||||
|
<string name="heads_up_snooze_disabled_summary">Snooze timer is disabled</string>
|
||||||
|
<string name="heads_up_snooze_1min">1 minute</string>
|
||||||
|
<string name="heads_up_snooze_5min">5 minutes</string>
|
||||||
|
<string name="heads_up_snooze_10min">10 minutes</string>
|
||||||
|
<string name="heads_up_snooze_15min">15 minutes</string>
|
||||||
|
<string name="heads_up_snooze_20min">20 minutes</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -29,6 +29,13 @@
|
|||||||
android:entryValues="@array/heads_up_time_out_values"
|
android:entryValues="@array/heads_up_time_out_values"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="heads_up_snooze_time"
|
||||||
|
android:title="@string/heads_up_snooze_title"
|
||||||
|
android:entries="@array/heads_up_snooze_entries"
|
||||||
|
android:entryValues="@array/heads_up_snooze_values"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/heads_up_stoplist_title"
|
android:title="@string/heads_up_stoplist_title"
|
||||||
android:key="stoplist_applications"
|
android:key="stoplist_applications"
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class HeadsUpSettings extends SettingsPreferenceFragment
|
|||||||
private static final int DIALOG_STOPLIST_APPS = 0;
|
private static final int DIALOG_STOPLIST_APPS = 0;
|
||||||
private static final int DIALOG_BLACKLIST_APPS = 1;
|
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_TIME_OUT = "heads_up_time_out";
|
||||||
|
private static final String PREF_HEADS_UP_SNOOZE_TIME = "heads_up_snooze_time";
|
||||||
|
|
||||||
private PackageListAdapter mPackageAdapter;
|
private PackageListAdapter mPackageAdapter;
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
@@ -63,6 +64,7 @@ public class HeadsUpSettings extends SettingsPreferenceFragment
|
|||||||
private Preference mAddStoplistPref;
|
private Preference mAddStoplistPref;
|
||||||
private Preference mAddBlacklistPref;
|
private Preference mAddBlacklistPref;
|
||||||
private ListPreference mHeadsUpTimeOut;
|
private ListPreference mHeadsUpTimeOut;
|
||||||
|
private ListPreference mHeadsUpSnoozeTime;
|
||||||
|
|
||||||
private String mStoplistPackageList;
|
private String mStoplistPackageList;
|
||||||
private String mBlacklistPackageList;
|
private String mBlacklistPackageList;
|
||||||
@@ -107,6 +109,15 @@ public class HeadsUpSettings extends SettingsPreferenceFragment
|
|||||||
Settings.System.HEADS_UP_TIMEOUT, defaultTimeOut);
|
Settings.System.HEADS_UP_TIMEOUT, defaultTimeOut);
|
||||||
mHeadsUpTimeOut.setValue(String.valueOf(headsUpTimeOut));
|
mHeadsUpTimeOut.setValue(String.valueOf(headsUpTimeOut));
|
||||||
updateHeadsUpTimeOutSummary(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -118,6 +129,13 @@ public class HeadsUpSettings extends SettingsPreferenceFragment
|
|||||||
headsUpTimeOut);
|
headsUpTimeOut);
|
||||||
updateHeadsUpTimeOutSummary(headsUpTimeOut);
|
updateHeadsUpTimeOutSummary(headsUpTimeOut);
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -128,6 +146,17 @@ public class HeadsUpSettings extends SettingsPreferenceFragment
|
|||||||
mHeadsUpTimeOut.setSummary(summary);
|
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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|||||||
Reference in New Issue
Block a user