12 Commits

Author SHA1 Message Date
6f69b581e4 MainActivity: sort events before saving 2025-12-25 01:54:03 +01:00
ec80f78baf StatisticsActivity: rework all statistics
Improve the overall code.
2025-12-25 01:51:17 +01:00
2f877bdec7 NumericUtils: remove possible trailing whitespace 2025-12-25 01:51:17 +01:00
22e5e3ddec MainActivity: do not switch logbook on reload 2025-12-25 01:51:17 +01:00
2ae5a2deda LunaEvent: reorganize event text getters
Use method names that better reflect
the use of the returned text.
2025-12-25 01:51:17 +01:00
e8480176c3 MainAcitivty: add dynamic header setting
The setting allows to build the menu and
popup list to be populated by the frequency
of events that has been created.
This also makes the 'no breastfeeding' setting irrelevant.
2025-12-25 01:51:13 +01:00
1c90fbd7c4 LunaEvent: use enum class for event types
This helps to have compile errors when some
case it not handled while adding a new type.
The enum class can also be interated over
to create a complete drop down list.
2025-12-25 01:46:38 +01:00
b164a80531 MainActivity: increase bottle volume to 340ml
This is the maximum amount found in sold bottles.
2025-12-25 01:46:38 +01:00
ae965ebe5e gradle: use uniform implementation directive for sardine-android 2025-12-25 01:46:38 +01:00
daac0d063f gradle: avoid inclusion of apk signing blobs
See https://android.izzysoft.de/articles/named/iod-scan-apkchecks?lang=en#blobs
2025-12-25 01:46:38 +01:00
eab55de651 gradle: set compileSDK/targetSdk to 36 2025-12-25 01:46:38 +01:00
7cf396026b StatisticsActivity: add statistics for bottle and sleep events 2025-12-25 01:46:20 +01:00
9 changed files with 679 additions and 384 deletions

View File

@@ -420,17 +420,6 @@ 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) { saveEvent(event) } askSleepValue(event) { saveEvent(event) }
} }
@@ -1116,23 +1105,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)
@@ -1144,6 +1116,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?.notifyItemInserted(0)
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.

View File

@@ -61,7 +61,7 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter<LunaEventRecyclerAdapter.Lu
val endTime = if (item.type == LunaEvent.Type.SLEEP) { val endTime = if (item.type == LunaEvent.Type.SLEEP) {
item.quantity + item.time item.quantity + item.time
} else { } else {
item.time item.time
} }
holder.time.text = DateUtils.formatTimeAgo(context, endTime) holder.time.text = DateUtils.formatTimeAgo(context, endTime)
var quantityText = numericUtils.formatEventQuantity(item) var quantityText = numericUtils.formatEventQuantity(item)

View File

@@ -32,25 +32,18 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Spinner <Spinner
android:id="@+id/type_selection" android:id="@+id/graph_type_selection"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_weight="1"
android:layout_weight="1" /> android:gravity="center"/>
<!--
<Spinner <Spinner
android:id="@+id/data_selection" android:id="@+id/time_range_selection"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_weight="1"
android:layout_weight="1"/> android:gravity="center"/>
-->
<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>

View File

@@ -18,13 +18,6 @@
<string name="event_colic_desc">Blähungskolik</string> <string name="event_colic_desc">Blähungskolik</string>
<string name="event_unknown_desc"></string> <string name="event_unknown_desc"></string>
<string name="overflow_event_weight">⚖️ Gewicht</string>
<string name="overflow_event_medicine">💊 Medikament</string>
<string name="overflow_event_enema">🪠 Einlauf</string>
<string name="overflow_event_note">📝 Notiz</string>
<string name="overflow_event_temperature">🌡️ Temperatur</string>
<string name="overflow_event_colic">💨 Blähungskolik</string>
<string name="toast_event_added">Ereignis gespeichert</string> <string name="toast_event_added">Ereignis gespeichert</string>
<string name="toast_logbook_saved">Logbuch gespeichert</string> <string name="toast_logbook_saved">Logbuch gespeichert</string>
<string name="toast_event_add_error">Ereignis konnte nicht protokolliert werden</string> <string name="toast_event_add_error">Ereignis konnte nicht protokolliert werden</string>
@@ -42,7 +35,6 @@
<string name="no_connection_retry">Erneut versuchen</string> <string name="no_connection_retry">Erneut versuchen</string>
<string name="settings_title">Einstellungen</string> <string name="settings_title">Einstellungen</string>
<string name="settings_no_breastfeeding">Kein Stillen</string>
<string name="settings_storage">Speicherort für Daten auswählen</string> <string name="settings_storage">Speicherort für Daten auswählen</string>
<string name="settings_storage_local">Auf dem Gerät</string> <string name="settings_storage_local">Auf dem Gerät</string>
<string name="settings_storage_local_desc">Datenschutzfreundlichste Lösung: Deine Daten verlassen dein Gerät nicht</string> <string name="settings_storage_local_desc">Datenschutzfreundlichste Lösung: Deine Daten verlassen dein Gerät nicht</string>

