Toast when trying to enter on skipped days

pull/2012/head
Dharanish 1 year ago
parent 053bfe116a
commit 21d8a008f1

@ -37,6 +37,7 @@ import org.isoron.uhabits.activities.common.dialogs.NumberDialog
import org.isoron.uhabits.activities.habits.edit.HabitTypeDialog import org.isoron.uhabits.activities.habits.edit.HabitTypeDialog
import org.isoron.uhabits.activities.habits.list.views.HabitCardListAdapter import org.isoron.uhabits.activities.habits.list.views.HabitCardListAdapter
import org.isoron.uhabits.core.commands.ArchiveHabitsCommand import org.isoron.uhabits.core.commands.ArchiveHabitsCommand
import org.isoron.uhabits.core.commands.BlockSkippedDayCommand
import org.isoron.uhabits.core.commands.ChangeHabitColorCommand import org.isoron.uhabits.core.commands.ChangeHabitColorCommand
import org.isoron.uhabits.core.commands.Command import org.isoron.uhabits.core.commands.Command
import org.isoron.uhabits.core.commands.CommandRunner import org.isoron.uhabits.core.commands.CommandRunner
@ -321,6 +322,9 @@ class ListHabitsScreen
command.selected.size command.selected.size
) )
} }
is BlockSkippedDayCommand -> {
return activity.resources.getString(R.string.toast_day_auto_skip)
}
else -> return null else -> return null
} }
} }

@ -48,6 +48,7 @@
<item quantity="one">Habit unarchived</item> <item quantity="one">Habit unarchived</item>
<item quantity="other">Habits unarchived</item> <item quantity="other">Habits unarchived</item>
</plurals> </plurals>
<string name="toast_day_auto_skip">Day regularly skipped</string>
<string name="title_activity_show_habit" translatable="false"/> <string name="title_activity_show_habit" translatable="false"/>
<string name="overview">Overview</string> <string name="overview">Overview</string>
<string name="habit_strength">Habit strength</string> <string name="habit_strength">Habit strength</string>

@ -0,0 +1,5 @@
package org.isoron.uhabits.core.commands
class BlockSkippedDayCommand : Command {
override fun run() {}
}

@ -18,6 +18,7 @@
*/ */
package org.isoron.uhabits.core.ui.screens.habits.list package org.isoron.uhabits.core.ui.screens.habits.list
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
@ -54,7 +55,10 @@ open class ListHabitsBehavior @Inject constructor(
fun onEdit(habit: Habit, timestamp: Timestamp?) { fun onEdit(habit: Habit, timestamp: Timestamp?) {
val entry = habit.computedEntries.get(timestamp!!) val entry = habit.computedEntries.get(timestamp!!)
if (habit.skipDays.isDaySkipped(timestamp)) return if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
return
}
if (habit.type == HabitType.NUMERICAL) { if (habit.type == HabitType.NUMERICAL) {
val oldValue = entry.value.toDouble() / 1000 val oldValue = entry.value.toDouble() / 1000
screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String, x: Float, y: Float -> screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String, x: Float, y: Float ->

Loading…
Cancel
Save