forked from penguin86/luna-tracker
LunaEvent: add sleep event
This commit is contained in:
@@ -62,10 +62,8 @@ class DateUtils {
|
||||
return format(days, hours, R.string.day_ago, R.string.days_ago, R.string.hour_ago, R.string.hours_ago)
|
||||
} else if (hours > 0) {
|
||||
return format(hours, minutes, R.string.hour_ago, R.string.hours_ago, R.string.minute_ago, R.string.minutes_ago)
|
||||
} else if (minutes > 0) {
|
||||
return format(minutes, seconds, R.string.minute_ago, R.string.minute_ago, R.string.second_ago, R.string.seconds_ago)
|
||||
} else {
|
||||
return context.getString(R.string.now)
|
||||
return format(minutes, seconds, R.string.minute_ago, R.string.minute_ago, R.string.second_ago, R.string.seconds_ago)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.Build
|
||||
import android.util.Log
|
||||
import it.danieleverducci.lunatracker.R
|
||||
import it.danieleverducci.lunatracker.entities.LunaEvent
|
||||
import utils.DateUtils.Companion.formatTimeDuration
|
||||
import java.text.NumberFormat
|
||||
|
||||
class NumericUtils (val context: Context) {
|
||||
@@ -76,6 +77,7 @@ class NumericUtils (val context: Context) {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
LunaEvent.TYPE_SLEEP -> formatTimeDuration(context, event.quantity.toLong())
|
||||
else ->
|
||||
event.quantity
|
||||
})
|
||||
@@ -90,6 +92,11 @@ class NumericUtils (val context: Context) {
|
||||
else -> ""
|
||||
}
|
||||
)
|
||||
} else {
|
||||
formatted.append(when (event.type) {
|
||||
LunaEvent.TYPE_SLEEP -> "💤" // baby is sleeping
|
||||
else -> ""
|
||||
})
|
||||
}
|
||||
return formatted.toString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user