forked from penguin86/luna-tracker
Compare commits
4 Commits
bottle_tim
...
quantity
| Author | SHA1 | Date | |
|---|---|---|---|
| 8493d2822f | |||
| 80a70dfbf3 | |||
| 0a8ca7f9d1 | |||
| 4492b36b23 |
@@ -12,7 +12,6 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.NumberPicker
|
import android.widget.NumberPicker
|
||||||
import android.widget.PopupWindow
|
import android.widget.PopupWindow
|
||||||
@@ -86,7 +85,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
showAddLogbookDialog(true)
|
showAddLogbookDialog(true)
|
||||||
}
|
}
|
||||||
findViewById<View>(R.id.button_bottle).setOnClickListener {
|
findViewById<View>(R.id.button_bottle).setOnClickListener {
|
||||||
addBabyBottleEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE))
|
addBabyBottleEvent()
|
||||||
}
|
}
|
||||||
findViewById<View>(R.id.button_food).setOnClickListener {
|
findViewById<View>(R.id.button_food).setOnClickListener {
|
||||||
addNoteEvent(LunaEvent(LunaEvent.TYPE_FOOD))
|
addNoteEvent(LunaEvent(LunaEvent.TYPE_FOOD))
|
||||||
@@ -196,8 +195,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return logbook?.logs ?: arrayListOf()
|
return logbook?.logs ?: arrayListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addBabyBottleEvent(event: LunaEvent) {
|
fun addBabyBottleEvent() {
|
||||||
setToPreviousQuantity(event)
|
val event = LunaEvent(LunaEvent.TYPE_BABY_BOTTLE)
|
||||||
askBabyBottleContent(event, true) {
|
askBabyBottleContent(event, true) {
|
||||||
saveEvent(event)
|
saveEvent(event)
|
||||||
}
|
}
|
||||||
@@ -240,7 +239,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addWeightEvent(event: LunaEvent) {
|
fun addWeightEvent(event: LunaEvent) {
|
||||||
setToPreviousQuantity(event)
|
|
||||||
askWeightValue(event, true) { saveEvent(event) }
|
askWeightValue(event, true) { saveEvent(event) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +282,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addTemperatureEvent(event: LunaEvent) {
|
fun addTemperatureEvent(event: LunaEvent) {
|
||||||
setToPreviousQuantity(event)
|
|
||||||
askTemperatureValue(event, true) { saveEvent(event) }
|
askTemperatureValue(event, true) { saveEvent(event) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +328,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun datePickerHelper(time: Long, dateTextView: TextView, onChange: (Long) -> Unit = {}): Calendar {
|
fun datePickerHelper(time: Long, dateTextView: TextView): Calendar {
|
||||||
dateTextView.text = DateUtils.formatDateTime(time)
|
dateTextView.text = DateUtils.formatDateTime(time)
|
||||||
|
|
||||||
val dateTime = Calendar.getInstance()
|
val dateTime = Calendar.getInstance()
|
||||||
@@ -350,7 +347,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
{ _, hour, minute ->
|
{ _, hour, minute ->
|
||||||
dateTime.set(year, month, day, hour, minute)
|
dateTime.set(year, month, day, hour, minute)
|
||||||
dateTextView.text = DateUtils.formatDateTime(dateTime.time.time / 1000)
|
dateTextView.text = DateUtils.formatDateTime(dateTime.time.time / 1000)
|
||||||
onChange.invoke(dateTime.time.time / 1000)
|
|
||||||
},
|
},
|
||||||
startHour,
|
startHour,
|
||||||
startMinute,
|
startMinute,
|
||||||
@@ -373,97 +369,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
saveLogbook()
|
saveLogbook()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addSleepEvent(event: LunaEvent) {
|
|
||||||
askSleepValue(event) { saveEvent(event) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun askSleepValue(event: LunaEvent, onPositive: () -> Unit) {
|
|
||||||
val d = AlertDialog.Builder(this)
|
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_edit_duration, null)
|
|
||||||
d.setTitle(event.getTypeDescription(this))
|
|
||||||
d.setMessage(event.getDialogMessage(this))
|
|
||||||
d.setView(dialogView)
|
|
||||||
|
|
||||||
val durationTextView = dialogView.findViewById<TextView>(R.id.dialog_date_duration)
|
|
||||||
val durationNowButton = dialogView.findViewById<Button>(R.id.dialog_date_duration_now)
|
|
||||||
val datePicker = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
|
||||||
val durationMinus15Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus15)
|
|
||||||
val durationMinus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus5)
|
|
||||||
val durationPlus15Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus15)
|
|
||||||
val durationPlus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus5)
|
|
||||||
|
|
||||||
val currentDurationTextColor = durationTextView.currentTextColor
|
|
||||||
val invalidDurationTextColor = ContextCompat.getColor(this, R.color.danger)
|
|
||||||
|
|
||||||
var duration = event.quantity
|
|
||||||
|
|
||||||
fun isValidTime(timeSeconds: Long, durationSeconds: Int): Boolean {
|
|
||||||
val now = Calendar.getInstance().time.time / 1000
|
|
||||||
return (timeSeconds + durationSeconds) <= now && durationSeconds < (12 * 60 * 60)
|
|
||||||
}
|
|
||||||
|
|
||||||
val onDateChange = { time: Long ->
|
|
||||||
durationTextView.setTextColor(currentDurationTextColor)
|
|
||||||
|
|
||||||
if (duration == 0) {
|
|
||||||
// baby is sleeping
|
|
||||||
durationTextView.text = "💤"
|
|
||||||
} else {
|
|
||||||
durationTextView.text = DateUtils.formatTimeDuration(applicationContext, duration.toLong())
|
|
||||||
if (!isValidTime(time, duration)) {
|
|
||||||
durationTextView.setTextColor(invalidDurationTextColor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val pickedDateTime = datePickerHelper(event.time, datePicker, onDateChange)
|
|
||||||
|
|
||||||
onDateChange(pickedDateTime.time.time / 1000)
|
|
||||||
|
|
||||||
fun adjust(minutes: Int) {
|
|
||||||
duration += minutes * 60
|
|
||||||
if (duration < 0) {
|
|
||||||
duration = 0
|
|
||||||
}
|
|
||||||
onDateChange(pickedDateTime.time.time / 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
durationMinus15Button.setOnClickListener { adjust(-15) }
|
|
||||||
durationMinus5Button.setOnClickListener { adjust(-5) }
|
|
||||||
durationPlus5Button.setOnClickListener { adjust(5) }
|
|
||||||
durationPlus15Button.setOnClickListener { adjust(15) }
|
|
||||||
|
|
||||||
durationNowButton.setOnClickListener {
|
|
||||||
val now = Calendar.getInstance().time.time / 1000
|
|
||||||
val start = pickedDateTime.time.time / 1000
|
|
||||||
if (now > start) {
|
|
||||||
duration = (now - start).toInt()
|
|
||||||
duration -= duration % 60 // prevent printing of seconds
|
|
||||||
onDateChange(pickedDateTime.time.time / 1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
|
||||||
val time = pickedDateTime.time.time / 1000
|
|
||||||
|
|
||||||
if (isValidTime(time, duration)) {
|
|
||||||
event.time = time
|
|
||||||
event.quantity = duration
|
|
||||||
onPositive()
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this, R.string.toast_date_error, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
dialogInterface.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
|
||||||
dialogInterface.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
val alertDialog = d.create()
|
|
||||||
alertDialog.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addAmountEvent(event: LunaEvent) {
|
fun addAmountEvent(event: LunaEvent) {
|
||||||
askAmountValue(event, true) { saveEvent(event) }
|
askAmountValue(event, true) { saveEvent(event) }
|
||||||
}
|
}
|
||||||
@@ -552,59 +457,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val notesET = dialogView.findViewById<EditText>(R.id.notes_edittext)
|
val notesET = dialogView.findViewById<EditText>(R.id.notes_edittext)
|
||||||
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.notes_date_picker)
|
||||||
val pickedTime = datePickerHelper(event.time, dateTV)
|
val pickedTime = datePickerHelper(event.time, dateTV)
|
||||||
|
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
val nextTextView = dialogView.findViewById<TextView>(R.id.notes_template_next)
|
|
||||||
val prevTextView = dialogView.findViewById<TextView>(R.id.notes_template_prev)
|
|
||||||
|
|
||||||
fun updateContent(current: LunaEvent) {
|
|
||||||
val allEvents = getAllEvents()
|
|
||||||
val prevEvent = getPreviousSameEvent(current, allEvents)
|
|
||||||
var nextEvent = getNextSameEvent(current, allEvents)
|
|
||||||
|
|
||||||
notesET.setText(current.notes)
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(current.quantity.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextEvent == null && current != event) {
|
|
||||||
nextEvent = event
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextEvent != null) {
|
|
||||||
nextTextView.setOnClickListener {
|
|
||||||
notesET.setText(nextEvent.notes)
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(nextEvent.quantity.toString())
|
|
||||||
}
|
|
||||||
updateContent(nextEvent)
|
|
||||||
}
|
|
||||||
nextTextView.alpha = 1.0f
|
|
||||||
} else {
|
|
||||||
nextTextView.setOnClickListener {}
|
|
||||||
nextTextView.alpha = 0.5f
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevEvent != null) {
|
|
||||||
prevTextView.setOnClickListener {
|
|
||||||
notesET.setText(prevEvent.notes)
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(prevEvent.quantity.toString())
|
|
||||||
}
|
|
||||||
updateContent(prevEvent)
|
|
||||||
}
|
|
||||||
prevTextView.alpha = 1.0f
|
|
||||||
} else {
|
|
||||||
prevTextView.setOnClickListener {}
|
|
||||||
prevTextView.alpha = 0.5f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notesET.setText(event.notes)
|
notesET.setText(event.notes)
|
||||||
|
|
||||||
if (useQuantity) {
|
if (useQuantity) {
|
||||||
@@ -613,8 +472,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
qtyET.visibility = View.GONE
|
qtyET.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
updateContent(event)
|
|
||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
val notes = notesET.text.toString()
|
val notes = notesET.text.toString()
|
||||||
|
|
||||||
@@ -626,7 +483,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
event.quantity = quantity
|
event.quantity = quantity
|
||||||
onPositive()
|
onPositive()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
Toast.makeText(applicationContext, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -666,13 +523,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setToPreviousQuantity(event: LunaEvent) {
|
|
||||||
val prev = getPreviousSameEvent(event, getAllEvents())
|
|
||||||
if (prev != null) {
|
|
||||||
event.quantity = prev.quantity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getPreviousSameEvent(event: LunaEvent, items: ArrayList<LunaEvent>): LunaEvent? {
|
fun getPreviousSameEvent(event: LunaEvent, items: ArrayList<LunaEvent>): LunaEvent? {
|
||||||
var previousEvent: LunaEvent? = null
|
var previousEvent: LunaEvent? = null
|
||||||
for (item in items) {
|
for (item in items) {
|
||||||
@@ -736,7 +586,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
LunaEvent.TYPE_PUKE -> askAmountValue(event, false, updateValues)
|
LunaEvent.TYPE_PUKE -> askAmountValue(event, false, updateValues)
|
||||||
LunaEvent.TYPE_TEMPERATURE -> askTemperatureValue(event, false, updateValues)
|
LunaEvent.TYPE_TEMPERATURE -> askTemperatureValue(event, false, updateValues)
|
||||||
LunaEvent.TYPE_NOTE -> askNotes(event, false, updateValues)
|
LunaEvent.TYPE_NOTE -> askNotes(event, false, updateValues)
|
||||||
LunaEvent.TYPE_SLEEP -> askSleepValue(event, updateValues)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,7 +772,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
loadLogbookList()
|
loadLogbookList()
|
||||||
Toast.makeText(this@MainActivity, getString(R.string.logbook_created) + logbookName, Toast.LENGTH_SHORT).show()
|
Toast.makeText(applicationContext, getString(R.string.logbook_created) + logbookName, Toast.LENGTH_SHORT).show()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +929,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@MainActivity,
|
applicationContext,
|
||||||
if (lastEventAdded != null)
|
if (lastEventAdded != null)
|
||||||
R.string.toast_event_added
|
R.string.toast_event_added
|
||||||
else
|
else
|
||||||
@@ -1142,7 +991,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
|
||||||
Toast.makeText(this@MainActivity, R.string.toast_event_add_error, Toast.LENGTH_SHORT).show()
|
Toast.makeText(applicationContext, R.string.toast_event_add_error, Toast.LENGTH_SHORT).show()
|
||||||
recyclerView.adapter?.notifyDataSetChanged()
|
recyclerView.adapter?.notifyDataSetChanged()
|
||||||
savingEvent(false)
|
savingEvent(false)
|
||||||
})
|
})
|
||||||
@@ -1194,10 +1043,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
addAmountEvent(LunaEvent(LunaEvent.TYPE_PUKE))
|
addAmountEvent(LunaEvent(LunaEvent.TYPE_PUKE))
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
contentView.findViewById<View>(R.id.button_sleep).setOnClickListener {
|
|
||||||
addSleepEvent(LunaEvent(LunaEvent.TYPE_SLEEP))
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
contentView.findViewById<View>(R.id.button_colic).setOnClickListener {
|
contentView.findViewById<View>(R.id.button_colic).setOnClickListener {
|
||||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_COLIC))
|
addPlainEvent(LunaEvent(LunaEvent.TYPE_COLIC))
|
||||||
dismiss()
|
dismiss()
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
const val TYPE_FOOD = "FOOD"
|
const val TYPE_FOOD = "FOOD"
|
||||||
const val TYPE_PUKE = "PUKE"
|
const val TYPE_PUKE = "PUKE"
|
||||||
const val TYPE_BATH = "BATH"
|
const val TYPE_BATH = "BATH"
|
||||||
const val TYPE_SLEEP = "SLEEP"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val jo: JSONObject
|
private val jo: JSONObject
|
||||||
@@ -46,12 +45,10 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
jo.put("type", value)
|
jo.put("type", value)
|
||||||
}
|
}
|
||||||
var quantity: Int
|
var quantity: Int
|
||||||
get() = jo.optInt("quantity")
|
get() = jo.optInt("quantity", -1)
|
||||||
set(value) {
|
set(value) {
|
||||||
if (value > 0)
|
if (value >= 0)
|
||||||
jo.put("quantity", value)
|
jo.put("quantity", value)
|
||||||
else
|
|
||||||
jo.remove("quantity")
|
|
||||||
}
|
}
|
||||||
var notes: String
|
var notes: String
|
||||||
get(): String = jo.optString("notes")
|
get(): String = jo.optString("notes")
|
||||||
@@ -112,7 +109,6 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
TYPE_FOOD -> R.string.event_food_type
|
TYPE_FOOD -> R.string.event_food_type
|
||||||
TYPE_PUKE -> R.string.event_puke_type
|
TYPE_PUKE -> R.string.event_puke_type
|
||||||
TYPE_BATH -> R.string.event_bath_type
|
TYPE_BATH -> R.string.event_bath_type
|
||||||
TYPE_SLEEP -> R.string.event_sleep_type
|
|
||||||
else -> R.string.event_unknown_type
|
else -> R.string.event_unknown_type
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -136,7 +132,6 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
TYPE_FOOD -> R.string.event_food_desc
|
TYPE_FOOD -> R.string.event_food_desc
|
||||||
TYPE_PUKE -> R.string.event_puke_desc
|
TYPE_PUKE -> R.string.event_puke_desc
|
||||||
TYPE_BATH -> R.string.event_bath_desc
|
TYPE_BATH -> R.string.event_bath_desc
|
||||||
TYPE_SLEEP -> R.string.event_sleep_desc
|
|
||||||
else -> R.string.event_unknown_desc
|
else -> R.string.event_unknown_desc
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -152,7 +147,6 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
TYPE_DIAPERCHANGE_PEE,
|
TYPE_DIAPERCHANGE_PEE,
|
||||||
TYPE_PUKE -> R.string.log_amount_dialog_description
|
TYPE_PUKE -> R.string.log_amount_dialog_description
|
||||||
TYPE_WEIGHT -> R.string.log_weight_dialog_description
|
TYPE_WEIGHT -> R.string.log_weight_dialog_description
|
||||||
TYPE_SLEEP -> R.string.log_sleep_dialog_description
|
|
||||||
else -> R.string.log_unknown_dialog_description
|
else -> R.string.log_unknown_dialog_description
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -62,8 +62,10 @@ class DateUtils {
|
|||||||
return format(days, hours, R.string.day_ago, R.string.days_ago, R.string.hour_ago, R.string.hours_ago)
|
return format(days, hours, R.string.day_ago, R.string.days_ago, R.string.hour_ago, R.string.hours_ago)
|
||||||
} else if (hours > 0) {
|
} else if (hours > 0) {
|
||||||
return format(hours, minutes, R.string.hour_ago, R.string.hours_ago, R.string.minute_ago, R.string.minutes_ago)
|
return format(hours, minutes, R.string.hour_ago, R.string.hours_ago, R.string.minute_ago, R.string.minutes_ago)
|
||||||
} else {
|
} else if (minutes > 0) {
|
||||||
return format(minutes, seconds, R.string.minute_ago, R.string.minute_ago, R.string.second_ago, R.string.seconds_ago)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import android.os.Build
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import it.danieleverducci.lunatracker.R
|
import it.danieleverducci.lunatracker.R
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEvent
|
import it.danieleverducci.lunatracker.entities.LunaEvent
|
||||||
import utils.DateUtils.Companion.formatTimeDuration
|
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
|
|
||||||
class NumericUtils (val context: Context) {
|
class NumericUtils (val context: Context) {
|
||||||
@@ -64,7 +63,7 @@ class NumericUtils (val context: Context) {
|
|||||||
|
|
||||||
fun formatEventQuantity(event: LunaEvent): String {
|
fun formatEventQuantity(event: LunaEvent): String {
|
||||||
val formatted = StringBuilder()
|
val formatted = StringBuilder()
|
||||||
if (event.quantity > 0) {
|
if (event.quantity >= 0) {
|
||||||
formatted.append(when (event.type) {
|
formatted.append(when (event.type) {
|
||||||
LunaEvent.TYPE_TEMPERATURE ->
|
LunaEvent.TYPE_TEMPERATURE ->
|
||||||
(event.quantity / 10.0f).toString()
|
(event.quantity / 10.0f).toString()
|
||||||
@@ -77,7 +76,6 @@ class NumericUtils (val context: Context) {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LunaEvent.TYPE_SLEEP -> formatTimeDuration(context, event.quantity.toLong())
|
|
||||||
else ->
|
else ->
|
||||||
event.quantity
|
event.quantity
|
||||||
})
|
})
|
||||||
@@ -92,11 +90,6 @@ class NumericUtils (val context: Context) {
|
|||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
formatted.append(when (event.type) {
|
|
||||||
LunaEvent.TYPE_SLEEP -> "💤" // baby is sleeping
|
|
||||||
else -> ""
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return formatted.toString()
|
return formatted.toString()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/dialog_amount_value"
|
|
||||||
android:layout_width="250dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingHorizontal="16dp"
|
|
||||||
android:paddingVertical="8dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dialog_date_picker"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="20dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
@@ -30,6 +30,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginTop="20dp"/>
|
android:layout_marginEnd="20dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dialog_date_duration"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:text="💤"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_marginHorizontal="10dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_minus15"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="-15"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_minus5"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="-5"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_now"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/now"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_plus5"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="+5"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_plus15"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="+15"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dialog_date_picker"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginTop="20dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -24,31 +24,8 @@
|
|||||||
android:hint="@string/log_notes_dialog_note_hint"
|
android:hint="@string/log_notes_dialog_note_hint"
|
||||||
android:background="@drawable/textview_background"/>
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/notes_template_prev"
|
android:id="@+id/notes_date_picker"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:text="⬅️"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/notes_template_next"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:text="➡️"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dialog_date_picker"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_date_picker"
|
android:id="@+id/dialog_date_picker"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_marginEnd="20dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
android:id="@+id/dialog_date_picker"
|
android:id="@+id/dialog_date_picker"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"/>
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginEnd="20dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -49,16 +49,6 @@
|
|||||||
style="@style/OverflowMenuText"
|
style="@style/OverflowMenuText"
|
||||||
android:text="@string/overflow_event_puke"/>
|
android:text="@string/overflow_event_puke"/>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/button_sleep"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:background="@drawable/dropdown_list_item_background"
|
|
||||||
style="@style/OverflowMenuText"
|
|
||||||
android:text="@string/overflow_event_sleep"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/button_colic"
|
android:id="@+id/button_colic"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
<string name="event_colic_type" translatable="false">💨</string>
|
<string name="event_colic_type" translatable="false">💨</string>
|
||||||
<string name="event_puke_type" translatable="false">🤮</string>
|
<string name="event_puke_type" translatable="false">🤮</string>
|
||||||
<string name="event_bath_type" translatable="false">🛁</string>
|
<string name="event_bath_type" translatable="false">🛁</string>
|
||||||
<string name="event_sleep_type" translatable="false">💤</string>
|
|
||||||
<string name="event_unknown_type" translatable="false">\?</string>
|
<string name="event_unknown_type" translatable="false">\?</string>
|
||||||
|
|
||||||
<string name="event_bottle_desc">Baby bottle</string>
|
<string name="event_bottle_desc">Baby bottle</string>
|
||||||
@@ -36,7 +35,6 @@
|
|||||||
<string name="event_colic_desc">Gaseous colic</string>
|
<string name="event_colic_desc">Gaseous colic</string>
|
||||||
<string name="event_puke_desc">Puke</string>
|
<string name="event_puke_desc">Puke</string>
|
||||||
<string name="event_bath_desc">Bath</string>
|
<string name="event_bath_desc">Bath</string>
|
||||||
<string name="event_sleep_desc">Sleep</string>
|
|
||||||
<string name="event_unknown_desc"></string>
|
<string name="event_unknown_desc"></string>
|
||||||
|
|
||||||
<string name="overflow_event_weight">⚖️ Weight</string>
|
<string name="overflow_event_weight">⚖️ Weight</string>
|
||||||
@@ -46,14 +44,12 @@
|
|||||||
<string name="overflow_event_temperature">🌡️ Temperature</string>
|
<string name="overflow_event_temperature">🌡️ Temperature</string>
|
||||||
<string name="overflow_event_colic">💨 Gaseous colic</string>
|
<string name="overflow_event_colic">💨 Gaseous colic</string>
|
||||||
<string name="overflow_event_puke">🤮 Puke</string>
|
<string name="overflow_event_puke">🤮 Puke</string>
|
||||||
<string name="overflow_event_sleep">💤 Sleep</string>
|
|
||||||
<string name="overflow_event_bath">🛁 Bath</string>
|
<string name="overflow_event_bath">🛁 Bath</string>
|
||||||
|
|
||||||
<string name="toast_event_added">Event logged</string>
|
<string name="toast_event_added">Event logged</string>
|
||||||
<string name="toast_logbook_saved">Logbook saved</string>
|
<string name="toast_logbook_saved">Logbook saved</string>
|
||||||
<string name="toast_event_add_error">Unable to log the event</string>
|
<string name="toast_event_add_error">Unable to log the event</string>
|
||||||
<string name="toast_integer_error">Invalid value. Insert an integer.</string>
|
<string name="toast_integer_error">Invalid value. Insert an integer.</string>
|
||||||
<string name="toast_date_error">Invalid date.</string>
|
|
||||||
|
|
||||||
<string name="now">now</string>
|
<string name="now">now</string>
|
||||||
<string name="second_ago">sec</string>
|
<string name="second_ago">sec</string>
|
||||||
@@ -116,7 +112,6 @@
|
|||||||
<string name="log_temperature_dialog_description">Select the temperature:</string>
|
<string name="log_temperature_dialog_description">Select the temperature:</string>
|
||||||
<string name="log_unknown_dialog_description"></string>
|
<string name="log_unknown_dialog_description"></string>
|
||||||
<string name="log_weight_dialog_description">Insert the weight:</string>
|
<string name="log_weight_dialog_description">Insert the weight:</string>
|
||||||
<string name="log_sleep_dialog_description">Set sleep duration:</string>
|
|
||||||
|
|
||||||
<string name="measurement_unit_liquid_base_metric" translatable="false">ml</string>
|
<string name="measurement_unit_liquid_base_metric" translatable="false">ml</string>
|
||||||
<string name="measurement_unit_weight_base_metric" translatable="false">g</string>
|
<string name="measurement_unit_weight_base_metric" translatable="false">g</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user