From ab7b6c9a4a875c0accab89335ad6a473c9177011 Mon Sep 17 00:00:00 2001 From: Arne Jans Date: Fri, 26 Aug 2011 23:17:27 +0200 Subject: [PATCH 1/3] Added default ringmode-setting (ring once, ring five times, ring until dismissed). --- .../com/todoroo/astrid/core/DefaultsPreferences.java | 3 +++ astrid/res/values-de/strings.xml | 5 +++++ astrid/res/values/keys.xml | 10 ++++++++++ astrid/res/values/strings-core.xml | 12 ++++++++++++ astrid/res/xml/preferences_defaults.xml | 5 +++++ .../com/todoroo/astrid/ui/ReminderControlSet.java | 7 +++++++ .../todoroo/astrid/utility/AstridPreferences.java | 3 ++- 7 files changed, 44 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/core/DefaultsPreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/DefaultsPreferences.java index 948b964a1..8eb13dae0 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/DefaultsPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/DefaultsPreferences.java @@ -46,6 +46,9 @@ public class DefaultsPreferences extends TodorooPreferenceActivity { } else if(r.getString(R.string.p_default_reminders_key).equals(preference.getKey())) { updateTaskListPreference(preference, value, r, R.array.EPr_default_reminders, R.array.EPr_default_reminders_values, R.string.EPr_default_reminders_desc); + } else if(r.getString(R.string.p_default_reminders_mode_key).equals(preference.getKey())) { + updateTaskListPreference(preference, value, r, R.array.EPr_default_reminders_mode, + R.array.EPr_default_reminders_mode_values, R.string.EPr_default_reminders_mode_desc); } else if(r.getString(R.string.p_rmd_default_random_hours).equals(preference.getKey())) { int index = AndroidUtilities.indexOf(r.getStringArray(R.array.EPr_reminder_random_hours), (String)value); if(index <= 0) diff --git a/astrid/res/values-de/strings.xml b/astrid/res/values-de/strings.xml index 6b1e8cd4c..33b7b7826 100644 --- a/astrid/res/values-de/strings.xml +++ b/astrid/res/values-de/strings.xml @@ -696,6 +696,11 @@ Momentan: %s + + Standard Klingeln/Vibrieren Typ + + Momentan: %s + Standard Kalendereintrag diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 7cf027a7f..03a134b31 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -232,6 +232,13 @@ 6 + + + 0 + 16 + 8 + + p_def_imp @@ -244,6 +251,9 @@ p_def_addtocalendar + + rmd_default_reminder_mode + diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index e7f1384e0..85886aa2c 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -396,6 +396,11 @@ Currently: %s + + Default Ring/Vibrate type + + Currently: %s + Default Add To Calendar @@ -432,6 +437,13 @@ At deadline or overdue + + + @string/TEA_reminder_mode_once + @string/TEA_reminder_mode_five + @string/TEA_reminder_mode_nonstop + + Day diff --git a/astrid/res/xml/preferences_defaults.xml b/astrid/res/xml/preferences_defaults.xml index 5cac62141..b3d4b3c21 100644 --- a/astrid/res/xml/preferences_defaults.xml +++ b/astrid/res/xml/preferences_defaults.xml @@ -27,6 +27,11 @@ android:title="@string/rmd_EPr_defaultRemind_title" android:entries="@array/EPr_reminder_random" android:entryValues="@array/EPr_reminder_random_hours" /> + 0); + int rmd_mode_default = Preferences.getIntegerFromString(R.string.p_default_reminders_mode_key, 0); + if((flags & Task.NOTIFY_MODE_NONSTOP) > 0) mode.setSelection(2); else if((flags & Task.NOTIFY_MODE_FIVE) > 0) mode.setSelection(1); + else if((rmd_mode_default & Task.NOTIFY_MODE_NONSTOP) > 0) + mode.setSelection(2); + else if((rmd_mode_default & Task.NOTIFY_MODE_FIVE) > 0) + mode.setSelection(1); else mode.setSelection(0); } diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index ce7c1a2f0..13fe56034 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -9,6 +9,7 @@ import com.timsu.astrid.R; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.api.AstridApiConstants; +import com.todoroo.astrid.data.Task; public class AstridPreferences { @@ -26,7 +27,7 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_default_urgency_key, 0); Preferences.setIfUnset(prefs, editor, r, R.string.p_default_importance_key, 2); Preferences.setIfUnset(prefs, editor, r, R.string.p_default_hideUntil_key, 0); - Preferences.setIfUnset(prefs, editor, r, R.string.p_default_reminders_key, 6); + Preferences.setIfUnset(prefs, editor, r, R.string.p_default_reminders_key, Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE); Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0); Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 20); Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false); From 1ddaca510991a426dded8d35e234cd6df2028a91 Mon Sep 17 00:00:00 2001 From: Arne Jans Date: Fri, 30 Sep 2011 09:32:07 +0200 Subject: [PATCH 2/3] Removed redundant getFlag-method from Task, as its already in AbstractModel --- api/src/com/todoroo/andlib/data/AbstractModel.java | 7 ++++--- api/src/com/todoroo/astrid/data/Task.java | 11 ----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/api/src/com/todoroo/andlib/data/AbstractModel.java b/api/src/com/todoroo/andlib/data/AbstractModel.java index 4bce165e9..3d45b96cf 100644 --- a/api/src/com/todoroo/andlib/data/AbstractModel.java +++ b/api/src/com/todoroo/andlib/data/AbstractModel.java @@ -331,9 +331,10 @@ public abstract class AbstractModel implements Parcelable, Cloneable { } /** - * Gets the state of the given flag on the given property - * @param property - * @param flag + * Returns the set state of the given flag on the given property + * @param property the property to get the set state of the flag + * @param flag the flag-descriptor (e.g. Task.FLAG_REPEAT_AFTER_COMPLETION) + * @return true if the flag is set */ public boolean getFlag(IntegerProperty property, int flag) { return (getValue(property) & flag) > 0; diff --git a/api/src/com/todoroo/astrid/data/Task.java b/api/src/com/todoroo/astrid/data/Task.java index a8df87e6a..ad747fe9e 100644 --- a/api/src/com/todoroo/astrid/data/Task.java +++ b/api/src/com/todoroo/astrid/data/Task.java @@ -304,17 +304,6 @@ public final class Task extends RemoteModel { return getValue(DUE_DATE) > 0; } - /** - * Returns the set state of the given flag on the given property - * @param property - * @param flag - * @return - */ - @Override - public boolean getFlag(IntegerProperty property, int flag) { - return (getValue(property) & flag) > 0; - } - // --- due and hide until date management /** urgency array index -> significance */ From b620c0d2603f2cc3c43265fa2f1425a463a8f31b Mon Sep 17 00:00:00 2001 From: Arne Jans Date: Fri, 30 Sep 2011 10:05:43 +0200 Subject: [PATCH 3/3] Fixed the flag-setting location for default reminder-mode, moved it to TaskDao. Also fixed a minor de-localization error for reminder-modes. --- astrid/res/values-de/strings.xml | 4 ++-- astrid/src/com/todoroo/astrid/dao/TaskDao.java | 7 ++++--- astrid/src/com/todoroo/astrid/ui/ReminderControlSet.java | 7 ------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/astrid/res/values-de/strings.xml b/astrid/res/values-de/strings.xml index 33b7b7826..182ca8571 100644 --- a/astrid/res/values-de/strings.xml +++ b/astrid/res/values-de/strings.xml @@ -1455,10 +1455,10 @@ Achtung: diese Aufgaben sind unwiederbringlich verloren, wenn Sie kein Backup ge Einmal klingeln - Ring Five Times + Fünfmal klingeln - Klingeln, bis ich den Arlarm abschalte + Klingeln, bis ich den Alarm abschalte diff --git a/astrid/src/com/todoroo/astrid/dao/TaskDao.java b/astrid/src/com/todoroo/astrid/dao/TaskDao.java index fb07fbfc1..b8e1f0942 100644 --- a/astrid/src/com/todoroo/astrid/dao/TaskDao.java +++ b/astrid/src/com/todoroo/astrid/dao/TaskDao.java @@ -224,9 +224,10 @@ public class TaskDao extends DatabaseDao { 0)); } if(!item.containsValue(Task.REMINDER_FLAGS)) { - item.setValue(Task.REMINDER_FLAGS, - Preferences.getIntegerFromString(R.string.p_default_reminders_key, - Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE)); + int reminder_flags = Preferences.getIntegerFromString(R.string.p_default_reminders_key, + Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE) | + Preferences.getIntegerFromString(R.string.p_default_reminders_mode_key, 0); + item.setValue(Task.REMINDER_FLAGS, reminder_flags); } } diff --git a/astrid/src/com/todoroo/astrid/ui/ReminderControlSet.java b/astrid/src/com/todoroo/astrid/ui/ReminderControlSet.java index 466624c8f..cc57ba052 100644 --- a/astrid/src/com/todoroo/astrid/ui/ReminderControlSet.java +++ b/astrid/src/com/todoroo/astrid/ui/ReminderControlSet.java @@ -6,7 +6,6 @@ import android.widget.CheckBox; import android.widget.Spinner; import com.timsu.astrid.R; -import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.activity.TaskEditActivity.TaskEditControlSet; import com.todoroo.astrid.data.Task; @@ -46,16 +45,10 @@ public class ReminderControlSet implements TaskEditControlSet { after.setChecked((flags & Task.NOTIFY_AFTER_DEADLINE) > 0); - int rmd_mode_default = Preferences.getIntegerFromString(R.string.p_default_reminders_mode_key, 0); - if((flags & Task.NOTIFY_MODE_NONSTOP) > 0) mode.setSelection(2); else if((flags & Task.NOTIFY_MODE_FIVE) > 0) mode.setSelection(1); - else if((rmd_mode_default & Task.NOTIFY_MODE_NONSTOP) > 0) - mode.setSelection(2); - else if((rmd_mode_default & Task.NOTIFY_MODE_FIVE) > 0) - mode.setSelection(1); else mode.setSelection(0); }