Implemented cancel to reminders of habits.

pull/320/head
srikanth r 8 years ago
parent b2a8c9c45f
commit e041d9041b

@ -54,6 +54,15 @@ class PendingIntentFactory
},
FLAG_UPDATE_CURRENT)
fun cancelNotification(habit: Habit): PendingIntent =
PendingIntent.getBroadcast(
context, 3,
Intent(context, WidgetReceiver::class.java).apply {
action = WidgetReceiver.ACTION_CANCEL_REPETITION
data = Uri.parse(habit.uriString)
},
FLAG_UPDATE_CURRENT)
fun showHabit(habit: Habit): PendingIntent =
android.support.v4.app.TaskStackBuilder
.create(context)

@ -61,6 +61,12 @@ class AndroidNotificationTray
context.getString(R.string.snooze),
pendingIntents.snoozeNotification(habit))
val cancelAction = Action(
R.drawable.ic_action_cancel,
context.getString(android.R.string.no),
pendingIntents.cancelNotification(habit)
)
val wearableBg = decodeResource(context.resources, R.drawable.stripe)
// Even though the set of actions is the same on the phone and
@ -70,6 +76,7 @@ class AndroidNotificationTray
.setBackground(wearableBg)
.addAction(checkAction)
.addAction(snoozeAction)
.addAction(cancelAction)
val notification = NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notification)
@ -79,6 +86,7 @@ class AndroidNotificationTray
.setDeleteIntent(pendingIntents.dismissNotification(habit))
.addAction(checkAction)
.addAction(snoozeAction)
.addAction(cancelAction)
.setSound(ringtoneManager.getURI())
.extend(wearableExtender)
.setWhen(reminderTime)

@ -46,6 +46,9 @@ public class WidgetReceiver extends BroadcastReceiver
public static final String ACTION_REMOVE_REPETITION =
"org.isoron.uhabits.ACTION_REMOVE_REPETITION";
public static final String ACTION_CANCEL_REPETITION =
"org.isoron.uhabits.ACTION_CANCEL_REPETITION";
public static final String ACTION_TOGGLE_REPETITION =
"org.isoron.uhabits.ACTION_TOGGLE_REPETITION";
@ -88,6 +91,11 @@ public class WidgetReceiver extends BroadcastReceiver
controller.onRemoveRepetition(data.getHabit(),
data.getTimestamp());
break;
case ACTION_CANCEL_REPETITION:
controller.onCancelRepetition(data.getHabit(),
data.getTimestamp());
break;
}
}
catch (RuntimeException e)

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

@ -61,6 +61,12 @@ public class WidgetBehavior
performToggle(habit, timestamp);
}
public void onCancelRepetition(@NonNull Habit habit, Timestamp timestamp)
{
onRemoveRepetition(habit, timestamp);
notificationTray.cancel(habit);
}
public void onToggleRepetition(@NonNull Habit habit, Timestamp timestamp)
{
performToggle(habit, timestamp);

Loading…
Cancel
Save