Add getters for notification flags

pull/189/head
Alex Baker 10 years ago
parent 1ee9c4a542
commit a2cedf52d5

@ -368,17 +368,6 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
}
}
/**
* Returns the set state of the given flag on the given property
* @param property the property to get the set state of the flag
* @param flag the flag-descriptor (e.g. <code>Task.FLAG_REPEAT_AFTER_COMPLETION</code>)
* @return true if the flag is set
*/
public boolean getFlag(IntegerProperty property, int flag) {
return (getValue(property) & flag) > 0;
}
// --- setting and retrieving flags
public synchronized void putTransitory(String key, Object value) {

@ -677,4 +677,24 @@ public class Task extends RemoteModel {
public void setID(Long id) {
setValue(ID, id);
}
public boolean isNotifyModeNonstop() {
return isReminderFlagSet(Task.NOTIFY_MODE_NONSTOP);
}
public boolean isNotifyModeFive() {
return isReminderFlagSet(Task.NOTIFY_MODE_FIVE);
}
public boolean isNotifyAfterDeadline() {
return isReminderFlagSet(Task.NOTIFY_AFTER_DEADLINE);
}
public boolean isNotifyAtDeadline() {
return isReminderFlagSet(Task.NOTIFY_AT_DEADLINE);
}
private boolean isReminderFlagSet(int flag) {
return (getReminderFlags() & flag) > 0;
}
}

@ -144,8 +144,8 @@ public class Notifications extends InjectingBroadcastReceiver {
// read properties
String taskTitle = task.getTitle();
boolean nonstopMode = task.getFlag(Task.REMINDER_FLAGS, Task.NOTIFY_MODE_NONSTOP);
boolean ringFiveMode = task.getFlag(Task.REMINDER_FLAGS, Task.NOTIFY_MODE_FIVE);
boolean nonstopMode = task.isNotifyModeNonstop();
boolean ringFiveMode = task.isNotifyModeFive();
int ringTimes = nonstopMode ? -1 : (ringFiveMode ? 5 : 1);
// update last reminder time

@ -249,7 +249,7 @@ public final class ReminderService {
*/
private long calculateNextOverdueReminder(Task task) {
// Uses getNowValue() instead of DateUtilities.now()
if(task.hasDueDate() && task.getFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE)) {
if(task.hasDueDate() && task.isNotifyAfterDeadline()) {
Date due = newDate(task.getDueDate());
if (!task.hasDueTime()) {
due.setHours(23);
@ -290,7 +290,7 @@ public final class ReminderService {
*/
long calculateNextDueDateReminder(Task task) {
// Uses getNowValue() instead of DateUtilities.now()
if(task.hasDueDate() && task.getFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AT_DEADLINE)) {
if(task.hasDueDate() && task.isNotifyAtDeadline()) {
long dueDate = task.getDueDate();
long lastReminder = task.getReminderLast();

Loading…
Cancel
Save