mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent being stuck while media list is processed
This commit is contained in:
parent
96a07fa8c6
commit
c709c720e4
10 changed files with 88 additions and 74 deletions
|
|
@ -27,7 +27,6 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.linphone.core.tools.Log
|
||||
import androidx.core.net.toUri
|
||||
|
||||
|
|
@ -72,7 +71,7 @@ class Api34Compatibility {
|
|||
intent.data = "package:${context.packageName}".toUri()
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
Log.i("$TAG Starting ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT")
|
||||
ContextCompat.startActivity(context, intent, null)
|
||||
context.startActivity(intent, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ class ConversationDocumentsListViewModel
|
|||
MutableLiveData<Event<FileModel>>()
|
||||
}
|
||||
|
||||
override fun beforeNotifyingChatRoomFound(sameOne: Boolean) {
|
||||
@WorkerThread
|
||||
override fun afterNotifyingChatRoomFound(sameOne: Boolean) {
|
||||
loadDocumentsList()
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +99,7 @@ class ConversationDocumentsListViewModel
|
|||
list.add(model)
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("$TAG [${documents.size}] documents have been processed")
|
||||
documentsList.postValue(list)
|
||||
operationInProgress.postValue(false)
|
||||
|
|
|
|||
|
|
@ -36,11 +36,14 @@ class ConversationMediaListViewModel
|
|||
|
||||
val mediaList = MutableLiveData<List<FileModel>>()
|
||||
|
||||
val operationInProgress = MutableLiveData<Boolean>()
|
||||
|
||||
val openMediaEvent: MutableLiveData<Event<FileModel>> by lazy {
|
||||
MutableLiveData<Event<FileModel>>()
|
||||
}
|
||||
|
||||
override fun beforeNotifyingChatRoomFound(sameOne: Boolean) {
|
||||
@WorkerThread
|
||||
override fun afterNotifyingChatRoomFound(sameOne: Boolean) {
|
||||
loadMediaList()
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +55,8 @@ class ConversationMediaListViewModel
|
|||
|
||||
@WorkerThread
|
||||
private fun loadMediaList() {
|
||||
operationInProgress.postValue(true)
|
||||
|
||||
val list = arrayListOf<FileModel>()
|
||||
Log.i(
|
||||
"$TAG Loading media contents for conversation [${LinphoneUtils.getConversationId(
|
||||
|
|
@ -85,7 +90,9 @@ class ConversationMediaListViewModel
|
|||
list.add(model)
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("$TAG [${media.size}] media have been processed")
|
||||
mediaList.postValue(list)
|
||||
operationInProgress.postValue(false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ class ConversationViewModel
|
|||
list.remove(found)
|
||||
eventsList = list
|
||||
updateEvents.postValue(Event(true))
|
||||
isEmpty.postValue(eventsList.isEmpty)
|
||||
isEmpty.postValue(eventsList.isEmpty())
|
||||
} else {
|
||||
Log.e("$TAG Failed to find matching message in conversation events list")
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ class ConversationViewModel
|
|||
list.remove(found)
|
||||
eventsList = list
|
||||
updateEvents.postValue(Event(true))
|
||||
isEmpty.postValue(eventsList.isEmpty)
|
||||
isEmpty.postValue(eventsList.isEmpty())
|
||||
} else {
|
||||
Log.e(
|
||||
"$TAG Failed to find chat message id [${chatMessageModel.id}] in events list!"
|
||||
|
|
@ -528,7 +528,7 @@ class ConversationViewModel
|
|||
list.addAll(eventsList)
|
||||
eventsList = list
|
||||
updateEvents.postValue(Event(true))
|
||||
isEmpty.postValue(eventsList.isEmpty)
|
||||
isEmpty.postValue(eventsList.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -651,7 +651,7 @@ class ConversationViewModel
|
|||
Log.i("$TAG Extracted [${list.size}] events from conversation history in database")
|
||||
eventsList = list
|
||||
updateEvents.postValue(Event(true))
|
||||
isEmpty.postValue(eventsList.isEmpty)
|
||||
isEmpty.postValue(eventsList.isEmpty())
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -698,7 +698,7 @@ class ConversationViewModel
|
|||
list.addAll(newList)
|
||||
eventsList = list
|
||||
updateEvents.postValue(Event(true))
|
||||
isEmpty.postValue(eventsList.isEmpty)
|
||||
isEmpty.postValue(eventsList.isEmpty())
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -730,7 +730,7 @@ class ConversationViewModel
|
|||
list.addAll(eventsList)
|
||||
eventsList = list
|
||||
updateEvents.postValue(Event(true))
|
||||
isEmpty.postValue(eventsList.isEmpty)
|
||||
isEmpty.postValue(eventsList.isEmpty())
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -801,7 +801,7 @@ class ConversationViewModel
|
|||
eventsList.addAll(processGroupedEvents(arrayListOf(event)))
|
||||
} else {
|
||||
for (event in history) {
|
||||
if (groupedEventLogs.isEmpty) {
|
||||
if (groupedEventLogs.isEmpty()) {
|
||||
groupedEventLogs.add(event)
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ class SendMessageInConversationViewModel
|
|||
attachments.value = list
|
||||
maxNumberOfAttachmentsReached.value = list.size >= MAX_FILES_TO_ATTACH
|
||||
|
||||
if (list.isEmpty) {
|
||||
if (list.isEmpty()) {
|
||||
isFileAttachmentsListOpen.value = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ abstract class AddressSelectionViewModel
|
|||
list.addAll(contactsList)
|
||||
list.addAll(suggestionsList)
|
||||
modelsList.postValue(list)
|
||||
isEmpty.postValue(list.isEmpty)
|
||||
isEmpty.postValue(list.isEmpty())
|
||||
Log.i(
|
||||
"$TAG Processed [${results.size}] results: [${conversationsList.size}] conversations, [${favoritesList.size}] favorites, [${contactsList.size}] contacts and [${suggestionsList.size}] suggestions"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package org.linphone.utils
|
|||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.LayoutInflater
|
||||
|
|
@ -67,6 +66,7 @@ import org.linphone.ui.call.model.ZrtpSasConfirmationDialogModel
|
|||
import org.linphone.ui.main.contacts.model.ContactTrustDialogModel
|
||||
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
|
||||
import org.linphone.ui.main.model.GroupSetOrEditSubjectDialogModel
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
|
||||
class DialogUtils {
|
||||
companion object {
|
||||
|
|
@ -543,9 +543,7 @@ class DialogUtils {
|
|||
)
|
||||
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
|
||||
val d: Drawable = ColorDrawable(
|
||||
context.getColor(R.color.bc_black)
|
||||
)
|
||||
val d: Drawable = context.getColor(R.color.bc_black).toDrawable()
|
||||
d.alpha = 153 // 60% opacity
|
||||
setBackgroundDrawable(d)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,11 +64,6 @@ class ImageUtils {
|
|||
if (path != null) {
|
||||
try {
|
||||
val fromPictureUri = path.toUri()
|
||||
if (fromPictureUri == null) {
|
||||
Log.e("$TAG Failed to parse path [$path] as URI")
|
||||
return null
|
||||
}
|
||||
|
||||
// We make a copy to ensure Bitmap will be Software and not Hardware, required for shortcuts
|
||||
val bitmap = ImageDecoder.decodeBitmap(
|
||||
ImageDecoder.createSource(context.contentResolver, fromPictureUri)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,9 @@ class ShortcutUtils {
|
|||
|
||||
var count = 0
|
||||
for (chatRoom in defaultAccount.chatRooms) {
|
||||
if (defaultAccount.params.instantMessagingEncryptionMandatory && !chatRoom.currentParams.isEncryptionEnabled) {
|
||||
if (defaultAccount.params.instantMessagingEncryptionMandatory &&
|
||||
!chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt())
|
||||
) {
|
||||
Log.w(
|
||||
"$TAG Account is in secure mode, skipping not encrypted conversation [${LinphoneUtils.getConversationId(
|
||||
chatRoom
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
|
|
@ -12,61 +13,71 @@
|
|||
type="org.linphone.ui.main.chat.viewmodel.ConversationMediaListViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/color_background_contrast_in_dark_mode">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="15dp"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:src="@drawable/caret_left"
|
||||
android:contentDescription="@string/content_description_go_back_icon"
|
||||
app:tint="?attr/color_main1_500"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title"/>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/color_background_contrast_in_dark_mode">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/main_page_title_style"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:text="@string/conversation_media_list_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="15dp"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:src="@drawable/caret_left"
|
||||
android:contentDescription="@string/content_description_go_back_icon"
|
||||
app:tint="?attr/color_main1_500"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mediaList"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="?attr/color_grey_100"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/main_page_title_style"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:text="@string/conversation_media_list_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/no_result"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/conversation_no_media_found"
|
||||
android:textColor="?attr/color_main2_600"
|
||||
android:textSize="16sp"
|
||||
android:visibility="@{viewModel.mediaList.empty ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mediaList"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="?attr/color_grey_100"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/no_result"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/conversation_no_media_found"
|
||||
android:textColor="?attr/color_main2_600"
|
||||
android:textSize="16sp"
|
||||
android:visibility="@{viewModel.mediaList.empty ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<include
|
||||
layout="@layout/operation_in_progress"
|
||||
bind:visibility="@{viewModel.operationInProgress}" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue