|
|
@ -38,43 +38,38 @@ class WidgetBehavior @Inject constructor(
|
|
|
|
fun onAddRepetition(habit: Habit, timestamp: Timestamp?) {
|
|
|
|
fun onAddRepetition(habit: Habit, timestamp: Timestamp?) {
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
val entry = habit.originalEntries.get(timestamp!!)
|
|
|
|
val entry = habit.originalEntries.get(timestamp!!)
|
|
|
|
val notes = entry.notes
|
|
|
|
setValue(habit, timestamp, Entry.YES_MANUAL, entry.notes)
|
|
|
|
setValue(habit, timestamp, Entry.YES_MANUAL, notes)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun onRemoveRepetition(habit: Habit, timestamp: Timestamp?) {
|
|
|
|
fun onRemoveRepetition(habit: Habit, timestamp: Timestamp?) {
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
val entry = habit.originalEntries.get(timestamp!!)
|
|
|
|
val entry = habit.originalEntries.get(timestamp!!)
|
|
|
|
val notes = entry.notes
|
|
|
|
setValue(habit, timestamp, Entry.NO, entry.notes)
|
|
|
|
setValue(habit, timestamp, Entry.NO, notes)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun onToggleRepetition(habit: Habit, timestamp: Timestamp) {
|
|
|
|
fun onToggleRepetition(habit: Habit, timestamp: Timestamp) {
|
|
|
|
val entry = habit.originalEntries.get(timestamp)
|
|
|
|
val entry = habit.originalEntries.get(timestamp)
|
|
|
|
val currentValue = entry.value
|
|
|
|
val currentValue = entry.value
|
|
|
|
val notes = entry.notes
|
|
|
|
|
|
|
|
val newValue = nextToggleValue(
|
|
|
|
val newValue = nextToggleValue(
|
|
|
|
value = currentValue,
|
|
|
|
value = currentValue,
|
|
|
|
isSkipEnabled = preferences.isSkipEnabled,
|
|
|
|
isSkipEnabled = preferences.isSkipEnabled,
|
|
|
|
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
|
|
|
|
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
|
|
|
|
)
|
|
|
|
)
|
|
|
|
setValue(habit, timestamp, newValue, notes)
|
|
|
|
setValue(habit, timestamp, newValue, entry.notes)
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun onIncrement(habit: Habit, timestamp: Timestamp, amount: Int) {
|
|
|
|
fun onIncrement(habit: Habit, timestamp: Timestamp, amount: Int) {
|
|
|
|
val entry = habit.computedEntries.get(timestamp)
|
|
|
|
val entry = habit.computedEntries.get(timestamp)
|
|
|
|
val currentValue = entry.value
|
|
|
|
val currentValue = entry.value
|
|
|
|
val notes = entry.notes
|
|
|
|
setValue(habit, timestamp, currentValue + amount, entry.notes)
|
|
|
|
setValue(habit, timestamp, currentValue + amount, notes)
|
|
|
|
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun onDecrement(habit: Habit, timestamp: Timestamp, amount: Int) {
|
|
|
|
fun onDecrement(habit: Habit, timestamp: Timestamp, amount: Int) {
|
|
|
|
val entry = habit.computedEntries.get(timestamp)
|
|
|
|
val entry = habit.computedEntries.get(timestamp)
|
|
|
|
val currentValue = entry.value
|
|
|
|
val currentValue = entry.value
|
|
|
|
val notes = entry.notes
|
|
|
|
setValue(habit, timestamp, currentValue - amount, entry.notes)
|
|
|
|
setValue(habit, timestamp, currentValue - amount, notes)
|
|
|
|
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
notificationTray.cancel(habit)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|