mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 04:58:52 -06:00
Revert "Skip days implemented. Scores not correct yet"
This reverts commit ec08b602
This commit is contained in:
@@ -51,7 +51,6 @@ import org.isoron.uhabits.core.models.HabitType
|
|||||||
import org.isoron.uhabits.core.models.NumericalHabitType
|
import org.isoron.uhabits.core.models.NumericalHabitType
|
||||||
import org.isoron.uhabits.core.models.PaletteColor
|
import org.isoron.uhabits.core.models.PaletteColor
|
||||||
import org.isoron.uhabits.core.models.Reminder
|
import org.isoron.uhabits.core.models.Reminder
|
||||||
import org.isoron.uhabits.core.models.SkipDays
|
|
||||||
import org.isoron.uhabits.core.models.WeekdayList
|
import org.isoron.uhabits.core.models.WeekdayList
|
||||||
import org.isoron.uhabits.databinding.ActivityEditHabitBinding
|
import org.isoron.uhabits.databinding.ActivityEditHabitBinding
|
||||||
import org.isoron.uhabits.utils.ColorUtils
|
import org.isoron.uhabits.utils.ColorUtils
|
||||||
@@ -82,8 +81,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
var androidColor = 0
|
var androidColor = 0
|
||||||
var freqNum = 1
|
var freqNum = 1
|
||||||
var freqDen = 1
|
var freqDen = 1
|
||||||
var isSkipDays = false
|
|
||||||
var listSkipDays: WeekdayList = WeekdayList.NO_DAY
|
|
||||||
var reminderHour = -1
|
var reminderHour = -1
|
||||||
var reminderMin = -1
|
var reminderMin = -1
|
||||||
var reminderDays: WeekdayList = WeekdayList.EVERY_DAY
|
var reminderDays: WeekdayList = WeekdayList.EVERY_DAY
|
||||||
@@ -107,8 +104,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
color = habit.color
|
color = habit.color
|
||||||
freqNum = habit.frequency.numerator
|
freqNum = habit.frequency.numerator
|
||||||
freqDen = habit.frequency.denominator
|
freqDen = habit.frequency.denominator
|
||||||
isSkipDays = habit.skipDays.isSkipDays
|
|
||||||
listSkipDays = habit.skipDays.days
|
|
||||||
targetType = habit.targetType
|
targetType = habit.targetType
|
||||||
habit.reminder?.let {
|
habit.reminder?.let {
|
||||||
reminderHour = it.hour
|
reminderHour = it.hour
|
||||||
@@ -130,8 +125,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
color = PaletteColor(state.getInt("paletteColor"))
|
color = PaletteColor(state.getInt("paletteColor"))
|
||||||
freqNum = state.getInt("freqNum")
|
freqNum = state.getInt("freqNum")
|
||||||
freqDen = state.getInt("freqDen")
|
freqDen = state.getInt("freqDen")
|
||||||
isSkipDays = state.getBoolean("isSkipDays", false)
|
|
||||||
listSkipDays = WeekdayList(state.getInt("listSkipDays", 0))
|
|
||||||
reminderHour = state.getInt("reminderHour")
|
reminderHour = state.getInt("reminderHour")
|
||||||
reminderMin = state.getInt("reminderMin")
|
reminderMin = state.getInt("reminderMin")
|
||||||
reminderDays = WeekdayList(state.getInt("reminderDays"))
|
reminderDays = WeekdayList(state.getInt("reminderDays"))
|
||||||
@@ -248,31 +241,12 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
dialog.setListener { days: WeekdayList ->
|
dialog.setListener { days: WeekdayList ->
|
||||||
reminderDays = days
|
reminderDays = days
|
||||||
if (reminderDays.isEmpty) reminderDays = WeekdayList.EVERY_DAY
|
if (reminderDays.isEmpty) reminderDays = WeekdayList.EVERY_DAY
|
||||||
if (isSkipDays) reminderDays = WeekdayList(reminderDays.toArray(), listSkipDays.toArray())
|
|
||||||
populateReminder()
|
populateReminder()
|
||||||
}
|
}
|
||||||
dialog.setSelectedDays(reminderDays)
|
dialog.setSelectedDays(reminderDays)
|
||||||
dialog.dismissCurrentAndShow(supportFragmentManager, "dayPicker")
|
dialog.dismissCurrentAndShow(supportFragmentManager, "dayPicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
populateSkipDays()
|
|
||||||
binding.skipDaysPicker.setOnClickListener {
|
|
||||||
val dialog = WeekdayPickerDialog()
|
|
||||||
|
|
||||||
dialog.setListener { days: WeekdayList ->
|
|
||||||
listSkipDays = days
|
|
||||||
if (listSkipDays.isEmpty) listSkipDays = WeekdayList.NO_DAY
|
|
||||||
isSkipDays = (listSkipDays != WeekdayList.NO_DAY)
|
|
||||||
if (reminderHour >= 0 && isSkipDays) {
|
|
||||||
reminderDays = WeekdayList(reminderDays.toArray(), listSkipDays.toArray())
|
|
||||||
populateReminder()
|
|
||||||
}
|
|
||||||
populateSkipDays()
|
|
||||||
}
|
|
||||||
dialog.setSelectedDays(listSkipDays)
|
|
||||||
dialog.dismissCurrentAndShow(supportFragmentManager, "dayPicker")
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.buttonSave.setOnClickListener {
|
binding.buttonSave.setOnClickListener {
|
||||||
if (validate()) save()
|
if (validate()) save()
|
||||||
}
|
}
|
||||||
@@ -303,7 +277,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
habit.frequency = Frequency(freqNum, freqDen)
|
habit.frequency = Frequency(freqNum, freqDen)
|
||||||
habit.skipDays = SkipDays(isSkipDays, listSkipDays)
|
|
||||||
if (habitType == HabitType.NUMERICAL) {
|
if (habitType == HabitType.NUMERICAL) {
|
||||||
habit.targetValue = binding.targetInput.text.toString().toDouble()
|
habit.targetValue = binding.targetInput.text.toString().toDouble()
|
||||||
habit.targetType = targetType
|
habit.targetType = targetType
|
||||||
@@ -357,20 +330,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun populateSkipDays() {
|
|
||||||
val preferences = (application as HabitsApplication).component.preferences
|
|
||||||
if (preferences.isSkipEnabled || isSkipDays) {
|
|
||||||
binding.skipDaysOuterBox.visibility = View.VISIBLE
|
|
||||||
} else {
|
|
||||||
binding.skipDaysOuterBox.visibility = View.GONE
|
|
||||||
}
|
|
||||||
if (isSkipDays) {
|
|
||||||
binding.skipDaysPicker.text = listSkipDays.toFormattedString(this)
|
|
||||||
} else {
|
|
||||||
binding.skipDaysPicker.text = getString(R.string.skip_days_off)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("StringFormatMatches")
|
@SuppressLint("StringFormatMatches")
|
||||||
private fun populateFrequency() {
|
private fun populateFrequency() {
|
||||||
binding.booleanFrequencyPicker.text = formatFrequency(freqNum, freqDen, resources)
|
binding.booleanFrequencyPicker.text = formatFrequency(freqNum, freqDen, resources)
|
||||||
@@ -413,8 +372,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
putInt("androidColor", androidColor)
|
putInt("androidColor", androidColor)
|
||||||
putInt("freqNum", freqNum)
|
putInt("freqNum", freqNum)
|
||||||
putInt("freqDen", freqDen)
|
putInt("freqDen", freqDen)
|
||||||
putBoolean("isSkipDays", isSkipDays)
|
|
||||||
putInt("listSkipDays", listSkipDays.toInteger())
|
|
||||||
putInt("reminderHour", reminderHour)
|
putInt("reminderHour", reminderHour)
|
||||||
putInt("reminderMin", reminderMin)
|
putInt("reminderMin", reminderMin)
|
||||||
putInt("reminderDays", reminderDays.toInteger())
|
putInt("reminderDays", reminderDays.toInteger())
|
||||||
|
|||||||
@@ -73,7 +73,6 @@
|
|||||||
android:paddingRight="4dp">
|
android:paddingRight="4dp">
|
||||||
|
|
||||||
<!-- Title and color -->
|
<!-- Title and color -->
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -250,25 +249,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Notes -->
|
<!-- Notes -->
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/skipDaysOuterBox"
|
|
||||||
style="@style/FormOuterBox"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout style="@style/FormInnerBox">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/FormLabel"
|
|
||||||
android:text="@string/skip_days" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/skipDaysPicker"
|
|
||||||
style="@style/FormDropdown"
|
|
||||||
android:text="@string/skip_days_off" />
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout style="@style/FormOuterBox">
|
<FrameLayout style="@style/FormOuterBox">
|
||||||
<LinearLayout style="@style/FormInnerBox">
|
<LinearLayout style="@style/FormInnerBox">
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -54,14 +54,12 @@
|
|||||||
<string name="history">History</string>
|
<string name="history">History</string>
|
||||||
<string name="clear">Clear</string>
|
<string name="clear">Clear</string>
|
||||||
<string name="reminder">Reminder</string>
|
<string name="reminder">Reminder</string>
|
||||||
<string name="skip_days">Skip days</string>
|
|
||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
<string name="streaks">Streaks</string>
|
<string name="streaks">Streaks</string>
|
||||||
<string name="no_habits_found">You have no active habits</string>
|
<string name="no_habits_found">You have no active habits</string>
|
||||||
<string name="no_habits_left_to_do">You\'re all done for today!</string>
|
<string name="no_habits_left_to_do">You\'re all done for today!</string>
|
||||||
<string name="long_press_to_toggle">Press-and-hold to check or uncheck</string>
|
<string name="long_press_to_toggle">Press-and-hold to check or uncheck</string>
|
||||||
<string name="reminder_off">Off</string>
|
<string name="reminder_off">Off</string>
|
||||||
<string name="skip_days_off">Off</string>
|
|
||||||
<string name="create_habit">Create habit</string>
|
<string name="create_habit">Create habit</string>
|
||||||
<string name="edit_habit">Edit habit</string>
|
<string name="edit_habit">Edit habit</string>
|
||||||
<string name="create_habit_group">Create habit group</string>
|
<string name="create_habit_group">Create habit group</string>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
create table Habits ( id integer primary key autoincrement, archived integer, color integer, description text, freq_den integer, freq_num integer highlight integer, name text, position integer, reminder_hour integer, reminder_min integer )
|
create table Habits ( id integer primary key autoincrement, archived integer, color integer, description text, freq_den integer, freq_num integer, highlight integer, name text, position integer, reminder_hour integer, reminder_min integer )
|
||||||
create table Checkmarks ( id integer primary key autoincrement, habit integer references habits(id), timestamp integer, value integer )
|
create table Checkmarks ( id integer primary key autoincrement, habit integer references habits(id), timestamp integer, value integer )
|
||||||
create table Repetitions ( id integer primary key autoincrement, habit integer references habits(id), timestamp integer )
|
create table Repetitions ( id integer primary key autoincrement, habit integer references habits(id), timestamp integer )
|
||||||
create table Streak ( id integer primary key autoincrement, end integer, habit integer references habits(id), length integer, start integer )
|
create table Streak ( id integer primary key autoincrement, end integer, habit integer references habits(id), length integer, start integer )
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ import org.isoron.platform.io.nextId
|
|||||||
class HabitRepository(var db: Database) {
|
class HabitRepository(var db: Database) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SELECT_COLUMNS = "id, name, description, freq_num, freq_den, skip_days, skip_days_list, color, archived, position, unit, target_value, type"
|
const val SELECT_COLUMNS = "id, name, description, freq_num, freq_den, color, archived, position, unit, target_value, type"
|
||||||
const val SELECT_PLACEHOLDERS = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"
|
const val SELECT_PLACEHOLDERS = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"
|
||||||
const val UPDATE_COLUMNS = "id=?, name=?, description=?, freq_num=?, freq_den=?, skip_days=?, skip_days_list=?, color=?, archived=?, position=?, unit=?, target_value=?, type=?"
|
const val UPDATE_COLUMNS = "id=?, name=?, description=?, freq_num=?, freq_den=?, color=?, archived=?, position=?, unit=?, target_value=?, type=?"
|
||||||
}
|
}
|
||||||
|
|
||||||
private val findAllStatement = db.prepareStatement("select $SELECT_COLUMNS from habits order by position")
|
private val findAllStatement = db.prepareStatement("select $SELECT_COLUMNS from habits order by position")
|
||||||
@@ -60,7 +60,7 @@ class HabitRepository(var db: Database) {
|
|||||||
|
|
||||||
fun update(habit: Habit) {
|
fun update(habit: Habit) {
|
||||||
bindHabitToStatement(habit, updateStatement)
|
bindHabitToStatement(habit, updateStatement)
|
||||||
updateStatement.bindInt(13, habit.id)
|
updateStatement.bindInt(11, habit.id)
|
||||||
updateStatement.step()
|
updateStatement.step()
|
||||||
updateStatement.reset()
|
updateStatement.reset()
|
||||||
}
|
}
|
||||||
@@ -70,14 +70,12 @@ class HabitRepository(var db: Database) {
|
|||||||
name = stmt.getText(1),
|
name = stmt.getText(1),
|
||||||
description = stmt.getText(2),
|
description = stmt.getText(2),
|
||||||
frequency = Frequency(stmt.getInt(3), stmt.getInt(4)),
|
frequency = Frequency(stmt.getInt(3), stmt.getInt(4)),
|
||||||
skipDays = (stmt.getInt(5) == 1),
|
color = PaletteColor(stmt.getInt(5)),
|
||||||
skipDaysList = WeekDayList(stmt.getInt(6)),
|
isArchived = stmt.getInt(6) != 0,
|
||||||
color = PaletteColor(stmt.getInt(7)),
|
position = stmt.getInt(7),
|
||||||
isArchived = stmt.getInt(8) != 0,
|
unit = stmt.getText(8),
|
||||||
position = stmt.getInt(9),
|
target = stmt.getReal(9),
|
||||||
unit = stmt.getText(10),
|
type = if (stmt.getInt(10) == 0) HabitType.BOOLEAN_HABIT else HabitType.NUMERICAL_HABIT)
|
||||||
target = stmt.getReal(11),
|
|
||||||
type = if (stmt.getInt(12) == 0) HabitType.BOOLEAN_HABIT else HabitType.NUMERICAL_HABIT)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindHabitToStatement(habit: Habit, statement: PreparedStatement) {
|
private fun bindHabitToStatement(habit: Habit, statement: PreparedStatement) {
|
||||||
@@ -86,14 +84,12 @@ class HabitRepository(var db: Database) {
|
|||||||
statement.bindText(2, habit.description)
|
statement.bindText(2, habit.description)
|
||||||
statement.bindInt(3, habit.frequency.numerator)
|
statement.bindInt(3, habit.frequency.numerator)
|
||||||
statement.bindInt(4, habit.frequency.denominator)
|
statement.bindInt(4, habit.frequency.denominator)
|
||||||
statement.bindInt(5, if (habit.skipDays) 1 else 0)
|
statement.bindInt(5, habit.color.index)
|
||||||
statement.bindInt(6, habit.skipDaysList.toInteger())
|
statement.bindInt(6, if (habit.isArchived) 1 else 0)
|
||||||
statement.bindInt(7, habit.color.index)
|
statement.bindInt(7, habit.position)
|
||||||
statement.bindInt(8, if (habit.isArchived) 1 else 0)
|
statement.bindText(8, habit.unit)
|
||||||
statement.bindInt(9, habit.position)
|
statement.bindReal(9, habit.target)
|
||||||
statement.bindText(10, habit.unit)
|
statement.bindInt(10, habit.type.code)
|
||||||
statement.bindReal(11, habit.target)
|
|
||||||
statement.bindInt(12, habit.type.code)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun delete(habit: Habit) {
|
fun delete(habit: Habit) {
|
||||||
|
|||||||
@@ -38,12 +38,11 @@ open class EntryList {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entry corresponding to the given timestamp. If no entry with such timestamp
|
* Returns the entry corresponding to the given timestamp. If no entry with such timestamp
|
||||||
* has been previously added, returns Entry(timestamp, UNKNOWN). or Entry(timestamp, SKIP) if
|
* has been previously added, returns Entry(timestamp, UNKNOWN).
|
||||||
* skip days are enabled and that day is to be skipped
|
|
||||||
*/
|
*/
|
||||||
@Synchronized
|
@Synchronized
|
||||||
open fun get(timestamp: Timestamp, skipDays: SkipDays = SkipDays.NONE): Entry {
|
open fun get(timestamp: Timestamp): Entry {
|
||||||
return if (skipDays.isDaySkipped(timestamp)) Entry(timestamp, SKIP) else entriesByTimestamp[timestamp] ?: Entry(timestamp, UNKNOWN)
|
return entriesByTimestamp[timestamp] ?: Entry(timestamp, UNKNOWN)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,12 +51,12 @@ open class EntryList {
|
|||||||
* included.
|
* included.
|
||||||
*/
|
*/
|
||||||
@Synchronized
|
@Synchronized
|
||||||
open fun getByInterval(from: Timestamp, to: Timestamp, skipDays: SkipDays = SkipDays.NONE): List<Entry> {
|
open fun getByInterval(from: Timestamp, to: Timestamp): List<Entry> {
|
||||||
val result = mutableListOf<Entry>()
|
val result = mutableListOf<Entry>()
|
||||||
if (from.isNewerThan(to)) return result
|
if (from.isNewerThan(to)) return result
|
||||||
var current = to
|
var current = to
|
||||||
while (current >= from) {
|
while (current >= from) {
|
||||||
result.add(get(current, skipDays))
|
result.add(get(current))
|
||||||
current = current.minus(1)
|
current = current.minus(1)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -91,18 +90,16 @@ open class EntryList {
|
|||||||
open fun recomputeFrom(
|
open fun recomputeFrom(
|
||||||
originalEntries: EntryList,
|
originalEntries: EntryList,
|
||||||
frequency: Frequency,
|
frequency: Frequency,
|
||||||
isNumerical: Boolean,
|
isNumerical: Boolean
|
||||||
skipDays: SkipDays
|
|
||||||
) {
|
) {
|
||||||
clear()
|
clear()
|
||||||
val original = originalEntries.getKnown()
|
val original = originalEntries.getKnown()
|
||||||
if (isNumerical) {
|
if (isNumerical) {
|
||||||
val computed = addEntriesWithSkipDays(original, skipDays)
|
original.forEach { add(it) }
|
||||||
computed.forEach { add(it) }
|
|
||||||
} else {
|
} else {
|
||||||
val intervals = buildIntervals(frequency, original)
|
val intervals = buildIntervals(frequency, original)
|
||||||
snapIntervalsTogether(intervals)
|
snapIntervalsTogether(intervals)
|
||||||
val computed = buildEntriesFromInterval(original, intervals, skipDays)
|
val computed = buildEntriesFromInterval(original, intervals)
|
||||||
computed.filter { it.value != UNKNOWN || it.notes.isNotEmpty() }.forEach { add(it) }
|
computed.filter { it.value != UNKNOWN || it.notes.isNotEmpty() }.forEach { add(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,10 +128,10 @@ open class EntryList {
|
|||||||
fun computeWeekdayFrequency(isNumerical: Boolean): HashMap<Timestamp, Array<Int>> {
|
fun computeWeekdayFrequency(isNumerical: Boolean): HashMap<Timestamp, Array<Int>> {
|
||||||
val entries = getKnown()
|
val entries = getKnown()
|
||||||
val map = hashMapOf<Timestamp, Array<Int>>()
|
val map = hashMapOf<Timestamp, Array<Int>>()
|
||||||
for ((computedTimestamp, value) in entries) {
|
for ((originalTimestamp, value) in entries) {
|
||||||
val weekday = computedTimestamp.weekday
|
val weekday = originalTimestamp.weekday
|
||||||
val truncatedTimestamp = Timestamp(
|
val truncatedTimestamp = Timestamp(
|
||||||
computedTimestamp.toCalendar().apply {
|
originalTimestamp.toCalendar().apply {
|
||||||
set(Calendar.DAY_OF_MONTH, 1)
|
set(Calendar.DAY_OF_MONTH, 1)
|
||||||
}.timeInMillis
|
}.timeInMillis
|
||||||
)
|
)
|
||||||
@@ -145,7 +142,7 @@ open class EntryList {
|
|||||||
map[truncatedTimestamp] = list
|
map[truncatedTimestamp] = list
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNumerical && value != SKIP) {
|
if (isNumerical) {
|
||||||
list[weekday] += value
|
list[weekday] += value
|
||||||
} else if (value == YES_MANUAL) {
|
} else if (value == YES_MANUAL) {
|
||||||
list[weekday] += 1
|
list[weekday] += 1
|
||||||
@@ -170,8 +167,7 @@ open class EntryList {
|
|||||||
*/
|
*/
|
||||||
fun buildEntriesFromInterval(
|
fun buildEntriesFromInterval(
|
||||||
original: List<Entry>,
|
original: List<Entry>,
|
||||||
intervals: List<Interval>,
|
intervals: List<Interval>
|
||||||
skipDays: SkipDays
|
|
||||||
): List<Entry> {
|
): List<Entry> {
|
||||||
val result = arrayListOf<Entry>()
|
val result = arrayListOf<Entry>()
|
||||||
if (original.isEmpty()) return result
|
if (original.isEmpty()) return result
|
||||||
@@ -200,17 +196,15 @@ open class EntryList {
|
|||||||
current = interval.end
|
current = interval.end
|
||||||
while (current >= interval.begin) {
|
while (current >= interval.begin) {
|
||||||
val offset = current.daysUntil(to)
|
val offset = current.daysUntil(to)
|
||||||
result[offset] = if (skipDays.isDaySkipped(current)) Entry(current, SKIP) else Entry(current, YES_AUTO)
|
result[offset] = Entry(current, YES_AUTO)
|
||||||
current = current.minus(1)
|
current = current.minus(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy original entries except for the skipped days
|
// Copy original entries
|
||||||
original.forEach { entry ->
|
original.forEach { entry ->
|
||||||
val offset = entry.timestamp.daysUntil(to)
|
val offset = entry.timestamp.daysUntil(to)
|
||||||
val value = if (skipDays.isDaySkipped(entry)) {
|
val value = if (
|
||||||
SKIP
|
|
||||||
} else if (
|
|
||||||
result[offset].value == UNKNOWN ||
|
result[offset].value == UNKNOWN ||
|
||||||
entry.value == SKIP ||
|
entry.value == SKIP ||
|
||||||
entry.value == YES_MANUAL
|
entry.value == YES_MANUAL
|
||||||
@@ -277,29 +271,6 @@ open class EntryList {
|
|||||||
}
|
}
|
||||||
return intervals
|
return intervals
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addEntriesWithSkipDays(original: List<Entry>, skipDays: SkipDays): List<Entry> {
|
|
||||||
if (original.isEmpty()) return original
|
|
||||||
val earliest = original.last().timestamp
|
|
||||||
val today = DateUtils.getTodayWithOffset()
|
|
||||||
val computed = mutableListOf<Entry>()
|
|
||||||
var current = today
|
|
||||||
var offset = 0
|
|
||||||
while (current >= earliest) {
|
|
||||||
if (current == original[offset].timestamp) {
|
|
||||||
if (!skipDays.isDaySkipped(current)) {
|
|
||||||
computed.add(original[offset])
|
|
||||||
} else {
|
|
||||||
computed.add(Entry(current, SKIP))
|
|
||||||
}
|
|
||||||
offset++
|
|
||||||
} else if (skipDays.isDaySkipped(current)) {
|
|
||||||
computed.add(Entry(current, SKIP))
|
|
||||||
}
|
|
||||||
current = current.minus(1)
|
|
||||||
}
|
|
||||||
return computed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,12 +323,10 @@ fun List<Entry>.groupedSum(
|
|||||||
*/
|
*/
|
||||||
fun List<Entry>.countSkippedDays(
|
fun List<Entry>.countSkippedDays(
|
||||||
truncateField: DateUtils.TruncateField,
|
truncateField: DateUtils.TruncateField,
|
||||||
firstWeekday: Int = Calendar.SATURDAY,
|
firstWeekday: Int = Calendar.SATURDAY
|
||||||
skipDays: SkipDays
|
|
||||||
): List<Entry> {
|
): List<Entry> {
|
||||||
val thisIntervalStart = DateUtils.getTodayWithOffset().truncate(truncateField, firstWeekday)
|
|
||||||
return this.map { (timestamp, value) ->
|
return this.map { (timestamp, value) ->
|
||||||
if (value == SKIP || skipDays.isDaySkipped(timestamp)) {
|
if (value == SKIP) {
|
||||||
Entry(timestamp, 1)
|
Entry(timestamp, 1)
|
||||||
} else {
|
} else {
|
||||||
Entry(timestamp, 0)
|
Entry(timestamp, 0)
|
||||||
@@ -371,5 +340,5 @@ fun List<Entry>.countSkippedDays(
|
|||||||
Entry(timestamp, entries.sumOf { it.value })
|
Entry(timestamp, entries.sumOf { it.value })
|
||||||
}.sortedBy { (timestamp, _) ->
|
}.sortedBy { (timestamp, _) ->
|
||||||
-timestamp.unixTime
|
-timestamp.unixTime
|
||||||
}.filter { it.timestamp == thisIntervalStart }
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ data class Habit(
|
|||||||
var color: PaletteColor = PaletteColor(8),
|
var color: PaletteColor = PaletteColor(8),
|
||||||
var description: String = "",
|
var description: String = "",
|
||||||
var frequency: Frequency = Frequency.DAILY,
|
var frequency: Frequency = Frequency.DAILY,
|
||||||
var skipDays: SkipDays = SkipDays.NONE,
|
|
||||||
var id: Long? = null,
|
var id: Long? = null,
|
||||||
var isArchived: Boolean = false,
|
var isArchived: Boolean = false,
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
@@ -40,15 +39,12 @@ data class Habit(
|
|||||||
val computedEntries: EntryList,
|
val computedEntries: EntryList,
|
||||||
val originalEntries: EntryList,
|
val originalEntries: EntryList,
|
||||||
val scores: ScoreList,
|
val scores: ScoreList,
|
||||||
val streaks: StreakList,
|
val streaks: StreakList
|
||||||
var parentID: Long? = null,
|
|
||||||
var parentUUID: String? = null
|
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
if (uuid == null) this.uuid = UUID.randomUUID().toString().replace("-", "")
|
if (uuid == null) this.uuid = UUID.randomUUID().toString().replace("-", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
var parent: HabitGroup? = null
|
|
||||||
var observable = ModelObservable()
|
var observable = ModelObservable()
|
||||||
|
|
||||||
val isNumerical: Boolean
|
val isNumerical: Boolean
|
||||||
@@ -82,8 +78,7 @@ data class Habit(
|
|||||||
computedEntries.recomputeFrom(
|
computedEntries.recomputeFrom(
|
||||||
originalEntries = originalEntries,
|
originalEntries = originalEntries,
|
||||||
frequency = frequency,
|
frequency = frequency,
|
||||||
isNumerical = isNumerical,
|
isNumerical = isNumerical
|
||||||
skipDays = skipDays
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val today = DateUtils.getTodayWithOffset()
|
val today = DateUtils.getTodayWithOffset()
|
||||||
@@ -95,7 +90,6 @@ data class Habit(
|
|||||||
scores.recompute(
|
scores.recompute(
|
||||||
frequency = frequency,
|
frequency = frequency,
|
||||||
isNumerical = isNumerical,
|
isNumerical = isNumerical,
|
||||||
skipDays = skipDays,
|
|
||||||
numericalHabitType = targetType,
|
numericalHabitType = targetType,
|
||||||
targetValue = targetValue,
|
targetValue = targetValue,
|
||||||
computedEntries = computedEntries,
|
computedEntries = computedEntries,
|
||||||
@@ -110,23 +104,10 @@ data class Habit(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun firstEntryDate(): Timestamp {
|
|
||||||
return computedEntries.getKnown().lastOrNull()?.timestamp ?: DateUtils.getTodayWithOffset()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hierarchyLevel(): Int {
|
|
||||||
return if (parentID == null) {
|
|
||||||
0
|
|
||||||
} else {
|
|
||||||
1 + parent!!.hierarchyLevel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun copyFrom(other: Habit) {
|
fun copyFrom(other: Habit) {
|
||||||
this.color = other.color
|
this.color = other.color
|
||||||
this.description = other.description
|
this.description = other.description
|
||||||
this.frequency = other.frequency
|
this.frequency = other.frequency
|
||||||
this.skipDays = other.skipDays
|
|
||||||
// this.id should not be copied
|
// this.id should not be copied
|
||||||
this.isArchived = other.isArchived
|
this.isArchived = other.isArchived
|
||||||
this.name = other.name
|
this.name = other.name
|
||||||
@@ -138,8 +119,6 @@ data class Habit(
|
|||||||
this.type = other.type
|
this.type = other.type
|
||||||
this.unit = other.unit
|
this.unit = other.unit
|
||||||
this.uuid = other.uuid
|
this.uuid = other.uuid
|
||||||
this.parentID = other.parentID
|
|
||||||
this.parentUUID = other.parentUUID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
@@ -149,7 +128,6 @@ data class Habit(
|
|||||||
if (color != other.color) return false
|
if (color != other.color) return false
|
||||||
if (description != other.description) return false
|
if (description != other.description) return false
|
||||||
if (frequency != other.frequency) return false
|
if (frequency != other.frequency) return false
|
||||||
if (skipDays != other.skipDays) return false
|
|
||||||
if (id != other.id) return false
|
if (id != other.id) return false
|
||||||
if (isArchived != other.isArchived) return false
|
if (isArchived != other.isArchived) return false
|
||||||
if (name != other.name) return false
|
if (name != other.name) return false
|
||||||
@@ -161,8 +139,6 @@ data class Habit(
|
|||||||
if (type != other.type) return false
|
if (type != other.type) return false
|
||||||
if (unit != other.unit) return false
|
if (unit != other.unit) return false
|
||||||
if (uuid != other.uuid) return false
|
if (uuid != other.uuid) return false
|
||||||
if (parentID != other.parentID) return false
|
|
||||||
if (parentUUID != other.parentUUID) return false
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -171,7 +147,6 @@ data class Habit(
|
|||||||
var result = color.hashCode()
|
var result = color.hashCode()
|
||||||
result = 31 * result + description.hashCode()
|
result = 31 * result + description.hashCode()
|
||||||
result = 31 * result + frequency.hashCode()
|
result = 31 * result + frequency.hashCode()
|
||||||
result = 31 * result + skipDays.hashCode()
|
|
||||||
result = 31 * result + (id?.hashCode() ?: 0)
|
result = 31 * result + (id?.hashCode() ?: 0)
|
||||||
result = 31 * result + isArchived.hashCode()
|
result = 31 * result + isArchived.hashCode()
|
||||||
result = 31 * result + name.hashCode()
|
result = 31 * result + name.hashCode()
|
||||||
@@ -183,8 +158,6 @@ data class Habit(
|
|||||||
result = 31 * result + type.value
|
result = 31 * result + type.value
|
||||||
result = 31 * result + unit.hashCode()
|
result = 31 * result + unit.hashCode()
|
||||||
result = 31 * result + (uuid?.hashCode() ?: 0)
|
result = 31 * result + (uuid?.hashCode() ?: 0)
|
||||||
result = 31 * result + (parentID?.hashCode() ?: 0)
|
|
||||||
result = 31 * result + (parentUUID?.hashCode() ?: 0)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
import org.isoron.uhabits.core.models.Score.Companion.compute
|
import org.isoron.uhabits.core.models.Score.Companion.compute
|
||||||
|
import java.util.ArrayList
|
||||||
|
import java.util.HashMap
|
||||||
import javax.annotation.concurrent.ThreadSafe
|
import javax.annotation.concurrent.ThreadSafe
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@@ -66,7 +68,6 @@ class ScoreList {
|
|||||||
fun recompute(
|
fun recompute(
|
||||||
frequency: Frequency,
|
frequency: Frequency,
|
||||||
isNumerical: Boolean,
|
isNumerical: Boolean,
|
||||||
skipDays: SkipDays,
|
|
||||||
numericalHabitType: NumericalHabitType,
|
numericalHabitType: NumericalHabitType,
|
||||||
targetValue: Double,
|
targetValue: Double,
|
||||||
computedEntries: EntryList,
|
computedEntries: EntryList,
|
||||||
@@ -78,7 +79,7 @@ class ScoreList {
|
|||||||
var numerator = frequency.numerator
|
var numerator = frequency.numerator
|
||||||
var denominator = frequency.denominator
|
var denominator = frequency.denominator
|
||||||
val freq = frequency.toDouble()
|
val freq = frequency.toDouble()
|
||||||
val values = computedEntries.getByInterval(from, to, skipDays).map { it.value }.toIntArray()
|
val values = computedEntries.getByInterval(from, to).map { it.value }.toIntArray()
|
||||||
val isAtMost = numericalHabitType == NumericalHabitType.AT_MOST
|
val isAtMost = numericalHabitType == NumericalHabitType.AT_MOST
|
||||||
|
|
||||||
// For non-daily boolean habits, we double the numerator and the denominator to smooth
|
// For non-daily boolean habits, we double the numerator and the denominator to smooth
|
||||||
@@ -137,19 +138,4 @@ class ScoreList {
|
|||||||
map[timestamp] = Score(timestamp, previousValue)
|
map[timestamp] = Score(timestamp, previousValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
fun combineFrom(
|
|
||||||
habitList: HabitList,
|
|
||||||
from: Timestamp,
|
|
||||||
to: Timestamp
|
|
||||||
) {
|
|
||||||
var current = to
|
|
||||||
while (current >= from) {
|
|
||||||
val habitScores = habitList.map { it.scores[current].value }
|
|
||||||
val averageScore = habitScores.average()
|
|
||||||
map[current] = Score(current, averageScore)
|
|
||||||
current = current.minus(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,13 +38,6 @@ class WeekdayList {
|
|||||||
this.weekdays = Arrays.copyOf(weekdays, 7)
|
this.weekdays = Arrays.copyOf(weekdays, 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(addDays: BooleanArray, removeDays: BooleanArray) {
|
|
||||||
weekdays = BooleanArray(7)
|
|
||||||
for (i in 0..6) {
|
|
||||||
weekdays[i] = addDays[i] && !removeDays[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val isEmpty: Boolean
|
val isEmpty: Boolean
|
||||||
get() {
|
get() {
|
||||||
for (d in weekdays) if (d) return false
|
for (d in weekdays) if (d) return false
|
||||||
@@ -65,10 +58,6 @@ class WeekdayList {
|
|||||||
return packedList
|
return packedList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isDayTrue(dayNum: Int): Boolean {
|
|
||||||
return weekdays[dayNum]
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other == null || javaClass != other.javaClass) return false
|
if (other == null || javaClass != other.javaClass) return false
|
||||||
@@ -84,6 +73,5 @@ class WeekdayList {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val EVERY_DAY = WeekdayList(127)
|
val EVERY_DAY = WeekdayList(127)
|
||||||
val NO_DAY = WeekdayList(booleanArrayOf(false, false, false, false, false, false, false))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import org.isoron.uhabits.core.database.Repository
|
|||||||
import org.isoron.uhabits.core.models.Entry
|
import org.isoron.uhabits.core.models.Entry
|
||||||
import org.isoron.uhabits.core.models.EntryList
|
import org.isoron.uhabits.core.models.EntryList
|
||||||
import org.isoron.uhabits.core.models.Frequency
|
import org.isoron.uhabits.core.models.Frequency
|
||||||
import org.isoron.uhabits.core.models.SkipDays
|
|
||||||
import org.isoron.uhabits.core.models.Timestamp
|
import org.isoron.uhabits.core.models.Timestamp
|
||||||
import org.isoron.uhabits.core.models.sqlite.records.EntryRecord
|
import org.isoron.uhabits.core.models.sqlite.records.EntryRecord
|
||||||
|
|
||||||
@@ -44,13 +43,14 @@ class SQLiteEntryList(database: Database) : EntryList() {
|
|||||||
isLoaded = true
|
isLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(timestamp: Timestamp, skipDays: SkipDays): Entry {
|
override fun get(timestamp: Timestamp): Entry {
|
||||||
loadRecords()
|
loadRecords()
|
||||||
return super.get(timestamp, skipDays)
|
return super.get(timestamp)
|
||||||
}
|
}
|
||||||
override fun getByInterval(from: Timestamp, to: Timestamp, skipDays: SkipDays): List<Entry> {
|
|
||||||
|
override fun getByInterval(from: Timestamp, to: Timestamp): List<Entry> {
|
||||||
loadRecords()
|
loadRecords()
|
||||||
return super.getByInterval(from, to, skipDays)
|
return super.getByInterval(from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun add(entry: Entry) {
|
override fun add(entry: Entry) {
|
||||||
@@ -78,7 +78,7 @@ class SQLiteEntryList(database: Database) : EntryList() {
|
|||||||
return super.getKnown()
|
return super.getKnown()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun recomputeFrom(originalEntries: EntryList, frequency: Frequency, isNumerical: Boolean, skipDays: SkipDays) {
|
override fun recomputeFrom(originalEntries: EntryList, frequency: Frequency, isNumerical: Boolean) {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.isoron.uhabits.core.models.HabitType
|
|||||||
import org.isoron.uhabits.core.models.NumericalHabitType
|
import org.isoron.uhabits.core.models.NumericalHabitType
|
||||||
import org.isoron.uhabits.core.models.PaletteColor
|
import org.isoron.uhabits.core.models.PaletteColor
|
||||||
import org.isoron.uhabits.core.models.Reminder
|
import org.isoron.uhabits.core.models.Reminder
|
||||||
import org.isoron.uhabits.core.models.SkipDays
|
|
||||||
import org.isoron.uhabits.core.models.WeekdayList
|
import org.isoron.uhabits.core.models.WeekdayList
|
||||||
import java.util.Objects.requireNonNull
|
import java.util.Objects.requireNonNull
|
||||||
|
|
||||||
@@ -50,12 +49,6 @@ class HabitRecord {
|
|||||||
@field:Column(name = "freq_den")
|
@field:Column(name = "freq_den")
|
||||||
var freqDen: Int? = null
|
var freqDen: Int? = null
|
||||||
|
|
||||||
@field:Column(name = "skip_days")
|
|
||||||
var skipDays: Int? = null
|
|
||||||
|
|
||||||
@field:Column(name = "skip_days_list")
|
|
||||||
var skipDaysList: Int? = null
|
|
||||||
|
|
||||||
@field:Column
|
@field:Column
|
||||||
var color: Int? = null
|
var color: Int? = null
|
||||||
|
|
||||||
@@ -95,12 +88,6 @@ class HabitRecord {
|
|||||||
@field:Column
|
@field:Column
|
||||||
var uuid: String? = null
|
var uuid: String? = null
|
||||||
|
|
||||||
@field:Column(name = "parent_id")
|
|
||||||
var parentID: Long? = null
|
|
||||||
|
|
||||||
@field:Column(name = "parent_uuid")
|
|
||||||
var parentUUID: String? = null
|
|
||||||
|
|
||||||
fun copyFrom(model: Habit) {
|
fun copyFrom(model: Habit) {
|
||||||
id = model.id
|
id = model.id
|
||||||
name = model.name
|
name = model.name
|
||||||
@@ -115,13 +102,9 @@ class HabitRecord {
|
|||||||
position = model.position
|
position = model.position
|
||||||
question = model.question
|
question = model.question
|
||||||
uuid = model.uuid
|
uuid = model.uuid
|
||||||
parentID = model.parentID
|
|
||||||
parentUUID = model.parentUUID
|
|
||||||
val (numerator, denominator) = model.frequency
|
val (numerator, denominator) = model.frequency
|
||||||
freqNum = numerator
|
freqNum = numerator
|
||||||
freqDen = denominator
|
freqDen = denominator
|
||||||
skipDays = if (model.skipDays.isSkipDays) 1 else 0
|
|
||||||
skipDaysList = model.skipDays.days.toInteger()
|
|
||||||
reminderDays = 0
|
reminderDays = 0
|
||||||
reminderMin = null
|
reminderMin = null
|
||||||
reminderHour = null
|
reminderHour = null
|
||||||
@@ -139,7 +122,6 @@ class HabitRecord {
|
|||||||
habit.description = description!!
|
habit.description = description!!
|
||||||
habit.question = question!!
|
habit.question = question!!
|
||||||
habit.frequency = Frequency(freqNum!!, freqDen!!)
|
habit.frequency = Frequency(freqNum!!, freqDen!!)
|
||||||
habit.skipDays = SkipDays(skipDays!! == 1, WeekdayList(skipDaysList!!))
|
|
||||||
habit.color = PaletteColor(color!!)
|
habit.color = PaletteColor(color!!)
|
||||||
habit.isArchived = archived != 0
|
habit.isArchived = archived != 0
|
||||||
habit.type = HabitType.fromInt(type!!)
|
habit.type = HabitType.fromInt(type!!)
|
||||||
@@ -148,8 +130,6 @@ class HabitRecord {
|
|||||||
habit.unit = unit!!
|
habit.unit = unit!!
|
||||||
habit.position = position!!
|
habit.position = position!!
|
||||||
habit.uuid = uuid
|
habit.uuid = uuid
|
||||||
habit.parentID = parentID
|
|
||||||
habit.parentUUID = parentUUID
|
|
||||||
if (reminderHour != null && reminderMin != null) {
|
if (reminderHour != null && reminderMin != null) {
|
||||||
habit.reminder = Reminder(
|
habit.reminder = Reminder(
|
||||||
reminderHour!!,
|
reminderHour!!,
|
||||||
|
|||||||
@@ -311,8 +311,7 @@ class HabitCardListCache @Inject constructor(
|
|||||||
newData.scores[habit.id] = habit.scores[today].value
|
newData.scores[habit.id] = habit.scores[today].value
|
||||||
val list: MutableList<Int> = ArrayList()
|
val list: MutableList<Int> = ArrayList()
|
||||||
val notes: MutableList<String> = ArrayList()
|
val notes: MutableList<String> = ArrayList()
|
||||||
val skipDays = habit.skipDays
|
for ((_, value, note) in habit.computedEntries.getByInterval(dateFrom, today)) {
|
||||||
for ((_, value, note) in habit.computedEntries.getByInterval(dateFrom, today, skipDays)) {
|
|
||||||
list.add(value)
|
list.add(value)
|
||||||
notes.add(note)
|
notes.add(note)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package org.isoron.uhabits.core.ui.screens.habits.list
|
|||||||
|
|
||||||
import org.isoron.uhabits.core.commands.CommandRunner
|
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.models.Entry
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
|
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.isoron.uhabits.core.models.HabitList
|
import org.isoron.uhabits.core.models.HabitList
|
||||||
@@ -54,12 +53,10 @@ open class ListHabitsBehavior @Inject constructor(
|
|||||||
|
|
||||||
fun onEdit(habit: Habit, timestamp: Timestamp?) {
|
fun onEdit(habit: Habit, timestamp: Timestamp?) {
|
||||||
val entry = habit.computedEntries.get(timestamp!!)
|
val entry = habit.computedEntries.get(timestamp!!)
|
||||||
if (habit.skipDays.isDaySkipped(timestamp)) return
|
|
||||||
if (habit.type == HabitType.NUMERICAL) {
|
if (habit.type == HabitType.NUMERICAL) {
|
||||||
val oldValue = entry.value.toDouble() / 1000
|
val oldValue = entry.value.toDouble() / 1000
|
||||||
screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String, x: Float, y: Float ->
|
screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String, x: Float, y: Float ->
|
||||||
val value = if (habit.skipDays.isDaySkipped(timestamp)) Entry.SKIP else (newValue * 1000).roundToInt()
|
val value = (newValue * 1000).roundToInt()
|
||||||
|
|
||||||
if (newValue != oldValue) {
|
if (newValue != oldValue) {
|
||||||
if (
|
if (
|
||||||
(habit.targetType == AT_LEAST && newValue >= habit.targetValue) ||
|
(habit.targetType == AT_LEAST && newValue >= habit.targetValue) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user