Merge branch 'dev' of git://github.com/rsri/uhabits into pull/cancel_notification

This commit is contained in:
2017-11-14 21:54:16 -06:00
8 changed files with 31 additions and 0 deletions

View File

@@ -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)

View File

@@ -76,6 +76,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
@@ -85,6 +91,7 @@ class AndroidNotificationTray
.setBackground(wearableBg)
.addAction(checkAction)
.addAction(snoozeAction)
.addAction(cancelAction)
val builder = NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_notification)
@@ -94,6 +101,7 @@ class AndroidNotificationTray
.setDeleteIntent(pendingIntents.dismissNotification(habit))
.addAction(checkAction)
.addAction(snoozeAction)
.addAction(cancelAction)
.setSound(ringtoneManager.getURI())
.extend(wearableExtender)
.setWhen(reminderTime)

View File

@@ -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