mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Compare commits
6 Commits
62d9d29e91
...
107c898f51
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
107c898f51 | ||
|
|
4a7d7ef490 | ||
|
|
13ecc2a386 | ||
|
|
2296a49999 | ||
|
|
303020a8c0 | ||
|
|
37219cb13f |
@@ -18,5 +18,6 @@ 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,7 +54,6 @@ 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 -> value != Entry.UNKNOWN && value / 1000.0 <= targetValue
|
NumericalHabitType.AT_MOST -> false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value != Entry.NO && value != Entry.UNKNOWN
|
value != Entry.NO && value != Entry.UNKNOWN
|
||||||
@@ -100,7 +100,10 @@ data class Habit(
|
|||||||
streaks.recompute(
|
streaks.recompute(
|
||||||
computedEntries,
|
computedEntries,
|
||||||
from,
|
from,
|
||||||
to
|
to,
|
||||||
|
isNumerical,
|
||||||
|
targetValue,
|
||||||
|
targetType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,25 @@ 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 { 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 }
|
.map { it.timestamp }
|
||||||
.toTypedArray()
|
.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.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
|
||||||
@@ -120,7 +121,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) {
|
if (isCompleted && habit.targetType != NumericalHabitType.AT_MOST) {
|
||||||
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()
|
||||||
assertTrue(h.isCompletedToday())
|
assertFalse(h.isCompletedToday())
|
||||||
h.originalEntries.add(Entry(getToday(), 50000))
|
h.originalEntries.add(Entry(getToday(), 50000))
|
||||||
h.recompute()
|
h.recompute()
|
||||||
assertTrue(h.isCompletedToday())
|
assertFalse(h.isCompletedToday())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user