Compare commits

...

6 Commits

Author SHA1 Message Date
Chris Smowton 107c898f51 Add repository now required for old kotlin-css-jvm versions
8 months ago
Abdul Majeed 4a7d7ef490 Added Streaks info for numeric habits
8 months ago
Abdul Majeed 13ecc2a386 Added Streaks info for numeric habits
8 months ago
Jakub Kalinowski 2296a49999 Corrected HabitTest
8 months ago
Jakub Kalinowski 303020a8c0 Never mark AT_MOST habits as completed for today
8 months ago
Jakub Kalinowski 37219cb13f Ignoring isCompleted for AT_MOST habits
8 months ago

@ -18,5 +18,6 @@ allprojects {
maven(url = "https://plugins.gradle.org/m2/")
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
maven(url = "https://jitpack.io")
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers/") // Repository for kotlin-css-jvm old versions, now that the Gradle Plugin Portal no longer brings these in by mirroring JCenter
}
}

@ -54,7 +54,6 @@ class ShowHabitView(context: Context) : FrameLayout(context) {
binding.barCard.setState(data.bar)
if (data.isNumerical) {
binding.overviewCard.visibility = GONE
binding.streakCard.visibility = GONE
} else {
binding.targetCard.visibility = GONE
}

@ -61,7 +61,7 @@ data class Habit(
return if (isNumerical) {
when (targetType) {
NumericalHabitType.AT_LEAST -> value / 1000.0 >= targetValue
NumericalHabitType.AT_MOST -> value != Entry.UNKNOWN && value / 1000.0 <= targetValue
NumericalHabitType.AT_MOST -> false
}
} else {
value != Entry.NO && value != Entry.UNKNOWN
@ -100,7 +100,10 @@ data class Habit(
streaks.recompute(
computedEntries,
from,
to
to,
isNumerical,
targetValue,
targetType
)
}

@ -37,12 +37,25 @@ class StreakList {
fun recompute(
computedEntries: EntryList,
from: Timestamp,
to: Timestamp
to: Timestamp,
isNumerical: Boolean,
targetValue: Double,
targetType: NumericalHabitType
) {
list.clear()
val timestamps = computedEntries
.getByInterval(from, to)
.filter { it.value > 0 }
.filter {
val value = it.value
if (isNumerical) {
when (targetType) {
NumericalHabitType.AT_LEAST -> value / 1000.0 >= targetValue
NumericalHabitType.AT_MOST -> value != Entry.UNKNOWN && value / 1000.0 <= targetValue
}
} else {
value > 0
}
}
.map { it.timestamp }
.toTypedArray()

@ -24,6 +24,7 @@ import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
import org.isoron.uhabits.core.commands.DeleteHabitsCommand
import org.isoron.uhabits.core.models.Habit
import org.isoron.uhabits.core.models.NumericalHabitType
import org.isoron.uhabits.core.models.Timestamp
import org.isoron.uhabits.core.preferences.Preferences
import org.isoron.uhabits.core.tasks.Task
@ -120,7 +121,7 @@ class NotificationTray @Inject constructor(
override fun onPostExecute() {
systemTray.log("Showing notification for habit=" + habit.id)
if (isCompleted) {
if (isCompleted && habit.targetType != NumericalHabitType.AT_MOST) {
systemTray.log(
String.format(
Locale.US,

@ -110,10 +110,10 @@ class HabitTest : BaseUnitTest() {
assertFalse(h.isCompletedToday())
h.originalEntries.add(Entry(getToday(), 100000))
h.recompute()
assertTrue(h.isCompletedToday())
assertFalse(h.isCompletedToday())
h.originalEntries.add(Entry(getToday(), 50000))
h.recompute()
assertTrue(h.isCompletedToday())
assertFalse(h.isCompletedToday())
}
@Test

Loading…
Cancel
Save