Fixin' the bugs with postpone pref.

pull/14/head
Tim Su 17 years ago
parent 3c6a8c8716
commit 3d5b8d45b3

@ -150,7 +150,7 @@
<string name="taskList_sort_reverse">Sort Reverse</string> <string name="taskList_sort_reverse">Sort Reverse</string>
<string name="taskList_postpone_count">Times You\'ve Postponed: %d</string> <string name="taskList_postpone_count">Times You\'ve Postponed: %d</string>
<string name="taskList_postpone_firsttime">(Turn off Astrid\'s Hints on the Preferences screen)</string> <string name="taskList_postpone_firsttime">(You can turn off Astrid\'s Hints on the Settings screen)</string>
<string name="taskList_postpone_dialog">Postpone for how long?</string> <string name="taskList_postpone_dialog">Postpone for how long?</string>
<string name="taskList_cleanup_dialog">"Delete completed tasks older than # days:"</string> <string name="taskList_cleanup_dialog">"Delete completed tasks older than # days:"</string>

@ -119,7 +119,7 @@ public class TaskListSubActivity extends SubActivity {
private static final int SORTFLAG_FILTERHIDDEN = (1 << 6); private static final int SORTFLAG_FILTERHIDDEN = (1 << 6);
private static final int HIDE_ADD_BTN_PORTRAIT = 4; private static final int HIDE_ADD_BTN_PORTRAIT = 4;
private static final int HIDE_ADD_BTN_LANDSCPE = 2; private static final int HIDE_ADD_BTN_LANDSCPE = 2;
private static final float POSTPONE_STAT_PCT = 0.3f; private static final float POSTPONE_STAT_PCT = 0.2f;
// UI components // UI components
private ListView listView; private ListView listView;
@ -985,7 +985,7 @@ public class TaskListSubActivity extends SubActivity {
if(Preferences.shouldShowNags(getParent())) { if(Preferences.shouldShowNags(getParent())) {
Random random = new Random(); Random random = new Random();
final String nagText; final String nagText;
if(postponeCount == 0) if(postponeCount == 1 || postponeCount == 5)
nagText = r.getString(R.string.taskList_postpone_firsttime); nagText = r.getString(R.string.taskList_postpone_firsttime);
else if(random.nextFloat() < POSTPONE_STAT_PCT) else if(random.nextFloat() < POSTPONE_STAT_PCT)
nagText = r.getString(R.string.taskList_postpone_count, nagText = r.getString(R.string.taskList_postpone_count,

@ -47,7 +47,7 @@ public class Preferences {
editor.putString(r.getString(R.string.p_deadlineTime), "1"); editor.putString(r.getString(R.string.p_deadlineTime), "1");
} }
if(!prefs.contains(r.getString(R.string.p_postponecount))) { if(!prefs.contains(r.getString(R.string.p_postponecount))) {
editor.putString(r.getString(R.string.p_postponecount), "0"); editor.putInt(r.getString(R.string.p_postponecount), 0);
} }
if(!prefs.contains(r.getString(R.string.p_notif_defaultRemind))) { if(!prefs.contains(r.getString(R.string.p_notif_defaultRemind))) {
editor.putString(r.getString(R.string.p_notif_defaultRemind), "0"); editor.putString(r.getString(R.string.p_notif_defaultRemind), "0");
@ -175,8 +175,13 @@ public class Preferences {
} }
/** gets # of times user has postponed a task */ /** gets # of times user has postponed a task */
public static Integer getPostponeCount(Context context) { public static int getPostponeCount(Context context) {
return getIntegerValue(context, R.string.p_postponecount); try {
return getPrefs(context).getInt(context.getResources().
getString(R.string.p_postponecount), 0);
} catch (ClassCastException e) {
return 0;
}
} }
/** sets # of times user has postponed a task */ /** sets # of times user has postponed a task */

Loading…
Cancel
Save