Update alarms on postpone.

pull/14/head
Tim Su 15 years ago
parent 90e57d3391
commit d2e8db4f10

@ -977,6 +977,7 @@ public class TaskListSubActivity extends SubActivity {
task.getHiddenUntil(), postponeMillis, false));
getTaskController().saveTask(task);
getTaskController().updateAlarmForTask(task.getTaskIdentifier());
context.listAdapter.refreshItem(listView, context.taskArray.indexOf(task));
}
});

@ -37,6 +37,7 @@ import android.util.Log;
import com.timsu.astrid.activities.TaskEdit;
import com.timsu.astrid.data.AbstractController;
import com.timsu.astrid.data.alerts.AlertController;
import com.timsu.astrid.data.sync.SyncDataController;
import com.timsu.astrid.data.task.AbstractTaskModel.RepeatInfo;
import com.timsu.astrid.data.task.AbstractTaskModel.TaskModelDatabaseHelper;
@ -249,6 +250,7 @@ public class TaskController extends AbstractController {
* @param values
*/
private void onTaskSave(AbstractTaskModel task, ContentValues values) {
// task was completed
if(values.containsKey(AbstractTaskModel.PROGRESS_PERCENTAGE) &&
values.getAsInteger(AbstractTaskModel.PROGRESS_PERCENTAGE)
@ -441,6 +443,15 @@ public class TaskController extends AbstractController {
return model;
}
/** Updates the alarm for the task identified by the given id */
public void updateAlarmForTask(TaskIdentifier taskId) throws SQLException {
TaskModelForNotify task = fetchTaskForNotify(taskId);
AlertController alertController = new AlertController(context);
alertController.open();
Notifications.updateAlarm(context, this, alertController, task);
alertController.close();
}
/** Returns null if unsuccessful, otherwise moves cursor to the task.
* Don't forget to close the cursor when you're done. */
private Cursor fetchTaskCursor(TaskIdentifier taskId, String[] fieldList) {

@ -13,7 +13,7 @@ public class Constants {
/** URL of Astrid Feature Survey */
public static final String SURVEY_URL = "http://www.haveasec.com/survey/m/detail/welcome/bf25e0/";
public static final boolean DEBUG = false;
public static final boolean DEBUG = true;
// result codes

@ -403,7 +403,7 @@ public class Notifications extends BroadcastReceiver {
PendingIntent pendingIntent = PendingIntent.getActivity(context,
(int)id, notifyIntent, PendingIntent.FLAG_ONE_SHOT);
// create notification object
// set up properties (name and icon) for the notification
String appName = r.getString(R.string.app_name);
int icon;
switch(Preferences.getNotificationIconTheme(context)) {
@ -417,6 +417,7 @@ public class Notifications extends BroadcastReceiver {
icon = R.drawable.notif_astrid;
}
// create notification object
Notification notification = new Notification(
icon, reminder, System.currentTimeMillis());
notification.setLatestEventInfo(context,
@ -434,10 +435,12 @@ public class Notifications extends BroadcastReceiver {
else
notification.defaults = Notification.DEFAULT_LIGHTS;
// if nonstop mode is activated, set up the flags for insistent
// notification, and increase the volume to full volume, so the user
// will actually pay attention to the alarm
if(nonstopMode && (flags & FLAG_PERIODIC) == 0) {
notification.flags |= Notification.FLAG_INSISTENT;
// if you're gonna do this... might as well crank up the volume!
AudioManager audioManager = (AudioManager)context.getSystemService(
Context.AUDIO_SERVICE);
notification.audioStreamType = AudioManager.STREAM_ALARM;

Loading…
Cancel
Save