3 Commits

Author SHA1 Message Date
d204b877f5 activity_setting: fine tune layout style 2025-09-29 05:04:13 +02:00
335c1d13af add signature setting
For multiple users it helps to
keep track about who did what.
2025-09-29 05:04:09 +02:00
15dc8a1bef DateUtils: move event details formatting to DateUtils
Also display second as 0 since it is easier
to read and does not have meaning for the user.
2025-09-29 04:57:16 +02:00
3 changed files with 14 additions and 14 deletions

View File

@@ -211,7 +211,7 @@ class MainActivity : AppCompatActivity() {
numberPicker.wrapSelectorWheel = false
numberPicker.value = localSettings.loadBabyBottleContent()
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
logEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE, numberPicker.value * 10))
logEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE, signature, numberPicker.value * 10))
localSettings.saveBabyBottleContent(numberPicker.value)
}
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
@@ -230,7 +230,7 @@ class MainActivity : AppCompatActivity() {
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
val weight = weightET.text.toString().toIntOrNull()
if (weight != null)
logEvent(LunaEvent(LunaEvent.TYPE_WEIGHT, weight))
logEvent(LunaEvent(LunaEvent.TYPE_WEIGHT, signature, weight))
else
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
}
@@ -256,7 +256,7 @@ class MainActivity : AppCompatActivity() {
tempSlider.addOnChangeListener({s, v, b -> tempTextView.text = v.toString()})
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
val temperature = (tempSlider.value * 10).toInt() // In tenth of a grade
logEvent(LunaEvent(LunaEvent.TYPE_TEMPERATURE, temperature))
logEvent(LunaEvent(LunaEvent.TYPE_TEMPERATURE, signature, temperature))
}
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
val alertDialog = d.create()
@@ -647,8 +647,6 @@ class MainActivity : AppCompatActivity() {
fun logEvent(event: LunaEvent) {
savingEvent(true)
event.signature = signature
setLoading(true)
logbook?.logs?.add(0, event)
recyclerView.adapter?.notifyItemInserted(0)
@@ -783,15 +781,15 @@ class MainActivity : AppCompatActivity() {
val inflater = LayoutInflater.from(anchor.context)
contentView = inflater.inflate(R.layout.more_events_popup, null)
contentView.findViewById<View>(R.id.button_medicine).setOnClickListener {
askNotes(LunaEvent(LunaEvent.TYPE_MEDICINE))
askNotes(LunaEvent(LunaEvent.TYPE_MEDICINE, signature))
dismiss()
}
contentView.findViewById<View>(R.id.button_enema).setOnClickListener({
logEvent(LunaEvent(LunaEvent.TYPE_ENEMA))
logEvent(LunaEvent(LunaEvent.TYPE_ENEMA, signature))
dismiss()
})
contentView.findViewById<View>(R.id.button_note).setOnClickListener({
askNotes(LunaEvent(LunaEvent.TYPE_NOTE))
askNotes(LunaEvent(LunaEvent.TYPE_NOTE, signature))
dismiss()
})
contentView.findViewById<View>(R.id.button_temperature).setOnClickListener({
@@ -800,13 +798,13 @@ class MainActivity : AppCompatActivity() {
})
contentView.findViewById<View>(R.id.button_puke).setOnClickListener({
logEvent(
LunaEvent(LunaEvent.TYPE_PUKE)
LunaEvent(LunaEvent.TYPE_PUKE, signature)
)
dismiss()
})
contentView.findViewById<View>(R.id.button_colic).setOnClickListener({
logEvent(
LunaEvent(LunaEvent.TYPE_COLIC)
LunaEvent(LunaEvent.TYPE_COLIC, signature)
)
dismiss()
})
@@ -816,7 +814,7 @@ class MainActivity : AppCompatActivity() {
})
contentView.findViewById<View>(R.id.button_bath).setOnClickListener({
logEvent(
LunaEvent(LunaEvent.TYPE_BATH)
LunaEvent(LunaEvent.TYPE_BATH, signature)
)
dismiss()
})

View File

@@ -69,16 +69,18 @@ class LunaEvent: Comparable<LunaEvent> {
throw IllegalArgumentException("JSONObject is not a LunaEvent")
}
constructor(type: String) {
constructor(type: String, signature: String) {
this.jo = JSONObject()
this.time = System.currentTimeMillis() / 1000
this.signature = signature
this.type = type
}
constructor(type: String, quantity: Int) {
constructor(type: String, signature: String, quantity: Int) {
this.jo = JSONObject()
this.time = System.currentTimeMillis() / 1000
this.type = type
this.signature = signature
this.quantity = quantity
}

View File

@@ -108,7 +108,7 @@ class DateUtils {
}
/**
* Format time as localized string. E.g. "28 Sept 03:36:00".
* Format time as localized string without seconds. E.g. "28 Sept 03:36:00".
* The seconds are set to 0 since they are distracting and not relevant.
* Used in the event detail dialog.
*/