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:
bleackstorm committed 2026-11-08 19:25:03 +01:00
1 parent f0487453c9
commit 87bbb448c2
34 files changed
+2026 -1170

No files matched your search

@@ -11,9 +11,11 @@ import kotlinx.coroutines.withContext
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.Locale
import java.util.UUID
@@ -25,17 +27,18 @@ data class CsvImportResult(
object CsvImporter {
private val supportedDateFormats = listOf(
SimpleDateFormat("dd/MM/yyyy", Locale.FRENCH),
SimpleDateFormat("yyyy-MM-dd", Locale.FRENCH),
SimpleDateFormat("dd-MM-yyyy", Locale.FRENCH),
SimpleDateFormat("d/M/yyyy", Locale.FRENCH)
private val supportedDatePatterns = listOf(
"dd/MM/yyyy",
"yyyy-MM-dd",
"dd-MM-yyyy",
"d/M/yyyy"
)
private val supportedTimeFormats = listOf(
SimpleDateFormat("HH:mm", Locale.FRENCH),
SimpleDateFormat("H:mm", Locale.FRENCH),
SimpleDateFormat("HH:mm:ss", Locale.FRENCH)
private val supportedTimePatterns = listOf(
"HH:mm",
"H:mm",
"HH:mm:ss",
"H:mm:ss"
)
suspend fun importFromUri(
@@ -157,36 +160,32 @@ object CsvImporter {
return if (colIndex != null && colIndex in row.indices) row[colIndex].trim() else ""
}
private fun parseTimestamp(dateStr: String, timeStr: String): Long? {
private fun parseTimestamp(dateStr: String, timeStr: String, zoneId: ZoneId = ZoneId.systemDefault()): Long? {
if (dateStr.isBlank()) return null
var parsedDate: Date? = null
for (df in supportedDateFormats) {
var parsedLocalDate: LocalDate? = null
for (pattern in supportedDatePatterns) {
try {
parsedDate = df.parse(dateStr.trim())
if (parsedDate != null) break
parsedLocalDate = LocalDate.parse(dateStr.trim(), DateTimeFormatter.ofPattern(pattern, Locale.FRENCH))
if (parsedLocalDate != null) break
} catch (_: Exception) {}
}
if (parsedDate == null) return null
val cal = Calendar.getInstance().apply { time = parsedDate }
if (parsedLocalDate == null) return null
var parsedLocalTime = LocalTime.NOON
if (timeStr.isNotBlank()) {
for (tf in supportedTimeFormats) {
for (pattern in supportedTimePatterns) {
try {
val parsedTime = tf.parse(timeStr.trim())
if (parsedTime != null) {
val timeCal = Calendar.getInstance().apply { time = parsedTime }
cal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY))
cal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE))
cal.set(Calendar.SECOND, 0)
cal.set(Calendar.MILLISECOND, 0)
break
}
parsedLocalTime = LocalTime.parse(timeStr.trim(), DateTimeFormatter.ofPattern(pattern, Locale.FRENCH))
break
} catch (_: Exception) {}
}
}
return cal.timeInMillis
return LocalDateTime.of(parsedLocalDate, parsedLocalTime)
.atZone(zoneId)
.toInstant()
.toEpochMilli()
}
private fun parseMealType(raw: String): MealType {