Numerical habits: allow Tasker to increment/decrement value

This commit is contained in:
2020-09-12 15:10:04 -05:00
parent 07f8583c3d
commit 61f32449dd
8 changed files with 145 additions and 67 deletions

View File

@@ -24,6 +24,7 @@ import androidx.annotation.*;
import org.isoron.uhabits.core.commands.*;
import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.ui.*;
import org.jetbrains.annotations.*;
import javax.inject.*;
@@ -82,4 +83,13 @@ public class WidgetBehavior
habit.getId());
}
public void onIncrement(@NotNull Habit habit, @NotNull Timestamp timestamp, int amount) {
int currentValue = habit.getCheckmarks().getValues(timestamp, timestamp)[0];
setNumericValue(habit, timestamp, currentValue + amount);
}
public void onDecrement(@NotNull Habit habit, @NotNull Timestamp timestamp, int amount) {
int currentValue = habit.getCheckmarks().getValues(timestamp, timestamp)[0];
setNumericValue(habit, timestamp, currentValue - amount);
}
}