Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for making reminder notifications sticky #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ public static boolean remindersVibrate(Context context) {
context.getResources().getBoolean(R.bool.pref_default_reminders_vibrate));
}

public static boolean remindersSticky(Context context) {
return getDefaultSharedPreferences(context).getBoolean(
context.getResources().getString(R.string.pref_key_reminders_sticky),
context.getResources().getBoolean(R.bool.pref_default_reminders_sticky));
}

public static int remindersSnoozeTime(Context context) {
return Integer.parseInt(getDefaultSharedPreferences(context).getString(
context.getResources().getString(R.string.pref_key_snooze_time),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ object RemindersNotifications {
builder.setVibrate(VIBRATION_PATTERN)
}

// Set notification sticky
if (AppPreferences.remindersSticky(context)) {
builder.setOngoing(true)
builder.setAutoCancel(false)
}

// Set notification sound
if (AppPreferences.remindersSound(context)) {
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/prefs_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@
<string name="pref_key_reminders_vibrate" translatable="false">pref_key_reminders_vibrate</string>
<bool name="pref_default_reminders_vibrate" translatable="false">false</bool>

<string name="pref_key_reminders_sticky" translatable="false">pref_key_reminders_sticky</string>
<bool name="pref_default_reminders_sticky" translatable="false">false</bool>

<string name="pref_key_reminders_led" translatable="false">pref_key_reminders_led</string>
<bool name="pref_default_reminders_led" translatable="false">true</bool>

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@
<string name="pref_title_reminders_for_event_times">Events</string>
<string name="pref_title_summary_reminders_for_event_times">Display notification for notes with event time</string>

<string name="pref_title_reminders_remindersSticky">Sticky Reminders"</string>
<string name="pref_title_summary_remindersSticky">Reminders cannot be dismissed by swiping</string>

<string name="pref_title_reminders_sound">Sound</string>
<string name="pref_title_reminders_vibrate">Vibration</string>
<string name="pref_title_reminders_led">Light</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml-v26/prefs_screen_reminders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
android:summary="@string/pref_title_summary_reminders_for_event_times"
android:defaultValue="@bool/pref_default_use_reminders_for_event_times" />

<SwitchPreference
android:key="@string/pref_key_reminders_sticky"
android:title="@string/pref_title_reminders_remindersSticky"
android:summary="@string/pref_title_summary_remindersSticky"
android:defaultValue="@bool/pref_default_reminders_sticky" />

<com.orgzly.android.prefs.TimePreference
android:key="@string/pref_key_daily_reminder_time"
android:title="@string/pref_title_daily_reminder_time" />
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/prefs_screen_reminders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
android:summary="@string/pref_title_summary_reminders_for_event_times"
android:defaultValue="@bool/pref_default_use_reminders_for_event_times" />

<SwitchPreference
android:key="@string/pref_key_reminders_sticky"
android:title="@string/pref_title_reminders_remindersSticky"
android:summary="@string/pref_title_summary_remindersSticky"
android:defaultValue="@bool/pref_default_reminders_sticky" />

<com.orgzly.android.prefs.TimePreference
android:key="@string/pref_key_daily_reminder_time"
android:title="@string/pref_title_daily_reminder_time" />
Expand Down