Compare commits

..

No commits in common. '107c898f5102226a2ff7387bded8b84a9e76c43f' and '62d9d29e91e0d40281466fcc21efdae9842b0aa4' have entirely different histories.

@ -18,6 +18,5 @@ allprojects {
maven(url = "https://plugins.gradle.org/m2/") maven(url = "https://plugins.gradle.org/m2/")
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/") maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
maven(url = "https://jitpack.io") 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,6 +54,7 @@ class ShowHabitView(context: Context) : FrameLayout(context) {
binding.barCard.setState(data.bar) binding.barCard.setState(data.bar)
if (data.isNumerical) { if (data.isNumerical) {
binding.overviewCard.visibility = GONE binding.overviewCard.visibility = GONE
binding.streakCard.visibility = GONE
} else { } else {
binding.targetCard.visibility = GONE binding.targetCard.visibility = GONE
} }

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

@ -37,25 +37,12 @@ class StreakList {
fun recompute( fun recompute(
computedEntries: EntryList, computedEntries: EntryList,
from: Timestamp, from: Timestamp,
to: Timestamp, to: Timestamp
isNumerical: Boolean,
targetValue: Double,
targetType: NumericalHabitType
) { ) {
list.clear() list.clear()
val timestamps = computedEntries val timestamps = computedEntries
.getByInterval(from, to) .getByInterval(from, to)
.filter { .filter { it.value > 0 }
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 } .map { it.timestamp }
.toTypedArray() .toTypedArray()

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

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

Loading…
Cancel
Save