5 Commits

Author SHA1 Message Date
e1dbc2c628 LunaEvent: rework sleep event
Make the UI more flexible and
slightly easier to understand.
2026-02-13 15:06:26 +01:00
1bcfc18a71 MainActivity: rename datepicker 2026-02-12 23:01:01 +01:00
e345e98668 layout: replace menu icon with utf8 character
The three dot menu icosn looks odd when stretched
due to the dynamic menu feature. Thus replace it
with the hamburger menu character that looks better
when scaled.
2026-02-12 23:01:01 +01:00
09f5a4e27b MainActivity: sort events before saving
Also replace notifyItemInserted since it does not
call the adapter to redraw the row striping when
a new event is added.
2026-02-12 23:01:01 +01:00
b3b432525e StatisticsActivity: rework all statistics
Improve the overall code.
2026-02-12 23:00:58 +01:00

View File

@@ -506,6 +506,7 @@ class StatisticsActivity : AppCompatActivity() {
mValuePaint.setColor(color)
c.drawText(valueText, x.coerceAtLeast(60F), y, mValuePaint)
}
}
fun showSleepBarGraph(state: GraphState) {
@@ -560,15 +561,12 @@ class StatisticsActivity : AppCompatActivity() {
}
val set1 = BarDataSet(values, "")
val data = BarData(set1)
set1.setDrawValues(true)
set1.setDrawIcons(false)
set1.isHighlightEnabled = false
val data = BarData(set1)
data.setValueTextSize(12f)
data.setValueFormatter(object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
val prefix = if (timeRangeSelection == TimeRange.DAY) { "" } else { "" }
return when (graphTypeSelection) {
GraphType.SLEEP_EVENTS -> {
@@ -585,10 +583,15 @@ class StatisticsActivity : AppCompatActivity() {
}
})
val valueCount = min(values.size, 24)
barChart.renderer = CustomHorizontalBarChartRenderer(barChart, barChart.animator, barChart.viewPortHandler)
set1.setDrawIcons(false)
data.setValueTextSize(12f)
barChart.setData(data)
barChart.setRenderer(CustomHorizontalBarChartRenderer(barChart, barChart.getAnimator(), barChart.getViewPortHandler()))
barChart.legend.isEnabled = false
val valueCount = min(values.size, 24)
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
barChart.xAxis.setLabelCount(valueCount)
barChart.xAxis.setCenterAxisLabels(false)
@@ -624,11 +627,11 @@ class StatisticsActivity : AppCompatActivity() {
}
val set1 = BarDataSet(values, "")
set1.setDrawValues(true)
set1.isHighlightEnabled = false
val data = BarData(set1)
data.setValueTextSize(12f)
data.setValueFormatter(object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
val prefix = if (timeRangeSelection == TimeRange.DAY) { "" } else { "" }
@@ -648,9 +651,12 @@ class StatisticsActivity : AppCompatActivity() {
}
})
val valueCount = min(values.size, 24)
barChart.renderer = CustomHorizontalBarChartRenderer(barChart, barChart.animator, barChart.viewPortHandler)
data.setValueTextSize(12f)
barChart.setData(data)
barChart.setRenderer(CustomHorizontalBarChartRenderer(barChart, barChart.getAnimator(), barChart.getViewPortHandler()))
val valueCount = min(values.size, 24)
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
barChart.xAxis.setLabelCount(valueCount)
barChart.xAxis.setCenterAxisLabels(false)