mirror of
https://github.com/bleackstorm/satiea.git
synced 2026-12-03 07:41:56 +01:00
feat: implement meal notification system
Add necessary permissions, services, and receivers to support scheduled meal notifications and boot completion handling. Also includes dependency updates and minor test fixes.
This commit is contained in:
1 parent
f13d46f778
commit
fe69d7621a
31 files changed
+2972
-350
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package com.example.util
|
||||
|
||||
import com.example.data.model.HungerSatietyScale
|
||||
import com.example.data.model.MealEntry
|
||||
import com.example.data.model.MealType
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
object GoogleSheetsDataFormatter {
|
||||
|
||||
val HEADERS: List<String> = listOf(
|
||||
"Date",
|
||||
"Heure",
|
||||
"Type de repas",
|
||||
"Faim avant (/10)",
|
||||
"Ressenti faim",
|
||||
"Satiété après (/10)",
|
||||
"Ressenti satiété",
|
||||
"Aliments & Poids",
|
||||
"Note globale",
|
||||
"Photos jointes"
|
||||
)
|
||||
|
||||
fun formatMealsToRows(meals: List<MealEntry>): List<List<Any>> {
|
||||
val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.FRENCH)
|
||||
val timeFormat = SimpleDateFormat("HH:mm", Locale.FRENCH)
|
||||
|
||||
val rows = mutableListOf<List<Any>>()
|
||||
// Header row
|
||||
rows.add(HEADERS)
|
||||
|
||||
// Sorted by descending timestamp (most recent first)
|
||||
val sortedMeals = meals.sortedByDescending { it.mealTimestamp }
|
||||
|
||||
for (meal in sortedMeals) {
|
||||
val dateObj = Date(meal.mealTimestamp)
|
||||
val dateStr = dateFormat.format(dateObj)
|
||||
val timeStr = timeFormat.format(dateObj)
|
||||
val mealTypeLabel = MealType.fromString(meal.mealType).displayName
|
||||
val hungerLabel = HungerSatietyScale.getHungerLabel(meal.hungerBefore)
|
||||
val satietyLabel = HungerSatietyScale.getSatietyLabel(meal.satietyAfter)
|
||||
val foodsFormatted = meal.parsedFoodItems().joinToString(" ; ") { it.displayCsv() }
|
||||
val cleanNote = meal.note.replace("\r\n", " ").replace("\n", " ").trim()
|
||||
val photosCount = meal.photosBase64.size
|
||||
|
||||
rows.add(
|
||||
listOf(
|
||||
dateStr,
|
||||
timeStr,
|
||||
mealTypeLabel,
|
||||
meal.hungerBefore,
|
||||
hungerLabel,
|
||||
meal.satietyAfter,
|
||||
satietyLabel,
|
||||
foodsFormatted,
|
||||
cleanNote,
|
||||
photosCount
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user