Add configurable timestamp date and clock formats
This commit is contained in:
@@ -103,8 +103,8 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
val settings = LogViewSettingsStore(context).load()
|
||||
context.contentResolver.openOutputStream(uri)?.use { output ->
|
||||
when (format) {
|
||||
ExportFormat.CSV -> writeCsv(output.bufferedWriter(Charsets.UTF_8), logStore, settings)
|
||||
ExportFormat.FORMATTED -> writeFormatted(output.bufferedWriter(Charsets.UTF_8), logStore, settings)
|
||||
ExportFormat.CSV -> writeCsv(output.bufferedWriter(Charsets.UTF_8), logStore, settings, context)
|
||||
ExportFormat.FORMATTED -> writeFormatted(output.bufferedWriter(Charsets.UTF_8), logStore, settings, context)
|
||||
ExportFormat.HTML_ZIP -> writeHtmlZip(ZipOutputStream(output), logStore, settings, context)
|
||||
}
|
||||
}
|
||||
@@ -115,11 +115,12 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
writer: java.io.BufferedWriter,
|
||||
logStore: EncryptedNotificationLogStore,
|
||||
settings: se.ajpanton.notificationlog.settings.LogViewSettings,
|
||||
context: android.content.Context,
|
||||
) = writer.use {
|
||||
it.write(LogExporter.csvHeader(settings))
|
||||
logStore.forEachNewest { entry ->
|
||||
it.newLine()
|
||||
it.write(LogExporter.csvRow(entry, settings))
|
||||
it.write(LogExporter.csvRow(entry, settings, context))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,18 +128,19 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
writer: java.io.BufferedWriter,
|
||||
logStore: EncryptedNotificationLogStore,
|
||||
settings: se.ajpanton.notificationlog.settings.LogViewSettings,
|
||||
context: android.content.Context,
|
||||
) = writer.use {
|
||||
val headers = LogExporter.headers(settings)
|
||||
val widths = headers.map { header -> header.length }.toMutableList()
|
||||
logStore.forEachNewest { entry ->
|
||||
LogExporter.values(entry, settings).forEachIndexed { index, value ->
|
||||
LogExporter.values(entry, settings, context).forEachIndexed { index, value ->
|
||||
widths[index] = maxOf(widths[index], value.length)
|
||||
}
|
||||
}
|
||||
it.write(LogExporter.formattedRow(headers, widths))
|
||||
logStore.forEachNewest { entry ->
|
||||
it.newLine()
|
||||
it.write(LogExporter.formattedRow(LogExporter.values(entry, settings), widths))
|
||||
it.write(LogExporter.formattedRow(LogExporter.values(entry, settings, context), widths))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +157,7 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
val imagePath = entry.imageId
|
||||
?.takeIf { LogField.CONTENTS in settings.visibleFields && imageStore.exists(it) }
|
||||
?.let { imageId -> "images/$imageId.png" }
|
||||
zipOutput.write(LogExporter.htmlRow(entry, settings, imagePath).encodeToByteArray())
|
||||
zipOutput.write(LogExporter.htmlRow(entry, settings, imagePath, context).encodeToByteArray())
|
||||
}
|
||||
zipOutput.write(LogExporter.htmlEnd().encodeToByteArray())
|
||||
zipOutput.closeEntry()
|
||||
|
||||
Reference in New Issue
Block a user