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:
bleackstorm committed 2026-11-08 16:57:11 +01:00
1 parent f13d46f778
commit fe69d7621a
31 files changed
+2972 -350

No files matched your search

@@ -0,0 +1,95 @@
package com.example
import com.example.data.model.MealEntry
import com.example.data.model.MealFoodItem
import com.example.data.model.MealType
import com.example.data.model.FoodUnit
import com.example.util.GoogleSheetsDataFormatter
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import java.util.Calendar
class GoogleSheetsDataFormatterTest {
@Test
fun `formatMealsToRows with empty list returns only header row`() {
val rows = GoogleSheetsDataFormatter.formatMealsToRows(emptyList())
assertEquals(1, rows.size)
assertEquals(GoogleSheetsDataFormatter.HEADERS, rows[0])
}
@Test
fun `formatMealsToRows formats meal fields accurately and sorts chronologically descending`() {
val cal1 = Calendar.getInstance().apply {
set(2026, Calendar.MARCH, 15, 12, 30, 0)
set(Calendar.MILLISECOND, 0)
}
val cal2 = Calendar.getInstance().apply {
set(2026, Calendar.MARCH, 15, 20, 0, 0)
set(Calendar.MILLISECOND, 0)
}
val meal1 = MealEntry(
id = "meal-1",
mealType = MealType.LUNCH.name,
mealTimestamp = cal1.timeInMillis,
hungerBefore = 3,
satietyAfter = 7,
note = "Repas calme et savoureux",
foodItemsSerialized = listOf(
MealFoodItem("Riz complet", 150.0, FoodUnit.G).serialize(),
MealFoodItem("Saumon", 120.0, FoodUnit.G).serialize()
),
photosBase64 = listOf("photo1")
)
val meal2 = MealEntry(
id = "meal-2",
mealType = MealType.DINNER.name,
mealTimestamp = cal2.timeInMillis,
hungerBefore = 4,
satietyAfter = 8,
note = "Dîner léger en famille",
foodItemsSerialized = listOf(
MealFoodItem("Soupe de légumes", 250.0, FoodUnit.ML).serialize()
),
photosBase64 = emptyList()
)
// Pass in reverse order to test sorting
val rows = GoogleSheetsDataFormatter.formatMealsToRows(listOf(meal1, meal2))
// 1 header + 2 data rows
assertEquals(3, rows.size)
// Row 0: Headers
assertEquals(10, rows[0].size)
assertEquals("Date", rows[0][0])
assertEquals("Photos jointes", rows[0][9])
// Row 1: Most recent meal (DINNER at 20:00)
val dinnerRow = rows[1]
assertEquals("15/03/2026", dinnerRow[0])
assertEquals("20:00", dinnerRow[1])
assertEquals("Dîner", dinnerRow[2])
assertEquals(4, dinnerRow[3])
assertEquals(8, dinnerRow[5])
assertTrue((dinnerRow[7] as String).contains("Soupe de légumes"))
assertEquals("Dîner léger en famille", dinnerRow[8])
assertEquals(0, dinnerRow[9])
// Row 2: Earlier meal (LUNCH at 12:30)
val lunchRow = rows[2]
assertEquals("15/03/2026", lunchRow[0])
assertEquals("12:30", lunchRow[1])
assertEquals("Déjeuner", lunchRow[2])
assertEquals(3, lunchRow[3])
assertEquals(7, lunchRow[5])
val lunchFoods = lunchRow[7] as String
assertTrue(lunchFoods.contains("Riz complet"))
assertTrue(lunchFoods.contains("Saumon"))
assertEquals("Repas calme et savoureux", lunchRow[8])
assertEquals(1, lunchRow[9])
}
}