Compare commits
3 Commits
cbba6b7a90
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 5eeb462836 | |||
| 5b777c0b88 | |||
| 6f3061974d |
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId = "it.danieleverducci.lunatracker"
|
applicationId = "it.danieleverducci.lunatracker"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 6
|
versionCode = 7
|
||||||
versionName = "0.8"
|
versionName = "0.9"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.content.DialogInterface
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.text.Editable
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -22,7 +21,6 @@ import android.widget.Toast
|
|||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.widget.doOnTextChanged
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
@@ -31,7 +29,6 @@ import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
|||||||
import it.danieleverducci.lunatracker.adapters.LunaEventRecyclerAdapter
|
import it.danieleverducci.lunatracker.adapters.LunaEventRecyclerAdapter
|
||||||
import it.danieleverducci.lunatracker.entities.Logbook
|
import it.danieleverducci.lunatracker.entities.Logbook
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEvent
|
import it.danieleverducci.lunatracker.entities.LunaEvent
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEvent.Companion.TYPE_BABY_BOTTLE
|
|
||||||
import it.danieleverducci.lunatracker.repository.FileLogbookRepository
|
import it.danieleverducci.lunatracker.repository.FileLogbookRepository
|
||||||
import it.danieleverducci.lunatracker.repository.LocalSettingsRepository
|
import it.danieleverducci.lunatracker.repository.LocalSettingsRepository
|
||||||
import it.danieleverducci.lunatracker.repository.LogbookListObtainedListener
|
import it.danieleverducci.lunatracker.repository.LogbookListObtainedListener
|
||||||
@@ -135,7 +132,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val adapter = LunaEventRecyclerAdapter(this, items)
|
val adapter = LunaEventRecyclerAdapter(this, items)
|
||||||
adapter.onItemClickListener = object: LunaEventRecyclerAdapter.OnItemClickListener {
|
adapter.onItemClickListener = object: LunaEventRecyclerAdapter.OnItemClickListener {
|
||||||
override fun onItemClick(event: LunaEvent) {
|
override fun onItemClick(event: LunaEvent) {
|
||||||
showEventDetailDialog(event)
|
showEventDetailDialog(event, items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
@@ -198,73 +195,25 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onStop()
|
super.onStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllEvents(): ArrayList<LunaEvent> {
|
fun askBabyBottleContent() {
|
||||||
return logbook?.logs ?: arrayListOf()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun askBabyBottleContent(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) {
|
|
||||||
val isNewEvent = (existingEvent != null)
|
|
||||||
// Show number picker dialog
|
// Show number picker dialog
|
||||||
val event = if (existingEvent == null) {
|
val localSettings = LocalSettingsRepository(this)
|
||||||
LunaEvent(TYPE_BABY_BOTTLE)
|
|
||||||
} else {
|
|
||||||
existingEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
val previous = getPreviousSameEvent(event, getAllEvents())
|
|
||||||
val d = AlertDialog.Builder(this)
|
val d = AlertDialog.Builder(this)
|
||||||
val dialogView = layoutInflater.inflate(R.layout.number_picker_dialog, null)
|
val dialogView = layoutInflater.inflate(R.layout.number_picker_dialog, null)
|
||||||
d.setTitle(R.string.log_bottle_dialog_title)
|
d.setTitle(R.string.log_bottle_dialog_title)
|
||||||
d.setMessage(R.string.log_bottle_dialog_description)
|
d.setMessage(R.string.log_bottle_dialog_description)
|
||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
|
|
||||||
val numberPicker = dialogView.findViewById<NumberPicker>(R.id.dialog_number_picker)
|
val numberPicker = dialogView.findViewById<NumberPicker>(R.id.dialog_number_picker)
|
||||||
numberPicker.minValue = 1 // "10"
|
numberPicker.minValue = 1 // "10"
|
||||||
numberPicker.maxValue = 25 // "250
|
numberPicker.maxValue = 25 // "250
|
||||||
numberPicker.displayedValues = ((10..250 step 10).map { it.toString() }.toTypedArray())
|
numberPicker.displayedValues = ((10..250 step 10).map { it.toString() }.toTypedArray())
|
||||||
numberPicker.wrapSelectorWheel = false
|
numberPicker.wrapSelectorWheel = false
|
||||||
if (previous != null) {
|
numberPicker.value = localSettings.loadBabyBottleContent()
|
||||||
numberPicker.value = previous.quantity / 10
|
|
||||||
}
|
|
||||||
|
|
||||||
val dateTextView = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
|
||||||
dateTextView.text =
|
|
||||||
String.format(getString(R.string.dialog_event_detail_datetime_icon), DateUtils.formatDateTime(event.time))
|
|
||||||
val currentDateTime = Calendar.getInstance()
|
|
||||||
currentDateTime.time = Date(event.time * 1000)
|
|
||||||
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))
|
|
||||||
}, startHour, startMinute, android.text.format.DateFormat.is24HourFormat(this@MainActivity)).show()
|
|
||||||
}, startYear, startMonth, startDay).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
event.quantity = numberPicker.value * 10
|
logEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE, numberPicker.value * 10))
|
||||||
if (isNewEvent) {
|
localSettings.saveBabyBottleContent(numberPicker.value)
|
||||||
logEvent(event)
|
|
||||||
}
|
|
||||||
logbook?.sort()
|
|
||||||
recyclerView.adapter?.notifyDataSetChanged()
|
|
||||||
saveLogbook()
|
|
||||||
onEnd?.invoke()
|
|
||||||
}
|
|
||||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
|
||||||
dialogInterface.dismiss()
|
|
||||||
onEnd?.invoke()
|
|
||||||
}
|
}
|
||||||
|
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
val alertDialog = d.create()
|
val alertDialog = d.create()
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
@@ -326,93 +275,38 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
val pos = spinner.selectedItemPosition
|
val pos = spinner.selectedItemPosition
|
||||||
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos))
|
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos + 1))
|
||||||
}
|
}
|
||||||
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()
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun askNotes(existingEvent: LunaEvent? = null, onEnd: (() -> Unit)? = null) {
|
fun askNotes(lunaEvent: LunaEvent) {
|
||||||
val isNewEvent = (existingEvent != null)
|
|
||||||
// Show number picker dialog
|
|
||||||
val event = if (existingEvent == null) {
|
|
||||||
LunaEvent(TYPE_BABY_BOTTLE)
|
|
||||||
} else {
|
|
||||||
existingEvent
|
|
||||||
}
|
|
||||||
val useQuantity = (event.type != LunaEvent.TYPE_NOTE && event.type != LunaEvent.TYPE_CUSTOM)
|
|
||||||
|
|
||||||
val d = AlertDialog.Builder(this)
|
val d = AlertDialog.Builder(this)
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
||||||
d.setTitle(event.getTypeDescription(this))
|
d.setTitle(lunaEvent.getTypeDescription(this))
|
||||||
d.setMessage(event.getDialogMessage(this))
|
d.setMessage(lunaEvent.getDialogMessage(this))
|
||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
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 dateET = dialogView.findViewById<TextView>(R.id.notes_date_picker)
|
if (lunaEvent.type == LunaEvent.TYPE_NOTE || lunaEvent.type == LunaEvent.TYPE_CUSTOM)
|
||||||
|
|
||||||
val currentDateTime = Calendar.getInstance()
|
|
||||||
currentDateTime.time = Date(event.time * 1000)
|
|
||||||
|
|
||||||
dateET.text = String.format(getString(R.string.dialog_event_detail_datetime_icon), DateUtils.formatDateTime(event.time))
|
|
||||||
dateET.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
|
|
||||||
dateET.setText(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()
|
|
||||||
}
|
|
||||||
|
|
||||||
notesET.setText(event.notes)
|
|
||||||
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(event.quantity.toString())
|
|
||||||
} else {
|
|
||||||
qtyET.visibility = View.GONE
|
qtyET.visibility = View.GONE
|
||||||
}
|
|
||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
if (useQuantity) {
|
val qtyStr = qtyET.text.toString()
|
||||||
val qty = qtyET.text.toString().toIntOrNull()
|
if (qtyStr.isNotEmpty()) {
|
||||||
if (qty != null) {
|
val qty = qtyStr.toIntOrNull()
|
||||||
event.quantity = qty
|
if (qty == null) {
|
||||||
event.notes = notesET.text.toString()
|
|
||||||
} 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()
|
||||||
onEnd?.invoke()
|
|
||||||
return@setPositiveButton
|
return@setPositiveButton
|
||||||
}
|
}
|
||||||
} else {
|
lunaEvent.quantity = qty
|
||||||
event.notes = notesET.text.toString()
|
|
||||||
}
|
}
|
||||||
|
val notes = notesET.text.toString()
|
||||||
if (isNewEvent) {
|
lunaEvent.notes = notes
|
||||||
logEvent(event)
|
logEvent(lunaEvent)
|
||||||
}
|
}
|
||||||
|
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
onEnd?.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i ->
|
|
||||||
dialogInterface.dismiss()
|
|
||||||
onEnd?.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
val alertDialog = d.create()
|
val alertDialog = d.create()
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
@@ -465,28 +359,23 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return nextEvent
|
return nextEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showEventDetailDialog(event: LunaEvent) {
|
fun showEventDetailDialog(event: LunaEvent, items: ArrayList<LunaEvent>) {
|
||||||
// Do not update list while the detail is shown, to avoid changing the object below while it is changed by the user
|
// Do not update list while the detail is shown, to avoid changing the object below while it is changed by the user
|
||||||
pauseLogbookUpdate = true
|
pauseLogbookUpdate = true
|
||||||
val d = AlertDialog.Builder(this)
|
val d = AlertDialog.Builder(this)
|
||||||
d.setTitle(R.string.dialog_event_detail_title)
|
d.setTitle(R.string.dialog_event_detail_title)
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_event_detail, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_event_detail, null)
|
||||||
val emojiTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_emoji)
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_emoji).text = event.getTypeEmoji(this)
|
||||||
val descriptionTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description)
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description).text = event.getTypeDescription(this)
|
||||||
val quantityTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity)
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity).text =
|
||||||
val notesTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes)
|
NumericUtils(this).formatEventQuantity(event)
|
||||||
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).text = event.notes
|
||||||
emojiTextView.text = event.getTypeEmoji(this)
|
|
||||||
descriptionTextView.text = event.getTypeDescription(this)
|
|
||||||
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
|
||||||
notesTextView.text = event.notes
|
|
||||||
|
|
||||||
|
val currentDateTime = Calendar.getInstance()
|
||||||
|
currentDateTime.time = Date(event.time * 1000)
|
||||||
|
|
||||||
val dateTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_date)
|
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.text = String.format(getString(R.string.dialog_event_detail_datetime_icon), DateUtils.formatDateTime(event.time))
|
||||||
/*
|
|
||||||
val currentDateTime = Calendar.getInstance()
|
|
||||||
currentDateTime.time = Date(event.time * 1000)
|
|
||||||
dateTextView.setOnClickListener {
|
dateTextView.setOnClickListener {
|
||||||
// Show datetime picker
|
// Show datetime picker
|
||||||
val startYear = currentDateTime.get(Calendar.YEAR)
|
val startYear = currentDateTime.get(Calendar.YEAR)
|
||||||
@@ -507,40 +396,18 @@ class MainActivity : AppCompatActivity() {
|
|||||||
saveLogbook()
|
saveLogbook()
|
||||||
}, startHour, startMinute, android.text.format.DateFormat.is24HourFormat(this@MainActivity)).show()
|
}, startHour, startMinute, android.text.format.DateFormat.is24HourFormat(this@MainActivity)).show()
|
||||||
}, startYear, startMonth, startDay).show()
|
}, startYear, startMonth, startDay).show()
|
||||||
}*/
|
}
|
||||||
|
|
||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
d.setPositiveButton(R.string.dialog_event_detail_close_button) { dialogInterface, i -> dialogInterface.dismiss() }
|
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.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) {
|
|
||||||
TYPE_BABY_BOTTLE -> askBabyBottleContent(event, { showEventDetailDialog(event) })
|
|
||||||
LunaEvent.TYPE_WEIGHT -> {}
|
|
||||||
LunaEvent.TYPE_BREASTFEEDING_LEFT_NIPPLE,
|
|
||||||
LunaEvent.TYPE_BREASTFEEDING_BOTH_NIPPLE,
|
|
||||||
LunaEvent.TYPE_BREASTFEEDING_RIGHT_NIPPLE -> {}
|
|
||||||
LunaEvent.TYPE_DIAPERCHANGE_POO,
|
|
||||||
LunaEvent.TYPE_DIAPERCHANGE_PEE -> {}
|
|
||||||
LunaEvent.TYPE_MEDICINE -> askNotes(event, { showEventDetailDialog(event) })
|
|
||||||
LunaEvent.TYPE_ENEMA -> {}
|
|
||||||
LunaEvent.TYPE_NOTE -> askNotes(event, { showEventDetailDialog(event) })
|
|
||||||
LunaEvent.TYPE_TEMPERATURE,
|
|
||||||
LunaEvent.TYPE_COLIC,
|
|
||||||
LunaEvent.TYPE_FOOD,
|
|
||||||
LunaEvent.TYPE_PUKE,
|
|
||||||
LunaEvent.TYPE_BATH,
|
|
||||||
LunaEvent.TYPE_CUSTOM -> {}
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val alertDialog = d.create()
|
val alertDialog = d.create()
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(ContextCompat.getColor(this, R.color.danger))
|
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(ContextCompat.getColor(this, R.color.danger))
|
||||||
alertDialog.setOnDismissListener {
|
alertDialog.setOnDismissListener({
|
||||||
// Resume logbook update
|
// Resume logbook update
|
||||||
pauseLogbookUpdate = false
|
pauseLogbookUpdate = false
|
||||||
}
|
})
|
||||||
|
|
||||||
// show optional signature
|
// show optional signature
|
||||||
if (event.signature.isNotEmpty()) {
|
if (event.signature.isNotEmpty()) {
|
||||||
@@ -553,9 +420,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val previousTextView = dialogView.findViewById<TextView>(R.id.dialog_event_previous)
|
val previousTextView = dialogView.findViewById<TextView>(R.id.dialog_event_previous)
|
||||||
val nextTextView = dialogView.findViewById<TextView>(R.id.dialog_event_next)
|
val nextTextView = dialogView.findViewById<TextView>(R.id.dialog_event_next)
|
||||||
val allEvents = getAllEvents()
|
val nextEvent = getNextSameEvent(event, items)
|
||||||
val nextEvent = getNextSameEvent(event, allEvents)
|
val previousEvent = getPreviousSameEvent(event, items)
|
||||||
val previousEvent = getPreviousSameEvent(event, allEvents)
|
|
||||||
|
|
||||||
if (previousEvent != null) {
|
if (previousEvent != null) {
|
||||||
val emoji = previousEvent.getTypeEmoji(applicationContext)
|
val emoji = previousEvent.getTypeEmoji(applicationContext)
|
||||||
@@ -563,7 +429,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
previousTextView.text = String.format("⬅️ %s %s", emoji, time)
|
previousTextView.text = String.format("⬅️ %s %s", emoji, time)
|
||||||
previousTextView.setOnClickListener {
|
previousTextView.setOnClickListener {
|
||||||
alertDialog.cancel()
|
alertDialog.cancel()
|
||||||
showEventDetailDialog(previousEvent)
|
showEventDetailDialog(previousEvent, items)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
previousTextView.visibility = View.GONE
|
previousTextView.visibility = View.GONE
|
||||||
@@ -575,7 +441,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
nextTextView.text = String.format("%s %s ➡️", time, emoji)
|
nextTextView.text = String.format("%s %s ➡️", time, emoji)
|
||||||
nextTextView.setOnClickListener {
|
nextTextView.setOnClickListener {
|
||||||
alertDialog.cancel()
|
alertDialog.cancel()
|
||||||
showEventDetailDialog(nextEvent)
|
showEventDetailDialog(nextEvent, items)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nextTextView.visibility = View.GONE
|
nextTextView.visibility = View.GONE
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ class LocalSettingsRepository(val context: Context) {
|
|||||||
sharedPreferences = context.getSharedPreferences(SHARED_PREFS_FILE_NAME, MODE_PRIVATE)
|
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) {
|
fun saveSignature(content: String) {
|
||||||
sharedPreferences.edit { putString(SHARED_PREFS_SIGNATURE, content) }
|
sharedPreferences.edit { putString(SHARED_PREFS_SIGNATURE, content) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class NumericUtils (val context: Context) {
|
|||||||
LunaEvent.TYPE_TEMPERATURE ->
|
LunaEvent.TYPE_TEMPERATURE ->
|
||||||
(item.quantity / 10.0f).toString()
|
(item.quantity / 10.0f).toString()
|
||||||
LunaEvent.TYPE_PUKE ->
|
LunaEvent.TYPE_PUKE ->
|
||||||
context.resources.getStringArray(R.array.AmountLabels)[item.quantity]
|
context.resources.getStringArray(R.array.AmountLabels)[item.quantity - 1]
|
||||||
else ->
|
else ->
|
||||||
item.quantity
|
item.quantity
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -36,7 +37,8 @@
|
|||||||
android:drawableTint="@color/accent"
|
android:drawableTint="@color/accent"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="@string/dialog_event_detail_datetime_icon" />
|
android:text="@string/dialog_event_detail_datetime_icon"
|
||||||
|
app:drawableEndCompat="@drawable/ic_edit" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_event_detail_type_quantity"
|
android:id="@+id/dialog_event_detail_type_quantity"
|
||||||
|
|||||||
@@ -24,11 +24,4 @@
|
|||||||
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"/>
|
||||||
|
|
||||||
<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>
|
</LinearLayout>
|
||||||
@@ -1,16 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
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_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
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:layout_gravity="center"
|
||||||
android:gravity="center"
|
android:gravity="center">
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<NumberPicker
|
<NumberPicker
|
||||||
android:id="@+id/dialog_number_picker"
|
android:id="@+id/dialog_number_picker"
|
||||||
@@ -22,14 +16,4 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:text="ml"/>
|
android:text="ml"/>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<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>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
<string name="log_puke_dialog_title">Puke</string>
|
<string name="log_puke_dialog_title">Puke</string>
|
||||||
<string name="log_puke_dialog_description">Select the amount</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_bottle_type" translatable="false">🍼</string>
|
||||||
<string name="event_food_type" translatable="false">🥣</string>
|
<string name="event_food_type" translatable="false">🥣</string>
|
||||||
<string name="event_scale_type" translatable="false">⚖️</string>
|
<string name="event_scale_type" translatable="false">⚖️</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user