Prevent crash when file transfer has no name nor file path
This commit is contained in:
parent
f27da5c95d
commit
e1714934b4
1 changed files with 15 additions and 8 deletions
|
@ -232,12 +232,19 @@ class ChatMessageContentData(
|
||||||
"[Content] Is ${if (content.isFile) "file" else "file transfer"} content encrypted ? $isFileEncrypted"
|
"[Content] Is ${if (content.isFile) "file" else "file transfer"} content encrypted ? $isFileEncrypted"
|
||||||
)
|
)
|
||||||
|
|
||||||
filePath.value = ""
|
val contentName = content.name
|
||||||
fileName.value = if (content.name.isNullOrEmpty() && !content.filePath.isNullOrEmpty()) {
|
val contentFilePath = content.filePath
|
||||||
FileUtils.getNameFromFilePath(content.filePath!!)
|
val name = if (contentName.isNullOrEmpty()) {
|
||||||
|
if (!contentFilePath.isNullOrEmpty()) {
|
||||||
|
FileUtils.getNameFromFilePath(contentFilePath)
|
||||||
|
} else {
|
||||||
|
"<unknown>"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
content.name
|
contentName
|
||||||
}
|
}
|
||||||
|
fileName.value = name
|
||||||
|
filePath.value = ""
|
||||||
|
|
||||||
// Display download size and underline text
|
// Display download size and underline text
|
||||||
val fileSize = AppUtils.bytesToDisplayableSize(content.fileSize.toLong())
|
val fileSize = AppUtils.bytesToDisplayableSize(content.fileSize.toLong())
|
||||||
|
@ -324,7 +331,7 @@ class ChatMessageContentData(
|
||||||
}
|
}
|
||||||
} else if (content.isFileTransfer) {
|
} else if (content.isFileTransfer) {
|
||||||
downloadable.value = true
|
downloadable.value = true
|
||||||
val extension = FileUtils.getExtensionFromFileName(fileName.value!!)
|
val extension = FileUtils.getExtensionFromFileName(name)
|
||||||
val mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
|
val mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
|
||||||
when (FileUtils.getMimeType(mime)) {
|
when (FileUtils.getMimeType(mime)) {
|
||||||
FileUtils.MimeType.Image -> {
|
FileUtils.MimeType.Image -> {
|
||||||
|
@ -354,9 +361,9 @@ class ChatMessageContentData(
|
||||||
|
|
||||||
private fun parseConferenceInvite(content: Content) {
|
private fun parseConferenceInvite(content: Content) {
|
||||||
val conferenceInfo = Factory.instance().createConferenceInfoFromIcalendarContent(content)
|
val conferenceInfo = Factory.instance().createConferenceInfoFromIcalendarContent(content)
|
||||||
val conferenceUri = conferenceInfo?.uri?.asStringUriOnly()
|
val conferenceUri = conferenceInfo?.uri?.asStringUriOnly() ?: ""
|
||||||
if (conferenceInfo != null && conferenceUri != null) {
|
if (conferenceInfo != null && conferenceUri.isNotEmpty()) {
|
||||||
conferenceAddress = conferenceUri!!
|
conferenceAddress = conferenceUri
|
||||||
Log.i(
|
Log.i(
|
||||||
"[Content] Created conference info from ICS with address $conferenceAddress"
|
"[Content] Created conference info from ICS with address $conferenceAddress"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue