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

added reminders for repeated notes #937

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions app/src/main/java/com/orgzly/android/prefs/AppPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ public static void reminderDailyTime(Context context, int value) {
getDefaultSharedPreferences(context).edit().putInt(key, value).apply();
}

public static boolean remindersForRepeatedNotesEnabled(Context context) {
return getDefaultSharedPreferences(context).getBoolean(
context.getResources().getString(R.string.pref_key_use_reminders_for_repeated_notes),
context.getResources().getBoolean(R.bool.pref_default_use_reminders_for_repeated_notes));
}

public static void remindersForRepeatedNotesEnabled(Context context, boolean value) {
String key = context.getResources().getString(R.string.pref_key_use_reminders_for_repeated_notes);
getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
}

public static boolean showSyncNotifications(Context context) {
return getDefaultSharedPreferences(context).getBoolean(
context.getResources().getString(R.string.pref_key_show_sync_notifications),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ class ReminderService : JobIntentService() {
} else {
null
}

// ########## This is where it's important
// ########## Have the time here being the time of the next occurence
val time = getFirstTime(
context,
orgDateTime,
interval,
AppPreferences.reminderDailyTime(context),
Expand Down Expand Up @@ -386,6 +388,7 @@ class ReminderService : JobIntentService() {
}

private fun getFirstTime(
context: Context,
orgDateTime: OrgDateTime,
interval: Pair<ReadableInstant, ReadableInstant?>,
defaultTimeOfDay: Int,
Expand All @@ -396,7 +399,7 @@ class ReminderService : JobIntentService() {
interval.first,
interval.second,
defaultTimeOfDay,
false, // Do not use repeater for reminders
AppPreferences.remindersForRepeatedNotesEnabled(context),
warningPeriod,
1)

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 @@ -240,6 +240,9 @@
<!-- Time in minutes after midnight. 540 minutes == 9 o'clock -->
<integer name="pref_default_daily_reminder_time" translatable="false">540</integer>

<string name="pref_key_use_reminders_for_repeated_notes" translatable="false">pref_key_use_reminders_for_repeated_notes</string>
<bool name="pref_default_use_reminders_for_repeated_notes" translatable="false">false</bool>

<!-- Auto-sync -->

<string name="pref_key_auto_sync" translatable="false">pref_key_auto_sync</string>
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 @@ -477,6 +477,9 @@

<string name="pref_title_daily_reminder_time">Daily reminder time</string>

<string name="pref_title_reminders_for_repeated_notes">Repeated notes</string>
<string name="pref_title_summary_reminders_for_repeated_notes">Display notifications for occurrences of repeated notes</string>

<string name="primary_storage">Main storage</string>

<string name="book_exported">Notebook exported to %s</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 @@ -27,6 +27,12 @@
android:key="@string/pref_key_daily_reminder_time"
android:title="@string/pref_title_daily_reminder_time" />

<SwitchPreference
android:key="@string/pref_key_use_reminders_for_repeated_notes"
android:title="@string/pref_title_reminders_for_repeated_notes"
android:summary="@string/pref_title_summary_reminders_for_repeated_notes"
android:defaultValue="@bool/pref_default_use_reminders_for_repeated_notes" />

<!-- Open system settings to configure reminders' notification channel -->
<androidx.preference.PreferenceScreen
android:key="@string/pref_key_reminders_channel_notification_settings"
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 @@ -27,6 +27,12 @@
android:key="@string/pref_key_daily_reminder_time"
android:title="@string/pref_title_daily_reminder_time" />

<SwitchPreference
android:key="@string/pref_key_use_reminders_for_repeated_notes"
android:title="@string/pref_title_reminders_for_repeated_notes"
android:summary="@string/pref_title_summary_reminders_for_repeated_notes"
android:defaultValue="@bool/pref_default_use_reminders_for_repeated_notes" />

<PreferenceCategory
android:key="@string/pref_key_reminders_notification_settings"
android:title="@string/prefs_title_notifications">
Expand Down