Fix skip days for short toggle

pull/2012/head
Dharanish 1 year ago
parent 21d8a008f1
commit 73fcf2e238

@ -89,12 +89,12 @@ class CheckmarkButtonView(
} }
fun performToggle() { fun performToggle() {
value = Entry.nextToggleValue( val next_value = Entry.nextToggleValue(
value = value, value = value,
isSkipEnabled = preferences.isSkipEnabled, isSkipEnabled = preferences.isSkipEnabled,
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
) )
onToggle(value, notes) onToggle(next_value, notes)
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
invalidate() invalidate()
} }

@ -137,11 +137,15 @@ open class ListHabitsBehavior @Inject constructor(
} }
fun onToggle(habit: Habit, timestamp: Timestamp, value: Int, notes: String, x: Float, y: Float) { fun onToggle(habit: Habit, timestamp: Timestamp, value: Int, notes: String, x: Float, y: Float) {
if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
} else {
commandRunner.run( commandRunner.run(
CreateRepetitionCommand(habitList, habit, timestamp, value, notes) CreateRepetitionCommand(habitList, habit, timestamp, value, notes)
) )
if (value == YES_MANUAL) screen.showConfetti(habit.color, x, y) if (value == YES_MANUAL) screen.showConfetti(habit.color, x, y)
} }
}
enum class Message { enum class Message {
COULD_NOT_EXPORT, COULD_NOT_EXPORT,

@ -21,6 +21,7 @@ package org.isoron.uhabits.core.ui.screens.habits.show.views
import org.isoron.platform.time.DayOfWeek import org.isoron.platform.time.DayOfWeek
import org.isoron.platform.time.LocalDate import org.isoron.platform.time.LocalDate
import org.isoron.uhabits.core.commands.BlockSkippedDayCommand
import org.isoron.uhabits.core.commands.CommandRunner import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.commands.CreateRepetitionCommand import org.isoron.uhabits.core.commands.CreateRepetitionCommand
import org.isoron.uhabits.core.models.Entry import org.isoron.uhabits.core.models.Entry
@ -67,7 +68,10 @@ class HistoryCardPresenter(
override fun onDateLongPress(date: LocalDate) { override fun onDateLongPress(date: LocalDate) {
val timestamp = Timestamp.fromLocalDate(date) val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback() screen.showFeedback()
if (habit.skipDays.isDaySkipped(timestamp)) return if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
return
}
if (habit.isNumerical) { if (habit.isNumerical) {
showNumberPopup(timestamp) showNumberPopup(timestamp)
} else { } else {
@ -82,7 +86,10 @@ class HistoryCardPresenter(
override fun onDateShortPress(date: LocalDate) { override fun onDateShortPress(date: LocalDate) {
val timestamp = Timestamp.fromLocalDate(date) val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback() screen.showFeedback()
if (habit.skipDays.isDaySkipped(timestamp)) return if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
return
}
if (habit.isNumerical) { if (habit.isNumerical) {
showNumberPopup(timestamp) showNumberPopup(timestamp)
} else { } else {

Loading…
Cancel
Save