mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed methods called from wrong thread, other code cleanup / improvements
This commit is contained in:
parent
e0ff593f3d
commit
5a16761fdf
20 changed files with 52 additions and 34 deletions
|
|
@ -175,7 +175,7 @@ class VFS {
|
|||
val cipher = Cipher.getInstance(TRANSFORMATION)
|
||||
cipher.init(Cipher.ENCRYPT_MODE, getSecretKey())
|
||||
val iv = cipher.iv
|
||||
return Pair<ByteArray, ByteArray>(
|
||||
return Pair(
|
||||
iv,
|
||||
cipher.doFinal(textToEncrypt.toByteArray(StandardCharsets.UTF_8))
|
||||
)
|
||||
|
|
@ -193,7 +193,7 @@ class VFS {
|
|||
@Throws(java.lang.Exception::class)
|
||||
private fun encryptToken(token: String): Pair<String?, String?> {
|
||||
val encryptedData = encryptData(token)
|
||||
return Pair<String?, String?>(
|
||||
return Pair(
|
||||
Base64.encodeToString(encryptedData.first, Base64.DEFAULT),
|
||||
Base64.encodeToString(encryptedData.second, Base64.DEFAULT)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1987,7 +1987,7 @@ class NotificationsManager
|
|||
|
||||
@AnyThread
|
||||
fun foregroundServiceTypeMaskToString(mask: Int): String {
|
||||
var stringBuilder = StringBuilder()
|
||||
val stringBuilder = StringBuilder()
|
||||
val values = hashMapOf(
|
||||
"PHONE_CALL" to Compatibility.FOREGROUND_SERVICE_TYPE_PHONE_CALL,
|
||||
"MICROPHONE" to Compatibility.FOREGROUND_SERVICE_TYPE_MICROPHONE,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
|
|
@ -65,6 +66,7 @@ class ConferenceAddParticipantsFragment : GenericAddressPickerFragment() {
|
|||
return false
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onSingleAddressSelected(address: Address, friend: Friend) {
|
||||
Log.e("$TAG This shouldn't happen as we should always be in multiple selection mode here!")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,9 @@ class ConferenceParticipantsListFragment : GenericCallFragment() {
|
|||
|
||||
model.confirmEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
viewModel.conferenceModel.kickParticipant(participant)
|
||||
coreContext.postOnCoreThread {
|
||||
viewModel.conferenceModel.kickParticipant(participant)
|
||||
}
|
||||
val message = getString(R.string.conference_participant_was_kicked_out_toast)
|
||||
val icon = R.drawable.check
|
||||
(requireActivity() as GenericActivity).showGreenToast(message, icon)
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class ConferenceViewModel
|
|||
} else {
|
||||
Log.w("$TAG Notified active speaker participant device is null, using first one that's not us")
|
||||
val firstNotUs = participantDevices.value.orEmpty().find {
|
||||
it.isMe == false
|
||||
!it.isMe
|
||||
}
|
||||
if (firstNotUs != null) {
|
||||
Log.i("$TAG Newly active speaker participant is [${firstNotUs.name}]")
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ import org.linphone.ui.main.history.viewmodel.StartCallViewModel
|
|||
import org.linphone.utils.ConfirmationDialogModel
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.RecyclerViewHeaderDecoration
|
||||
import org.linphone.utils.hideKeyboard
|
||||
import org.linphone.utils.setKeyboardInsetListener
|
||||
|
|
@ -233,8 +232,10 @@ class TransferCallFragment : GenericCallFragment() {
|
|||
}
|
||||
|
||||
viewModel.initiateBlindTransferEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { address ->
|
||||
showConfirmBlindTransferDialog(address, LinphoneUtils.getDisplayName(address))
|
||||
it.consume { pair ->
|
||||
val address = pair.first
|
||||
val displayName = pair.second
|
||||
showConfirmBlindTransferDialog(address, displayName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class VuMeterView : View {
|
|||
}
|
||||
|
||||
private fun createShader(): Shader {
|
||||
val level = (height - height * vuMeterPercentage).toFloat()
|
||||
val level = (height - height * vuMeterPercentage)
|
||||
|
||||
val bitmap = createBitmap(width, height)
|
||||
val canvas = Canvas(bitmap)
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ class MainActivity : GenericActivity() {
|
|||
|
||||
viewModel.clearFilesOrTextPendingSharingEvent.observe(this) {
|
||||
it.consume {
|
||||
sharedViewModel.filesToShareFromIntent.value = arrayListOf<String>()
|
||||
sharedViewModel.filesToShareFromIntent.value = arrayListOf()
|
||||
sharedViewModel.textToShareFromIntent.value = ""
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -545,8 +545,8 @@ open class ConversationFragment : SlidingPaneChildFragment() {
|
|||
"$TAG Voice record playback finished, looking for voice record in next message"
|
||||
)
|
||||
val list = viewModel.eventsList
|
||||
val model = list.find {
|
||||
(it.model as? MessageModel)?.id == id
|
||||
val model = list.find { eventLogModel ->
|
||||
(eventLogModel.model as? MessageModel)?.id == id
|
||||
}
|
||||
if (model != null) {
|
||||
val index = list.indexOf(model)
|
||||
|
|
@ -770,13 +770,15 @@ open class ConversationFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel.sipUriToCallEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { sipUri ->
|
||||
if (messageLongPressViewModel.visible.value == true) return@consume
|
||||
val address = coreContext.core.interpretUrl(sipUri, false)
|
||||
if (address != null) {
|
||||
Log.i("$TAG Starting audio call to parsed SIP URI [${address.asStringUriOnly()}]")
|
||||
coreContext.startAudioCall(address)
|
||||
} else {
|
||||
Log.w("$TAG Failed to parse [$sipUri] as SIP URI")
|
||||
coreContext.postOnCoreThread {
|
||||
if (messageLongPressViewModel.visible.value == true) return@postOnCoreThread
|
||||
val address = coreContext.core.interpretUrl(sipUri, false)
|
||||
if (address != null) {
|
||||
Log.i("$TAG Starting audio call to parsed SIP URI [${address.asStringUriOnly()}]")
|
||||
coreContext.startAudioCall(address)
|
||||
} else {
|
||||
Log.w("$TAG Failed to parse [$sipUri] as SIP URI")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ class ConversationsListFragment : AbstractMainFragment() {
|
|||
|
||||
sharedViewModel.updateConversationLastMessageEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { conversationId ->
|
||||
val model = listViewModel.conversations.value.orEmpty().find {
|
||||
it.id == conversationId
|
||||
val model = listViewModel.conversations.value.orEmpty().find { conversationModel ->
|
||||
conversationModel.id == conversationId
|
||||
}
|
||||
model?.updateLastMessageInfo()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,7 +311,6 @@ class SendMessageInConversationViewModel
|
|||
voiceMessage.send()
|
||||
} else {
|
||||
message.addContent(content)
|
||||
contentAdded = true
|
||||
}
|
||||
} else {
|
||||
Log.e("$TAG Voice recording content couldn't be created!")
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class ContactsListViewModel
|
|||
corePreferences.contactsFilter = domainFilter
|
||||
Log.i("$TAG Newly set filter is [${corePreferences.contactsFilter}]")
|
||||
|
||||
coreContext.postOnMainThread {
|
||||
coreContext.postOnCoreThread {
|
||||
applyFilter(currentFilter, domainFilter, filterChanged = true)
|
||||
}
|
||||
}
|
||||
|
|
@ -207,7 +207,10 @@ class ContactsListViewModel
|
|||
fun toggleFavouritesVisibility() {
|
||||
val show = showFavourites.value == false
|
||||
showFavourites.value = show
|
||||
corePreferences.showFavoriteContacts = show
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
corePreferences.showFavoriteContacts = show
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.slidingpanelayout.widget.SlidingPaneLayout
|
||||
import androidx.slidingpanelayout.widget.SlidingPaneLayout.PanelSlideListener
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
|
|
@ -192,7 +193,9 @@ abstract class AbstractMainFragment : GenericMainFragment() {
|
|||
|
||||
sharedViewModel.forceUpdateAvailableNavigationItems.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
viewModel.updateAvailableMenus()
|
||||
coreContext.postOnCoreThread {
|
||||
viewModel.updateAvailableMenus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
|
|
@ -91,6 +92,7 @@ class AddParticipantsFragment : GenericAddressPickerFragment() {
|
|||
return false
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onSingleAddressSelected(address: Address, friend: Friend) {
|
||||
Log.e("$TAG This shouldn't happen as we should always be in multiple selection mode here!")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ class StartCallViewModel
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val initiateBlindTransferEvent: MutableLiveData<Event<Address>> by lazy {
|
||||
MutableLiveData<Event<Address>>()
|
||||
val initiateBlindTransferEvent: MutableLiveData<Event<Pair<Address, String>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Address, String>>>()
|
||||
}
|
||||
|
||||
private val conferenceListener = object : ConferenceListenerStub() {
|
||||
|
|
@ -153,7 +153,7 @@ class StartCallViewModel
|
|||
LinphoneUtils.applyInternationalPrefix()
|
||||
)
|
||||
if (address != null) {
|
||||
initiateBlindTransferEvent.postValue(Event(address))
|
||||
initiateBlindTransferEvent.postValue(Event(Pair(address, LinphoneUtils.getDisplayName(address))))
|
||||
leaveFragmentEvent.postValue(Event(true))
|
||||
} else {
|
||||
Log.e("$TAG Failed to parse [$suggestion] as SIP address")
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ class MeetingsListFragment : AbstractMainFragment() {
|
|||
|
||||
adapter.meetingLongClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val isUserOrganizer = model.isOrganizer() && !model.isCancelled
|
||||
val isUserOrganizer = model.isMyselfOrganizer && !model.isCancelled
|
||||
val modalBottomSheet = MeetingsMenuDialogFragment(
|
||||
isUserOrganizer,
|
||||
{ // onDismiss
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ class MeetingModel
|
|||
|
||||
val time = "$startTime - $endTime"
|
||||
|
||||
val isMyselfOrganizer = isOrganizer()
|
||||
|
||||
val isBroadcast = MutableLiveData<Boolean>()
|
||||
|
||||
val subject = MutableLiveData<String>()
|
||||
|
|
@ -90,7 +92,7 @@ class MeetingModel
|
|||
}
|
||||
|
||||
@WorkerThread
|
||||
fun isOrganizer(): Boolean {
|
||||
private fun isOrganizer(): Boolean {
|
||||
return coreContext.core.accountList.find { account ->
|
||||
val address = account.params.identityAddress
|
||||
address != null && conferenceInfo.organizer?.weakEqual(address) == true
|
||||
|
|
|
|||
|
|
@ -924,7 +924,9 @@ class SettingsViewModel
|
|||
if (newValue.isNotEmpty()) {
|
||||
try {
|
||||
val delay = newValue.toInt()
|
||||
corePreferences.autoAnswerDelay = delay
|
||||
coreContext.postOnCoreThread {
|
||||
corePreferences.autoAnswerDelay = delay
|
||||
}
|
||||
} catch (nfe: NumberFormatException) {
|
||||
Log.e("$TAG Ignoring new auto answer incoming calls delay as it can't be converted to int: $nfe")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ class AppUtils {
|
|||
|
||||
var textToCheck = text
|
||||
do {
|
||||
var firstSymbol = extractFirstSymbol(textToCheck)
|
||||
var symbolLength = firstSymbol.length
|
||||
val firstSymbol = extractFirstSymbol(textToCheck)
|
||||
val symbolLength = firstSymbol.length
|
||||
if (symbolLength <= 1) return false
|
||||
textToCheck = textToCheck.substring(symbolLength)
|
||||
} while (textToCheck.isNotEmpty())
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ class LinphoneUtils {
|
|||
return Pair(0, "")
|
||||
}
|
||||
|
||||
var icon = R.drawable.chat_teardrop_dots
|
||||
val icon = R.drawable.chat_teardrop_dots
|
||||
val composingFriends = arrayListOf<String>()
|
||||
var label = ""
|
||||
for (participant in chatRoom.composingParticipants) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue