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,25 +373,14 @@ 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) {
|
||||||
Log.d("$TAG Starting downloading content for file [${model.fileName}]")
|
val path = content.filePath ?: ""
|
||||||
|
FileModel(path, name, content.fileSize.toLong(), false) { model ->
|
||||||
if (content.filePath.orEmpty().isEmpty()) {
|
onContentClicked?.invoke(model.file)
|
||||||
val contentName = content.name
|
}
|
||||||
if (contentName != null) {
|
} else {
|
||||||
val isImage = FileUtils.isExtensionImage(contentName)
|
FileModel(name, name, content.fileSize.toLong(), true) { model ->
|
||||||
val file = FileUtils.getFileStoragePath(contentName, isImage)
|
downloadContent(model, content)
|
||||||
content.filePath = file.path
|
|
||||||
Log.i(
|
|
||||||
"$TAG File [$contentName] will be downloaded at [${content.filePath}]"
|
|
||||||
)
|
|
||||||
|
|
||||||
model.downloadProgress.postValue(0)
|
|
||||||
downloadingFileModel = model
|
|
||||||
chatMessage.downloadContent(content)
|
|
||||||
} else {
|
|
||||||
Log.e("$TAG Content name is null, can't download it!")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filesPath.add(fileModel)
|
filesPath.add(fileModel)
|
||||||
|
|
@ -407,13 +398,38 @@ class MessageModel @WorkerThread constructor(
|
||||||
filesList.postValue(filesPath)
|
filesList.postValue(filesPath)
|
||||||
|
|
||||||
if (!displayableContentFound) { // Temporary workaround to prevent empty bubbles
|
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 describe = LinphoneUtils.getTextDescribingMessage(chatMessage)
|
||||||
|
Log.w(
|
||||||
|
"$TAG No displayable content found, generating text based description [$describe]"
|
||||||
|
)
|
||||||
val spannable = Spannable.Factory.getInstance().newSpannable(describe)
|
val spannable = Spannable.Factory.getInstance().newSpannable(describe)
|
||||||
text.postValue(spannable)
|
text.postValue(spannable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WorkerThread
|
||||||
|
private fun downloadContent(model: FileModel, content: Content) {
|
||||||
|
Log.d("$TAG Starting downloading content for file [${model.fileName}]")
|
||||||
|
|
||||||
|
if (content.filePath.orEmpty().isEmpty()) {
|
||||||
|
val contentName = content.name
|
||||||
|
if (contentName != null) {
|
||||||
|
val isImage = FileUtils.isExtensionImage(contentName)
|
||||||
|
val file = FileUtils.getFileStoragePath(contentName, isImage)
|
||||||
|
content.filePath = file.path
|
||||||
|
Log.i(
|
||||||
|
"$TAG File [$contentName] will be downloaded at [${content.filePath}]"
|
||||||
|
)
|
||||||
|
|
||||||
|
model.downloadProgress.postValue(0)
|
||||||
|
downloadingFileModel = model
|
||||||
|
chatMessage.downloadContent(content)
|
||||||
|
} else {
|
||||||
|
Log.e("$TAG Content name is null, can't download it!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private fun updateReactionsList() {
|
private fun updateReactionsList() {
|
||||||
var reactionsList = ""
|
var reactionsList = ""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue