mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Update checkmark widget for numerical support
Co-authored-by: Alinson S. Xavier <git@axavier.org>
This commit is contained in:
@@ -327,9 +327,9 @@ public class Habit
|
||||
if (isNumerical())
|
||||
{
|
||||
if(getTargetType() == AT_LEAST)
|
||||
return todayCheckmark >= data.targetValue;
|
||||
return todayCheckmark / 1000.0 >= data.targetValue;
|
||||
else
|
||||
return todayCheckmark <= data.targetValue;
|
||||
return todayCheckmark / 1000.0 <= data.targetValue;
|
||||
}
|
||||
else return (todayCheckmark != UNCHECKED);
|
||||
}
|
||||
|
||||
@@ -177,6 +177,8 @@ public class ListHabitsBehavior
|
||||
public interface NumberPickerCallback
|
||||
{
|
||||
void onNumberPicked(double newValue);
|
||||
|
||||
default void onNumberPickerDismissed() {}
|
||||
}
|
||||
|
||||
public interface Screen
|
||||
|
||||
@@ -73,4 +73,11 @@ public class WidgetBehavior
|
||||
new ToggleRepetitionCommand(habitList, habit, timestamp),
|
||||
habit.getId());
|
||||
}
|
||||
|
||||
public void setNumericValue(@NonNull Habit habit, Timestamp timestamp, int newValue) {
|
||||
commandRunner.execute(
|
||||
new CreateRepetitionCommand(habit, timestamp, newValue),
|
||||
habit.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,19 +102,19 @@ public class HabitTest extends BaseUnitTest
|
||||
h.setTargetValue(100.0);
|
||||
assertFalse(h.isCompletedToday());
|
||||
|
||||
h.getRepetitions().toggle(getToday(), 200);
|
||||
h.getRepetitions().toggle(getToday(), 200_000);
|
||||
assertTrue(h.isCompletedToday());
|
||||
h.getRepetitions().toggle(getToday(), 100);
|
||||
h.getRepetitions().toggle(getToday(), 100_000);
|
||||
assertTrue(h.isCompletedToday());
|
||||
h.getRepetitions().toggle(getToday(), 50);
|
||||
h.getRepetitions().toggle(getToday(), 50_000);
|
||||
assertFalse(h.isCompletedToday());
|
||||
|
||||
h.setTargetType(Habit.AT_MOST);
|
||||
h.getRepetitions().toggle(getToday(), 200);
|
||||
h.getRepetitions().toggle(getToday(), 200_000);
|
||||
assertFalse(h.isCompletedToday());
|
||||
h.getRepetitions().toggle(getToday(), 100);
|
||||
h.getRepetitions().toggle(getToday(), 100_000);
|
||||
assertTrue(h.isCompletedToday());
|
||||
h.getRepetitions().toggle(getToday(), 50);
|
||||
h.getRepetitions().toggle(getToday(), 50_000);
|
||||
assertTrue(h.isCompletedToday());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user