mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-27 19:36:21 +00:00
Fixed outgoing message file upload display
This commit is contained in:
parent
1b827bcf76
commit
a2b86ff5f6
1 changed files with 36 additions and 20 deletions
|
|
@ -201,6 +201,8 @@ class MessageModel @WorkerThread constructor(
|
||||||
offset: Int,
|
offset: Int,
|
||||||
total: Int
|
total: Int
|
||||||
) {
|
) {
|
||||||
|
if (message.isOutgoing) return
|
||||||
|
|
||||||
val model = downloadingFileModel
|
val model = downloadingFileModel
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
val percent = ((offset * 100.0) / total).toInt() // Conversion from int to double and back to int is required
|
val percent = ((offset * 100.0) / total).toInt() // Conversion from int to double and back to int is required
|
||||||
|
|
@ -371,7 +373,42 @@ class MessageModel @WorkerThread constructor(
|
||||||
filesContentCount += 1
|
filesContentCount += 1
|
||||||
val name = content.name ?: ""
|
val name = content.name ?: ""
|
||||||
if (name.isNotEmpty()) {
|
if (name.isNotEmpty()) {
|
||||||
val fileModel = FileModel(name, name, content.fileSize.toLong(), true) { model ->
|
val fileModel = if (isOutgoing && chatMessage.isFileTransferInProgress) {
|
||||||
|
val path = content.filePath ?: ""
|
||||||
|
FileModel(path, name, content.fileSize.toLong(), false) { model ->
|
||||||
|
onContentClicked?.invoke(model.file)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FileModel(name, name, content.fileSize.toLong(), true) { model ->
|
||||||
|
downloadContent(model, content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filesPath.add(fileModel)
|
||||||
|
|
||||||
|
displayableContentFound = true
|
||||||
|
} else {
|
||||||
|
Log.e("$TAG No name found for FileTransfer Content!")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.i("$TAG Content is not a File")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filesList.postValue(filesPath)
|
||||||
|
|
||||||
|
if (!displayableContentFound) { // Temporary workaround to prevent empty bubbles
|
||||||
|
val describe = LinphoneUtils.getTextDescribingMessage(chatMessage)
|
||||||
|
Log.w(
|
||||||
|
"$TAG No displayable content found, generating text based description [$describe]"
|
||||||
|
)
|
||||||
|
val spannable = Spannable.Factory.getInstance().newSpannable(describe)
|
||||||
|
text.postValue(spannable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
private fun downloadContent(model: FileModel, content: Content) {
|
||||||
Log.d("$TAG Starting downloading content for file [${model.fileName}]")
|
Log.d("$TAG Starting downloading content for file [${model.fileName}]")
|
||||||
|
|
||||||
if (content.filePath.orEmpty().isEmpty()) {
|
if (content.filePath.orEmpty().isEmpty()) {
|
||||||
|
|
@ -392,27 +429,6 @@ class MessageModel @WorkerThread constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filesPath.add(fileModel)
|
|
||||||
|
|
||||||
displayableContentFound = true
|
|
||||||
} else {
|
|
||||||
Log.e("$TAG No name found for FileTransfer Content!")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.i("$TAG Content is not a File")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filesList.postValue(filesPath)
|
|
||||||
|
|
||||||
if (!displayableContentFound) { // Temporary workaround to prevent empty bubbles
|
|
||||||
Log.w("$TAG No displayable content found, generating text based description")
|
|
||||||
val describe = LinphoneUtils.getTextDescribingMessage(chatMessage)
|
|
||||||
val spannable = Spannable.Factory.getInstance().newSpannable(describe)
|
|
||||||
text.postValue(spannable)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private fun updateReactionsList() {
|
private fun updateReactionsList() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue