3 Commits

Author SHA1 Message Date
66fbc9b55f activity_setting: fine tune layout style 2025-09-29 09:08:12 +02:00
3043b86a14 add signature setting
For multiple users it helps to
keep track about who did what.
2025-09-29 09:08:12 +02:00
c4b345bfd9 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 09:08:08 +02:00
3 changed files with 14 additions and 14 deletions

View File

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

View File

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

View File

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