mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Fixed issue with forward message
This commit is contained in:
parent
b2b55305d2
commit
fa7486ff36
3 changed files with 43 additions and 6 deletions
|
|
@ -55,6 +55,8 @@ class ConversationForwardMessageFragment : SlidingPaneChildFragment() {
|
|||
|
||||
private var numberOrAddressPickerDialog: Dialog? = null
|
||||
|
||||
private var disableConsumingEventOnPause = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
|
@ -135,6 +137,7 @@ class ConversationForwardMessageFragment : SlidingPaneChildFragment() {
|
|||
localSipUri,
|
||||
remoteSipUri
|
||||
)
|
||||
disableConsumingEventOnPause = true
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
|
|
@ -171,10 +174,12 @@ class ConversationForwardMessageFragment : SlidingPaneChildFragment() {
|
|||
numberOrAddressPickerDialog?.dismiss()
|
||||
numberOrAddressPickerDialog = null
|
||||
|
||||
sharedViewModel.messageToForwardEvent.value?.consume {
|
||||
Log.w(
|
||||
"$TAG Fragment is pausing, consuming forward event to prevent it from being used later"
|
||||
)
|
||||
if (!disableConsumingEventOnPause) {
|
||||
sharedViewModel.messageToForwardEvent.value?.consume {
|
||||
Log.w(
|
||||
"$TAG Fragment is pausing, consuming forward event to prevent it from being used later"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -469,8 +469,9 @@ open class ConversationFragment : SlidingPaneChildFragment() {
|
|||
Log.i("$TAG Found message to forward")
|
||||
if (viewModel.isReadOnly.value == true || viewModel.isDisabledBecauseNotSecured.value == true) {
|
||||
Log.w(
|
||||
"$TAG Can't forward message in this conversation as it is read only"
|
||||
"$TAG Can't forward message in this conversation as it is read only, keeping it in memory until conversation is joined just in case"
|
||||
)
|
||||
viewModel.pendingForwardMessage = toForward
|
||||
} else {
|
||||
sendMessageViewModel.forwardMessage(toForward)
|
||||
}
|
||||
|
|
@ -480,6 +481,19 @@ open class ConversationFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.forwardMessageEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { toForward ->
|
||||
Log.i("$TAG Found pending message to forward")
|
||||
if (viewModel.isReadOnly.value == true || viewModel.isDisabledBecauseNotSecured.value == true) {
|
||||
Log.w(
|
||||
"$TAG Can't forward message in this conversation as it is still read only"
|
||||
)
|
||||
} else {
|
||||
sendMessageViewModel.forwardMessage(toForward)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.updateEvents.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
val items = viewModel.eventsList
|
||||
|
|
|
|||
|
|
@ -129,8 +129,14 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val forwardMessageEvent: MutableLiveData<Event<MessageModel>> by lazy {
|
||||
MutableLiveData<Event<MessageModel>>()
|
||||
}
|
||||
|
||||
var eventsList = arrayListOf<EventLogModel>()
|
||||
|
||||
var pendingForwardMessage: MessageModel? = null
|
||||
|
||||
private var latestMatch: EventLog? = null
|
||||
|
||||
private val chatRoomListener = object : ChatRoomListenerStub() {
|
||||
|
|
@ -138,6 +144,13 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
override fun onConferenceJoined(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||
Log.i("$TAG Conversation was joined")
|
||||
computeConversationInfo()
|
||||
|
||||
val messageToForward = pendingForwardMessage
|
||||
if (messageToForward != null) {
|
||||
Log.i("$TAG Found pending forward message, doing it now")
|
||||
forwardMessageEvent.postValue(Event(messageToForward))
|
||||
pendingForwardMessage = null
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -552,7 +565,7 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
if (!chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt())) {
|
||||
if (LinphoneUtils.getAccountForAddress(chatRoom.localAddress)?.params?.instantMessagingEncryptionMandatory == true) {
|
||||
Log.w(
|
||||
"$TAG Conversation with subject [${chatRoom.subject}] has been disabled because it isn't encrypted and default account is in secure mode"
|
||||
"$TAG Conversation with subject [${chatRoom.subject}] is considered as read-only because it isn't encrypted and default account is in secure mode"
|
||||
)
|
||||
isDisabledBecauseNotSecured.postValue(true)
|
||||
} else {
|
||||
|
|
@ -604,6 +617,11 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
|
||||
val empty =
|
||||
chatRoom.hasCapability(ChatRoom.Capabilities.Conference.toInt()) && chatRoom.participants.isEmpty()
|
||||
if (empty) {
|
||||
Log.w(
|
||||
"$TAG Conversation has conference capability but has no participants, will be considered as read only!"
|
||||
)
|
||||
}
|
||||
val readOnly = chatRoom.isReadOnly || empty
|
||||
isReadOnly.postValue(readOnly)
|
||||
if (readOnly) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue