Tweaked the notifications a bit more, and fixed a date display bug with deadlines too far in the future.

pull/14/head
Tim Su 16 years ago
parent a073b5eef2
commit 080878e216

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid"
android:versionCode="21"
android:versionName="1.7.11">
android:versionCode="22"
android:versionName="1.7.12">
<uses-permission android:name="android.permission.VIBRATE"/>

@ -124,8 +124,8 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
// due date / completion date
if(task.isTaskCompleted()) {
if(task.getCompletionDate() != null) {
int secondsLeft = (int)(task.getCompletionDate().getTime() -
System.currentTimeMillis()) / 1000;
int secondsLeft = (int)((task.getCompletionDate().getTime() -
System.currentTimeMillis()) / 1000);
StringBuilder label = new StringBuilder().
append(r.getString(R.string.taskList_completedPrefix)).
append(" ").
@ -148,17 +148,17 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
dueDate = task.getPreferredDueDate();
}
if(dueDate != null) {
int secondsLeft = (int)(dueDate.getTime() -
System.currentTimeMillis()) / 1000;
long timeLeft = dueDate.getTime() - System.currentTimeMillis();
if(secondsLeft > 0)
if(timeLeft > 0)
dueString += r.getString(R.string.taskList_dueIn) + " ";
else {
dueString += r.getString(R.string.taskList_overdueBy) + " ";
dueDateView.setTextColor(r.getColor(R.color.taskList_dueDateOverdue));
}
dueString += DateUtilities.getDurationString(r, Math.abs(secondsLeft), 1);
dueString += DateUtilities.getDurationString(r,
(int)Math.abs(timeLeft/1000), 1);
dueDateView.setText(dueString);
hasProperties = true;
} else

@ -29,8 +29,8 @@ public class Notifications extends BroadcastReceiver {
// stuff for scheduling
private static final int MIN_INTERVAL_SECONDS = 300;
private static final int FUDGE_MIN_SECS = -1200;
private static final int FUDGE_MAX_SECS = 1200;
private static final float FUDGE_MIN = -0.5f;
private static final float FUDGE_MAX = 0.5f;
/** # of seconds before a deadline to notify */
private static final int DEADLINE_NOTIFY_SECS = 3600;
/** # of seconds after now, if a deadline is in the past */
@ -128,8 +128,8 @@ public class Notifications extends BroadcastReceiver {
interval = task.getNotificationIntervalSeconds();
int currentSeconds = (int)(System.currentTimeMillis() / 1000);
int untilNextInterval = interval - currentSeconds % interval;
untilNextInterval += FUDGE_MIN_SECS + (int)(random.nextFloat()
* (FUDGE_MAX_SECS - FUDGE_MIN_SECS));
untilNextInterval += interval * (FUDGE_MIN + random.nextFloat()
* (FUDGE_MAX - FUDGE_MIN));
if(untilNextInterval < MIN_INTERVAL_SECONDS)
untilNextInterval = MIN_INTERVAL_SECONDS;
when = System.currentTimeMillis() + untilNextInterval * 1000;

Loading…
Cancel
Save