Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ import androidx.core.view.isVisible
import androidx.core.widget.doAfterTextChanged
import androidx.emoji2.widget.EmojiTextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import autodagger.AutoInjector
import coil.Coil.imageLoader
import coil.load
Expand Down Expand Up @@ -154,7 +156,6 @@ class MessageInputFragment : Fragment() {
if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
mentionAutocomplete?.dismissPopup()
}
clearEditUI()
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -219,8 +220,12 @@ class MessageInputFragment : Fragment() {
} ?: clearReplyUi()
}

chatActivity.messageInputViewModel.getEditChatMessage.observe(viewLifecycleOwner) { message ->
message?.let { setEditUI(it as ChatMessage) }
viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.CREATED) {
chatActivity.messageInputViewModel.getEditChatMessage.collect { message ->
message?.let { setEditUI(it as ChatMessage) } ?: clearEditUI()
}
}
}

chatActivity.messageInputViewModel.createThreadViewState.observe(viewLifecycleOwner) { state ->
Expand Down Expand Up @@ -383,7 +388,6 @@ class MessageInputFragment : Fragment() {
val filters = arrayOfNulls<InputFilter>(1)
val lengthFilter = CapabilitiesUtil.getMessageMaxLength(spreedCapabilities)

binding.fragmentEditView.editMessageView.visibility = View.GONE
binding.fragmentMessageInputView.setPadding(0, 0, 0, 0)

filters[0] = InputFilter.LengthFilter(lengthFilter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import com.nextcloud.talk.utils.message.SendMessageUtils
import com.stfalcon.chatkit.commons.models.IMessage
import io.reactivex.disposables.Disposable
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand Down Expand Up @@ -86,8 +88,8 @@ class MessageInputViewModel @Inject constructor(
val mediaPlayerSeekbarObserver: Flow<Int>
get() = mediaPlayerManager.mediaPlayerSeekBarPosition

private val _getEditChatMessage: MutableLiveData<IMessage?> = MutableLiveData()
val getEditChatMessage: LiveData<IMessage?>
private val _getEditChatMessage: MutableStateFlow<IMessage?> = MutableStateFlow(null)
val getEditChatMessage: StateFlow<IMessage?>
get() = _getEditChatMessage

private val _getReplyChatMessage: MutableLiveData<ChatMessage?> = MutableLiveData()
Expand Down Expand Up @@ -218,7 +220,7 @@ class MessageInputViewModel @Inject constructor(
}

fun edit(message: IMessage?) {
_getEditChatMessage.postValue(message)
_getEditChatMessage.value = message
}

fun startMicInput(context: Context) {
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/res/layout/fragment_message_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
android:layout_marginVertical="@dimen/standard_margin"
android:visibility="gone" />

<include
android:id="@+id/fragment_editView"
layout="@layout/edit_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
android:id="@+id/fragment_editView"
layout="@layout/edit_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible" />

<include
android:id="@+id/fragment_create_thread_view"
Expand Down
Loading