Compare commits
29 Commits
v0.1
...
e23ab77274
Author | SHA1 | Date | |
---|---|---|---|
e23ab77274 | |||
e3aceaf133 | |||
0494a11538 | |||
ecbde64ca1 | |||
32fbeac079 | |||
0b0fd8f5af | |||
fe5da015cb | |||
b1e26f8a96 | |||
48017f70f6 | |||
524a121149 | |||
e1388f9bad | |||
90761afef2 | |||
b02a6c9aad | |||
0d331d90ff | |||
5d17ebf46b | |||
3cbc4139ae | |||
f31c68193a | |||
de5b1d4ead | |||
de75ed584b | |||
a4b43ffb10 | |||
37b68450da | |||
841da9e28e | |||
876c68ce81 | |||
35a3b42a32 | |||
d5cb30cdd7 | |||
57f997e6f1 | |||
7b44d0c610 | |||
abee1be72c | |||
653c57e6e0 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -106,3 +106,4 @@ app/release/output-metadata.json
|
|||||||
|
|
||||||
# Other
|
# Other
|
||||||
app/src/main/java/it/danieleverducci/lunatracker/TemporaryHardcodedCredentials.kt
|
app/src/main/java/it/danieleverducci/lunatracker/TemporaryHardcodedCredentials.kt
|
||||||
|
.kotlin/sessions/*
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
LunaTracker is a newborn baby tracking app.
|
LunaTracker is a newborn baby tracking app.
|
||||||
|
|
||||||
Parenting can be tough. You get home from the hospital, exhausted, with this little fragile unknown thingy that has no user manual and a single way to let you know something's not ok: crying.
|
Parenting can be tough. You get home from the hospital, exhausted, with this little fragile unknown thingy that has no user manual and a single way to let you know something's not ok: crying.
|
||||||
You have to react fast, event if it's 4 AM and you have no idea why is crying.
|
You have to react fast, even if it's 4 AM and you have no idea why is crying.
|
||||||
|
|
||||||
This app is meant to log all the relevant events (diaper change, breastfeeding, baby bottle feeding...), so you can always remember when has been done last time. It supports syncing the data between different devices (using your WebDAV server for the best privacy) so that when the baby needs attentions, the dad can step in leaving the mom sleeping peacefully.
|
This app is meant to log all the relevant events (diaper change, breastfeeding, baby bottle feeding...), so you can always remember when has been done last time. It supports syncing the data between different devices (using your WebDAV server for the best privacy) so that when the baby needs attentions, the dad can step in leaving the mom sleeping peacefully.
|
||||||
|
|
||||||
Dedicated to my daughter Luna.
|
Dedicated to my daughter Luna.
|
||||||
|
|
||||||
|

|
||||||
|
@ -10,10 +10,10 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "it.danieleverducci.lunatracker"
|
applicationId = "it.danieleverducci.lunatracker"
|
||||||
minSdk = 29
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 2
|
||||||
versionName = "1.0"
|
versionName = "0.3"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,32 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.EditText
|
||||||
import android.widget.NumberPicker
|
import android.widget.NumberPicker
|
||||||
|
import android.widget.PopupWindow
|
||||||
|
import android.widget.Spinner
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
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.view.children
|
||||||
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
|
||||||
|
import com.google.android.material.slider.Slider
|
||||||
import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
||||||
import it.danieleverducci.lunatracker.SettingsActivity
|
|
||||||
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.LunaEventType
|
|
||||||
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.LogbookLoadedListener
|
import it.danieleverducci.lunatracker.repository.LogbookLoadedListener
|
||||||
import it.danieleverducci.lunatracker.repository.LogbookRepository
|
import it.danieleverducci.lunatracker.repository.LogbookRepository
|
||||||
import it.danieleverducci.lunatracker.repository.LogbookSavedListener
|
import it.danieleverducci.lunatracker.repository.LogbookSavedListener
|
||||||
@ -29,10 +37,15 @@ import it.danieleverducci.lunatracker.repository.WebDAVLogbookRepository
|
|||||||
import kotlinx.coroutines.Runnable
|
import kotlinx.coroutines.Runnable
|
||||||
import okio.IOException
|
import okio.IOException
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
import utils.NumericUtils
|
||||||
|
import java.text.DateFormat
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "MainActivity"
|
val TAG = "MainActivity"
|
||||||
|
val UPDATE_EVERY_SECS: Long = 30
|
||||||
|
val DEBUG_CHECK_LOGBOOK_CONSISTENCY = false
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var logbook: Logbook
|
lateinit var logbook: Logbook
|
||||||
@ -47,12 +60,18 @@ class MainActivity : AppCompatActivity() {
|
|||||||
handler.postDelayed(updateListRunnable, 1000*60)
|
handler.postDelayed(updateListRunnable, 1000*60)
|
||||||
}
|
}
|
||||||
var logbookRepo: LogbookRepository? = null
|
var logbookRepo: LogbookRepository? = null
|
||||||
|
var showingOverflowPopupWindow = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
handler = Handler(mainLooper)
|
handler = Handler(mainLooper)
|
||||||
adapter = LunaEventRecyclerAdapter(this)
|
adapter = LunaEventRecyclerAdapter(this)
|
||||||
|
adapter.onItemClickListener = object: LunaEventRecyclerAdapter.OnItemClickListener{
|
||||||
|
override fun onItemClick(event: LunaEvent) {
|
||||||
|
showEventDetailDialog(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Show view
|
// Show view
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
@ -64,33 +83,38 @@ class MainActivity : AppCompatActivity() {
|
|||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
|
|
||||||
// Set listeners
|
// Set listeners
|
||||||
|
findViewById<View>(R.id.logbooks_add_button).setOnClickListener { showAddLogbookDialog() }
|
||||||
findViewById<View>(R.id.button_bottle).setOnClickListener { askBabyBottleContent() }
|
findViewById<View>(R.id.button_bottle).setOnClickListener { askBabyBottleContent() }
|
||||||
findViewById<View>(R.id.button_scale).setOnClickListener { askWeightValue() }
|
findViewById<View>(R.id.button_scale).setOnClickListener { askWeightValue() }
|
||||||
findViewById<View>(R.id.button_nipple_left).setOnClickListener { logEvent(
|
findViewById<View>(R.id.button_nipple_left).setOnClickListener { logEvent(
|
||||||
LunaEvent(
|
LunaEvent(
|
||||||
LunaEventType.BREASTFEEDING_LEFT_NIPPLE
|
LunaEvent.TYPE_BREASTFEEDING_LEFT_NIPPLE
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
findViewById<View>(R.id.button_nipple_both).setOnClickListener { logEvent(
|
findViewById<View>(R.id.button_nipple_both).setOnClickListener { logEvent(
|
||||||
LunaEvent(
|
LunaEvent(
|
||||||
LunaEventType.BREASTFEEDING_BOTH_NIPPLE
|
LunaEvent.TYPE_BREASTFEEDING_BOTH_NIPPLE
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
findViewById<View>(R.id.button_nipple_right).setOnClickListener { logEvent(
|
findViewById<View>(R.id.button_nipple_right).setOnClickListener { logEvent(
|
||||||
LunaEvent(
|
LunaEvent(
|
||||||
LunaEventType.BREASTFEEDING_RIGHT_NIPPLE
|
LunaEvent.TYPE_BREASTFEEDING_RIGHT_NIPPLE
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
findViewById<View>(R.id.button_change_poo).setOnClickListener { logEvent(
|
findViewById<View>(R.id.button_change_poo).setOnClickListener { logEvent(
|
||||||
LunaEvent(
|
LunaEvent(
|
||||||
LunaEventType.DIAPERCHANGE_POO
|
LunaEvent.TYPE_DIAPERCHANGE_POO
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
findViewById<View>(R.id.button_change_pee).setOnClickListener { logEvent(
|
findViewById<View>(R.id.button_change_pee).setOnClickListener { logEvent(
|
||||||
LunaEvent(
|
LunaEvent(
|
||||||
LunaEventType.DIAPERCHANGE_PEE
|
LunaEvent.TYPE_DIAPERCHANGE_PEE
|
||||||
)
|
)
|
||||||
) }
|
) }
|
||||||
|
val moreButton = findViewById<View>(R.id.button_more)
|
||||||
|
moreButton.setOnClickListener {
|
||||||
|
showOverflowPopupWindow(moreButton)
|
||||||
|
}
|
||||||
findViewById<View>(R.id.button_no_connection_settings).setOnClickListener({
|
findViewById<View>(R.id.button_no_connection_settings).setOnClickListener({
|
||||||
showSettings()
|
showSettings()
|
||||||
})
|
})
|
||||||
@ -139,8 +163,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
|
|
||||||
// Reload data
|
// Reload data
|
||||||
loadLogbook()
|
loadLogbookList()
|
||||||
handler.postDelayed(updateListRunnable, 1000*30)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
@ -164,7 +187,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(LunaEventType.BABY_BOTTLE, 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() }
|
||||||
@ -179,11 +202,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
d.setTitle(R.string.log_weight_dialog_title)
|
d.setTitle(R.string.log_weight_dialog_title)
|
||||||
d.setMessage(R.string.log_weight_dialog_description)
|
d.setMessage(R.string.log_weight_dialog_description)
|
||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
val weightET = dialogView.findViewById<TextView>(R.id.dialog_number_edittext)
|
val weightET = dialogView.findViewById<EditText>(R.id.dialog_number_edittext)
|
||||||
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(LunaEventType.WEIGHT, 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()
|
||||||
}
|
}
|
||||||
@ -192,19 +215,195 @@ class MainActivity : AppCompatActivity() {
|
|||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadLogbook() {
|
fun askTemperatureValue() {
|
||||||
|
// Show number picker dialog
|
||||||
|
val d = AlertDialog.Builder(this)
|
||||||
|
val dialogView = layoutInflater.inflate(R.layout.temperature_dialog, null)
|
||||||
|
d.setTitle(R.string.log_temperature_dialog_title)
|
||||||
|
d.setMessage(R.string.log_temperature_dialog_description)
|
||||||
|
d.setView(dialogView)
|
||||||
|
val tempSlider = dialogView.findViewById<Slider>(R.id.dialog_temperature_value)
|
||||||
|
val range = NumericUtils(this).getValidEventQuantityRange(LunaEvent.TYPE_TEMPERATURE)!!
|
||||||
|
tempSlider.valueFrom = range.first.toFloat()
|
||||||
|
tempSlider.valueTo = range.second.toFloat()
|
||||||
|
tempSlider.value = range.third.toFloat()
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
|
val alertDialog = d.create()
|
||||||
|
alertDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun askNotes(lunaEvent: LunaEvent) {
|
||||||
|
val d = AlertDialog.Builder(this)
|
||||||
|
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
||||||
|
d.setTitle(lunaEvent.getTypeDescription(this))
|
||||||
|
d.setMessage(
|
||||||
|
when (lunaEvent.type){
|
||||||
|
LunaEvent.TYPE_MEDICINE -> R.string.log_medicine_dialog_description
|
||||||
|
else -> R.string.log_notes_dialog_description
|
||||||
|
}
|
||||||
|
)
|
||||||
|
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)
|
||||||
|
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() }
|
||||||
|
val alertDialog = d.create()
|
||||||
|
alertDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun askToTrimLogbook() {
|
||||||
|
val d = AlertDialog.Builder(this)
|
||||||
|
d.setTitle(R.string.trim_logbook_dialog_title)
|
||||||
|
d.setMessage(
|
||||||
|
when (LocalSettingsRepository(this).loadDataRepository()) {
|
||||||
|
LocalSettingsRepository.DATA_REPO.WEBDAV -> R.string.trim_logbook_dialog_message_dav
|
||||||
|
else -> R.string.trim_logbook_dialog_message_local
|
||||||
|
}
|
||||||
|
)
|
||||||
|
d.setPositiveButton(R.string.trim_logbook_dialog_button_ok) { dialogInterface, i ->
|
||||||
|
logbook.trim()
|
||||||
|
saveLogbook()
|
||||||
|
}
|
||||||
|
d.setNegativeButton(R.string.trim_logbook_dialog_button_cancel) { dialogInterface, i ->
|
||||||
|
dialogInterface.dismiss()
|
||||||
|
}
|
||||||
|
val alertDialog = d.create()
|
||||||
|
alertDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showEventDetailDialog(event: LunaEvent) {
|
||||||
|
val dateFormat = DateFormat.getDateTimeInstance();
|
||||||
|
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).setText(event.getTypeEmoji(this))
|
||||||
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description).setText(event.getTypeDescription(this))
|
||||||
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_date).setText(dateFormat.format(Date(event.time * 1000)))
|
||||||
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity).setText(
|
||||||
|
NumericUtils(this).formatEventQuantity(event)
|
||||||
|
)
|
||||||
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).setText(event.notes)
|
||||||
|
d.setView(dialogView)
|
||||||
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
|
val alertDialog = d.create()
|
||||||
|
alertDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showAddLogbookDialog() {
|
||||||
|
val d = AlertDialog.Builder(this)
|
||||||
|
d.setTitle(R.string.dialog_add_logbook_title)
|
||||||
|
val dialogView = layoutInflater.inflate(R.layout.dialog_add_logbook, null)
|
||||||
|
val logbookNameEditText = dialogView.findViewById<EditText>(R.id.dialog_add_logbook_logbookname)
|
||||||
|
d.setView(dialogView)
|
||||||
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i -> addLogbook(logbookNameEditText.text.toString()) }
|
||||||
|
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
|
val alertDialog = d.create()
|
||||||
|
alertDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun loadLogbookList() {
|
||||||
|
setLoading(true)
|
||||||
|
logbookRepo?.listLogbooks(this, object: LogbookListObtainedListener {
|
||||||
|
override fun onLogbookListObtained(logbooksNames: ArrayList<String>) {
|
||||||
|
runOnUiThread({
|
||||||
|
// Show logbooks dropdown
|
||||||
|
val spinner = findViewById<Spinner>(R.id.logbooks_spinner)
|
||||||
|
val sAdapter = ArrayAdapter<String>(this@MainActivity, android.R.layout.simple_spinner_item)
|
||||||
|
sAdapter.setDropDownViewResource(R.layout.row_logbook_spinner)
|
||||||
|
for (ln in logbooksNames) {
|
||||||
|
sAdapter.add(
|
||||||
|
if (ln.isEmpty()) getString(R.string.default_logbook_name) else ln
|
||||||
|
)
|
||||||
|
}
|
||||||
|
spinner.adapter = sAdapter
|
||||||
|
spinner.onItemSelectedListener = object: AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long
|
||||||
|
) {
|
||||||
|
// Changed logbook: empty list
|
||||||
|
adapter.items.clear()
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
// Load logbook
|
||||||
|
loadLogbook(logbooksNames.get(position))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onIOError(error: IOException) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onWebDAVError(error: SardineException) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(error: Exception) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addLogbook(logbookName: String) {
|
||||||
|
this.logbook = Logbook(logbookName)
|
||||||
|
saveLogbook()
|
||||||
|
loadLogbookList() // TODO: Does not reload logbooks buttons on top, why?
|
||||||
|
}
|
||||||
|
|
||||||
|
fun loadLogbook(name: String = LogbookRepository.DEFAULT_LOGBOOK_NAME) {
|
||||||
if (savingEvent)
|
if (savingEvent)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
// Reset time counter
|
||||||
|
handler.removeCallbacks(updateListRunnable)
|
||||||
|
handler.postDelayed(updateListRunnable, UPDATE_EVERY_SECS*1000)
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
logbookRepo?.loadLogbook(this, object: LogbookLoadedListener{
|
logbookRepo?.loadLogbook(this, name, object: LogbookLoadedListener{
|
||||||
override fun onLogbookLoaded(lb: Logbook) {
|
override fun onLogbookLoaded(lb: Logbook) {
|
||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
findViewById<View>(R.id.no_connection_screen).visibility = View.GONE
|
findViewById<View>(R.id.no_connection_screen).visibility = View.GONE
|
||||||
logbook = lb
|
logbook = lb
|
||||||
showLogbook()
|
showLogbook()
|
||||||
|
|
||||||
|
if (DEBUG_CHECK_LOGBOOK_CONSISTENCY) {
|
||||||
|
for (e in logbook.logs) {
|
||||||
|
val em = e.getTypeEmoji(this@MainActivity)
|
||||||
|
if (em == getString(R.string.event_unknown_type)) {
|
||||||
|
Log.e(TAG, "UNKNOWN: ${e.type}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,13 +460,33 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
logbook.logs.add(0, event)
|
logbook.logs.add(0, event)
|
||||||
|
saveLogbook(event)
|
||||||
|
|
||||||
|
// Check logbook size to avoid OOM errors
|
||||||
|
if (logbook.isTooBig()) {
|
||||||
|
askToTrimLogbook()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the logbook. If saving while adding an event, please specify the event so in case
|
||||||
|
* of error can be removed from the list.
|
||||||
|
*/
|
||||||
|
fun saveLogbook(lastEventAdded: LunaEvent? = null) {
|
||||||
logbookRepo?.saveLogbook(this, logbook, object: LogbookSavedListener{
|
logbookRepo?.saveLogbook(this, logbook, object: LogbookSavedListener{
|
||||||
override fun onLogbookSaved() {
|
override fun onLogbookSaved() {
|
||||||
Log.d(TAG, "Logbook saved")
|
Log.d(TAG, "Logbook saved")
|
||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
|
||||||
Toast.makeText(this@MainActivity, R.string.toast_event_added, Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
this@MainActivity,
|
||||||
|
if (lastEventAdded != null)
|
||||||
|
R.string.toast_event_added
|
||||||
|
else
|
||||||
|
R.string.toast_logbook_saved,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
savingEvent(false)
|
savingEvent(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -276,7 +495,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
onRepoError(getString(R.string.settings_network_error) + error.toString())
|
onRepoError(getString(R.string.settings_network_error) + error.toString())
|
||||||
onAddError(event, error.toString())
|
if (lastEventAdded != null)
|
||||||
|
onAddError(lastEventAdded, error.toString())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +510,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
getString(R.string.settings_webdav_error_generic) + error.toString()
|
getString(R.string.settings_webdav_error_generic) + error.toString()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
onAddError(event, error.toString())
|
if (lastEventAdded != null)
|
||||||
|
onAddError(lastEventAdded, error.toString())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +519,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
onRepoError(getString(R.string.settings_json_error) + error.toString())
|
onRepoError(getString(R.string.settings_json_error) + error.toString())
|
||||||
onAddError(event, error.toString())
|
if (lastEventAdded != null)
|
||||||
|
onAddError(lastEventAdded, error.toString())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +528,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
onRepoError(getString(R.string.settings_generic_error) + error.toString())
|
onRepoError(getString(R.string.settings_generic_error) + error.toString())
|
||||||
onAddError(event, error.toString())
|
if (lastEventAdded != null)
|
||||||
|
onAddError(lastEventAdded, error.toString())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -342,4 +565,44 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showOverflowPopupWindow(anchor: View) {
|
||||||
|
if (showingOverflowPopupWindow)
|
||||||
|
return
|
||||||
|
|
||||||
|
PopupWindow(anchor.context).apply {
|
||||||
|
isOutsideTouchable = true
|
||||||
|
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))
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
|
contentView.findViewById<View>(R.id.button_enema).setOnClickListener({
|
||||||
|
logEvent(LunaEvent(LunaEvent.TYPE_ENEMA))
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
|
contentView.findViewById<View>(R.id.button_note).setOnClickListener({
|
||||||
|
askNotes(LunaEvent(LunaEvent.TYPE_NOTE))
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
|
contentView.findViewById<View>(R.id.button_temperature).setOnClickListener({
|
||||||
|
askTemperatureValue()
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
|
contentView.findViewById<View>(R.id.button_colic).setOnClickListener({
|
||||||
|
logEvent(
|
||||||
|
LunaEvent(LunaEvent.TYPE_COLIC)
|
||||||
|
)
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
|
}.also { popupWindow ->
|
||||||
|
popupWindow.setOnDismissListener({
|
||||||
|
Handler(mainLooper).postDelayed({
|
||||||
|
showingOverflowPopupWindow = false
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
popupWindow.showAsDropDown(anchor)
|
||||||
|
showingOverflowPopupWindow = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
||||||
import it.danieleverducci.lunatracker.repository.LocalSettingsRepository
|
import it.danieleverducci.lunatracker.repository.LocalSettingsRepository
|
||||||
|
import it.danieleverducci.lunatracker.repository.LogbookRepository
|
||||||
import it.danieleverducci.lunatracker.repository.WebDAVLogbookRepository
|
import it.danieleverducci.lunatracker.repository.WebDAVLogbookRepository
|
||||||
import okio.IOException
|
import okio.IOException
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
@ -72,7 +73,7 @@ open class SettingsActivity : AppCompatActivity() {
|
|||||||
textViewWebDAVPass.text.toString()
|
textViewWebDAVPass.text.toString()
|
||||||
)
|
)
|
||||||
progressIndicator.visibility = View.VISIBLE
|
progressIndicator.visibility = View.VISIBLE
|
||||||
webDAVLogbookRepo.createLogbook(this, object: WebDAVLogbookRepository.LogbookCreatedListener{
|
webDAVLogbookRepo.createLogbook(this, LogbookRepository.DEFAULT_LOGBOOK_NAME, object: WebDAVLogbookRepository.LogbookCreatedListener{
|
||||||
override fun onLogbookCreated() {
|
override fun onLogbookCreated() {
|
||||||
runOnUiThread({
|
runOnUiThread({
|
||||||
progressIndicator.visibility = View.INVISIBLE
|
progressIndicator.visibility = View.INVISIBLE
|
||||||
|
@ -1,32 +1,42 @@
|
|||||||
package it.danieleverducci.lunatracker.adapters
|
package it.danieleverducci.lunatracker.adapters
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.format.DateFormat
|
|
||||||
import android.text.format.DateUtils
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEvent
|
import it.danieleverducci.lunatracker.entities.LunaEvent
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEventType
|
|
||||||
import it.danieleverducci.lunatracker.R
|
import it.danieleverducci.lunatracker.R
|
||||||
import java.util.Date
|
import utils.DateUtils
|
||||||
|
import utils.NumericUtils
|
||||||
|
|
||||||
class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.LunaEventVH> {
|
class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.LunaEventVH> {
|
||||||
private val context: Context
|
private val context: Context
|
||||||
val items = ArrayList<LunaEvent>()
|
val items = ArrayList<LunaEvent>()
|
||||||
|
val numericUtils: NumericUtils
|
||||||
|
var onItemClickListener: OnItemClickListener? = null
|
||||||
|
val layoutRes: Int
|
||||||
|
|
||||||
constructor(context: Context) {
|
constructor(context: Context) {
|
||||||
this.context = context
|
this.context = context
|
||||||
|
this.numericUtils = NumericUtils(context)
|
||||||
|
|
||||||
|
val fontScale = context.resources.configuration.fontScale
|
||||||
|
val screenSize = context.resources.configuration.screenWidthDp
|
||||||
|
this.layoutRes =
|
||||||
|
if(fontScale > 1.2 || screenSize < 320 || (fontScale > 1 && screenSize < 400))
|
||||||
|
R.layout.row_luna_event_vertical
|
||||||
|
else
|
||||||
|
R.layout.row_luna_event
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
viewType: Int
|
viewType: Int
|
||||||
): LunaEventVH {
|
): LunaEventVH {
|
||||||
|
val view = LayoutInflater.from(context).inflate(layoutRes, parent, false)
|
||||||
val view = LayoutInflater.from(context).inflate(R.layout.row_luna_event, parent, false)
|
|
||||||
return LunaEventVH(view)
|
return LunaEventVH(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,86 +45,78 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.Lu
|
|||||||
position: Int
|
position: Int
|
||||||
) {
|
) {
|
||||||
val item = items.get(position)
|
val item = items.get(position)
|
||||||
holder.type.text = context.getString(
|
// Colors
|
||||||
when (item.type) {
|
holder.root.setBackgroundResource(
|
||||||
LunaEventType.BABY_BOTTLE -> R.string.event_bottle_type
|
if (position % 2 == 0) R.color.list_background_even else R.color.list_background_odd
|
||||||
LunaEventType.WEIGHT -> R.string.event_scale_type
|
|
||||||
LunaEventType.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_type
|
|
||||||
LunaEventType.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_type
|
|
||||||
LunaEventType.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_type
|
|
||||||
LunaEventType.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_type
|
|
||||||
LunaEventType.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_type
|
|
||||||
else -> R.string.event_unknown_type
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
holder.description.text = context.getString(
|
holder.quantity.setTextColor(ContextCompat.getColor(context, R.color.textColor))
|
||||||
when (item.type) {
|
// Contents
|
||||||
LunaEventType.BABY_BOTTLE -> R.string.event_bottle_desc
|
holder.type.text = item.getTypeEmoji(context)
|
||||||
LunaEventType.WEIGHT -> R.string.event_scale_desc
|
holder.description.text = when(item.type) {
|
||||||
LunaEventType.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_desc
|
LunaEvent.TYPE_MEDICINE -> item.notes
|
||||||
LunaEventType.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_desc
|
LunaEvent.TYPE_NOTE -> item.notes
|
||||||
LunaEventType.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_desc
|
LunaEvent.TYPE_CUSTOM -> item.notes
|
||||||
LunaEventType.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_desc
|
else -> item.getTypeDescription(context)
|
||||||
LunaEventType.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_desc
|
}
|
||||||
else -> R.string.event_unknown_desc
|
holder.time.text = DateUtils.formatTimeAgo(context, item.time)
|
||||||
|
var quantityText = numericUtils.formatEventQuantity(item)
|
||||||
|
|
||||||
|
// if the event is weight, show difference with the last one
|
||||||
|
if (item.type == LunaEvent.TYPE_WEIGHT) {
|
||||||
|
val lastWeight = getPreviousWeightEvent(position)
|
||||||
|
if (lastWeight != null) {
|
||||||
|
val differenceInWeight = item.quantity - lastWeight.quantity
|
||||||
|
val sign = if (differenceInWeight > 0) "+" else ""
|
||||||
|
quantityText += "\n($sign$differenceInWeight)"
|
||||||
|
if (differenceInWeight < 0) {
|
||||||
|
holder.quantity.setTextColor(ContextCompat.getColor(context, R.color.danger))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
holder.quantity.text = if ((item.quantity ?: 0) > 0) item.quantity.toString() else ""
|
|
||||||
holder.time.text = formatTimeAgo(context, item.time)
|
holder.quantity.text = quantityText
|
||||||
|
|
||||||
|
// Listeners
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
holder.root.setOnClickListener({
|
||||||
|
onItemClickListener?.onItemClick(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return items.size
|
return items.size
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private fun getPreviousWeightEvent(startFromPosition: Int): LunaEvent? {
|
||||||
* Formats the provided unix timestamp in a string like "3 hours, 26 minutes ago)
|
if (startFromPosition == items.size - 1)
|
||||||
*/
|
return null
|
||||||
fun formatTimeAgo(context: Context, unixTime: Long): String {
|
for (pos in startFromPosition + 1 until items.size) {
|
||||||
val secondsDiff = (System.currentTimeMillis() / 1000) - unixTime
|
val item = items.get(pos)
|
||||||
val minutesDiff = secondsDiff / 60
|
if (item.type != LunaEvent.TYPE_WEIGHT)
|
||||||
|
continue
|
||||||
if (minutesDiff < 1)
|
return item
|
||||||
return context.getString(R.string.now)
|
|
||||||
|
|
||||||
val hoursAgo = (secondsDiff / (60 * 60)).toInt()
|
|
||||||
val minutesAgo = (minutesDiff % 60).toInt()
|
|
||||||
|
|
||||||
if (hoursAgo > 24)
|
|
||||||
return DateFormat.getDateFormat(context).format(Date(unixTime*1000)) + "\n" +
|
|
||||||
DateFormat.getTimeFormat(context).format(Date(unixTime*1000))
|
|
||||||
|
|
||||||
var formattedTime = StringBuilder()
|
|
||||||
if (hoursAgo > 0) {
|
|
||||||
formattedTime.append(hoursAgo).append(" ")
|
|
||||||
if (hoursAgo.toInt() == 1)
|
|
||||||
formattedTime.append(context.getString(R.string.hour_ago))
|
|
||||||
else
|
|
||||||
formattedTime.append(context.getString(R.string.hours_ago))
|
|
||||||
}
|
}
|
||||||
if (formattedTime.isNotEmpty())
|
return null
|
||||||
formattedTime.append(", ")
|
|
||||||
if (minutesAgo > 0) {
|
|
||||||
formattedTime.append(minutesAgo).append(" ")
|
|
||||||
if (minutesAgo.toInt() == 1)
|
|
||||||
formattedTime.append(context.getString(R.string.minute_ago))
|
|
||||||
else
|
|
||||||
formattedTime.append(context.getString(R.string.minutes_ago))
|
|
||||||
}
|
|
||||||
return formattedTime.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LunaEventVH: RecyclerView.ViewHolder {
|
class LunaEventVH: RecyclerView.ViewHolder {
|
||||||
|
val root: View
|
||||||
val type: TextView
|
val type: TextView
|
||||||
val description: TextView
|
val description: TextView
|
||||||
val quantity: TextView
|
val quantity: TextView
|
||||||
val time: TextView
|
val time: TextView
|
||||||
|
|
||||||
constructor(v: View) : super(v) {
|
constructor(v: View) : super(v) {
|
||||||
|
root = v
|
||||||
type = v.findViewById<TextView>(R.id.type)
|
type = v.findViewById<TextView>(R.id.type)
|
||||||
description = v.findViewById<TextView>(R.id.description)
|
description = v.findViewById<TextView>(R.id.description)
|
||||||
quantity = v.findViewById<TextView>(R.id.quantity)
|
quantity = v.findViewById<TextView>(R.id.quantity)
|
||||||
time = v.findViewById<TextView>(R.id.time)
|
time = v.findViewById<TextView>(R.id.time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface OnItemClickListener {
|
||||||
|
fun onItemClick(event: LunaEvent)
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,19 @@
|
|||||||
package it.danieleverducci.lunatracker.entities
|
package it.danieleverducci.lunatracker.entities
|
||||||
|
|
||||||
class Logbook {
|
class Logbook(val name: String) {
|
||||||
|
companion object {
|
||||||
|
val MAX_SAFE_LOGBOOK_SIZE = 30000
|
||||||
|
}
|
||||||
val logs = ArrayList<LunaEvent>()
|
val logs = ArrayList<LunaEvent>()
|
||||||
|
|
||||||
|
fun isTooBig(): Boolean {
|
||||||
|
return logs.size > MAX_SAFE_LOGBOOK_SIZE
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Halves the logbook to avoid the file being too big
|
||||||
|
*/
|
||||||
|
fun trim() {
|
||||||
|
logs.subList(MAX_SAFE_LOGBOOK_SIZE/2, logs.size).clear()
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,68 +1,123 @@
|
|||||||
package it.danieleverducci.lunatracker.entities
|
package it.danieleverducci.lunatracker.entities
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import it.danieleverducci.lunatracker.R
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
class LunaEvent(
|
/**
|
||||||
val type: LunaEventType,
|
* Represents a logged event.
|
||||||
val quantity: Int? = null,
|
* It encloses, but doesn't parse entirely, a jsonObject. This was done to
|
||||||
){
|
* allow expandability and backwards compatibility (if a field is added in a
|
||||||
var time: Long // In unix time (seconds since 1970)
|
* release, it is simply ignored by previous ones).
|
||||||
|
*/
|
||||||
|
class LunaEvent {
|
||||||
|
|
||||||
init {
|
companion object {
|
||||||
time = System.currentTimeMillis() / 1000
|
val TYPE_BABY_BOTTLE = "BABY_BOTTLE"
|
||||||
|
val TYPE_WEIGHT = "WEIGHT"
|
||||||
|
val TYPE_BREASTFEEDING_LEFT_NIPPLE = "BREASTFEEDING_LEFT_NIPPLE"
|
||||||
|
val TYPE_BREASTFEEDING_BOTH_NIPPLE = "BREASTFEEDING_BOTH_NIPPLE"
|
||||||
|
val TYPE_BREASTFEEDING_RIGHT_NIPPLE = "BREASTFEEDING_RIGHT_NIPPLE"
|
||||||
|
val TYPE_DIAPERCHANGE_POO = "DIAPERCHANGE_POO"
|
||||||
|
val TYPE_DIAPERCHANGE_PEE = "DIAPERCHANGE_PEE"
|
||||||
|
val TYPE_MEDICINE = "MEDICINE"
|
||||||
|
val TYPE_ENEMA = "ENEMA"
|
||||||
|
val TYPE_NOTE = "NOTE"
|
||||||
|
val TYPE_CUSTOM = "CUSTOM"
|
||||||
|
val TYPE_COLIC = "COLIC"
|
||||||
|
val TYPE_TEMPERATURE = "TEMPERATURE"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
private val jo: JSONObject
|
||||||
return "${type.toString()} qty: $quantity time: ${Date(time * 1000)}"
|
|
||||||
|
var time: Long // In unix time (seconds since 1970)
|
||||||
|
get() = jo.getLong("time")
|
||||||
|
set(value) {
|
||||||
|
jo.put("time", value)
|
||||||
|
}
|
||||||
|
var type: String
|
||||||
|
get(): String = jo.getString("type")
|
||||||
|
set(value) {
|
||||||
|
jo.put("type", value)
|
||||||
|
}
|
||||||
|
var quantity: Int
|
||||||
|
get() = jo.optInt("quantity")
|
||||||
|
set(value) {
|
||||||
|
if (value > 0)
|
||||||
|
jo.put("quantity", value)
|
||||||
|
}
|
||||||
|
var notes: String
|
||||||
|
get(): String = jo.optString("notes")
|
||||||
|
set(value) {
|
||||||
|
jo.put("notes", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(jo: JSONObject) {
|
||||||
|
this.jo = jo
|
||||||
|
// A minimal LunaEvent should have at least time and type
|
||||||
|
if (!jo.has("time") || !jo.has("type"))
|
||||||
|
throw IllegalArgumentException("JSONObject is not a LunaEvent")
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(type: String) {
|
||||||
|
this.jo = JSONObject()
|
||||||
|
this.time = System.currentTimeMillis() / 1000
|
||||||
|
this.type = type
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(type: String, quantity: Int) {
|
||||||
|
this.jo = JSONObject()
|
||||||
|
this.time = System.currentTimeMillis() / 1000
|
||||||
|
this.type = type
|
||||||
|
this.quantity = quantity
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTypeEmoji(context: Context): String {
|
||||||
|
return context.getString(
|
||||||
|
when (type) {
|
||||||
|
TYPE_BABY_BOTTLE -> R.string.event_bottle_type
|
||||||
|
TYPE_WEIGHT -> R.string.event_scale_type
|
||||||
|
TYPE_BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_type
|
||||||
|
TYPE_BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_type
|
||||||
|
TYPE_BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_type
|
||||||
|
TYPE_DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_type
|
||||||
|
TYPE_DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_type
|
||||||
|
TYPE_MEDICINE -> R.string.event_medicine_type
|
||||||
|
TYPE_ENEMA -> R.string.event_enema_type
|
||||||
|
TYPE_NOTE -> R.string.event_note_type
|
||||||
|
TYPE_TEMPERATURE -> R.string.event_temperature_type
|
||||||
|
TYPE_COLIC -> R.string.event_colic_type
|
||||||
|
else -> R.string.event_unknown_type
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTypeDescription(context: Context): String {
|
||||||
|
return context.getString(
|
||||||
|
when (type) {
|
||||||
|
TYPE_BABY_BOTTLE -> R.string.event_bottle_desc
|
||||||
|
TYPE_WEIGHT -> R.string.event_scale_desc
|
||||||
|
TYPE_BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_desc
|
||||||
|
TYPE_BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_desc
|
||||||
|
TYPE_BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_desc
|
||||||
|
TYPE_DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_desc
|
||||||
|
TYPE_DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_desc
|
||||||
|
TYPE_MEDICINE -> R.string.event_medicine_desc
|
||||||
|
TYPE_ENEMA -> R.string.event_enema_desc
|
||||||
|
TYPE_NOTE -> R.string.event_note_desc
|
||||||
|
TYPE_TEMPERATURE -> R.string.event_temperature_desc
|
||||||
|
TYPE_COLIC -> R.string.event_colic_desc
|
||||||
|
else -> R.string.event_unknown_desc
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toJson(): JSONObject {
|
fun toJson(): JSONObject {
|
||||||
val jo = JSONObject()
|
|
||||||
val type = when (type) {
|
|
||||||
LunaEventType.BABY_BOTTLE -> "BABY_BOTTLE"
|
|
||||||
LunaEventType.WEIGHT -> "SCALE"
|
|
||||||
LunaEventType.BREASTFEEDING_LEFT_NIPPLE -> "BREASTFEEDING_LEFT_NIPPLE"
|
|
||||||
LunaEventType.BREASTFEEDING_BOTH_NIPPLE -> "BREASTFEEDING_BOTH_NIPPLE"
|
|
||||||
LunaEventType.BREASTFEEDING_RIGHT_NIPPLE -> "BREASTFEEDING_RIGHT_NIPPLE"
|
|
||||||
LunaEventType.DIAPERCHANGE_POO -> "DIAPERCHANGE_POO"
|
|
||||||
LunaEventType.DIAPERCHANGE_PEE -> "DIAPERCHANGE_PEE"
|
|
||||||
else -> "UNKNOWN"
|
|
||||||
}
|
|
||||||
jo.put("type", type)
|
|
||||||
jo.put("quantity", quantity)
|
|
||||||
jo.put("time", time)
|
|
||||||
return jo
|
return jo
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
override fun toString(): String {
|
||||||
fun fromJson(j: JSONObject): LunaEvent {
|
return "${type} qty: $quantity time: ${Date(time * 1000)}"
|
||||||
val type = when (j.getString("type")) {
|
|
||||||
"BABY_BOTTLE" -> LunaEventType.BABY_BOTTLE
|
|
||||||
"SCALE" -> LunaEventType.WEIGHT
|
|
||||||
"BREASTFEEDING_LEFT_NIPPLE" -> LunaEventType.BREASTFEEDING_LEFT_NIPPLE
|
|
||||||
"BREASTFEEDING_BOTH_NIPPLE" -> LunaEventType.BREASTFEEDING_BOTH_NIPPLE
|
|
||||||
"BREASTFEEDING_RIGHT_NIPPLE" -> LunaEventType.BREASTFEEDING_RIGHT_NIPPLE
|
|
||||||
"DIAPERCHANGE_POO" -> LunaEventType.DIAPERCHANGE_POO
|
|
||||||
"DIAPERCHANGE_PEE" -> LunaEventType.DIAPERCHANGE_PEE
|
|
||||||
else -> LunaEventType.UNKNOWN
|
|
||||||
}
|
|
||||||
val quantity = j.optInt("quantity")
|
|
||||||
val time = j.getLong("time")
|
|
||||||
val evt = LunaEvent(type, quantity)
|
|
||||||
evt.time = time
|
|
||||||
return evt
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
enum class LunaEventType {
|
|
||||||
BABY_BOTTLE,
|
|
||||||
WEIGHT,
|
|
||||||
BREASTFEEDING_LEFT_NIPPLE,
|
|
||||||
BREASTFEEDING_BOTH_NIPPLE,
|
|
||||||
BREASTFEEDING_RIGHT_NIPPLE,
|
|
||||||
DIAPERCHANGE_POO,
|
|
||||||
DIAPERCHANGE_PEE,
|
|
||||||
UNKNOWN
|
|
||||||
}
|
}
|
@ -5,35 +5,44 @@ import it.danieleverducci.lunatracker.entities.Logbook
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEvent
|
import it.danieleverducci.lunatracker.entities.LunaEvent
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONException
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
|
import java.io.FilenameFilter
|
||||||
|
|
||||||
class FileLogbookRepository: LogbookRepository {
|
class FileLogbookRepository: LogbookRepository {
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "FileLogbookRepository"
|
val TAG = "FileLogbookRepository"
|
||||||
|
val FILE_NAME_START = "data"
|
||||||
|
val FILE_NAME_END = ".json"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadLogbook(context: Context, listener: LogbookLoadedListener) {
|
override fun loadLogbook(context: Context, name: String, listener: LogbookLoadedListener) {
|
||||||
try {
|
try {
|
||||||
listener.onLogbookLoaded(loadLogbook(context))
|
listener.onLogbookLoaded(loadLogbook(context, name))
|
||||||
} catch (e: FileNotFoundException) {
|
} catch (e: FileNotFoundException) {
|
||||||
Log.d(TAG, "No logbook file found, create one")
|
Log.d(TAG, "No logbook file found, create one")
|
||||||
val newLogbook = Logbook()
|
val newLogbook = Logbook(name)
|
||||||
saveLogbook(context, newLogbook)
|
saveLogbook(context, newLogbook)
|
||||||
listener.onLogbookLoaded(newLogbook)
|
listener.onLogbookLoaded(newLogbook)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadLogbook(context: Context): Logbook {
|
fun loadLogbook(context: Context, name: String): Logbook {
|
||||||
val logbook = Logbook()
|
val logbook = Logbook(name)
|
||||||
val file = File(context.getFilesDir(), "data.json")
|
val fileName = getFileName(name)
|
||||||
|
val file = File(context.getFilesDir(), fileName)
|
||||||
val json = FileInputStream(file).bufferedReader().use { it.readText() }
|
val json = FileInputStream(file).bufferedReader().use { it.readText() }
|
||||||
val ja = JSONArray(json)
|
val ja = JSONArray(json)
|
||||||
for (i in 0 until ja.length()) {
|
for (i in 0 until ja.length()) {
|
||||||
val jo = ja.getJSONObject(i)
|
try {
|
||||||
val evt = LunaEvent.fromJson(jo)
|
val evt: LunaEvent = LunaEvent(ja.getJSONObject(i))
|
||||||
logbook.logs.add(evt)
|
logbook.logs.add(evt)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
// Mangled JSON?
|
||||||
|
throw JSONException(e.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return logbook
|
return logbook
|
||||||
}
|
}
|
||||||
@ -48,11 +57,42 @@ class FileLogbookRepository: LogbookRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveLogbook(context: Context, logbook: Logbook) {
|
fun saveLogbook(context: Context, logbook: Logbook) {
|
||||||
val file = File(context.getFilesDir(), "data.json")
|
val fileName = getFileName(logbook.name)
|
||||||
|
val file = File(context.getFilesDir(), fileName)
|
||||||
val ja = JSONArray()
|
val ja = JSONArray()
|
||||||
for (l in logbook.logs) {
|
for (l in logbook.logs) {
|
||||||
ja.put(l.toJson())
|
ja.put(l.toJson())
|
||||||
}
|
}
|
||||||
file.writeText(ja.toString())
|
file.writeText(ja.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun listLogbooks(
|
||||||
|
context: Context,
|
||||||
|
listener: LogbookListObtainedListener
|
||||||
|
) {
|
||||||
|
val logbooksFileNames = context.getFilesDir().list(object: FilenameFilter {
|
||||||
|
override fun accept(dir: File?, name: String?): Boolean {
|
||||||
|
if (name == null)
|
||||||
|
return false
|
||||||
|
if (name.startsWith(FILE_NAME_START) && name.endsWith(FILE_NAME_END))
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (logbooksFileNames == null || logbooksFileNames.isEmpty())
|
||||||
|
listener.onLogbookListObtained(arrayListOf())
|
||||||
|
|
||||||
|
val logbooksNames = arrayListOf<String>()
|
||||||
|
logbooksFileNames.forEach { it ->
|
||||||
|
logbooksNames.add(
|
||||||
|
it.replace("${FILE_NAME_START}_", "").replace(FILE_NAME_START, "").replace(FILE_NAME_END, "")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
listener.onLogbookListObtained(logbooksNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getFileName(name: String): String {
|
||||||
|
return "$FILE_NAME_START${if (name.isNotEmpty()) "_" else ""}${name}$FILE_NAME_END"
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,8 +7,12 @@ import okio.IOException
|
|||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
|
||||||
interface LogbookRepository {
|
interface LogbookRepository {
|
||||||
fun loadLogbook(context: Context, listener: LogbookLoadedListener)
|
companion object {
|
||||||
fun saveLogbook(context: Context, logbook: Logbook, listener: LogbookSavedListener)
|
val DEFAULT_LOGBOOK_NAME = "" // For compatibility with older app versions
|
||||||
|
}
|
||||||
|
fun loadLogbook(context: Context, name: String = "", listener: LogbookLoadedListener)
|
||||||
|
fun saveLogbook(context: Context,logbook: Logbook, listener: LogbookSavedListener)
|
||||||
|
fun listLogbooks(context: Context, listener: LogbookListObtainedListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LogbookLoadedListener {
|
interface LogbookLoadedListener {
|
||||||
@ -26,3 +30,10 @@ interface LogbookSavedListener {
|
|||||||
fun onJSONError(error: JSONException)
|
fun onJSONError(error: JSONException)
|
||||||
fun onError(error: Exception)
|
fun onError(error: Exception)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface LogbookListObtainedListener {
|
||||||
|
fun onLogbookListObtained(logbooksNames: ArrayList<String>)
|
||||||
|
fun onIOError(error: IOException)
|
||||||
|
fun onWebDAVError(error: SardineException)
|
||||||
|
fun onError(error: Exception)
|
||||||
|
}
|
@ -2,6 +2,7 @@ package it.danieleverducci.lunatracker.repository
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.thegrizzlylabs.sardineandroid.DavResource
|
||||||
import com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine
|
import com.thegrizzlylabs.sardineandroid.impl.OkHttpSardine
|
||||||
import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
import com.thegrizzlylabs.sardineandroid.impl.SardineException
|
||||||
import it.danieleverducci.lunatracker.entities.Logbook
|
import it.danieleverducci.lunatracker.entities.Logbook
|
||||||
@ -14,11 +15,13 @@ import java.io.FileNotFoundException
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.SocketTimeoutException
|
import java.net.SocketTimeoutException
|
||||||
import kotlin.io.bufferedReader
|
import kotlin.io.bufferedReader
|
||||||
|
import kotlin.text.replace
|
||||||
|
|
||||||
class WebDAVLogbookRepository(val webDavURL: String, val username: String, val password: String): LogbookRepository {
|
class WebDAVLogbookRepository(val webDavURL: String, val username: String, val password: String): LogbookRepository {
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "LogbookRepository"
|
val TAG = "LogbookRepository"
|
||||||
val FILE_NAME = "lunatracker_logbook.json"
|
val FILE_NAME_START = "lunatracker_logbook"
|
||||||
|
val FILE_NAME_END = ".json"
|
||||||
}
|
}
|
||||||
val sardine: OkHttpSardine = OkHttpSardine()
|
val sardine: OkHttpSardine = OkHttpSardine()
|
||||||
|
|
||||||
@ -29,10 +32,10 @@ class WebDAVLogbookRepository(val webDavURL: String, val username: String, val p
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadLogbook(context: Context, listener: LogbookLoadedListener) {
|
override fun loadLogbook(context: Context, name: String, listener: LogbookLoadedListener) {
|
||||||
Thread(Runnable {
|
Thread(Runnable {
|
||||||
try {
|
try {
|
||||||
val logbook = loadLogbook(context)
|
val logbook = loadLogbook(name)
|
||||||
listener.onLogbookLoaded(logbook)
|
listener.onLogbookLoaded(logbook)
|
||||||
} catch (e: SardineException) {
|
} catch (e: SardineException) {
|
||||||
Log.e(TAG, e.toString())
|
Log.e(TAG, e.toString())
|
||||||
@ -52,17 +55,22 @@ class WebDAVLogbookRepository(val webDavURL: String, val username: String, val p
|
|||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadLogbook(context: Context): Logbook {
|
private fun loadLogbook(name: String,): Logbook {
|
||||||
val inputStream = sardine.get("$webDavURL/$FILE_NAME")
|
val inputStream = sardine.get(getUrl(name))
|
||||||
val json = inputStream.bufferedReader().use(BufferedReader::readText)
|
val json = inputStream.bufferedReader().use(BufferedReader::readText)
|
||||||
inputStream.close()
|
inputStream.close()
|
||||||
val ja = JSONArray(json)
|
val ja = JSONArray(json)
|
||||||
val logbook = Logbook()
|
val logbook = Logbook(name)
|
||||||
for (i in 0 until ja.length()) {
|
for (i in 0 until ja.length()) {
|
||||||
val jo = ja.getJSONObject(i)
|
try {
|
||||||
val evt = LunaEvent.fromJson(jo)
|
val evt: LunaEvent = LunaEvent(ja.getJSONObject(i))
|
||||||
logbook.logs.add(evt)
|
logbook.logs.add(evt)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
// Mangled JSON?
|
||||||
|
throw JSONException(e.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "Loaded ${logbook.logs.size} events into logbook")
|
||||||
return logbook
|
return logbook
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +98,27 @@ class WebDAVLogbookRepository(val webDavURL: String, val username: String, val p
|
|||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun listLogbooks(
|
||||||
|
context: Context,
|
||||||
|
listener: LogbookListObtainedListener
|
||||||
|
) {
|
||||||
|
Thread(Runnable {
|
||||||
|
val logbooksNames = arrayListOf<String>()
|
||||||
|
for (dr: DavResource in sardine.list(webDavURL)){
|
||||||
|
if(!dr.name.startsWith(FILE_NAME_START))
|
||||||
|
continue
|
||||||
|
if(!dr.name.endsWith(FILE_NAME_END))
|
||||||
|
continue
|
||||||
|
logbooksNames.add(
|
||||||
|
dr.name.replace("${FILE_NAME_START}_", "")
|
||||||
|
.replace(FILE_NAME_START, "")
|
||||||
|
.replace(FILE_NAME_END, "")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
listener.onLogbookListObtained(logbooksNames)
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
|
||||||
private fun saveLogbook(context: Context, logbook: Logbook) {
|
private fun saveLogbook(context: Context, logbook: Logbook) {
|
||||||
// Lock logbook on WebDAV to avoid concurrent changes
|
// Lock logbook on WebDAV to avoid concurrent changes
|
||||||
//sardine.lock(getUrl())
|
//sardine.lock(getUrl())
|
||||||
@ -103,30 +132,30 @@ class WebDAVLogbookRepository(val webDavURL: String, val username: String, val p
|
|||||||
for (l in logbook.logs) {
|
for (l in logbook.logs) {
|
||||||
ja.put(l.toJson())
|
ja.put(l.toJson())
|
||||||
}
|
}
|
||||||
sardine.put(getUrl(), ja.toString().toByteArray())
|
sardine.put(getUrl(logbook.name), ja.toString().toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to server and check if a logbook already exists.
|
* Connect to server and check if a logbook already exists.
|
||||||
* If it does not exist, try to upload the local one (or create a new one).
|
* If it does not exist, try to upload the local one (or create a new one).
|
||||||
*/
|
*/
|
||||||
fun createLogbook(context: Context, listener: LogbookCreatedListener) {
|
fun createLogbook(context: Context, name: String, listener: LogbookCreatedListener) {
|
||||||
Thread(Runnable {
|
Thread(Runnable {
|
||||||
try {
|
try {
|
||||||
loadLogbook(context)
|
loadLogbook(name)
|
||||||
listener.onLogbookCreated()
|
listener.onLogbookCreated()
|
||||||
} catch (e: SardineException) {
|
} catch (e: SardineException) {
|
||||||
if (e.toString().contains("404")) {
|
if (e.toString().contains("404")) {
|
||||||
// Connection successful, but no existing save. Upload the local one.
|
// Connection successful, but no existing save. Upload the local one.
|
||||||
try {
|
try {
|
||||||
val flr = FileLogbookRepository()
|
val flr = FileLogbookRepository()
|
||||||
val logbook = flr.loadLogbook(context)
|
val logbook = flr.loadLogbook(context, name)
|
||||||
saveLogbook(context, logbook)
|
saveLogbook(context, logbook)
|
||||||
Log.d(TAG, "Local logbook file found, uploaded")
|
Log.d(TAG, "Local logbook file found, uploaded")
|
||||||
listener.onLogbookCreated()
|
listener.onLogbookCreated()
|
||||||
} catch (e: FileNotFoundException) {
|
} catch (e: FileNotFoundException) {
|
||||||
Log.d(TAG, "No local logbook file found, uploading empty file")
|
Log.d(TAG, "No local logbook file found, uploading empty file")
|
||||||
saveLogbook(context, Logbook())
|
saveLogbook(context, Logbook(name))
|
||||||
listener.onLogbookCreated()
|
listener.onLogbookCreated()
|
||||||
} catch (e: SardineException) {
|
} catch (e: SardineException) {
|
||||||
Log.e(TAG, "Unable to upload logbook: $e")
|
Log.e(TAG, "Unable to upload logbook: $e")
|
||||||
@ -151,8 +180,10 @@ class WebDAVLogbookRepository(val webDavURL: String, val username: String, val p
|
|||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getUrl(): String {
|
private fun getUrl(name: String): String {
|
||||||
return "$webDavURL/$FILE_NAME"
|
val fileName = "${FILE_NAME_START}${if (name.isNotEmpty()) "_" else ""}${name}${FILE_NAME_END}"
|
||||||
|
Log.d(TAG, fileName)
|
||||||
|
return "$webDavURL/$fileName"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
48
app/src/main/java/utils/DateUtils.kt
Normal file
48
app/src/main/java/utils/DateUtils.kt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.text.format.DateFormat
|
||||||
|
import it.danieleverducci.lunatracker.R
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
class DateUtils {
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the provided unix timestamp in a string like "3 hours, 26 minutes ago)
|
||||||
|
*/
|
||||||
|
fun formatTimeAgo(context: Context, unixTime: Long): String {
|
||||||
|
val secondsDiff = (System.currentTimeMillis() / 1000) - unixTime
|
||||||
|
val minutesDiff = secondsDiff / 60
|
||||||
|
|
||||||
|
if (minutesDiff < 1)
|
||||||
|
return context.getString(R.string.now)
|
||||||
|
|
||||||
|
val hoursAgo = (secondsDiff / (60 * 60)).toInt()
|
||||||
|
val minutesAgo = (minutesDiff % 60).toInt()
|
||||||
|
|
||||||
|
if (hoursAgo > 24)
|
||||||
|
return DateFormat.getDateFormat(context).format(Date(unixTime*1000)) + "\n" +
|
||||||
|
DateFormat.getTimeFormat(context).format(Date(unixTime*1000))
|
||||||
|
|
||||||
|
var formattedTime = StringBuilder()
|
||||||
|
if (hoursAgo > 0) {
|
||||||
|
formattedTime.append(hoursAgo).append(" ")
|
||||||
|
if (hoursAgo.toInt() == 1)
|
||||||
|
formattedTime.append(context.getString(R.string.hour_ago))
|
||||||
|
else
|
||||||
|
formattedTime.append(context.getString(R.string.hours_ago))
|
||||||
|
}
|
||||||
|
if (minutesAgo > 0) {
|
||||||
|
if (formattedTime.isNotEmpty())
|
||||||
|
formattedTime.append(", ")
|
||||||
|
formattedTime.append(minutesAgo).append(" ")
|
||||||
|
if (minutesAgo.toInt() == 1)
|
||||||
|
formattedTime.append(context.getString(R.string.minute_ago))
|
||||||
|
else
|
||||||
|
formattedTime.append(context.getString(R.string.minutes_ago))
|
||||||
|
}
|
||||||
|
return formattedTime.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
92
app/src/main/java/utils/NumericUtils.kt
Normal file
92
app/src/main/java/utils/NumericUtils.kt
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.icu.util.LocaleData
|
||||||
|
import android.icu.util.ULocale
|
||||||
|
import it.danieleverducci.lunatracker.R
|
||||||
|
import it.danieleverducci.lunatracker.entities.LunaEvent
|
||||||
|
import java.text.NumberFormat
|
||||||
|
|
||||||
|
class NumericUtils (val context: Context) {
|
||||||
|
val numberFormat: NumberFormat
|
||||||
|
val measurement_unit_liquid_base: String
|
||||||
|
val measurement_unit_weight_base: String
|
||||||
|
val measurement_unit_weight_tiny: String
|
||||||
|
val measurement_unit_temperature_base: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.numberFormat = NumberFormat.getInstance()
|
||||||
|
val measurementSystem = LocaleData.getMeasurementSystem(ULocale.getDefault())
|
||||||
|
this.measurement_unit_liquid_base = context.getString(
|
||||||
|
if (measurementSystem == LocaleData. MeasurementSystem.SI)
|
||||||
|
R.string.measurement_unit_liquid_base_metric
|
||||||
|
else
|
||||||
|
R.string.measurement_unit_liquid_base_imperial
|
||||||
|
)
|
||||||
|
this.measurement_unit_weight_base = context.getString(
|
||||||
|
if (measurementSystem == LocaleData. MeasurementSystem.SI)
|
||||||
|
R.string.measurement_unit_weight_base_metric
|
||||||
|
else
|
||||||
|
R.string.measurement_unit_weight_base_imperial
|
||||||
|
)
|
||||||
|
this.measurement_unit_weight_tiny = context.getString(
|
||||||
|
if (measurementSystem == LocaleData. MeasurementSystem.SI)
|
||||||
|
R.string.measurement_unit_weight_tiny_metric
|
||||||
|
else
|
||||||
|
R.string.measurement_unit_weight_tiny_imperial
|
||||||
|
)
|
||||||
|
this.measurement_unit_temperature_base = context.getString(
|
||||||
|
if (measurementSystem == LocaleData. MeasurementSystem.SI)
|
||||||
|
R.string.measurement_unit_temperature_base_metric
|
||||||
|
else
|
||||||
|
R.string.measurement_unit_temperature_base_imperial
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun formatEventQuantity(item: LunaEvent): String {
|
||||||
|
val formatted = StringBuilder()
|
||||||
|
if ((item.quantity ?: 0) > 0) {
|
||||||
|
if (item.type == LunaEvent.TYPE_TEMPERATURE)
|
||||||
|
formatted.append((item.quantity / 10.0f).toString())
|
||||||
|
else
|
||||||
|
formatted.append(item.quantity)
|
||||||
|
|
||||||
|
formatted.append(" ")
|
||||||
|
formatted.append(
|
||||||
|
when (item.type) {
|
||||||
|
LunaEvent.TYPE_BABY_BOTTLE -> measurement_unit_liquid_base
|
||||||
|
LunaEvent.TYPE_WEIGHT -> measurement_unit_weight_base
|
||||||
|
LunaEvent.TYPE_MEDICINE -> measurement_unit_weight_tiny
|
||||||
|
LunaEvent.TYPE_TEMPERATURE -> measurement_unit_temperature_base
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return formatted.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid quantity range for the event type.
|
||||||
|
* @return min, max, normal
|
||||||
|
*/
|
||||||
|
fun getValidEventQuantityRange(lunaEventType: String): Triple<Int, Int, Int>? {
|
||||||
|
val measurementSystem = LocaleData.getMeasurementSystem(ULocale.getDefault())
|
||||||
|
return when (lunaEventType) {
|
||||||
|
LunaEvent.TYPE_TEMPERATURE -> {
|
||||||
|
if (measurementSystem == LocaleData. MeasurementSystem.SI)
|
||||||
|
Triple(
|
||||||
|
context.resources.getInteger(R.integer.human_body_temp_min_metric),
|
||||||
|
context.resources.getInteger(R.integer.human_body_temp_max_metric),
|
||||||
|
context.resources.getInteger(R.integer.human_body_temp_normal_metric)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Triple(
|
||||||
|
context.resources.getInteger(R.integer.human_body_temp_min_imperial),
|
||||||
|
context.resources.getInteger(R.integer.human_body_temp_max_imperial),
|
||||||
|
context.resources.getInteger(R.integer.human_body_temp_normal_imperial)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@
|
|||||||
<stroke
|
<stroke
|
||||||
android:width="2dp"
|
android:width="2dp"
|
||||||
android:color="@color/accent" />
|
android:color="@color/accent" />
|
||||||
|
<solid
|
||||||
|
android:color="@color/cardview_dark_background"/>
|
||||||
<corners android:radius="15dp" />
|
<corners android:radius="15dp" />
|
||||||
<padding
|
<padding
|
||||||
android:bottom="5dp"
|
android:bottom="5dp"
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true"
|
||||||
|
android:drawable="@drawable/dropdown_list_item_background_pressed"/>
|
||||||
|
<item android:drawable="@drawable/dropdown_list_item_background_released"/>
|
||||||
|
</selector>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke
|
||||||
|
android:width="2dp"
|
||||||
|
android:color="@color/grey" />
|
||||||
|
<solid
|
||||||
|
android:color="@color/grey" />
|
||||||
|
<corners android:radius="15dp" />
|
||||||
|
<padding
|
||||||
|
android:bottom="5dp"
|
||||||
|
android:left="5dp"
|
||||||
|
android:right="5dp"
|
||||||
|
android:top="5dp" />
|
||||||
|
</shape>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke
|
||||||
|
android:width="2dp"
|
||||||
|
android:color="@color/grey" />
|
||||||
|
<solid
|
||||||
|
android:color="@color/cardview_dark_background"/>
|
||||||
|
<corners android:radius="15dp" />
|
||||||
|
<padding
|
||||||
|
android:bottom="5dp"
|
||||||
|
android:left="5dp"
|
||||||
|
android:right="5dp"
|
||||||
|
android:top="5dp" />
|
||||||
|
</shape>
|
5
app/src/main/res/drawable/ic_more.xml
Normal file
5
app/src/main/res/drawable/ic_more.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||||
|
|
||||||
|
</vector>
|
12
app/src/main/res/drawable/textview_background.xml
Normal file
12
app/src/main/res/drawable/textview_background.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke
|
||||||
|
android:width="2dp"
|
||||||
|
android:color="@color/grey" />
|
||||||
|
<corners android:radius="10dp" />
|
||||||
|
<padding
|
||||||
|
android:bottom="10dp"
|
||||||
|
android:left="20dp"
|
||||||
|
android:right="20dp"
|
||||||
|
android:top="10dp" />
|
||||||
|
</shape>
|
@ -6,18 +6,78 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingTop="30dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/title"
|
android:orientation="horizontal">
|
||||||
android:textSize="30sp"
|
|
||||||
android:gravity="center_horizontal"/>
|
<ImageView
|
||||||
|
android:id="@+id/button_settings"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:src="@drawable/ic_settings"
|
||||||
|
app:tint="@color/grey"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/title"
|
||||||
|
android:textSize="26dp"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/button_sync"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:src="@drawable/ic_sync"
|
||||||
|
app:tint="@color/grey"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="38dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/button_background">
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/logbooks_spinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/logbooks_add_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:text="+"
|
||||||
|
android:background="@drawable/button_background"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -108,7 +168,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="2"
|
||||||
android:background="@drawable/button_background"
|
android:background="@drawable/button_background"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textSize="30dp"
|
android:textSize="30dp"
|
||||||
@ -119,12 +179,23 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="2"
|
||||||
android:background="@drawable/button_background"
|
android:background="@drawable/button_background"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textSize="30dp"
|
android:textSize="30dp"
|
||||||
android:text="🚼 💧"/>
|
android:text="🚼 💧"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/button_more"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/button_background"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:src="@drawable/ic_more"
|
||||||
|
app:tint="@android:color/darker_gray"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -141,7 +212,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Diario di bordo"
|
android:text="@string/logbook"
|
||||||
android:textColor="@color/accent"
|
android:textColor="@color/accent"
|
||||||
android:textStyle="bold"/>
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
@ -154,24 +225,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/button_settings"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:src="@drawable/ic_settings"
|
|
||||||
app:tint="@color/grey"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/button_sync"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:src="@drawable/ic_sync"
|
|
||||||
app:tint="@color/grey"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/no_connection_screen"
|
android:id="@+id/no_connection_screen"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -68,7 +68,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="30dp"
|
android:layout_marginLeft="30dp"
|
||||||
android:hint="@string/settings_storage_dav_url_hint"
|
android:hint="@string/settings_storage_dav_url_hint"
|
||||||
android:inputType="textUri"/>
|
android:inputType="textUri"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -83,7 +84,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="30dp"
|
android:layout_marginLeft="30dp"
|
||||||
android:inputType="textEmailAddress"/>
|
android:inputType="textEmailAddress"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -98,7 +100,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="30dp"
|
android:layout_marginLeft="30dp"
|
||||||
android:inputType="textPassword"/>
|
android:inputType="textPassword"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
android:id="@+id/progress_indicator"
|
android:id="@+id/progress_indicator"
|
||||||
@ -119,6 +122,9 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:background="@drawable/button_background"
|
||||||
|
android:textColor="@color/accent"
|
||||||
android:text="@android:string/cancel"/>
|
android:text="@android:string/cancel"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@ -127,6 +133,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textColor="@color/accent"
|
android:textColor="@color/accent"
|
||||||
|
android:background="@drawable/button_background"
|
||||||
android:text="@android:string/ok"/>
|
android:text="@android:string/ok"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
24
app/src/main/res/layout/dialog_add_logbook.xml
Normal file
24
app/src/main/res/layout/dialog_add_logbook.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dialog_add_logbook_message"/>
|
||||||
|
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/dialog_add_logbook_logbookname"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:lines="1"
|
||||||
|
android:inputType="text"
|
||||||
|
android:hint="@string/dialog_add_logbook_logbookname"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
55
app/src/main/res/layout/dialog_event_detail.xml
Normal file
55
app/src/main/res/layout/dialog_event_detail.xml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_event_detail_type_emoji"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textSize="60dp"
|
||||||
|
android:text="@string/event_diaperchange_pee_type"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_event_detail_type_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@color/accent"
|
||||||
|
android:textSize="24dp"
|
||||||
|
android:text="@string/event_diaperchange_pee_desc"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_event_detail_type_date"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="2020"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_event_detail_type_quantity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="2020"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_marginTop="20dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_event_detail_type_notes"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:text="Lorem ipsum"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
</LinearLayout>
|
27
app/src/main/res/layout/dialog_notes.xml
Normal file
27
app/src/main/res/layout/dialog_notes.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/notes_qty_edittext"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="1"
|
||||||
|
android:inputType="number"
|
||||||
|
android:hint="@string/log_notes_dialog_qty_hint"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/notes_edittext"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="top"
|
||||||
|
android:lines="10"
|
||||||
|
android:hint="@string/log_notes_dialog_note_hint"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
64
app/src/main/res/layout/more_events_popup.xml
Normal file
64
app/src/main/res/layout/more_events_popup.xml
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:background="@color/transparent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/button_medicine"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:background="@drawable/dropdown_list_item_background"
|
||||||
|
style="@style/OverflowMenuText"
|
||||||
|
android:text="@string/overflow_event_medicine"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/button_enema"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:background="@drawable/dropdown_list_item_background"
|
||||||
|
style="@style/OverflowMenuText"
|
||||||
|
android:text="@string/overflow_event_enema"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/button_note"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:background="@drawable/dropdown_list_item_background"
|
||||||
|
style="@style/OverflowMenuText"
|
||||||
|
android:text="@string/overflow_event_note"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/button_temperature"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:background="@drawable/dropdown_list_item_background"
|
||||||
|
style="@style/OverflowMenuText"
|
||||||
|
android:text="@string/overflow_event_temperature"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/button_colic"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:background="@drawable/dropdown_list_item_background"
|
||||||
|
style="@style/OverflowMenuText"
|
||||||
|
android:text="@string/overflow_event_colic"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -11,7 +11,8 @@
|
|||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:hint="0"/>
|
android:hint="0"
|
||||||
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
11
app/src/main/res/layout/row_logbook_spinner.xml
Normal file
11
app/src/main/res/layout/row_logbook_spinner.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/text1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="20dp"
|
||||||
|
android:paddingEnd="20dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"/>
|
@ -3,21 +3,28 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/type"
|
android:id="@+id/type"
|
||||||
android:layout_width="0dp"
|
android:layout_width="90dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="2"
|
android:paddingLeft="10dp"
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:text="Type"/>
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/event_diaperchange_pee_type"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="@color/accent"
|
||||||
android:text="Description"/>
|
android:text="Description"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -25,6 +32,8 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:text="Qty"/>
|
android:text="Qty"/>
|
||||||
|
|
||||||
@ -35,6 +44,8 @@
|
|||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
android:text="Time"/>
|
android:text="Time"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
59
app/src/main/res/layout/row_luna_event_vertical.xml
Normal file
59
app/src/main/res/layout/row_luna_event_vertical.xml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/type"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="28sp"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/event_diaperchange_pee_type"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textColor="@color/accent"
|
||||||
|
android:text="Description"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/quantity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="Qty"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:text="Time"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
26
app/src/main/res/layout/temperature_dialog.xml
Normal file
26
app/src/main/res/layout/temperature_dialog.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<com.google.android.material.slider.Slider
|
||||||
|
android:id="@+id/dialog_temperature_value"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:valueFrom="@integer/human_body_temp_min_metric"
|
||||||
|
android:valueTo="@integer/human_body_temp_max_metric"
|
||||||
|
android:stepSize="0.1"
|
||||||
|
android:value="@integer/human_body_temp_normal_metric"
|
||||||
|
android:theme="@style/LTSlider"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_temperature_display"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:textColor="@color/accent"/>
|
||||||
|
</LinearLayout>
|
@ -10,14 +10,14 @@
|
|||||||
<string name="log_weight_dialog_title">Pesata</string>
|
<string name="log_weight_dialog_title">Pesata</string>
|
||||||
<string name="log_weight_dialog_description">Inserisci il peso rilevato</string>
|
<string name="log_weight_dialog_description">Inserisci il peso rilevato</string>
|
||||||
|
|
||||||
<string name="event_bottle_type">🍼</string>
|
<string name="log_temperature_dialog_title">Temperatura</string>
|
||||||
<string name="event_scale_type">⚖️</string>
|
<string name="log_temperature_dialog_description">Inserisci la temperatura</string>
|
||||||
<string name="event_breastfeeding_left_type">🤱 ←</string>
|
|
||||||
<string name="event_breastfeeding_both_type">🤱 ↔</string>
|
<string name="overflow_event_medicine">💊 Medicina</string>
|
||||||
<string name="event_breastfeeding_right_type">🤱 →</string>
|
<string name="overflow_event_enema">🪠 Clistere</string>
|
||||||
<string name="event_diaperchange_poo_type">🚼 💩</string>
|
<string name="overflow_event_note">📝 Nota</string>
|
||||||
<string name="event_diaperchange_pee_type">🚼 💧</string>
|
<string name="overflow_event_temperature">🌡️ Temperatura</string>
|
||||||
<string name="event_unknown_type">-</string>
|
<string name="overflow_event_colic">💨 Colichette</string>
|
||||||
|
|
||||||
<string name="event_bottle_desc">Biberon</string>
|
<string name="event_bottle_desc">Biberon</string>
|
||||||
<string name="event_scale_desc">Pesata</string>
|
<string name="event_scale_desc">Pesata</string>
|
||||||
@ -26,9 +26,15 @@
|
|||||||
<string name="event_breastfeeding_right_desc">Allatt. al seno (dx)</string>
|
<string name="event_breastfeeding_right_desc">Allatt. al seno (dx)</string>
|
||||||
<string name="event_diaperchange_poo_desc">Cambio (con cacca)</string>
|
<string name="event_diaperchange_poo_desc">Cambio (con cacca)</string>
|
||||||
<string name="event_diaperchange_pee_desc">Cambio (con pipì)</string>
|
<string name="event_diaperchange_pee_desc">Cambio (con pipì)</string>
|
||||||
|
<string name="event_medicine_desc">Medicina</string>
|
||||||
|
<string name="event_enema_desc">Clistere</string>
|
||||||
|
<string name="event_note_desc">Nota</string>
|
||||||
|
<string name="event_temperature_desc">Temperatura</string>
|
||||||
|
<string name="event_colic_desc">Colichette</string>
|
||||||
<string name="event_unknown_desc"></string>
|
<string name="event_unknown_desc"></string>
|
||||||
|
|
||||||
<string name="toast_event_added">Evento aggiunto</string>
|
<string name="toast_event_added">Evento aggiunto</string>
|
||||||
|
<string name="toast_logbook_saved">Diario salvato</string>
|
||||||
<string name="toast_event_add_error">Impossibile aggiungere l\'evento</string>
|
<string name="toast_event_add_error">Impossibile aggiungere l\'evento</string>
|
||||||
<string name="toast_integer_error">Valore non valido. Inserire un numero intero.</string>
|
<string name="toast_integer_error">Valore non valido. Inserire un numero intero.</string>
|
||||||
|
|
||||||
@ -48,7 +54,7 @@
|
|||||||
<string name="settings_storage_local">Sul dispositivo</string>
|
<string name="settings_storage_local">Sul dispositivo</string>
|
||||||
<string name="settings_storage_local_desc">La soluzione più privacy-friendly: i dati non escono mai dal tuo dispositivo</string>
|
<string name="settings_storage_local_desc">La soluzione più privacy-friendly: i dati non escono mai dal tuo dispositivo</string>
|
||||||
<string name="settings_storage_dav">Su un server WebDAV</string>
|
<string name="settings_storage_dav">Su un server WebDAV</string>
|
||||||
<string name="settings_storage_dav_desc">Puoi usare un qualunque servizio che supporti WebDAV (come ad esempio Nextcloud, Owncloud, Dropbox, Box...) per salvare i dati. In questo modo puoi sincronizzarli tra più dispositivi, ad esempio quello del papà, della mamma, dei nonni... Ti servirà l\'url WebDAV, che trovi nella documentazione del tuo provider (ad es. in Nextcloud è nelle impostazioni di Files)</string>
|
<string name="settings_storage_dav_desc">Puoi usare un qualunque servizio che supporti WebDAV (come ad esempio Nextcloud, Owncloud, Dropbox, Box…) per salvare i dati. In questo modo puoi sincronizzarli tra più dispositivi, ad esempio quello del papà, della mamma, dei nonni… Ti servirà l\'url WebDAV, che trovi nella documentazione del tuo provider (ad es. in Nextcloud è nelle impostazioni di Files)</string>
|
||||||
<string name="settings_storage_dav_url">Url WebDAV</string>
|
<string name="settings_storage_dav_url">Url WebDAV</string>
|
||||||
<string name="settings_storage_dav_url_hint">https://</string>
|
<string name="settings_storage_dav_url_hint">https://</string>
|
||||||
<string name="settings_storage_dav_user">Username</string>
|
<string name="settings_storage_dav_user">Username</string>
|
||||||
@ -60,4 +66,24 @@
|
|||||||
<string name="settings_webdav_creation_ok">Connessione al server WebDAV avvenuta con successo</string>
|
<string name="settings_webdav_creation_ok">Connessione al server WebDAV avvenuta con successo</string>
|
||||||
<string name="settings_json_error">Sul server esiste un salvataggio, ma è corrotto o illeggibile. Cancellare il file </string>
|
<string name="settings_json_error">Sul server esiste un salvataggio, ma è corrotto o illeggibile. Cancellare il file </string>
|
||||||
<string name="settings_generic_error">Si è verificato un errore: </string>
|
<string name="settings_generic_error">Si è verificato un errore: </string>
|
||||||
|
|
||||||
|
<string name="trim_logbook_dialog_title">Il tuo diario è bello grande!</string>
|
||||||
|
<string name="trim_logbook_dialog_message_local">Il file del tuo diario sta crescendo molto. Ti suggeriamo di cancellare gli eventi più vecchi per evitare problemi di memoria.</string>
|
||||||
|
<string name="trim_logbook_dialog_message_dav">Il file del tuo diario sta crescendo molto. Ti suggeriamo di cancellare gli eventi più vecchi per evitare problemi di memoria. Se vuoi conservare tutto lo storico, fai un backup del file "lunatracker_logbook.json" sul tuo server WebDAV o rinominalo per mantenerlo così e cominciare un nuovo diario.</string>
|
||||||
|
<string name="trim_logbook_dialog_button_ok">Cancella i più vecchi</string>
|
||||||
|
<string name="trim_logbook_dialog_button_cancel">Ricordamelo dopo</string>
|
||||||
|
|
||||||
|
<string name="log_notes_dialog_description">Note:</string>
|
||||||
|
<string name="log_medicine_dialog_description">Nome della medicina, quantità, formato, note…:</string>
|
||||||
|
<string name="log_notes_dialog_qty_hint">Quantità, o vuoto</string>
|
||||||
|
<string name="log_notes_dialog_note_hint">Inserisci le note</string>
|
||||||
|
|
||||||
|
<string name="dialog_event_detail_title">Dettaglio evento</string>
|
||||||
|
|
||||||
|
<string name="dialog_add_logbook_title">Aggiungi diario</string>
|
||||||
|
<string name="dialog_add_logbook_logbookname">Nome del diario</string>
|
||||||
|
<string name="dialog_add_logbook_message">Scrivi un nome per identificare questo diario. Comparirà in cima allo schermo, e se usi WebDAV sarà incluso anche nel nome del file di salvataggio.</string>
|
||||||
|
|
||||||
|
<string name="default_logbook_name">👶 Il mio primo diario</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -4,5 +4,10 @@
|
|||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
<color name="translucent">#c000</color>
|
<color name="translucent">#c000</color>
|
||||||
|
<color name="transparent">#0000</color>
|
||||||
<color name="grey">#ccc</color>
|
<color name="grey">#ccc</color>
|
||||||
|
<color name="list_background_odd">#423B25</color>
|
||||||
|
<color name="list_background_even">@color/transparent</color>
|
||||||
|
<color name="danger">#f00</color>
|
||||||
|
<color name="textColor">@color/grey</color>
|
||||||
</resources>
|
</resources>
|
@ -10,14 +10,22 @@
|
|||||||
<string name="log_weight_dialog_title">Weight</string>
|
<string name="log_weight_dialog_title">Weight</string>
|
||||||
<string name="log_weight_dialog_description">Insert the weight</string>
|
<string name="log_weight_dialog_description">Insert the weight</string>
|
||||||
|
|
||||||
<string name="event_bottle_type">🍼</string>
|
<string name="log_temperature_dialog_title">Temperature</string>
|
||||||
<string name="event_scale_type">⚖️</string>
|
<string name="log_temperature_dialog_description">Insert the temperature</string>
|
||||||
<string name="event_breastfeeding_left_type">🤱 ←</string>
|
|
||||||
<string name="event_breastfeeding_both_type">🤱 ↔</string>
|
<string name="event_bottle_type" translatable="false">🍼</string>
|
||||||
<string name="event_breastfeeding_right_type">🤱 →</string>
|
<string name="event_scale_type" translatable="false">⚖️</string>
|
||||||
<string name="event_diaperchange_poo_type">🚼 💩</string>
|
<string name="event_breastfeeding_left_type" translatable="false">🤱 ←</string>
|
||||||
<string name="event_diaperchange_pee_type">🚼 💧</string>
|
<string name="event_breastfeeding_both_type" translatable="false">🤱 ↔</string>
|
||||||
<string name="event_unknown_type">-</string>
|
<string name="event_breastfeeding_right_type" translatable="false">🤱 →</string>
|
||||||
|
<string name="event_diaperchange_poo_type" translatable="false">🚼 💩</string>
|
||||||
|
<string name="event_diaperchange_pee_type" translatable="false">🚼 💧</string>
|
||||||
|
<string name="event_medicine_type" translatable="false">💊</string>
|
||||||
|
<string name="event_enema_type" translatable="false">🪠</string>
|
||||||
|
<string name="event_note_type" translatable="false">📝</string>
|
||||||
|
<string name="event_temperature_type" translatable="false">🌡️</string>
|
||||||
|
<string name="event_colic_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>
|
||||||
<string name="event_scale_desc">Weight</string>
|
<string name="event_scale_desc">Weight</string>
|
||||||
@ -26,9 +34,21 @@
|
|||||||
<string name="event_breastfeeding_right_desc">Breastfeeding (right)</string>
|
<string name="event_breastfeeding_right_desc">Breastfeeding (right)</string>
|
||||||
<string name="event_diaperchange_poo_desc">Diaper chg (poo)</string>
|
<string name="event_diaperchange_poo_desc">Diaper chg (poo)</string>
|
||||||
<string name="event_diaperchange_pee_desc">Diaper chg (pee)</string>
|
<string name="event_diaperchange_pee_desc">Diaper chg (pee)</string>
|
||||||
|
<string name="event_medicine_desc">Medicine</string>
|
||||||
|
<string name="event_enema_desc">Enema</string>
|
||||||
|
<string name="event_note_desc">Note</string>
|
||||||
|
<string name="event_temperature_desc">Temperature</string>
|
||||||
|
<string name="event_colic_desc">Gaseous colic</string>
|
||||||
<string name="event_unknown_desc"></string>
|
<string name="event_unknown_desc"></string>
|
||||||
|
|
||||||
|
<string name="overflow_event_medicine">💊 Medicine</string>
|
||||||
|
<string name="overflow_event_enema">🪠 Enema</string>
|
||||||
|
<string name="overflow_event_note">📝 Note</string>
|
||||||
|
<string name="overflow_event_temperature">🌡️ Temperature</string>
|
||||||
|
<string name="overflow_event_colic">💨 Gaseous colic</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_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>
|
||||||
|
|
||||||
@ -48,7 +68,7 @@
|
|||||||
<string name="settings_storage_local">On device</string>
|
<string name="settings_storage_local">On device</string>
|
||||||
<string name="settings_storage_local_desc">Most privacy-friendly solution: data doesn\'t leave your device</string>
|
<string name="settings_storage_local_desc">Most privacy-friendly solution: data doesn\'t leave your device</string>
|
||||||
<string name="settings_storage_dav">On a WebDAV server</string>
|
<string name="settings_storage_dav">On a WebDAV server</string>
|
||||||
<string name="settings_storage_dav_desc">You can use any WebDAV service (i.e. Nextcloud, Owncloud, Dropbox, Box...) to save the data. In this way you can syncronize it between more devices, i.e. the dad\'s, the mom\'s, the grandma\'s... You will need the WebDAV url, you can find it in your provider\'s documentation (i.e. in Nextcloud web is in the Files app settings)</string>
|
<string name="settings_storage_dav_desc">You can use any WebDAV service (i.e. Nextcloud, Owncloud, Dropbox, Box…) to save the data. In this way you can syncronize it between more devices, i.e. the dad\'s, the mom\'s, the grandma\'s… You will need the WebDAV url, you can find it in your provider\'s documentation (i.e. in Nextcloud web is in the Files app settings)</string>
|
||||||
<string name="settings_storage_dav_url">WebDAV url</string>
|
<string name="settings_storage_dav_url">WebDAV url</string>
|
||||||
<string name="settings_storage_dav_url_hint">https://</string>
|
<string name="settings_storage_dav_url_hint">https://</string>
|
||||||
<string name="settings_storage_dav_user">Username</string>
|
<string name="settings_storage_dav_user">Username</string>
|
||||||
@ -60,4 +80,33 @@
|
|||||||
<string name="settings_webdav_creation_ok">Successfully connected with WebDAV server</string>
|
<string name="settings_webdav_creation_ok">Successfully connected with WebDAV server</string>
|
||||||
<string name="settings_json_error">There\'s a save file on the server, but is corrupted or unreadable. Please delete it </string>
|
<string name="settings_json_error">There\'s a save file on the server, but is corrupted or unreadable. Please delete it </string>
|
||||||
<string name="settings_generic_error">Error: </string>
|
<string name="settings_generic_error">Error: </string>
|
||||||
|
|
||||||
|
<string name="trim_logbook_dialog_title">Your logbook is pretty big!</string>
|
||||||
|
<string name="trim_logbook_dialog_message_local">Your logbook file is growing a lot. We suggest trimming the oldest events to avoid crashes.</string>
|
||||||
|
<string name="trim_logbook_dialog_message_dav">Your logbook file is growing a lot. We suggest trimming the oldest events to avoid crashes. If you want to preserve all the events, please backup the "lunatracker_logbook.json" file on the WebDAV server or rename it to start a new logbook keeping the old one.</string>
|
||||||
|
<string name="trim_logbook_dialog_button_ok">Trim it now</string>
|
||||||
|
<string name="trim_logbook_dialog_button_cancel">Remind me later</string>
|
||||||
|
|
||||||
|
<string name="log_notes_dialog_description">Notes:</string>
|
||||||
|
<string name="log_medicine_dialog_description">Medicine name, quantity, type, notes…:</string>
|
||||||
|
<string name="log_notes_dialog_qty_hint">Quantity (or empty)</string>
|
||||||
|
<string name="log_notes_dialog_note_hint">Write some notes</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_tiny_metric" translatable="false">mg</string>
|
||||||
|
<string name="measurement_unit_liquid_base_imperial" translatable="false">fl oz.</string>
|
||||||
|
<string name="measurement_unit_weight_base_imperial" translatable="false">oz</string>
|
||||||
|
<string name="measurement_unit_weight_tiny_imperial" translatable="false">gr</string>
|
||||||
|
<string name="measurement_unit_temperature_base_imperial" translatable="false">°F</string>
|
||||||
|
<string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
|
||||||
|
|
||||||
|
<string name="dialog_event_detail_title">Event detail</string>
|
||||||
|
|
||||||
|
<string name="dialog_add_logbook_title">Add logbook</string>
|
||||||
|
<string name="dialog_add_logbook_logbookname">Logbook name</string>
|
||||||
|
<string name="dialog_add_logbook_message">Write a name to identify this logbook. This name will appear on top of the screen and, if you use WebDAV, will be in the save file name as well.</string>
|
||||||
|
|
||||||
|
<string name="default_logbook_name">👶 My first logbook</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -1,5 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="Theme.LunaTracker" parent="Theme.AppCompat.NoActionBar" />
|
<style name="Theme.LunaTracker" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="colorAccent">@color/accent</item>
|
||||||
|
<item name="android:textColor">@color/textColor</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="OverflowMenuText">
|
||||||
|
<item name="android:textSize">20sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="LTSlider" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||||
|
<item name="colorPrimary">@color/accent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
9
app/src/main/res/values/values.xml
Normal file
9
app/src/main/res/values/values.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="human_body_temp_min_imperial">91</integer>
|
||||||
|
<integer name="human_body_temp_min_metric">33</integer>
|
||||||
|
<integer name="human_body_temp_max_imperial">109</integer>
|
||||||
|
<integer name="human_body_temp_max_metric">43</integer>
|
||||||
|
<integer name="human_body_temp_normal_imperial">98</integer>
|
||||||
|
<integer name="human_body_temp_normal_metric">37</integer>
|
||||||
|
</resources>
|
@ -1,7 +1,5 @@
|
|||||||
LunaTracker is a newborn baby tracking app.
|
|
||||||
|
|
||||||
Parenting can be tough. You get home from the hospital, exhausted, with this little fragile unknown thingy that has no user manual and a single way to let you know something's not ok: crying.
|
Parenting can be tough. You get home from the hospital, exhausted, with this little fragile unknown thingy that has no user manual and a single way to let you know something's not ok: crying.
|
||||||
You have to react fast, event if it's 4 AM and you have no idea why is crying.
|
You have to react fast, even if it's 4 AM and you have no idea why is crying.
|
||||||
|
|
||||||
This app is meant to log all the relevant events (diaper change, breastfeeding, baby bottle feeding...), so you can always remember when has been done last time. It supports syncing the data between different devices (using your WebDAV server for the best privacy) so that when the baby needs attentions, the dad can step in leaving the mom sleeping peacefully.
|
This app is meant to log all the relevant events (diaper change, breastfeeding, baby bottle feeding...), so you can always remember when has been done last time. It supports syncing the data between different devices (using your WebDAV server for the best privacy) so that when the baby needs attentions, the dad can step in leaving the mom sleeping peacefully.
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
LunaTracker è un'app di tracciamento neonatale
|
|
||||||
|
|
||||||
Essere genitori può essere dura. Arrivate a casa dall'ospedale, esausti, con questo cosino fragile e sconosciuto che non ha un manuale d'uso, e ha un solo modo per segnalare che c'è qualcosa che non va: piangere.
|
Essere genitori può essere dura. Arrivate a casa dall'ospedale, esausti, con questo cosino fragile e sconosciuto che non ha un manuale d'uso, e ha un solo modo per segnalare che c'è qualcosa che non va: piangere.
|
||||||
Dovete essere sempre pronti a reagire, anche se sono le 4 di mattina e non avete idea del perché stia piangendo.
|
Dovete essere sempre pronti a reagire, anche se sono le 4 di mattina e non avete idea del perché stia piangendo.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user