mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Reset some message model fields when re-computing contents list
This commit is contained in:
parent
aab9704d24
commit
02b372fa3d
3 changed files with 27 additions and 17 deletions
|
|
@ -86,10 +86,6 @@ class MessageModel @WorkerThread constructor(
|
|||
|
||||
val isInError = chatMessage.state == ChatMessage.State.NotDelivered
|
||||
|
||||
val statusIcon = MutableLiveData<Int>()
|
||||
|
||||
val text = MutableLiveData<Spannable>()
|
||||
|
||||
val timestamp = chatMessage.time
|
||||
|
||||
val time = TimestampUtils.toString(timestamp)
|
||||
|
|
@ -100,11 +96,15 @@ class MessageModel @WorkerThread constructor(
|
|||
|
||||
val groupedWithPreviousMessage = MutableLiveData<Boolean>()
|
||||
|
||||
val statusIcon = MutableLiveData<Int>()
|
||||
|
||||
val text = MutableLiveData<Spannable>()
|
||||
|
||||
val reactions = MutableLiveData<String>()
|
||||
|
||||
val filesList = MutableLiveData<ArrayList<FileModel>>()
|
||||
|
||||
val firstImage = MutableLiveData<FileModel>()
|
||||
val firstImagePath = MutableLiveData<String>()
|
||||
|
||||
val isSelected = MutableLiveData<Boolean>()
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ class MessageModel @WorkerThread constructor(
|
|||
override fun onMsgStateChanged(message: ChatMessage, messageState: ChatMessage.State?) {
|
||||
statusIcon.postValue(LinphoneUtils.getChatIconResId(chatMessage.state))
|
||||
|
||||
if (messageState == ChatMessage.State.FileTransferDone) {
|
||||
if (messageState == ChatMessage.State.FileTransferDone && !message.isOutgoing) {
|
||||
Log.i("$TAG File transfer is done")
|
||||
downloadingFileModel?.downloadProgress?.postValue(-1)
|
||||
downloadingFileModel = null
|
||||
|
|
@ -279,9 +279,18 @@ class MessageModel @WorkerThread constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun firstImageClicked() {
|
||||
filesList.value.orEmpty().firstOrNull()?.onClick()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun computeContentsList() {
|
||||
Log.d("$TAG Computing message contents list")
|
||||
text.postValue(Spannable.Factory.getInstance().newSpannable(""))
|
||||
filesList.postValue(arrayListOf())
|
||||
firstImagePath.postValue("")
|
||||
|
||||
var displayableContentFound = false
|
||||
var filesContentCount = 0
|
||||
val filesPath = arrayListOf<FileModel>()
|
||||
|
|
@ -295,8 +304,8 @@ class MessageModel @WorkerThread constructor(
|
|||
computeTextContent(content)
|
||||
displayableContentFound = true
|
||||
} else {
|
||||
filesContentCount += 1
|
||||
if (content.isFile) {
|
||||
filesContentCount += 1
|
||||
val path = content.filePath ?: ""
|
||||
if (path.isNotEmpty()) {
|
||||
Log.d(
|
||||
|
|
@ -310,7 +319,7 @@ class MessageModel @WorkerThread constructor(
|
|||
filesPath.add(fileModel)
|
||||
|
||||
if (filesContentCount == 1) {
|
||||
firstImage.postValue(fileModel)
|
||||
firstImagePath.postValue(path)
|
||||
}
|
||||
|
||||
displayableContentFound = true
|
||||
|
|
@ -340,6 +349,7 @@ class MessageModel @WorkerThread constructor(
|
|||
Log.e("$TAG No path found for File Content!")
|
||||
}
|
||||
} else if (content.isFileTransfer) {
|
||||
filesContentCount += 1
|
||||
val name = content.name ?: ""
|
||||
if (name.isNotEmpty()) {
|
||||
val fileModel = FileModel(name, content.fileSize.toLong(), true) { model ->
|
||||
|
|
@ -472,7 +482,7 @@ class MessageModel @WorkerThread constructor(
|
|||
override fun onSpanClicked(text: String) {
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i("$TAG Clicked on SIP URI: $text")
|
||||
val address = coreContext.core.interpretUrl(text)
|
||||
val address = coreContext.core.interpretUrl(text, false)
|
||||
if (address != null) {
|
||||
coreContext.startCall(address)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onLongClick="@{onLongClickListener}"
|
||||
android:visibility="@{model.filesList.size() >= 2 || (model.filesList.size() >= 1 && model.firstImage.path.length() == 0) ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:visibility="@{model.filesList.size() >= 2 || (model.filesList.size() >= 1 && model.firstImagePath.length() == 0) ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:alignItems="center"
|
||||
app:flexWrap="wrap"
|
||||
app:justifyContent="@{model.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"
|
||||
|
|
@ -159,15 +159,15 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/single_image"
|
||||
android:onClick="@{() -> model.firstImage.onClick()}"
|
||||
android:onClick="@{() -> model.firstImageClicked()}"
|
||||
android:onLongClick="@{onLongClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="@dimen/chat_bubble_big_image_max_size"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="@{model.filesList.size() > 1 || model.firstImage.path.length() == 0 ? View.GONE : View.VISIBLE}"
|
||||
coilBubble="@{model.firstImage.path}"/>
|
||||
android:visibility="@{model.filesList.size() == 1 && model.firstImagePath.length() >= 0 ? View.VISIBLE : View.GONE}"
|
||||
coilBubble="@{model.firstImagePath}"/>/>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/meeting_info"
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onLongClick="@{onLongClickListener}"
|
||||
android:visibility="@{model.filesList.size() >= 2 || (model.filesList.size() >= 1 && model.firstImage.path.length() == 0) ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:visibility="@{model.filesList.size() >= 2 || (model.filesList.size() >= 1 && model.firstImagePath.length() == 0) ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:alignItems="center"
|
||||
app:flexWrap="wrap"
|
||||
app:justifyContent="@{model.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"
|
||||
|
|
@ -121,15 +121,15 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/single_image"
|
||||
android:onClick="@{() -> model.firstImage.onClick()}"
|
||||
android:onClick="@{() -> model.firstImageClicked()}"
|
||||
android:onLongClick="@{onLongClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="@dimen/chat_bubble_big_image_max_size"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="@{model.filesList.size() > 1 || model.firstImage.path.length() == 0 ? View.GONE : View.VISIBLE}"
|
||||
coilBubble="@{model.firstImage.path}"/>
|
||||
android:visibility="@{model.filesList.size() == 1 && model.firstImagePath.length() >= 0 ? View.VISIBLE : View.GONE}"
|
||||
coilBubble="@{model.firstImagePath}"/>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/meeting_info"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue