Resolving comments

pull/1319/head
Jakub Kalinowski 4 years ago
parent 9ee9427bfd
commit 5d25b236f7

@ -183,16 +183,16 @@ class NumberButtonView(
val textSize: Float val textSize: Float
when { when {
value >= 0 -> {
label = value.toShortString()
typeface = BOLD_TYPEFACE
textSize = dim(R.dimen.smallTextSize)
}
value == Entry.SKIP.toDouble() / 1000 -> { value == Entry.SKIP.toDouble() / 1000 -> {
label = resources.getString(R.string.fa_skipped) label = resources.getString(R.string.fa_skipped)
textSize = dim(R.dimen.smallTextSize) textSize = dim(R.dimen.smallTextSize)
typeface = getFontAwesome() typeface = getFontAwesome()
} }
value >= 0 -> {
label = value.toShortString()
typeface = BOLD_TYPEFACE
textSize = dim(R.dimen.smallTextSize)
}
preferences.areQuestionMarksEnabled -> { preferences.areQuestionMarksEnabled -> {
label = resources.getString(R.string.fa_question) label = resources.getString(R.string.fa_question)
typeface = getFontAwesome() typeface = getFontAwesome()

@ -276,7 +276,7 @@ open class EntryList {
* For numerical habits, non-positive entry values are converted to zero. For boolean habits, each * For numerical habits, non-positive entry values are converted to zero. For boolean habits, each
* YES_MANUAL value is converted to 1000 and all other values are converted to zero. * YES_MANUAL value is converted to 1000 and all other values are converted to zero.
* *
* SKIP values are treated converted to zero (if they weren't, each SKIP day would count as 0.003). * SKIP values are converted to zero (if they weren't, each SKIP day would count as 0.003).
* *
* The returned list is sorted by timestamp, with the newest entry coming first and the oldest entry * The returned list is sorted by timestamp, with the newest entry coming first and the oldest entry
* coming last. If the original list has gaps in it (for example, weeks or months without any * coming last. If the original list has gaps in it (for example, weeks or months without any
@ -311,12 +311,11 @@ fun List<Entry>.groupedSum(
} }
/** /**
* Counts the number of days with vaLue SKIP in the given perio * Counts the number of days with vaLue SKIP in the given period.
*/ */
fun List<Entry>.countSkippedDays( fun List<Entry>.countSkippedDays(
truncateField: DateUtils.TruncateField, truncateField: DateUtils.TruncateField,
firstWeekday: Int = Calendar.SATURDAY, firstWeekday: Int = Calendar.SATURDAY
isNumerical: Boolean,
): List<Entry> { ): List<Entry> {
return this.map { (timestamp, value) -> return this.map { (timestamp, value) ->
if (value == SKIP) { if (value == SKIP) {

@ -53,8 +53,7 @@ class TargetCardPresenter {
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val skippedDayToday = entries.countSkippedDays( val skippedDayToday = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.DAY, truncateField = DateUtils.TruncateField.DAY
isNumerical = habit.isNumerical
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val valueThisWeek = entries.groupedSum( val valueThisWeek = entries.groupedSum(
@ -65,8 +64,7 @@ class TargetCardPresenter {
val skippedDaysThisWeek = entries.countSkippedDays( val skippedDaysThisWeek = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.WEEK_NUMBER, truncateField = DateUtils.TruncateField.WEEK_NUMBER,
firstWeekday = firstWeekday, firstWeekday = firstWeekday
isNumerical = habit.isNumerical
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val valueThisMonth = entries.groupedSum( val valueThisMonth = entries.groupedSum(
@ -76,7 +74,6 @@ class TargetCardPresenter {
val skippedDaysThisMonth = entries.countSkippedDays( val skippedDaysThisMonth = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.MONTH, truncateField = DateUtils.TruncateField.MONTH,
isNumerical = habit.isNumerical
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val valueThisQuarter = entries.groupedSum( val valueThisQuarter = entries.groupedSum(
@ -85,8 +82,7 @@ class TargetCardPresenter {
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val skippedDaysThisQuarter = entries.countSkippedDays( val skippedDaysThisQuarter = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.QUARTER, truncateField = DateUtils.TruncateField.QUARTER
isNumerical = habit.isNumerical
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val valueThisYear = entries.groupedSum( val valueThisYear = entries.groupedSum(
@ -95,8 +91,7 @@ class TargetCardPresenter {
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val skippedDaysThisYear = entries.countSkippedDays( val skippedDaysThisYear = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.YEAR, truncateField = DateUtils.TruncateField.YEAR
isNumerical = habit.isNumerical
).firstOrNull()?.value ?: 0 ).firstOrNull()?.value ?: 0
val cal = DateUtils.getStartOfTodayCalendarWithOffset() val cal = DateUtils.getStartOfTodayCalendarWithOffset()

Loading…
Cancel
Save