View File

@@ -18,13 +18,6 @@
<string name="event_colic_desc">Colique gazeuse</string> <string name="event_colic_desc">Colique gazeuse</string>
<string name="event_unknown_desc"></string> <string name="event_unknown_desc"></string>
<string name="overflow_event_weight">⚖️ Poids</string>
<string name="overflow_event_medicine">💊 Médicament</string>
<string name="overflow_event_enema">🪠 Lavement</string>
<string name="overflow_event_note">📝 Note</string>
<string name="overflow_event_temperature">🌡️ Température</string>
<string name="overflow_event_colic">💨 Colique gazeuse</string>
<string name="toast_event_added">Entrée ajoutée</string> <string name="toast_event_added">Entrée ajoutée</string>
<string name="toast_logbook_saved">Journal ajouté</string> <string name="toast_logbook_saved">Journal ajouté</string>
<string name="toast_event_add_error">Impossible d\'enregistrer cette entrée</string> <string name="toast_event_add_error">Impossible d\'enregistrer cette entrée</string>

View File

@@ -3,13 +3,6 @@
<string name="title">🌜 LunaTracker 🌛</string> <string name="title">🌜 LunaTracker 🌛</string>
<string name="logbook">Diario di bordo</string> <string name="logbook">Diario di bordo</string>
<string name="overflow_event_weight">⚖️ Peso</string>
<string name="overflow_event_medicine">💊 Medicina</string>
<string name="overflow_event_enema">🪠 Clistere</string>
<string name="overflow_event_note">📝 Nota</string>
<string name="overflow_event_temperature">🌡️ Temperatura</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_food_desc">Cibo</string> <string name="event_food_desc">Cibo</string>
<string name="event_weight_desc">Pesata</string> <string name="event_weight_desc">Pesata</string>

View File

@@ -8,33 +8,23 @@
</string-array> </string-array>
<string-array name="StatisticsTypeLabels"> <string-array name="StatisticsTypeLabels">
<item>BOTTLE_EVENTS</item> <item>@string/statistics_bottle_sum</item>
<item>BOTTLE_SUM</item> <item>@string/statistics_bottle_events</item>
<item>BOTTLE_SUM_AVERAGE</item> <item>@string/statistics_sleep_sum</item>
<item>SLEEP_SUM_AVERAGE</item> <item>@string/statistics_sleep_events</item>
<item>SLEEP_EVENTS</item> <item>@string/statistics_sleep_pattern</item>
<item>SLEEP_PATTERN</item> <item>@string/statistics_medicine_events</item>
</string-array> </string-array>
<string-array name="StatisticsTypeValues"> <string-array name="StatisticsTypeValues">
<item>BOTTLE_EVENTS</item>
<item>BOTTLE_SUM</item> <item>BOTTLE_SUM</item>
<item>BOTTLE_SUM_AVERAGE</item> <item>BOTTLE_EVENTS</item>
<item>SLEEP_SUM_AVERAGE</item> <item>SLEEP_SUM</item>
<item>SLEEP_EVENTS</item> <item>SLEEP_EVENTS</item>
<item>SLEEP_PATTERN</item> <item>SLEEP_PATTERN</item>
</string-array> <item>MEDICINE_EVENTS</item>
<!--
<string-array name="StatisticsDataLabels">
<item>Event</item>
<item>Amount</item>
</string-array> </string-array>
<string-array name="StatisticsDataValues">
<item>EVENT</item>
<item>AMOUNT</item>
</string-array>
-->
<string-array name="StatisticsTimeLabels"> <string-array name="StatisticsTimeLabels">
<item>Day</item> <item>Day</item>
<item>Week</item> <item>Week</item>
@@ -46,5 +36,4 @@
<item>WEEK</item> <item>WEEK</item>
<item>MONTH</item> <item>MONTH</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -140,6 +140,13 @@
<string name="measurement_unit_temperature_base_imperial" translatable="false">°F</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="measurement_unit_temperature_base_metric" translatable="false">°C</string>
<string name="statistics_bottle_events">Bottle Events</string>
<string name="statistics_bottle_sum">Bottle Per Day</string>
<string name="statistics_medicine_events">Medicine Events</string>
<string name="statistics_sleep_sum">Sleep Per Day</string>
<string name="statistics_sleep_events">Sleep Events</string>
<string name="statistics_sleep_pattern">Sleep Pattern</string>
<string name="row_luna_event_description">Description</string> <string name="row_luna_event_description">Description</string>
<string name="row_luna_event_quantity">Qty</string> <string name="row_luna_event_quantity">Qty</string>
<string name="row_luna_event_time">Time</string> <string name="row_luna_event_time">Time</string>