|
|
|
@ -40,6 +40,7 @@ import org.isoron.uhabits.helpers.DateHelper;
|
|
|
|
|
import org.isoron.uhabits.helpers.ReminderHelper;
|
|
|
|
|
import org.isoron.uhabits.models.Checkmark;
|
|
|
|
|
import org.isoron.uhabits.models.Habit;
|
|
|
|
|
import org.isoron.uhabits.tasks.BaseTask;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
@ -138,19 +139,29 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createNotification(Context context, Intent intent)
|
|
|
|
|
private void createNotification(final Context context, final Intent intent)
|
|
|
|
|
{
|
|
|
|
|
Uri data = intent.getData();
|
|
|
|
|
Habit habit = Habit.get(ContentUris.parseId(data));
|
|
|
|
|
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
|
|
|
|
Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());
|
|
|
|
|
final Uri data = intent.getData();
|
|
|
|
|
final Habit habit = Habit.get(ContentUris.parseId(data));
|
|
|
|
|
final Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
|
|
|
|
final Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());
|
|
|
|
|
|
|
|
|
|
if (habit == null) return;
|
|
|
|
|
if (habit.checkmarks.getTodayValue() != Checkmark.UNCHECKED) return;
|
|
|
|
|
|
|
|
|
|
habit.highlight = 1;
|
|
|
|
|
habit.save();
|
|
|
|
|
new BaseTask()
|
|
|
|
|
{
|
|
|
|
|
int todayValue;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInBackground()
|
|
|
|
|
{
|
|
|
|
|
todayValue = habit.checkmarks.getTodayValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Void aVoid)
|
|
|
|
|
{
|
|
|
|
|
if (todayValue != Checkmark.UNCHECKED) return;
|
|
|
|
|
if (!checkWeekday(intent, habit)) return;
|
|
|
|
|
|
|
|
|
|
// Check if reminder has been turned off after alarm was scheduled
|
|
|
|
@ -194,6 +205,10 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|
|
|
|
|
|
|
|
|
int notificationId = (int) (habit.getId() % Integer.MAX_VALUE);
|
|
|
|
|
notificationManager.notify(notificationId, notification);
|
|
|
|
|
|
|
|
|
|
super.onPostExecute(aVoid);
|
|
|
|
|
}
|
|
|
|
|
}.execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static PendingIntent buildSnoozeIntent(Context context, Habit habit)
|
|
|
|
|