mirror of
https://github.com/bleackstorm/satiea.git
synced 2026-12-03 07:41:56 +01:00
feat: support meal photo URIs and improve UI events
- Add `photoUris` field to `MealEntry` and update Firestore rules. - Implement `UiEvent` handling in `MainActivity` for navigation/links. - Remove sensitive email data from error logs and clean up manifest.
This commit is contained in:
1 parent
f0487453c9
commit
87bbb448c2
34 files changed
+2026
-1170
No files matched your search
@@ -10,21 +10,24 @@ import com.example.data.model.MealType
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
|
||||
object CsvExporter {
|
||||
|
||||
private val fileDateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.FRENCH)
|
||||
private val dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.FRENCH)
|
||||
private val timeFormatter = DateTimeFormatter.ofPattern("HH:mm", Locale.FRENCH)
|
||||
|
||||
fun buildDefaultFileName(): String {
|
||||
val dateStr = SimpleDateFormat("yyyy-MM-dd", Locale.FRENCH).format(Date())
|
||||
val dateStr = fileDateFormatter.format(LocalDate.now())
|
||||
return "satiea_repas_$dateStr.csv"
|
||||
}
|
||||
|
||||
fun generateCsvContent(meals: List<MealEntry>): String {
|
||||
val dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.FRENCH)
|
||||
val timeFormat = SimpleDateFormat("HH:mm", Locale.FRENCH)
|
||||
|
||||
fun generateCsvContent(meals: List<MealEntry>, zoneId: ZoneId = ZoneId.systemDefault()): String {
|
||||
val sb = StringBuilder()
|
||||
// UTF-8 BOM for proper French accent display in Excel / LibreOffice / Google Sheets
|
||||
sb.append('\uFEFF')
|
||||
@@ -32,15 +35,15 @@ object CsvExporter {
|
||||
|
||||
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 zonedDateTime = Instant.ofEpochMilli(meal.mealTimestamp).atZone(zoneId)
|
||||
val dateStr = dateFormatter.format(zonedDateTime)
|
||||
val timeStr = timeFormatter.format(zonedDateTime)
|
||||
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 = escapeCsvField(meal.note)
|
||||
val photoCount = meal.photosBase64.size
|
||||
val photoCount = meal.displayPhotoUris.size
|
||||
|
||||
sb.append(escapeCsvField(dateStr)).append(',')
|
||||
sb.append(escapeCsvField(timeStr)).append(',')
|
||||
|
||||
Reference in new issue
Block a user