From 6611fc5843472750260d955c974808e949d6891c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 7 Oct 2021 11:43:54 +0200 Subject: [PATCH] [Messages] Disable showing 0-byte attachment sizes. --- .../edziennik/ui/modules/views/AttachmentsView.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/views/AttachmentsView.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/views/AttachmentsView.kt index c981a4ba..59131672 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/views/AttachmentsView.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/views/AttachmentsView.kt @@ -6,7 +6,6 @@ package pl.szczodrzynski.edziennik.ui.modules.views import android.content.Context import android.os.Bundle -import android.os.Environment import android.util.AttributeSet import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.PopupMenu @@ -68,7 +67,10 @@ class AttachmentsView @JvmOverloads constructor( attachmentIds.forEachIndexed { index, id -> val name = attachmentNames[index] ?: return@forEachIndexed - val size = attachmentSizes?.getOrNull(index) + var size = attachmentSizes?.getOrNull(index) + // hide the size if less than 1 byte + if (size?.compareTo(1) == -1) + size = null val item = AttachmentAdapter.Item(profileId, owner, id, name, size) adapter.items += item @@ -100,6 +102,8 @@ class AttachmentsView @JvmOverloads constructor( val fileUrl = item.name.substringAfter(":", missingDelimiterValue = "") // update file name with the downloaded one item.name = attachmentFile.name + // update file size (useful for items with no defined size) + item.size = attachmentFile.length() // save the download url back if (fileUrl != "") item.name += ":$fileUrl"