From 3c6a8c871619d80e01115726e1bcce6750c55f9c Mon Sep 17 00:00:00 2001 From: Tim Su Date: Sat, 14 Mar 2009 08:13:03 +0000 Subject: [PATCH] Bug fixes: - new RTM synchronization automatically starts the sync process - nags after postpone - if tag has special characters, no '@' in shortcut - delete old tasks --- AndroidManifest.xml | 4 +- res/values/arrays.xml | 18 +++ res/values/strings.xml | 9 ++ res/xml/preferences.xml | 5 + .../astrid/activities/TagListSubActivity.java | 7 +- src/com/timsu/astrid/activities/TaskList.java | 10 +- .../activities/TaskListSubActivity.java | 147 +++++++++++++----- .../astrid/data/task/TaskController.java | 7 + src/com/timsu/astrid/sync/RTMSyncService.java | 2 + .../timsu/astrid/utilities/Preferences.java | 70 ++++++++- 10 files changed, 227 insertions(+), 52 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index bf2ce27e8..a9991b12a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="97" + android:versionName="2.5.5"> diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 24933a8d4..fd9d27ca1 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -52,6 +52,24 @@ Time to shorten your todo list! + + + Please tell me it isn\'t true that you're a procrastinator! + Doesn\'t being lazy get old sometimes? + Somewhere, someone is depending on you to finish this! + When you said postpone, you really meant \'I\'m doing this\', right? + This is the last time you postpone this, right? + Just finish this today, I won\'t tell anyone! + Why postpone when you can um... not postpone! + You\'ll finish this eventually, I presume? + I think you\'re really great! How about not putting this off? + Every time you do that, God kills a kitten, meow! + Postpone, postpone, postpone. When will you change! + I\'ve had enough with your excuses! Just do it already! + Didn\'t you make that excuse last time? + I can\'t help you organize your life if you do that... + + Pink diff --git a/res/values/strings.xml b/res/values/strings.xml index 964785a2b..a12956b4c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -131,6 +131,7 @@ Help (opens in Browser) Take Astrid\'s Survey! Quick Tips + Clean Up Old Tasks Edit Task Delete Task @@ -148,7 +149,10 @@ Sort By Due Date Sort Reverse + Times You\'ve Postponed: %d + (Turn off Astrid\'s Hints on the Preferences screen) Postpone for how long? + "Delete completed tasks older than # days:" @@ -359,6 +363,11 @@ Thanks for using Astrid!\n Font on the main listing page (i.e. 22) Other + + ppcount + nagging + Nag Messages + Astrid\'s little messages help you stay on track deadline_time Default Deadlines diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 3a928bce2..2a88cf336 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -89,6 +89,11 @@ + = '%d' AND `%s` <= '%d'", + AbstractTaskModel.PROGRESS_PERCENTAGE, AbstractTaskModel.COMPLETE_PERCENTAGE, + AbstractTaskModel.COMPLETION_DATE, olderThanDate.getTime()), null); + } + /** Create a list of tasks from the db cursor given */ public ArrayList createTaskListFromCursor(Cursor cursor) { ArrayList list = new ArrayList(); diff --git a/src/com/timsu/astrid/sync/RTMSyncService.java b/src/com/timsu/astrid/sync/RTMSyncService.java index 5904589b2..a4fa551c8 100644 --- a/src/com/timsu/astrid/sync/RTMSyncService.java +++ b/src/com/timsu/astrid/sync/RTMSyncService.java @@ -49,6 +49,7 @@ import com.mdt.rtm.data.RtmTasks; import com.mdt.rtm.data.RtmAuth.Perms; import com.mdt.rtm.data.RtmTask.Priority; import com.timsu.astrid.R; +import com.timsu.astrid.activities.TaskList; import com.timsu.astrid.data.enums.Importance; import com.timsu.astrid.data.sync.SyncMapping; import com.timsu.astrid.data.task.TaskModelForSync; @@ -145,6 +146,7 @@ public class RTMSyncService extends SynchronizationService { new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + TaskList.synchronizeNow = true; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); activity.startActivity(intent); diff --git a/src/com/timsu/astrid/utilities/Preferences.java b/src/com/timsu/astrid/utilities/Preferences.java index a99138e28..68249c08f 100644 --- a/src/com/timsu/astrid/utilities/Preferences.java +++ b/src/com/timsu/astrid/utilities/Preferences.java @@ -46,6 +46,9 @@ public class Preferences { if(!prefs.contains(r.getString(R.string.p_deadlineTime))) { editor.putString(r.getString(R.string.p_deadlineTime), "1"); } + if(!prefs.contains(r.getString(R.string.p_postponecount))) { + editor.putString(r.getString(R.string.p_postponecount), "0"); + } if(!prefs.contains(r.getString(R.string.p_notif_defaultRemind))) { editor.putString(r.getString(R.string.p_notif_defaultRemind), "0"); } @@ -93,6 +96,8 @@ public class Preferences { } } + // --- sysetm preferences + /** CurrentVersion: the currently installed version of Astrid */ public static int getCurrentVersion(Context context) { return getPrefs(context).getInt(P_CURRENT_VERSION, 0); @@ -116,6 +121,8 @@ public class Preferences { editor.commit(); } + // --- notification settings + /** returns hour at which quiet hours start, or null if not set */ public static Integer getQuietHourStart(Context context) { return getIntegerValue(context, R.string.p_notif_quietStart); @@ -154,6 +161,33 @@ public class Preferences { R.string.p_notif_annoy), DEFAULT_PERSISTENCE_MODE); } + /** Return # of days to remind by default */ + public static Integer getDefaultReminder(Context context) { + return getIntegerValue(context, R.string.p_notif_defaultRemind); + } + + // --- postpone count & settings + + /** whether nags for postponing and other things should be shown */ + public static boolean shouldShowNags(Context context) { + return getPrefs(context).getBoolean(context.getResources(). + getString(R.string.p_nagging), true); + } + + /** gets # of times user has postponed a task */ + public static Integer getPostponeCount(Context context) { + return getIntegerValue(context, R.string.p_postponecount); + } + + /** sets # of times user has postponed a task */ + public static void setPostponeCount(Context context, int value) { + Editor editor = getPrefs(context).edit(); + editor.putInt(context.getResources().getString(R.string.p_postponecount), value); + editor.commit(); + } + + // --- appearance settings + /** returns the font size user wants on the front page */ public static Integer getTaskListFontSize(Context context) { return getIntegerValue(context, R.string.p_fontSize); @@ -171,11 +205,6 @@ public class Preferences { R.string.p_colorize), DEFAULT_COLORIZE); } - /** Return # of days to remind by default */ - public static Integer getDefaultReminder(Context context) { - return getIntegerValue(context, R.string.p_notif_defaultRemind); - } - /** TaskListSort: the sorting method for the task list */ public static int getTaskListSort(Context context) { return getPrefs(context).getInt(P_TASK_LIST_SORT, 0); @@ -244,8 +273,8 @@ public class Preferences { } /** returns the font size user wants on the front page */ - public static Integer autoSyncFrequency(Context context) { - return getIntegerValue(context, R.string.p_sync_every); + public static Float autoSyncFrequency(Context context) { + return getFloatValue(context, R.string.p_sync_every); } /** Last Auto-Sync Date, or null */ @@ -270,16 +299,25 @@ public class Preferences { // --- helper methods + /** Clear the given preference */ private static void clearPref(Context context, String key) { Editor editor = getPrefs(context).edit(); editor.remove(key); editor.commit(); } + /** Get preferences object from the context */ private static SharedPreferences getPrefs(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); } + /** Gets an integer value from a string resource id. Returns null + * if the value is not set or not an integer. + * + * @param context + * @param keyResource resource from string.xml + * @return integer value, or null on error + */ private static Integer getIntegerValue(Context context, int keyResource) { Resources r = context.getResources(); String value = getPrefs(context).getString(r.getString(keyResource), ""); @@ -291,6 +329,24 @@ public class Preferences { } } + /** Gets an float value from a string resource id. Returns null + * if the value is not set or not an flat. + * + * @param context + * @param keyResource resource from string.xml + * @return + */ + private static Float getFloatValue(Context context, int keyResource) { + Resources r = context.getResources(); + String value = getPrefs(context).getString(r.getString(keyResource), ""); + + try { + return Float.parseFloat(value); + } catch (Exception e) { + return null; + } + } + public static TaskFieldsVisibility getTaskFieldsVisibility(Context context) { return TaskFieldsVisibility.getFromPreferences(context, getPrefs(context)); }