use creation dialog as edit dialog
This commit is contained in:
@@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
// Set listeners
|
||||
findViewById<View>(R.id.logbooks_add_button).setOnClickListener { showAddLogbookDialog(true) }
|
||||
findViewById<View>(R.id.button_bottle).setOnClickListener { askBabyBottleContent() }
|
||||
findViewById<View>(R.id.button_bottle).setOnClickListener { askBabyBottleContent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE)) }
|
||||
findViewById<View>(R.id.button_food).setOnClickListener { askNotes(LunaEvent(LunaEvent.TYPE_FOOD)) }
|
||||
findViewById<View>(R.id.button_nipple_left).setOnClickListener { logEvent(
|
||||
LunaEvent(
|
||||
@@ -100,14 +100,10 @@ class MainActivity : AppCompatActivity() {
|
||||
)
|
||||
) }
|
||||
findViewById<View>(R.id.button_change_poo).setOnClickListener { logEvent(
|
||||
LunaEvent(
|
||||
LunaEvent.TYPE_DIAPERCHANGE_POO
|
||||
)
|
||||
LunaEvent(LunaEvent.TYPE_DIAPERCHANGE_POO)
|
||||
) }
|
||||
findViewById<View>(R.id.button_change_pee).setOnClickListener { logEvent(
|
||||
LunaEvent(
|
||||
LunaEvent.TYPE_DIAPERCHANGE_PEE
|
||||
)
|
||||
LunaEvent(LunaEvent.TYPE_DIAPERCHANGE_PEE)
|
||||
) }
|
||||
val moreButton = findViewById<View>(R.id.button_more)
|
||||
moreButton.setOnClickListener {
|
||||
@@ -132,7 +128,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val adapter = LunaEventRecyclerAdapter(this, items)
|
||||
adapter.onItemClickListener = object: LunaEventRecyclerAdapter.OnItemClickListener {
|
||||
override fun onItemClick(event: LunaEvent) {
|
||||
showEventDetailDialog(event, items)
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
recyclerView.adapter = adapter
|
||||
@@ -195,30 +191,55 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
fun askBabyBottleContent() {
|
||||
// Show number picker dialog
|
||||
val localSettings = LocalSettingsRepository(this)
|
||||
fun getAllEvents(): ArrayList<LunaEvent> {
|
||||
return logbook?.logs ?: arrayListOf()
|
||||
}
|
||||
|
||||
fun askBabyBottleContent(event: LunaEvent, showDetailsAtEnd : Boolean = false) {
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.number_picker_dialog, null)
|
||||
d.setTitle(R.string.log_bottle_dialog_title)
|
||||
d.setMessage(R.string.log_bottle_dialog_description)
|
||||
d.setView(dialogView)
|
||||
|
||||
val numberPicker = dialogView.findViewById<NumberPicker>(R.id.dialog_number_picker)
|
||||
numberPicker.minValue = 1 // "10"
|
||||
numberPicker.maxValue = 25 // "250
|
||||
numberPicker.displayedValues = ((10..250 step 10).map { it.toString() }.toTypedArray())
|
||||
numberPicker.wrapSelectorWheel = false
|
||||
numberPicker.value = localSettings.loadBabyBottleContent()
|
||||
numberPicker.value = event.quantity / 10
|
||||
|
||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||
val pickedDateTime = datePickHelper(event.time, dateTV)
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE, numberPicker.value * 10))
|
||||
localSettings.saveBabyBottleContent(numberPicker.value)
|
||||
val quantity = numberPicker.value * 10
|
||||
val time = pickedDateTime.time.time / 1000
|
||||
|
||||
if (event.time != time || event.quantity != quantity) {
|
||||
event.quantity = quantity
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
||||
dialogInterface.dismiss()
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askWeightValue() {
|
||||
fun askWeightValue(event: LunaEvent, showDetailsAtEnd: Boolean = false) {
|
||||
// Show number picker dialog
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.number_edit_dialog, null)
|
||||
@@ -226,19 +247,41 @@ class MainActivity : AppCompatActivity() {
|
||||
d.setMessage(R.string.log_weight_dialog_description)
|
||||
d.setView(dialogView)
|
||||
val weightET = dialogView.findViewById<EditText>(R.id.dialog_number_edittext)
|
||||
|
||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||
val pickedDateTime = datePickHelper(event.time, dateTV)
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val weight = weightET.text.toString().toIntOrNull()
|
||||
if (weight != null)
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_WEIGHT, weight))
|
||||
else
|
||||
if (weight != null) {
|
||||
val quantity = weight
|
||||
val time = pickedDateTime.time.time / 1000
|
||||
if (event.quantity != quantity || event.time != time) {
|
||||
event.quantity = quantity
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
dialogInterface.dismiss()
|
||||
}
|
||||
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askTemperatureValue() {
|
||||
fun askTemperatureValue(event: LunaEvent, showDetailsAtEnd: Boolean = false) {
|
||||
// Show number picker dialog
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.temperature_dialog, null)
|
||||
@@ -250,19 +293,75 @@ class MainActivity : AppCompatActivity() {
|
||||
tempSlider.valueFrom = range.first.toFloat()
|
||||
tempSlider.valueTo = range.second.toFloat()
|
||||
tempSlider.value = range.third.toFloat()
|
||||
|
||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||
val pickedDateTime = datePickHelper(event.time, dateTV)
|
||||
|
||||
val tempTextView = dialogView.findViewById<TextView>(R.id.dialog_temperature_display)
|
||||
|
||||
tempTextView.text = range.third.toString()
|
||||
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))
|
||||
val quantity = (tempSlider.value * 10).toInt() // temperature in tenth of a grade
|
||||
val time = pickedDateTime.time.time / 1000
|
||||
if (event.time != time || event.quantity != quantity) {
|
||||
event.quantity = quantity
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
||||
dialogInterface.dismiss()
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askPukeValue() {
|
||||
fun datePickHelper(eventTime: Long, dateTextView: TextView): Calendar {
|
||||
val fmt = getString(R.string.dialog_event_detail_datetime_icon)
|
||||
dateTextView.text = String.format(fmt, DateUtils.formatDateTime(eventTime))
|
||||
|
||||
val dateTime = Calendar.getInstance()
|
||||
dateTime.time = Date(eventTime * 1000)
|
||||
dateTextView.setOnClickListener {
|
||||
// Show datetime picker
|
||||
val startYear = dateTime.get(Calendar.YEAR)
|
||||
val startMonth = dateTime.get(Calendar.MONTH)
|
||||
val startDay = dateTime.get(Calendar.DAY_OF_MONTH)
|
||||
val startHour = dateTime.get(Calendar.HOUR_OF_DAY)
|
||||
val startMinute = dateTime.get(Calendar.MINUTE)
|
||||
|
||||
DatePickerDialog(this, { _, year, month, day ->
|
||||
TimePickerDialog(this, { _, hour, minute ->
|
||||
dateTime.set(year, month, day, hour, minute)
|
||||
val time = dateTime.time.time / 1000
|
||||
dateTextView.text = String.format(getString(R.string.dialog_event_detail_datetime_icon), DateUtils.formatDateTime(time))
|
||||
}, startHour, startMinute, android.text.format.DateFormat.is24HourFormat(this@MainActivity)).show()
|
||||
}, startYear, startMonth, startDay).show()
|
||||
}
|
||||
|
||||
return dateTime
|
||||
}
|
||||
|
||||
fun saveEvent(event: LunaEvent) {
|
||||
if (!getAllEvents().contains(event)) {
|
||||
// new event
|
||||
logEvent(event)
|
||||
}
|
||||
|
||||
logbook?.sort()
|
||||
recyclerView.adapter?.notifyDataSetChanged()
|
||||
saveLogbook()
|
||||
}
|
||||
|
||||
fun askPukeValue(event: LunaEvent, showDetailsAtEnd: Boolean = false) {
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.puke_dialog, null)
|
||||
d.setTitle(R.string.log_puke_dialog_title)
|
||||
@@ -271,42 +370,132 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
val spinner = dialogView.findViewById<Spinner>(R.id.dialog_puke_value)
|
||||
spinner.adapter = ArrayAdapter.createFromResource(this, R.array.AmountLabels, android.R.layout.simple_spinner_dropdown_item)
|
||||
spinner.setSelection(1)
|
||||
spinner.setSelection(event.quantity)
|
||||
|
||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||
val pickedDateTime = datePickHelper(event.time, dateTV)
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val pos = spinner.selectedItemPosition
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos + 1))
|
||||
val quantity = spinner.selectedItemPosition + 1
|
||||
val time = pickedDateTime.time.time / 1000
|
||||
if (event.quantity != quantity || event.time != time) {
|
||||
event.quantity = quantity
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
||||
dialogInterface.dismiss()
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askNotes(lunaEvent: LunaEvent) {
|
||||
// Ask to edit events to be edited (only affects date)
|
||||
fun askPlain(event: LunaEvent, showDetailsAtEnd: Boolean = false) {
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.dialog_plain_event, null)
|
||||
d.setTitle(event.getTypeDescription(this))
|
||||
d.setMessage(event.getDialogMessage(this))
|
||||
d.setView(dialogView)
|
||||
|
||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||
val pickedDateTime = datePickHelper(event.time, dateTV)
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val time = pickedDateTime.time.time / 1000
|
||||
if (event.time != time) {
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
||||
dialogInterface.dismiss()
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askNotes(event: LunaEvent, showDetailsAtEnd: Boolean = false) {
|
||||
val useQuantity = (event.type != LunaEvent.TYPE_NOTE && event.type != LunaEvent.TYPE_CUSTOM)
|
||||
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
||||
d.setTitle(lunaEvent.getTypeDescription(this))
|
||||
d.setMessage(lunaEvent.getDialogMessage(this))
|
||||
d.setTitle(event.getTypeDescription(this))
|
||||
d.setMessage(event.getDialogMessage(this))
|
||||
d.setView(dialogView)
|
||||
val notesET = dialogView.findViewById<EditText>(R.id.notes_edittext)
|
||||
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
||||
if (lunaEvent.type == LunaEvent.TYPE_NOTE || lunaEvent.type == LunaEvent.TYPE_CUSTOM)
|
||||
|
||||
val dateTV = dialogView.findViewById<TextView>(R.id.notes_date_picker)
|
||||
val pickedDateTime = datePickHelper(event.time, dateTV)
|
||||
|
||||
notesET.setText(event.notes)
|
||||
|
||||
if (useQuantity) {
|
||||
qtyET.setText(event.quantity.toString())
|
||||
} else {
|
||||
qtyET.visibility = View.GONE
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val qtyStr = qtyET.text.toString()
|
||||
if (qtyStr.isNotEmpty()) {
|
||||
val qty = qtyStr.toIntOrNull()
|
||||
if (qty == null) {
|
||||
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
||||
return@setPositiveButton
|
||||
}
|
||||
lunaEvent.quantity = qty
|
||||
}
|
||||
val notes = notesET.text.toString()
|
||||
lunaEvent.notes = notes
|
||||
logEvent(lunaEvent)
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val notes = notesET.text.toString()
|
||||
val time = pickedDateTime.time.time / 1000
|
||||
|
||||
if (useQuantity) {
|
||||
val quantity = qtyET.text.toString().toIntOrNull()
|
||||
if (quantity != null) {
|
||||
if (event.time != time || event.notes != notes || event.quantity != quantity ) {
|
||||
event.quantity = quantity
|
||||
event.notes = notes
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
} else {
|
||||
if (event.time != time || event.notes != notes) {
|
||||
event.notes = notes
|
||||
event.time = time
|
||||
saveEvent(event)
|
||||
}
|
||||
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
||||
dialogInterface.dismiss()
|
||||
if (showDetailsAtEnd) {
|
||||
showEventDetailDialog(event)
|
||||
}
|
||||
}
|
||||
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
@@ -359,55 +548,57 @@ class MainActivity : AppCompatActivity() {
|
||||
return nextEvent
|
||||
}
|
||||
|
||||
fun showEventDetailDialog(event: LunaEvent, items: ArrayList<LunaEvent>) {
|
||||
fun showEventDetailDialog(event: LunaEvent) {
|
||||
// Do not update list while the detail is shown, to avoid changing the object below while it is changed by the user
|
||||
pauseLogbookUpdate = true
|
||||
val d = AlertDialog.Builder(this)
|
||||
d.setTitle(R.string.dialog_event_detail_title)
|
||||
val dialogView = layoutInflater.inflate(R.layout.dialog_event_detail, null)
|
||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_emoji).text = event.getTypeEmoji(this)
|
||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description).text = event.getTypeDescription(this)
|
||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity).text =
|
||||
NumericUtils(this).formatEventQuantity(event)
|
||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).text = event.notes
|
||||
val emojiTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_emoji)
|
||||
val descriptionTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description)
|
||||
val quantityTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity)
|
||||
val notesTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes)
|
||||
|
||||
val currentDateTime = Calendar.getInstance()
|
||||
currentDateTime.time = Date(event.time * 1000)
|
||||
emojiTextView.text = event.getTypeEmoji(this)
|
||||
descriptionTextView.text = event.getTypeDescription(this)
|
||||
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
||||
notesTextView.text = event.notes
|
||||
|
||||
val dateTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_date)
|
||||
dateTextView.text = String.format(getString(R.string.dialog_event_detail_datetime_icon), DateUtils.formatDateTime(event.time))
|
||||
dateTextView.setOnClickListener {
|
||||
// Show datetime picker
|
||||
val startYear = currentDateTime.get(Calendar.YEAR)
|
||||
val startMonth = currentDateTime.get(Calendar.MONTH)
|
||||
val startDay = currentDateTime.get(Calendar.DAY_OF_MONTH)
|
||||
val startHour = currentDateTime.get(Calendar.HOUR_OF_DAY)
|
||||
val startMinute = currentDateTime.get(Calendar.MINUTE)
|
||||
|
||||
DatePickerDialog(this, { _, year, month, day ->
|
||||
TimePickerDialog(this, { _, hour, minute ->
|
||||
val pickedDateTime = Calendar.getInstance()
|
||||
pickedDateTime.set(year, month, day, hour, minute)
|
||||
// Save event and move it to the right position in the logbook
|
||||
event.time = pickedDateTime.time.time / 1000 // Seconds since epoch
|
||||
dateTextView.text = String.format(getString(R.string.dialog_event_detail_datetime_icon), DateUtils.formatDateTime(event.time))
|
||||
logbook?.sort()
|
||||
recyclerView.adapter?.notifyDataSetChanged()
|
||||
saveLogbook()
|
||||
}, startHour, startMinute, android.text.format.DateFormat.is24HourFormat(this@MainActivity)).show()
|
||||
}, startYear, startMonth, startDay).show()
|
||||
}
|
||||
|
||||
d.setView(dialogView)
|
||||
d.setPositiveButton(R.string.dialog_event_detail_close_button) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
d.setNeutralButton(R.string.dialog_event_detail_delete_button) { dialogInterface, i -> deleteEvent(event) }
|
||||
d.setNegativeButton(R.string.dialog_event_detail_edit_button) { dialogInterface, i ->
|
||||
Log.d("MainActivity", "negative button pressed: ${event.type}")
|
||||
when (event.type) {
|
||||
LunaEvent.TYPE_BABY_BOTTLE -> askBabyBottleContent(event, true)
|
||||
LunaEvent.TYPE_WEIGHT -> askWeightValue(event, true)
|
||||
LunaEvent.TYPE_BREASTFEEDING_LEFT_NIPPLE,
|
||||
LunaEvent.TYPE_BREASTFEEDING_BOTH_NIPPLE,
|
||||
LunaEvent.TYPE_BREASTFEEDING_RIGHT_NIPPLE,
|
||||
LunaEvent.TYPE_ENEMA,
|
||||
LunaEvent.TYPE_BATH,
|
||||
LunaEvent.TYPE_COLIC,
|
||||
LunaEvent.TYPE_CUSTOM,
|
||||
LunaEvent.TYPE_DIAPERCHANGE_POO,
|
||||
LunaEvent.TYPE_DIAPERCHANGE_PEE -> askPlain(event, true)
|
||||
LunaEvent.TYPE_MEDICINE -> askNotes(event, true)
|
||||
LunaEvent.TYPE_NOTE -> askNotes(event, true)
|
||||
LunaEvent.TYPE_TEMPERATURE -> askTemperatureValue(event, true)
|
||||
LunaEvent.TYPE_FOOD -> askNotes(event, true)
|
||||
LunaEvent.TYPE_PUKE -> askPukeValue(event, true)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(ContextCompat.getColor(this, R.color.danger))
|
||||
alertDialog.setOnDismissListener({
|
||||
alertDialog.setOnDismissListener {
|
||||
// Resume logbook update
|
||||
pauseLogbookUpdate = false
|
||||
})
|
||||
}
|
||||
|
||||
// show optional signature
|
||||
if (event.signature.isNotEmpty()) {
|
||||
@@ -420,8 +611,9 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
val previousTextView = dialogView.findViewById<TextView>(R.id.dialog_event_previous)
|
||||
val nextTextView = dialogView.findViewById<TextView>(R.id.dialog_event_next)
|
||||
val nextEvent = getNextSameEvent(event, items)
|
||||
val previousEvent = getPreviousSameEvent(event, items)
|
||||
val allEvents = getAllEvents()
|
||||
val nextEvent = getNextSameEvent(event, allEvents)
|
||||
val previousEvent = getPreviousSameEvent(event, allEvents)
|
||||
|
||||
if (previousEvent != null) {
|
||||
val emoji = previousEvent.getTypeEmoji(applicationContext)
|
||||
@@ -429,7 +621,7 @@ class MainActivity : AppCompatActivity() {
|
||||
previousTextView.text = String.format("⬅️ %s %s", emoji, time)
|
||||
previousTextView.setOnClickListener {
|
||||
alertDialog.cancel()
|
||||
showEventDetailDialog(previousEvent, items)
|
||||
showEventDetailDialog(previousEvent)
|
||||
}
|
||||
} else {
|
||||
previousTextView.visibility = View.GONE
|
||||
@@ -441,7 +633,7 @@ class MainActivity : AppCompatActivity() {
|
||||
nextTextView.text = String.format("%s %s ➡️", time, emoji)
|
||||
nextTextView.setOnClickListener {
|
||||
alertDialog.cancel()
|
||||
showEventDetailDialog(nextEvent, items)
|
||||
showEventDetailDialog(nextEvent)
|
||||
}
|
||||
} else {
|
||||
nextTextView.visibility = View.GONE
|
||||
@@ -804,38 +996,34 @@ class MainActivity : AppCompatActivity() {
|
||||
askNotes(LunaEvent(LunaEvent.TYPE_MEDICINE))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_enema).setOnClickListener({
|
||||
contentView.findViewById<View>(R.id.button_enema).setOnClickListener {
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_ENEMA))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_note).setOnClickListener({
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_note).setOnClickListener {
|
||||
askNotes(LunaEvent(LunaEvent.TYPE_NOTE))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_temperature).setOnClickListener({
|
||||
askTemperatureValue()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_temperature).setOnClickListener {
|
||||
askTemperatureValue(LunaEvent(LunaEvent.TYPE_TEMPERATURE))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_puke).setOnClickListener({
|
||||
askPukeValue()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_puke).setOnClickListener {
|
||||
askPukeValue(LunaEvent(LunaEvent.TYPE_PUKE))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_colic).setOnClickListener({
|
||||
logEvent(
|
||||
LunaEvent(LunaEvent.TYPE_COLIC)
|
||||
)
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_colic).setOnClickListener {
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_COLIC))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_scale).setOnClickListener({
|
||||
askWeightValue()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_scale).setOnClickListener {
|
||||
askWeightValue(LunaEvent(LunaEvent.TYPE_WEIGHT))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_bath).setOnClickListener({
|
||||
logEvent(
|
||||
LunaEvent(LunaEvent.TYPE_BATH)
|
||||
)
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_bath).setOnClickListener {
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_BATH))
|
||||
dismiss()
|
||||
})
|
||||
}
|
||||
}.also { popupWindow ->
|
||||
popupWindow.setOnDismissListener({
|
||||
Handler(mainLooper).postDelayed({
|
||||
|
||||
@@ -23,14 +23,6 @@ class LocalSettingsRepository(val context: Context) {
|
||||
sharedPreferences = context.getSharedPreferences(SHARED_PREFS_FILE_NAME, MODE_PRIVATE)
|
||||
}
|
||||
|
||||
fun saveBabyBottleContent(content: Int) {
|
||||
sharedPreferences.edit { putInt(SHARED_PREFS_BB_CONTENT, content) }
|
||||
}
|
||||
|
||||
fun loadBabyBottleContent(): Int {
|
||||
return sharedPreferences.getInt(SHARED_PREFS_BB_CONTENT, 1)
|
||||
}
|
||||
|
||||
fun saveSignature(content: String) {
|
||||
sharedPreferences.edit { putString(SHARED_PREFS_SIGNATURE, content) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -37,8 +36,7 @@
|
||||
android:drawableTint="@color/accent"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/dialog_event_detail_datetime_icon"
|
||||
app:drawableEndCompat="@drawable/ic_edit" />
|
||||
android:text="@string/dialog_event_detail_datetime_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_event_detail_type_quantity"
|
||||
|
||||
@@ -24,4 +24,11 @@
|
||||
android:hint="@string/log_notes_dialog_note_hint"
|
||||
android:background="@drawable/textview_background"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/notes_date_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
16
app/src/main/res/layout/dialog_plain_event.xml
Normal file
16
app/src/main/res/layout/dialog_plain_event.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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:orientation="vertical">
|
||||
|
||||
<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"
|
||||
android:layout_marginEnd="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -3,20 +3,36 @@
|
||||
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">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dialog_number_edittext"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:hint="0"
|
||||
android:background="@drawable/textview_background"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dialog_number_edittext"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:hint="0"
|
||||
android:background="@drawable/textview_background"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="g"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_date_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="g"/>
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -3,17 +3,33 @@
|
||||
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">
|
||||
|
||||
<NumberPicker
|
||||
android:id="@+id/dialog_number_picker"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<NumberPicker
|
||||
android:id="@+id/dialog_number_picker"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="ml"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_date_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="ml"/>
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -14,4 +14,11 @@
|
||||
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_gravity="center"
|
||||
android:layout_marginEnd="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -23,4 +23,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="30sp"
|
||||
android:textColor="@color/accent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_date_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<string name="log_puke_dialog_title">Puke</string>
|
||||
<string name="log_puke_dialog_description">Select the amount</string>
|
||||
|
||||
<string name="dialog_event_detail_edit_button">Edit</string>
|
||||
|
||||
<string name="event_bottle_type" translatable="false">🍼</string>
|
||||
<string name="event_food_type" translatable="false">🥣</string>
|
||||
<string name="event_scale_type" translatable="false">⚖️</string>
|
||||
|
||||
Reference in New Issue
Block a user