forked from penguin86/luna-tracker
Compare commits
6 Commits
80fa8d8294
...
remove_sta
| Author | SHA1 | Date | |
|---|---|---|---|
| a8305b8fc9 | |||
| 43f0519487 | |||
| 1bcfc18a71 | |||
| e345e98668 | |||
| 09f5a4e27b | |||
| b3b432525e |
@@ -65,5 +65,4 @@ dependencies {
|
|||||||
androidTestImplementation(libs.androidx.ui.test.junit4)
|
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||||
debugImplementation(libs.androidx.ui.tooling)
|
debugImplementation(libs.androidx.ui.tooling)
|
||||||
debugImplementation(libs.androidx.ui.test.manifest)
|
debugImplementation(libs.androidx.ui.test.manifest)
|
||||||
implementation(libs.mpandroidchart.vv310)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,6 @@
|
|||||||
android:name=".SettingsActivity"
|
android:name=".SettingsActivity"
|
||||||
android:label="@string/settings_title"
|
android:label="@string/settings_title"
|
||||||
android:theme="@style/Theme.LunaTracker"/>
|
android:theme="@style/Theme.LunaTracker"/>
|
||||||
<activity
|
|
||||||
android:name=".StatisticsActivity"
|
|
||||||
android:label="@string/statistics_title"
|
|
||||||
android:theme="@style/Theme.LunaTracker"/>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -276,7 +276,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
numberPicker.value = event.quantity / 10
|
numberPicker.value = event.quantity / 10
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val pickedTime = datePickerHelper(event.time, dateTV)
|
val pickedTime = dateTimePicker(event.time, dateTV)
|
||||||
|
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
@@ -314,7 +314,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
weightET.setText(event.quantity.toString())
|
weightET.setText(event.quantity.toString())
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val pickedTime = datePickerHelper(event.time, dateTV)
|
val pickedTime = dateTimePicker(event.time, dateTV)
|
||||||
|
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
@@ -365,7 +365,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val pickedTime = datePickerHelper(event.time, dateTV)
|
val pickedTime = dateTimePicker(event.time, dateTV)
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun datePickerHelper(time: Long, dateTextView: TextView, onChange: (Long) -> Unit = {}): Calendar {
|
// Pick a date/time.
|
||||||
|
fun dateTimePicker(time: Long, dateTextView: TextView, onChange: (Long) -> Unit = {}): Calendar {
|
||||||
dateTextView.text = DateUtils.formatDateTime(time)
|
dateTextView.text = DateUtils.formatDateTime(time)
|
||||||
|
|
||||||
val dateTime = Calendar.getInstance()
|
val dateTime = Calendar.getInstance()
|
||||||
@@ -420,97 +421,83 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return dateTime
|
return dateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveEvent(event: LunaEvent) {
|
|
||||||
if (!allEvents.contains(event)) {
|
|
||||||
// new event
|
|
||||||
logEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
logbook?.sort()
|
|
||||||
recyclerView.adapter?.notifyDataSetChanged()
|
|
||||||
saveLogbook()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addSleepEvent(event: LunaEvent) {
|
fun addSleepEvent(event: LunaEvent) {
|
||||||
askSleepValue(event, true) { saveEvent(event) }
|
askSleepValue(event, true) { saveEvent(event) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun askSleepValue(event: LunaEvent, hideDurationButtons: Boolean, onPositive: () -> Unit) {
|
fun askSleepValue(event: LunaEvent, showTime: Boolean, onPositive: () -> Unit) {
|
||||||
val d = AlertDialog.Builder(this)
|
val d = AlertDialog.Builder(this)
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_edit_duration, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_edit_duration, null)
|
||||||
d.setTitle(event.getDialogTitle(this))
|
d.setTitle(event.getDialogTitle(this))
|
||||||
d.setMessage(event.getDialogMessage(this))
|
|
||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
|
|
||||||
val durationTextView = dialogView.findViewById<TextView>(R.id.dialog_date_duration)
|
val durationTextView = dialogView.findViewById<TextView>(R.id.dialog_date_duration)
|
||||||
val datePicker = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val datePickerBegin = dialogView.findViewById<TextView>(R.id.dialog_date_picker_begin)
|
||||||
val durationButtons = dialogView.findViewById<LinearLayout>(R.id.duration_buttons)
|
val datePickerEnd = dialogView.findViewById<TextView>(R.id.dialog_date_picker_end)
|
||||||
val durationNowButton = dialogView.findViewById<Button>(R.id.dialog_date_duration_now)
|
|
||||||
val durationMinus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus5)
|
|
||||||
val durationPlus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus5)
|
|
||||||
|
|
||||||
val currentDurationTextColor = durationTextView.currentTextColor
|
val currentDurationTextColor = durationTextView.currentTextColor
|
||||||
val invalidDurationTextColor = ContextCompat.getColor(this, R.color.danger)
|
val invalidDurationTextColor = ContextCompat.getColor(this, R.color.danger)
|
||||||
|
|
||||||
var duration = event.quantity
|
// in seconds
|
||||||
|
var sleepStart = event.time
|
||||||
|
var sleepEnd = event.time + event.quantity
|
||||||
|
|
||||||
fun isValidTime(timeSeconds: Long, durationSeconds: Int): Boolean {
|
fun isValidTimeSpan(timeBeginUnix: Long, timeEndUnix: Long): Boolean {
|
||||||
val now = System.currentTimeMillis() / 1000
|
val now = System.currentTimeMillis() / 1000
|
||||||
return (timeSeconds + durationSeconds) <= now && durationSeconds < (24 * 60 * 60)
|
return (timeBeginUnix > 0)
|
||||||
|
&& (timeEndUnix > 0)
|
||||||
|
&& (timeBeginUnix <= timeEndUnix)
|
||||||
|
&& (timeBeginUnix <= now)
|
||||||
|
&& (timeEndUnix <= now)
|
||||||
|
&& (timeEndUnix - timeBeginUnix) < (24 * 60 * 60)
|
||||||
}
|
}
|
||||||
|
|
||||||
val onDateChange = { time: Long ->
|
// prevent printing of seconds
|
||||||
durationTextView.setTextColor(currentDurationTextColor)
|
fun adjustToMinute(unixTime: Long): Long {
|
||||||
|
return unixTime - (unixTime % 60)
|
||||||
|
}
|
||||||
|
|
||||||
if (duration == 0) {
|
fun updateDuration() {
|
||||||
|
durationTextView.setTextColor(currentDurationTextColor)
|
||||||
|
val duration = sleepEnd - sleepStart
|
||||||
|
if (duration == 0L) {
|
||||||
// baby is sleeping
|
// baby is sleeping
|
||||||
durationTextView.text = "💤"
|
durationTextView.text = "💤"
|
||||||
} else {
|
} else {
|
||||||
durationTextView.text = DateUtils.formatTimeDuration(applicationContext, duration.toLong())
|
durationTextView.text = DateUtils.formatTimeDuration(applicationContext, duration)
|
||||||
if (!isValidTime(time, duration)) {
|
if (!isValidTimeSpan(sleepStart, sleepEnd)) {
|
||||||
durationTextView.setTextColor(invalidDurationTextColor)
|
durationTextView.setTextColor(invalidDurationTextColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val pickedDateTime = datePickerHelper(event.time, datePicker, onDateChange)
|
val pickedDateTimeBegin = dateTimePicker(event.time, datePickerBegin) { time: Long ->
|
||||||
|
sleepStart = adjustToMinute(time)
|
||||||
|
updateDuration()
|
||||||
|
}
|
||||||
|
|
||||||
onDateChange(pickedDateTime.time.time / 1000)
|
val pickedDateTimeEnd = dateTimePicker(event.time + event.quantity, datePickerEnd) { time: Long ->
|
||||||
|
sleepEnd = adjustToMinute(time)
|
||||||
|
updateDuration()
|
||||||
|
}
|
||||||
|
|
||||||
if (hideDurationButtons) {
|
sleepStart = adjustToMinute(pickedDateTimeBegin.time.time / 1000)
|
||||||
durationButtons.visibility = View.GONE
|
sleepEnd = adjustToMinute(pickedDateTimeEnd.time.time / 1000)
|
||||||
d.setMessage(getString(R.string.log_sleep_dialog_description_start))
|
updateDuration()
|
||||||
|
|
||||||
|
if (showTime) {
|
||||||
|
datePickerEnd.visibility = View.GONE
|
||||||
|
durationTextView.visibility = View.GONE
|
||||||
|
//d.setMessage("")
|
||||||
} else {
|
} else {
|
||||||
durationButtons.visibility = View.VISIBLE
|
durationTextView.visibility = View.VISIBLE
|
||||||
d.setMessage(event.getDialogMessage(this))
|
d.setMessage(event.getDialogMessage(this))
|
||||||
|
|
||||||
fun adjust(minutes: Int) {
|
|
||||||
duration += minutes * 60
|
|
||||||
if (duration < 0) {
|
|
||||||
duration = 0
|
|
||||||
}
|
|
||||||
onDateChange(pickedDateTime.time.time / 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
durationMinus5Button.setOnClickListener { adjust(-5) }
|
|
||||||
durationPlus5Button.setOnClickListener { adjust(5) }
|
|
||||||
|
|
||||||
durationNowButton.setOnClickListener {
|
|
||||||
val now = System.currentTimeMillis() / 1000
|
|
||||||
val start = pickedDateTime.time.time / 1000
|
|
||||||
if (now > start) {
|
|
||||||
duration = (now - start).toInt()
|
|
||||||
duration -= duration % 60 // prevent printing of seconds
|
|
||||||
onDateChange(pickedDateTime.time.time / 1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
val time = pickedDateTime.time.time / 1000
|
if (isValidTimeSpan(sleepStart, sleepEnd)) {
|
||||||
if (isValidTime(time, duration)) {
|
event.time = sleepStart
|
||||||
event.time = time
|
event.quantity = (sleepEnd - sleepStart).toInt()
|
||||||
event.quantity = duration
|
|
||||||
onPositive()
|
onPositive()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.toast_date_error, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.toast_date_error, Toast.LENGTH_SHORT).show()
|
||||||
@@ -548,7 +535,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
spinner.setSelection(event.quantity.coerceIn(0, spinner.count - 1))
|
spinner.setSelection(event.quantity.coerceIn(0, spinner.count - 1))
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val pickedTime = datePickerHelper(event.time, dateTV)
|
val pickedTime = dateTimePicker(event.time, dateTV)
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@@ -581,7 +568,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val pickedDateTime = datePickerHelper(event.time, dateTV)
|
val pickedDateTime = dateTimePicker(event.time, dateTV)
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@@ -616,7 +603,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
||||||
|
|
||||||
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val dateTV = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val pickedTime = datePickerHelper(event.time, dateTV)
|
val pickedTime = dateTimePicker(event.time, dateTV)
|
||||||
|
|
||||||
if (!showTime) {
|
if (!showTime) {
|
||||||
dateTV.visibility = View.GONE
|
dateTV.visibility = View.GONE
|
||||||
@@ -828,7 +815,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
||||||
notesTextView.text = event.notes
|
notesTextView.text = event.notes
|
||||||
if (event.type == LunaEvent.Type.SLEEP && event.quantity > 0) {
|
if (event.type == LunaEvent.Type.SLEEP && event.quantity > 0) {
|
||||||
dateEndTextView.text = DateUtils.formatDateTime(event.time + event.quantity)
|
dateEndTextView.text = DateUtils.formatDateTime(event.getEndTime())
|
||||||
dateEndTextView.visibility = View.VISIBLE
|
dateEndTextView.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
dateEndTextView.visibility = View.GONE
|
dateEndTextView.visibility = View.GONE
|
||||||
@@ -842,7 +829,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
updateValues()
|
updateValues()
|
||||||
|
|
||||||
datePickerHelper(event.time, dateTextView, { newTime: Long ->
|
dateTimePicker(event.time, dateTextView, { newTime: Long ->
|
||||||
event.time = newTime
|
event.time = newTime
|
||||||
updateValues()
|
updateValues()
|
||||||
})
|
})
|
||||||
@@ -886,7 +873,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val previousEvent = getPreviousSameEvent(event, allEvents)
|
val previousEvent = getPreviousSameEvent(event, allEvents)
|
||||||
if (previousEvent != null) {
|
if (previousEvent != null) {
|
||||||
val emoji = previousEvent.getHeaderEmoji(applicationContext)
|
val emoji = previousEvent.getHeaderEmoji(applicationContext)
|
||||||
val time = DateUtils.formatTimeDuration(applicationContext, event.time - previousEvent.time)
|
val time = DateUtils.formatTimeDuration(applicationContext, event.getStartTime() - previousEvent.getEndTime())
|
||||||
previousTextView.text = String.format("⬅️ %s %s", emoji, time)
|
previousTextView.text = String.format("⬅️ %s %s", emoji, time)
|
||||||
previousTextView.setOnClickListener {
|
previousTextView.setOnClickListener {
|
||||||
alertDialog.cancel()
|
alertDialog.cancel()
|
||||||
@@ -901,7 +888,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val nextEvent = getNextSameEvent(event, allEvents)
|
val nextEvent = getNextSameEvent(event, allEvents)
|
||||||
if (nextEvent != null) {
|
if (nextEvent != null) {
|
||||||
val emoji = nextEvent.getHeaderEmoji(applicationContext)
|
val emoji = nextEvent.getHeaderEmoji(applicationContext)
|
||||||
val time = DateUtils.formatTimeDuration(applicationContext, nextEvent.time - event.time)
|
val time = DateUtils.formatTimeDuration(applicationContext, nextEvent.getStartTime() - event.getEndTime())
|
||||||
nextTextView.text = String.format("%s %s ➡️", time, emoji)
|
nextTextView.text = String.format("%s %s ➡️", time, emoji)
|
||||||
nextTextView.setOnClickListener {
|
nextTextView.setOnClickListener {
|
||||||
alertDialog.cancel()
|
alertDialog.cancel()
|
||||||
@@ -1126,23 +1113,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun logEvent(event: LunaEvent) {
|
|
||||||
savingEvent(true)
|
|
||||||
|
|
||||||
event.signature = signature
|
|
||||||
|
|
||||||
setLoading(true)
|
|
||||||
logbook?.logs?.add(0, event)
|
|
||||||
recyclerView.adapter?.notifyItemInserted(0)
|
|
||||||
recyclerView.smoothScrollToPosition(0)
|
|
||||||
saveLogbook(event)
|
|
||||||
|
|
||||||
// Check logbook size to avoid OOM errors
|
|
||||||
if (logbook?.isTooBig() == true) {
|
|
||||||
askToTrimLogbook()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun deleteEvent(event: LunaEvent) {
|
fun deleteEvent(event: LunaEvent) {
|
||||||
// Update view
|
// Update view
|
||||||
savingEvent(true)
|
savingEvent(true)
|
||||||
@@ -1154,6 +1124,32 @@ class MainActivity : AppCompatActivity() {
|
|||||||
saveLogbook()
|
saveLogbook()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveEvent(event: LunaEvent) {
|
||||||
|
if (allEvents.contains(event)) {
|
||||||
|
// event was modified
|
||||||
|
logbook?.sort()
|
||||||
|
recyclerView.adapter?.notifyDataSetChanged()
|
||||||
|
saveLogbook()
|
||||||
|
} else {
|
||||||
|
// add new event
|
||||||
|
savingEvent(true)
|
||||||
|
setLoading(true)
|
||||||
|
if (signature.isNotEmpty()) {
|
||||||
|
event.signature = signature
|
||||||
|
}
|
||||||
|
logbook?.logs?.add(0, event)
|
||||||
|
logbook?.sort()
|
||||||
|
recyclerView.adapter?.notifyDataSetChanged()
|
||||||
|
recyclerView.smoothScrollToPosition(0)
|
||||||
|
saveLogbook(event)
|
||||||
|
|
||||||
|
// Check logbook size to avoid OOM errors
|
||||||
|
if (logbook?.isTooBig() == true) {
|
||||||
|
askToTrimLogbook()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the logbook. If saving while adding an event, please specify the event so in case
|
* Saves the logbook. If saving while adding an event, please specify the event so in case
|
||||||
* of error can be removed from the list.
|
* of error can be removed from the list.
|
||||||
@@ -1288,18 +1284,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val inflater = LayoutInflater.from(anchor.context)
|
val inflater = LayoutInflater.from(anchor.context)
|
||||||
contentView = inflater.inflate(R.layout.more_events_popup, null)
|
contentView = inflater.inflate(R.layout.more_events_popup, null)
|
||||||
|
|
||||||
// Add statistics (hard coded)
|
|
||||||
contentView.findViewById<View>(R.id.button_statistics).setOnClickListener {
|
|
||||||
if (logbook != null && !pauseLogbookUpdate) {
|
|
||||||
val i = Intent(applicationContext, StatisticsActivity::class.java)
|
|
||||||
i.putExtra("LOOGBOOK_NAME", logbook!!.name)
|
|
||||||
startActivity(i)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(applicationContext, "No logbook selected!", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
val linearLayout = contentView.findViewById<LinearLayout>(R.id.layout_list)
|
val linearLayout = contentView.findViewById<LinearLayout>(R.id.layout_list)
|
||||||
|
|
||||||
// Add buttons to create other events
|
// Add buttons to create other events
|
||||||
|
|||||||
@@ -1,374 +0,0 @@
|
|||||||
package it.danieleverducci.lunatracker
|
|
||||||
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.AdapterView
|
|
||||||
import android.widget.ArrayAdapter
|
|
||||||
import android.widget.Spinner
|
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.github.mikephil.charting.charts.BarChart
|
|
||||||
import com.github.mikephil.charting.data.BarData
|
|
||||||
import com.github.mikephil.charting.data.BarDataSet
|
|
||||||
import com.github.mikephil.charting.data.BarEntry
|
|
||||||
import com.github.mikephil.charting.formatter.ValueFormatter
|
|
||||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet
|
|
||||||
import it.danieleverducci.lunatracker.entities.LunaEvent
|
|
||||||
import utils.DateUtils.Companion.formatTimeDuration
|
|
||||||
import utils.NumericUtils
|
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
|
||||||
import kotlin.math.max
|
|
||||||
import kotlin.math.min
|
|
||||||
|
|
||||||
class StatisticsActivity : AppCompatActivity() {
|
|
||||||
lateinit var barChart: BarChart
|
|
||||||
lateinit var noDataTextView: TextView
|
|
||||||
lateinit var eventTypeSelection: Spinner
|
|
||||||
lateinit var dataTypeSelection: Spinner
|
|
||||||
lateinit var timeRangeSelection: Spinner
|
|
||||||
|
|
||||||
// default selection
|
|
||||||
var eventTypeSelectionValue = "BOTTLE"
|
|
||||||
var dataTypeSelectionValue = "AMOUNT"
|
|
||||||
var timeRangeSelectionValue = "DAY"
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_statistics)
|
|
||||||
|
|
||||||
val logbookName = intent.getStringExtra("LOOGBOOK_NAME")
|
|
||||||
if (logbookName == null) {
|
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
noDataTextView = findViewById(R.id.no_data)
|
|
||||||
|
|
||||||
barChart = findViewById(R.id.bar_chart)
|
|
||||||
barChart.setBackgroundColor(Color.WHITE)
|
|
||||||
barChart.description.text = "$logbookName"
|
|
||||||
barChart.setDrawValueAboveBar(false)
|
|
||||||
|
|
||||||
barChart.axisLeft.setAxisMinimum(0F)
|
|
||||||
barChart.axisLeft.setDrawGridLines(false)
|
|
||||||
barChart.axisLeft.setDrawLabels(false)
|
|
||||||
|
|
||||||
barChart.axisRight.setDrawGridLines(false)
|
|
||||||
barChart.axisRight.setDrawLabels(false)
|
|
||||||
|
|
||||||
barChart.xAxis.setDrawGridLines(true)
|
|
||||||
barChart.xAxis.setDrawLabels(true)
|
|
||||||
barChart.xAxis.setDrawAxisLine(false)
|
|
||||||
|
|
||||||
eventTypeSelection = findViewById(R.id.type_selection)
|
|
||||||
dataTypeSelection = findViewById(R.id.data_selection)
|
|
||||||
timeRangeSelection = findViewById(R.id.time_selection)
|
|
||||||
|
|
||||||
setupSpinner(eventTypeSelectionValue,
|
|
||||||
R.id.type_selection,
|
|
||||||
R.array.StatisticsTypeLabels,
|
|
||||||
R.array.StatisticsTypeValues,
|
|
||||||
object : SpinnerItemSelected {
|
|
||||||
override fun call(newValue: String?) {
|
|
||||||
if (newValue != null) {
|
|
||||||
eventTypeSelectionValue = newValue
|
|
||||||
//Log.d("event", "new value: $newValue")
|
|
||||||
updateGraph()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
setupSpinner(dataTypeSelectionValue,
|
|
||||||
R.id.data_selection,
|
|
||||||
R.array.StatisticsDataLabels,
|
|
||||||
R.array.StatisticsDataValues,
|
|
||||||
object : SpinnerItemSelected {
|
|
||||||
override fun call(newValue: String?) {
|
|
||||||
if (newValue != null) {
|
|
||||||
dataTypeSelectionValue = newValue
|
|
||||||
//Log.d("event", "new value: $newValue")
|
|
||||||
updateGraph()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
setupSpinner(timeRangeSelectionValue,
|
|
||||||
R.id.time_selection,
|
|
||||||
R.array.StatisticsTimeLabels,
|
|
||||||
R.array.StatisticsTimeValues,
|
|
||||||
object : SpinnerItemSelected {
|
|
||||||
override fun call(newValue: String?) {
|
|
||||||
if (newValue != null) {
|
|
||||||
timeRangeSelectionValue = newValue
|
|
||||||
//Log.d("event", "new value: $newValue")
|
|
||||||
updateGraph()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
updateGraph()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateGraph() {
|
|
||||||
val eventType = when (eventTypeSelectionValue) {
|
|
||||||
"BOTTLE" -> LunaEvent.TYPE_BABY_BOTTLE
|
|
||||||
"SLEEP" -> LunaEvent.TYPE_SLEEP
|
|
||||||
else -> {
|
|
||||||
Log.e(TAG, "unhandled eventTypeSelectionValue: $eventTypeSelectionValue")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val allEvents = MainActivity.allEvents.filter { it.type == eventType }.sortedBy { it.time }
|
|
||||||
|
|
||||||
val values = ArrayList<BarEntry>()
|
|
||||||
val labels = ArrayList<String>()
|
|
||||||
|
|
||||||
val unixToSpan = when (timeRangeSelectionValue) {
|
|
||||||
"DAY" -> { unix: Long -> unixToDays(unix) }
|
|
||||||
"WEEK" -> { unix: Long -> unixToWeeks(unix) }
|
|
||||||
"MONTH" -> { unix: Long -> unixToMonths(unix) }
|
|
||||||
else -> {
|
|
||||||
Log.e(TAG, "Invalid timeRangeSelectionValue: $timeRangeSelectionValue")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val spanToUnix = when (timeRangeSelectionValue) {
|
|
||||||
"DAY" -> { span: Int -> daysToUnix(span) }
|
|
||||||
"WEEK" -> { span: Int -> weeksToUnix(span) }
|
|
||||||
"MONTH" -> { span: Int -> monthsToUnix(span) }
|
|
||||||
else -> {
|
|
||||||
Log.e(TAG, "Invalid timeRangeSelectionValue: $timeRangeSelectionValue")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun spanToLabel(span: Int): String {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(1000 * spanToUnix(span))
|
|
||||||
val year = dateTime.get(Calendar.YEAR)
|
|
||||||
val month = dateTime.get(Calendar.MONTH) + 1 // month starts at 0
|
|
||||||
val week = dateTime.get(Calendar.WEEK_OF_YEAR)
|
|
||||||
val day = dateTime.get(Calendar.DAY_OF_MONTH)
|
|
||||||
return when (timeRangeSelectionValue) {
|
|
||||||
"DAY" -> "$day/$month/$year"
|
|
||||||
"WEEK" -> "$week/$year"
|
|
||||||
"MONTH" -> "$month/$year"
|
|
||||||
else -> {
|
|
||||||
Log.e(TAG, "Invalid timeRangeSelectionValue: $timeRangeSelectionValue")
|
|
||||||
"?"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allEvents.isNotEmpty()) {
|
|
||||||
barChart.visibility = View.VISIBLE
|
|
||||||
noDataTextView.visibility = View.GONE
|
|
||||||
|
|
||||||
// unix time span of all events
|
|
||||||
val startUnix = allEvents.minOf { it.getStartTime() }
|
|
||||||
val endUnix = allEvents.maxOf { it.getEndTime() }
|
|
||||||
|
|
||||||
// convert to days, weeks or months
|
|
||||||
val startSpan = unixToSpan(startUnix)
|
|
||||||
val endSpan = unixToSpan(endUnix)
|
|
||||||
|
|
||||||
//Log.d(TAG, "startUnix: $startUnix (${Date(1000 * startUnix)}), startSpan: $startSpan (${Date(1000 * spanToUnix(startSpan))}), endUnix: $endUnix (${Date(1000 * endUnix)}), endSpan: $endSpan (${Date(1000 * spanToUnix(endSpan))})")
|
|
||||||
for (span in startSpan..endSpan) {
|
|
||||||
values.add(BarEntry(values.size.toFloat(), 0F))
|
|
||||||
labels.add(spanToLabel(span))
|
|
||||||
}
|
|
||||||
|
|
||||||
for (event in allEvents) {
|
|
||||||
if (dataTypeSelectionValue == "AMOUNT") {
|
|
||||||
if (eventTypeSelectionValue == "SLEEP") {
|
|
||||||
// a sleep event can span to another day
|
|
||||||
// distribute sleep time over the days
|
|
||||||
val startUnix = event.getStartTime()
|
|
||||||
val endUnix = event.getEndTime()
|
|
||||||
val begIndex = unixToSpan(startUnix)
|
|
||||||
val endIndex = unixToSpan(endUnix)
|
|
||||||
var mid = startUnix
|
|
||||||
|
|
||||||
//Log.d(TAG, "startUnix: ${Date(startUnix * 1000)}, endUnix: ${Date(endUnix * 1000)}, begIndex: $begIndex, endIndex: $endIndex (index diff: ${endIndex - begIndex})")
|
|
||||||
for (i in begIndex..endIndex) {
|
|
||||||
val spanBegin = spanToUnix(i)
|
|
||||||
val spanEnd = spanToUnix(i + 1)
|
|
||||||
//Log.d(TAG, "mid: ${Date(mid * 1000)}, spanBegin: ${Date(spanBegin * 1000)}, spanEnd: ${Date(spanEnd * 1000)}, endUnix: ${Date(endUnix * 1000)}")
|
|
||||||
val beg = max(mid, spanBegin)
|
|
||||||
val end = min(endUnix, spanEnd)
|
|
||||||
val index = i - startSpan
|
|
||||||
val duration = end - beg
|
|
||||||
//Log.d(TAG, "[$index] beg: ${Date(beg * 1000)}, end: ${Date(end * 1000)}, ${formatTimeDuration(this, duration)}")
|
|
||||||
|
|
||||||
values[index].y += duration
|
|
||||||
mid = end
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val index = unixToSpan(event.time) - startSpan
|
|
||||||
//Log.d(TAG, "[${index}] ${event.quantity}")
|
|
||||||
values[index].y += event.quantity
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val index = unixToSpan(event.time) - startSpan
|
|
||||||
values[index].y += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
barChart.visibility = View.GONE
|
|
||||||
noDataTextView.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
barChart.xAxis.setLabelCount(min(values.size, 24))
|
|
||||||
|
|
||||||
val set1 = BarDataSet(values, "")
|
|
||||||
|
|
||||||
set1.setDrawValues(true)
|
|
||||||
set1.setDrawIcons(false)
|
|
||||||
|
|
||||||
val dataSets = ArrayList<IBarDataSet?>()
|
|
||||||
dataSets.add(set1)
|
|
||||||
|
|
||||||
val data = BarData(dataSets)
|
|
||||||
|
|
||||||
data.setValueFormatter(object : ValueFormatter() {
|
|
||||||
override fun getFormattedValue(value: Float): String {
|
|
||||||
//Log.d(TAG, "getFormattedValue ${dataTypeSelectionValue} ${eventTypeSelectionValue}")
|
|
||||||
return when (dataTypeSelectionValue) {
|
|
||||||
"EVENT" -> value.toInt().toString()
|
|
||||||
"AMOUNT" -> when (eventTypeSelectionValue) {
|
|
||||||
"BOTTLE" -> NumericUtils(applicationContext).formatEventQuantity(LunaEvent.TYPE_BABY_BOTTLE, value.toInt())
|
|
||||||
"SLEEP" -> NumericUtils(applicationContext).formatEventQuantity(LunaEvent.TYPE_SLEEP, value.toInt())
|
|
||||||
else -> {
|
|
||||||
Log.e(TAG, "unhandled eventTypeSelectionValue: $eventTypeSelectionValue")
|
|
||||||
value.toInt().toString()
|
|
||||||
}
|
|
||||||
} else -> {
|
|
||||||
Log.e(TAG, "unhandled dataTypeSelectionValue: $dataTypeSelectionValue")
|
|
||||||
value.toInt().toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
barChart.xAxis.valueFormatter = object: ValueFormatter() {
|
|
||||||
override fun getFormattedValue(value: Float): String {
|
|
||||||
return labels.getOrElse(value.toInt(), {"?"})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data.setValueTextSize(12f)
|
|
||||||
barChart.setData(data)
|
|
||||||
barChart.invalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface SpinnerItemSelected {
|
|
||||||
fun call(newValue: String?)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupSpinner(
|
|
||||||
currentValue: String,
|
|
||||||
spinnerId: Int,
|
|
||||||
arrayId: Int,
|
|
||||||
arrayValuesId: Int,
|
|
||||||
callback: SpinnerItemSelected
|
|
||||||
) {
|
|
||||||
val arrayValues = resources.getStringArray(arrayValuesId)
|
|
||||||
val spinner = findViewById<Spinner>(spinnerId)
|
|
||||||
val spinnerAdapter =
|
|
||||||
ArrayAdapter.createFromResource(this, arrayId, R.layout.statistics_spinner_item)
|
|
||||||
|
|
||||||
spinner.adapter = spinnerAdapter
|
|
||||||
spinner.setSelection(arrayValues.indexOf(currentValue))
|
|
||||||
spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
|
||||||
var check = 0
|
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, pos: Int, id: Long) {
|
|
||||||
if (pos >= arrayValues.size) {
|
|
||||||
Toast.makeText(
|
|
||||||
this@StatisticsActivity,
|
|
||||||
"pos out of bounds: $arrayValues", Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (check++ > 0) {
|
|
||||||
callback.call(arrayValues[pos])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TAG = "StatisticsActivity"
|
|
||||||
|
|
||||||
fun unixToMonths(seconds: Long): Int {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(seconds * 1000)
|
|
||||||
val years = dateTime.get(Calendar.YEAR)
|
|
||||||
val months = dateTime.get(Calendar.MONTH)
|
|
||||||
return 12 * years + months
|
|
||||||
}
|
|
||||||
|
|
||||||
fun monthsToUnix(months: Int): Long {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(0)
|
|
||||||
dateTime.set(Calendar.YEAR, months / 12)
|
|
||||||
dateTime.set(Calendar.MONTH, months % 12)
|
|
||||||
dateTime.set(Calendar.HOUR, 0)
|
|
||||||
dateTime.set(Calendar.MINUTE, 0)
|
|
||||||
dateTime.set(Calendar.SECOND, 0)
|
|
||||||
return dateTime.time.time / 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
fun unixToWeeks(seconds: Long): Int {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(seconds * 1000)
|
|
||||||
val years = dateTime.get(Calendar.YEAR)
|
|
||||||
val weeks = dateTime.get(Calendar.WEEK_OF_YEAR)
|
|
||||||
return 52 * years + weeks
|
|
||||||
}
|
|
||||||
|
|
||||||
fun weeksToUnix(weeks: Int): Long {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(0)
|
|
||||||
dateTime.set(Calendar.YEAR, weeks / 52)
|
|
||||||
dateTime.set(Calendar.WEEK_OF_YEAR, weeks % 52)
|
|
||||||
dateTime.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY)
|
|
||||||
dateTime.set(Calendar.HOUR, 0)
|
|
||||||
dateTime.set(Calendar.MINUTE, 0)
|
|
||||||
dateTime.set(Calendar.SECOND, 0)
|
|
||||||
return dateTime.time.time / 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
fun unixToDays(seconds: Long): Int {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(seconds * 1000)
|
|
||||||
val years = dateTime.get(Calendar.YEAR)
|
|
||||||
val days = dateTime.get(Calendar.DAY_OF_YEAR)
|
|
||||||
return 365 * years + days
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert from days to Date
|
|
||||||
fun daysToUnix(days: Int): Long {
|
|
||||||
val dateTime = Calendar.getInstance()
|
|
||||||
dateTime.time = Date(0)
|
|
||||||
dateTime.set(Calendar.YEAR, days / 365)
|
|
||||||
dateTime.set(Calendar.DAY_OF_YEAR, days % 365)
|
|
||||||
dateTime.set(Calendar.HOUR, 0)
|
|
||||||
dateTime.set(Calendar.MINUTE, 0)
|
|
||||||
dateTime.set(Calendar.SECOND, 0)
|
|
||||||
return dateTime.time.time / 1000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -58,12 +58,7 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.Lu
|
|||||||
LunaEvent.Type.NOTE -> item.notes
|
LunaEvent.Type.NOTE -> item.notes
|
||||||
else -> item.getRowItemTitle(context)
|
else -> item.getRowItemTitle(context)
|
||||||
}
|
}
|
||||||
val endTime = if (item.type == LunaEvent.Type.SLEEP) {
|
holder.time.text = DateUtils.formatTimeAgo(context, item.getEndTime())
|
||||||
item.quantity + item.time
|
|
||||||
} else {
|
|
||||||
item.time
|
|
||||||
}
|
|
||||||
holder.time.text = DateUtils.formatTimeAgo(context, endTime)
|
|
||||||
var quantityText = numericUtils.formatEventQuantity(item)
|
var quantityText = numericUtils.formatEventQuantity(item)
|
||||||
|
|
||||||
// if the event is weight, show difference with the last one
|
// if the event is weight, show difference with the last one
|
||||||
|
|||||||
@@ -115,6 +115,18 @@ class LunaEvent: Comparable<LunaEvent> {
|
|||||||
return getDialogMessage(context, type)
|
return getDialogMessage(context, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getStartTime(): Long {
|
||||||
|
return time
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getEndTime(): Long {
|
||||||
|
return if (type == Type.SLEEP) {
|
||||||
|
time + quantity
|
||||||
|
} else {
|
||||||
|
time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun toJson(): JSONObject {
|
fun toJson(): JSONObject {
|
||||||
return jo
|
return jo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ class DateUtils {
|
|||||||
return builder.toString()
|
return builder.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (years > 0) {
|
if (years != 0L) {
|
||||||
return format(years, days, R.string.year_ago, R.string.years_ago, R.string.day_ago, R.string.days_ago)
|
return format(years, days, R.string.year_ago, R.string.years_ago, R.string.day_ago, R.string.days_ago)
|
||||||
} else if (days > 0) {
|
} else if (days != 0L) {
|
||||||
return format(days, hours, R.string.day_ago, R.string.days_ago, R.string.hour_ago, R.string.hours_ago)
|
return format(days, hours, R.string.day_ago, R.string.days_ago, R.string.hour_ago, R.string.hours_ago)
|
||||||
} else if (hours > 0) {
|
} else if (hours != 0L) {
|
||||||
return format(hours, minutes, R.string.hour_ago, R.string.hours_ago, R.string.minute_ago, R.string.minutes_ago)
|
return format(hours, minutes, R.string.hour_ago, R.string.hours_ago, R.string.minute_ago, R.string.minutes_ago)
|
||||||
} else {
|
} else {
|
||||||
return format(minutes, seconds, R.string.minute_ago, R.string.minute_ago, R.string.second_ago, R.string.seconds_ago)
|
return format(minutes, seconds, R.string.minute_ago, R.string.minute_ago, R.string.second_ago, R.string.seconds_ago)
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -177,15 +177,16 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textSize="30sp"/>
|
android:textSize="30sp"/>
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:id="@+id/button_more"
|
android:id="@+id/button_more"
|
||||||
android:layout_width="60dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:layout_weight="0"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/button_background"
|
android:background="@drawable/button_background"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:src="@drawable/ic_more"
|
android:textSize="30sp"
|
||||||
|
android:text="☰"
|
||||||
app:tint="@android:color/darker_gray"/>
|
app:tint="@android:color/darker_gray"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<com.github.mikephil.charting.charts.HorizontalBarChart
|
|
||||||
android:id="@+id/bar_chart"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/no_data"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="No Data"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/type_selection"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/data_selection"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/time_selection"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -7,47 +7,23 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_date_picker_begin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="10dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_date_duration"
|
android:id="@+id/dialog_date_duration"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:text="💤"/>
|
android:text="💤"/>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/duration_buttons"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_marginHorizontal="10dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_minus5"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="-5"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_now"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/now"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_plus5"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="+5"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_date_picker"
|
android:id="@+id/dialog_date_picker_end"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|||||||
@@ -10,17 +10,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
<!-- Buttons are inserted dynamically -->
|
||||||
<TextView
|
|
||||||
android:id="@+id/button_statistics"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:background="@drawable/dropdown_list_item_background"
|
|
||||||
style="@style/OverflowMenuText"
|
|
||||||
android:text="📊 Statistics"/>
|
|
||||||
|
|
||||||
<!-- Other buttons are inserted dynamically -->
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
@@ -6,37 +6,4 @@
|
|||||||
<item>@string/amount_normal</item>
|
<item>@string/amount_normal</item>
|
||||||
<item>@string/amount_plenty</item>
|
<item>@string/amount_plenty</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="StatisticsTypeLabels">
|
|
||||||
<item>Bottle</item>
|
|
||||||
<item>Sleep</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="StatisticsTypeValues">
|
|
||||||
<item>BOTTLE</item>
|
|
||||||
<item>SLEEP</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="StatisticsDataLabels">
|
|
||||||
<item>Event</item>
|
|
||||||
<item>Amount</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="StatisticsDataValues">
|
|
||||||
<item>EVENT</item>
|
|
||||||
<item>AMOUNT</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="StatisticsTimeLabels">
|
|
||||||
<item>Day</item>
|
|
||||||
<item>Week</item>
|
|
||||||
<item>Month</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="StatisticsTimeValues">
|
|
||||||
<item>DAY</item>
|
|
||||||
<item>WEEK</item>
|
|
||||||
<item>MONTH</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -88,8 +88,6 @@
|
|||||||
<string name="no_connection_go_to_settings">Settings</string>
|
<string name="no_connection_go_to_settings">Settings</string>
|
||||||
<string name="no_connection_retry">Retry</string>
|
<string name="no_connection_retry">Retry</string>
|
||||||
|
|
||||||
<string name="statistics_title">Statistics</string>
|
|
||||||
|
|
||||||
<string name="settings_dynamic_menu">Dynamic Menu</string>
|
<string name="settings_dynamic_menu">Dynamic Menu</string>
|
||||||
<string name="settings_dynamic_menu_desc">Populate the header menu with the most used events.</string>
|
<string name="settings_dynamic_menu_desc">Populate the header menu with the most used events.</string>
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
@@ -130,7 +128,6 @@
|
|||||||
<string name="log_unknown_dialog_description"></string>
|
<string name="log_unknown_dialog_description"></string>
|
||||||
<string name="log_weight_dialog_description">Insert the weight:</string>
|
<string name="log_weight_dialog_description">Insert the weight:</string>
|
||||||
<string name="log_sleep_dialog_description">Set sleep duration:</string>
|
<string name="log_sleep_dialog_description">Set sleep duration:</string>
|
||||||
<string name="log_sleep_dialog_description_start">Start sleep cycle:</string>
|
|
||||||
|
|
||||||
<string name="measurement_unit_liquid_base_metric" translatable="false">ml</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_base_metric" translatable="false">g</string>
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ lifecycleRuntimeKtx = "2.6.1"
|
|||||||
activityCompose = "1.8.0"
|
activityCompose = "1.8.0"
|
||||||
composeBom = "2024.04.01"
|
composeBom = "2024.04.01"
|
||||||
appcompat = "1.7.0"
|
appcompat = "1.7.0"
|
||||||
mpandroidchart = "v4.2.2"
|
|
||||||
mpandroidchartVersion = "v3.1.0"
|
|
||||||
recyclerview = "1.3.2"
|
recyclerview = "1.3.2"
|
||||||
material = "1.12.0"
|
material = "1.12.0"
|
||||||
sardineAndroid = "v0.9"
|
sardineAndroid = "v0.9"
|
||||||
@@ -33,8 +31,6 @@ androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit
|
|||||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||||
mpandroidchart = { module = "com.github.PhilJay:MPAndroidChart", version.ref = "mpandroidchart" }
|
|
||||||
mpandroidchart-vv310 = { module = "com.github.PhilJay:MPAndroidChart", version.ref = "mpandroidchartVersion" }
|
|
||||||
sardine-android = { module = "com.github.thegrizzlylabs:sardine-android", version.ref = "sardineAndroid" }
|
sardine-android = { module = "com.github.thegrizzlylabs:sardine-android", version.ref = "sardineAndroid" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
|||||||
Reference in New Issue
Block a user