Fixed another startup bug, updated layouts, improved quiet hours handling.

pull/14/head
Tim Su 16 years ago
parent 06a49752fb
commit e5ee881b21

@ -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="26"
android:versionName="1.9.1">
android:versionCode="27"
android:versionName="1.9.2">
<uses-permission android:name="android.permission.VIBRATE"/>

@ -19,19 +19,18 @@
android:layout_height="wrap_content">
<Button android:id="@+id/date"
android:layout_weight="0.45"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/time"
android:layout_weight="0.45"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton android:id="@+id/button1"
style="?android:attr/buttonStyleInset"
android:src="@android:drawable/ic_delete"
android:layout_weight="0.1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginTop="2dip"

@ -133,20 +133,23 @@
<LinearLayout
android:orientation="horizontal"
android:paddingRight="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:id="@+id/definiteDueDate_notnull"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/definiteDueDate_date"
android:layout_weight="1"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/definiteDueDate_time"
android:layout_weight="1"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
@ -160,20 +163,23 @@
<LinearLayout
android:orientation="horizontal"
android:paddingRight="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:id="@+id/preferredDueDate_notnull"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/preferredDueDate_date"
android:layout_weight="1"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/preferredDueDate_time"
android:layout_weight="1"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
@ -187,21 +193,23 @@
<LinearLayout
android:orientation="horizontal"
android:paddingRight="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:id="@+id/hiddenUntil_notnull"
android:layout_weight="0.1"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/hiddenUntil_date"
android:layout_weight="0.45"
android:layout_weight="0.7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:id="@+id/hiddenUntil_time"
android:layout_weight="0.45"
android:layout_weight="1"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

@ -381,6 +381,7 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
DateControlSet dcs = new DateControlSet(this,
(Button)alertItem.findViewById(R.id.date),
(Button)alertItem.findViewById(R.id.time));
dcs.setDate(alert);
alertItem.setTag(dcs);
ImageButton reminderRemoveButton;

@ -78,6 +78,13 @@ public class TaskModelForList extends AbstractTaskModel {
private int getWeight() {
int weight = 0;
// bubble completed tasks to the bottom
if(isTaskCompleted()) {
weight += Math.max(5e6 - (System.currentTimeMillis() -
getCompletionDate().getTime()) / 1000, 5000);
return weight;
}
// importance
weight += getImportance().ordinal() * 60;
@ -102,10 +109,6 @@ public class TaskModelForList extends AbstractTaskModel {
weight += (hoursLeft - 5*24)/2;
}
// bubble completed tasks to the bottom
if(isTaskCompleted())
weight += 1000;
return weight;
}

@ -41,6 +41,7 @@ public class Notifications extends BroadcastReceiver {
public static final int FLAG_DEFINITE_DEADLINE = 1;
public static final int FLAG_PREFERRED_DEADLINE = 2;
public static final int FLAG_OVERDUE = 4;
public static final int FLAG_FIXED = 8;
private static Random random = new Random();
@ -95,10 +96,11 @@ public class Notifications extends BroadcastReceiver {
taskController.open();
AlertController alertController = new AlertController(context);
alertController.open();
List<TaskModelForNotify> tasks = taskController.getTasksWithNotifications();
List<TaskModelForNotify> tasks = taskController.getTasksWithNotifications();
for(TaskModelForNotify task : tasks)
updateAlarm(context, taskController, alertController, task);
alertController.close();
taskController.close();
}
@ -122,7 +124,7 @@ public class Notifications extends BroadcastReceiver {
// get or make up a last notification time
if(task.getLastNotificationDate() == null) {
when = System.currentTimeMillis() +
(long)(interval * random.nextFloat());
(long)(interval * (0.3f + 0.7f * random.nextFloat()));
taskController.setLastNotificationTime(task.getTaskIdentifier(),
new Date(when));
} else {
@ -159,11 +161,11 @@ public class Notifications extends BroadcastReceiver {
// fixed alerts
Cursor cursor = alertController.getTaskAlertsCursor(task.getTaskIdentifier());
while(!cursor.isLast()) {
while(cursor.getCount() > 0 && !cursor.isLast()) {
cursor.moveToNext();
Date alert = new Alert(cursor).getDate();
scheduleAlarm(context, task.getTaskIdentifier().getId(),
alert.getTime(), 0);
alert.getTime(), FLAG_FIXED);
}
cursor.close();
}
@ -188,6 +190,7 @@ public class Notifications extends BroadcastReceiver {
long id, int flags) {
Intent intent = new Intent(context, Notifications.class);
intent.setType(Long.toString(id));
intent.setAction(Integer.toString(flags));
intent.putExtra(ID_KEY, id);
intent.putExtra(FLAGS_KEY, flags);
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
@ -262,12 +265,11 @@ public class Notifications extends BroadcastReceiver {
if(task.isTaskCompleted())
return false;
// it's hidden - don't sound, do don't delete
// it's hidden - don't sound, don't delete
if(task.getHiddenUntil() != null && task.getHiddenUntil().after(new Date()))
return true;
taskName = task.getName();
controller.setLastNotificationTime(task.getTaskIdentifier(), new Date());
} catch (Exception e) {
@ -315,10 +317,10 @@ public class Notifications extends BroadcastReceiver {
appName,
reminder + " " + taskName,
pendingIntent);
if(!quietHours)
notification.defaults = 0;
else
notification.defaults = Notification.DEFAULT_ALL;
if(!quietHours) {
notification.vibrate = null;
notification.sound = null;
}
Log.w("Notifications", "Logging notification: " + reminder);
nm.notify((int)id, notification);

Loading…
Cancel
Save