mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed ephemeral message conversation menu item not working
This commit is contained in:
parent
34c3dff137
commit
46570a4152
5 changed files with 60 additions and 20 deletions
|
|
@ -675,6 +675,15 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sharedViewModel.newChatMessageEphemeralLifetimeToSet.observe(viewLifecycleOwner) {
|
||||
it.consume { ephemeralLifetime ->
|
||||
Log.i(
|
||||
"$TAG Setting [$ephemeralLifetime] as new ephemeral lifetime for messages"
|
||||
)
|
||||
viewModel.updateEphemeralLifetime(ephemeralLifetime)
|
||||
}
|
||||
}
|
||||
|
||||
binding.sendArea.messageToSend.setControlEnterListener(object :
|
||||
RichEditText.RichEditTextSendListener {
|
||||
override fun onControlEnterPressedAndReleased() {
|
||||
|
|
@ -884,7 +893,15 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
}
|
||||
|
||||
popupView.setConfigureEphemeralMessagesClickListener {
|
||||
// TODO: go to configure ephemeral messages
|
||||
if (findNavController().currentDestination?.id == R.id.conversationFragment) {
|
||||
val currentValue = viewModel.ephemeralLifetime.value ?: 0L
|
||||
Log.i("$TAG Going to ephemeral lifetime fragment (currently [$currentValue])")
|
||||
val action =
|
||||
ConversationFragmentDirections.actionConversationFragmentToConversationEphemeralLifetimeFragment(
|
||||
currentValue
|
||||
)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -431,28 +431,10 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
@UiThread
|
||||
fun updateEphemeralLifetime(lifetime: Long) {
|
||||
coreContext.postOnCoreThread {
|
||||
if (lifetime == 0L) {
|
||||
if (chatRoom.isEphemeralEnabled) {
|
||||
Log.i("$TAG Disabling ephemeral messages")
|
||||
chatRoom.isEphemeralEnabled = false
|
||||
}
|
||||
} else {
|
||||
if (!chatRoom.isEphemeralEnabled) {
|
||||
Log.i("$TAG Enabling ephemeral messages")
|
||||
chatRoom.isEphemeralEnabled = true
|
||||
}
|
||||
|
||||
if (chatRoom.ephemeralLifetime != lifetime) {
|
||||
Log.i("$TAG Updating lifetime to [$lifetime]")
|
||||
chatRoom.ephemeralLifetime = lifetime
|
||||
}
|
||||
}
|
||||
LinphoneUtils.chatRoomConfigureEphemeralMessagesLifetime(chatRoom, lifetime)
|
||||
ephemeralLifetime.postValue(
|
||||
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
|
||||
)
|
||||
Log.i(
|
||||
"$TAG Ephemeral messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -424,6 +424,16 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun updateEphemeralLifetime(lifetime: Long) {
|
||||
coreContext.postOnCoreThread {
|
||||
LinphoneUtils.chatRoomConfigureEphemeralMessagesLifetime(chatRoom, lifetime)
|
||||
ephemeralLifetime.postValue(
|
||||
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun loadMoreData(totalItemsCount: Int) {
|
||||
coreContext.postOnCoreThread {
|
||||
|
|
|
|||
|
|
@ -353,6 +353,29 @@ class LinphoneUtils {
|
|||
return text
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun chatRoomConfigureEphemeralMessagesLifetime(chatRoom: ChatRoom, lifetime: Long) {
|
||||
if (lifetime == 0L) {
|
||||
if (chatRoom.isEphemeralEnabled) {
|
||||
Log.i("$TAG Disabling ephemeral messages")
|
||||
chatRoom.isEphemeralEnabled = false
|
||||
}
|
||||
} else {
|
||||
if (!chatRoom.isEphemeralEnabled) {
|
||||
Log.i("$TAG Enabling ephemeral messages")
|
||||
chatRoom.isEphemeralEnabled = true
|
||||
}
|
||||
|
||||
if (chatRoom.ephemeralLifetime != lifetime) {
|
||||
Log.i("$TAG Updating lifetime to [$lifetime]")
|
||||
chatRoom.ephemeralLifetime = lifetime
|
||||
}
|
||||
}
|
||||
Log.i(
|
||||
"$TAG Ephemeral messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
|
||||
)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getAvatarModelForConferenceInfo(conferenceInfo: ConferenceInfo): ContactAvatarModel {
|
||||
val fakeFriend = coreContext.core.createFriend()
|
||||
|
|
|
|||
|
|
@ -51,6 +51,14 @@
|
|||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right" />
|
||||
<action
|
||||
android:id="@+id/action_conversationFragment_to_conversationEphemeralLifetimeFragment"
|
||||
app:destination="@id/conversationEphemeralLifetimeFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right" />
|
||||
</fragment>
|
||||
|
||||
<action
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue