mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
resolve codacy/ktlint warnings
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
8f1f22fd54
commit
ab007fc444
@ -119,7 +119,6 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
|||||||
binding.messageQuote.quotedChatMessageView.visibility = View.GONE
|
binding.messageQuote.quotedChatMessageView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
if (message.isTemporary && !networkMonitor.isOnline.first()) {
|
if (message.isTemporary && !networkMonitor.isOnline.first()) {
|
||||||
updateStatus(
|
updateStatus(
|
||||||
@ -134,12 +133,11 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
|||||||
binding.bubble.setOnClickListener {
|
binding.bubble.setOnClickListener {
|
||||||
commonMessageInterface.onOpenMessageActionsDialog(message)
|
commonMessageInterface.onOpenMessageActionsDialog(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (message.isTemporary) {
|
} else if (message.isTemporary) {
|
||||||
showSendingSpinner()
|
showSendingSpinner()
|
||||||
} else if(message.readStatus == ReadStatus.READ) {
|
} else if (message.readStatus == ReadStatus.READ) {
|
||||||
updateStatus(R.drawable.ic_check_all, context.resources?.getString(R.string.nc_message_read))
|
updateStatus(R.drawable.ic_check_all, context.resources?.getString(R.string.nc_message_read))
|
||||||
} else if(message.readStatus == ReadStatus.SENT) {
|
} else if (message.readStatus == ReadStatus.SENT) {
|
||||||
updateStatus(R.drawable.ic_check, context.resources?.getString(R.string.nc_message_sent))
|
updateStatus(R.drawable.ic_check, context.resources?.getString(R.string.nc_message_sent))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,8 +174,6 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
|||||||
viewThemeUtils.material.colorProgressBar(binding.sendingProgress)
|
viewThemeUtils.material.colorProgressBar(binding.sendingProgress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun longClickOnReaction(chatMessage: ChatMessage) {
|
private fun longClickOnReaction(chatMessage: ChatMessage) {
|
||||||
commonMessageInterface.onLongClickReactions(chatMessage)
|
commonMessageInterface.onLongClickReactions(chatMessage)
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,7 @@ interface NcApiCoroutines {
|
|||||||
@DELETE
|
@DELETE
|
||||||
suspend fun unarchiveConversation(@Header("Authorization") authorization: String, @Url url: String): GenericOverall
|
suspend fun unarchiveConversation(@Header("Authorization") authorization: String, @Url url: String): GenericOverall
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST
|
@POST
|
||||||
suspend fun sendChatMessage(
|
suspend fun sendChatMessage(
|
||||||
|
@ -1142,14 +1142,13 @@ class ChatActivity :
|
|||||||
private fun removeMessageById(idToDelete: String) {
|
private fun removeMessageById(idToDelete: String) {
|
||||||
val indexToDelete = adapter?.getMessagePositionById(idToDelete)
|
val indexToDelete = adapter?.getMessagePositionById(idToDelete)
|
||||||
if (indexToDelete != null && indexToDelete != UNREAD_MESSAGES_MARKER_ID) {
|
if (indexToDelete != null && indexToDelete != UNREAD_MESSAGES_MARKER_ID) {
|
||||||
|
|
||||||
// If user sent a message as a first message in todays chat, the temp message will be deleted when
|
// If user sent a message as a first message in todays chat, the temp message will be deleted when
|
||||||
// messages are retrieved from server, but also the date has to be deleted as it will be added again
|
// messages are retrieved from server, but also the date has to be deleted as it will be added again
|
||||||
// when the chat messages are added from server. Otherwise date "Today" would be shown twice.
|
// when the chat messages are added from server. Otherwise date "Today" would be shown twice.
|
||||||
if (indexToDelete == 0 && (adapter?.items?.get(1))?.item is Date) {
|
if (indexToDelete == 0 && (adapter?.items?.get(1))?.item is Date) {
|
||||||
adapter?.items?.removeAt(0)
|
adapter?.items?.removeAt(0)
|
||||||
adapter?.items?.removeAt(0)
|
adapter?.items?.removeAt(0)
|
||||||
adapter?.notifyItemRangeRemoved(indexToDelete,1)
|
adapter?.notifyItemRangeRemoved(indexToDelete, 1)
|
||||||
} else {
|
} else {
|
||||||
adapter?.items?.removeAt(indexToDelete)
|
adapter?.items?.removeAt(indexToDelete)
|
||||||
adapter?.notifyItemRemoved(indexToDelete)
|
adapter?.notifyItemRemoved(indexToDelete)
|
||||||
@ -1170,7 +1169,7 @@ class ChatActivity :
|
|||||||
|
|
||||||
cancelNotificationsForCurrentConversation()
|
cancelNotificationsForCurrentConversation()
|
||||||
|
|
||||||
chatViewModel.getRoom(conversationUser!!, roomToken)
|
chatViewModel.getRoom(roomToken)
|
||||||
|
|
||||||
actionBar?.show()
|
actionBar?.show()
|
||||||
|
|
||||||
@ -1627,7 +1626,7 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
getRoomInfoTimerHandler?.postDelayed(
|
getRoomInfoTimerHandler?.postDelayed(
|
||||||
{
|
{
|
||||||
chatViewModel.getRoom(conversationUser!!, roomToken)
|
chatViewModel.getRoom(roomToken)
|
||||||
},
|
},
|
||||||
delayForRecursiveCall
|
delayForRecursiveCall
|
||||||
)
|
)
|
||||||
@ -2938,8 +2937,11 @@ class ChatActivity :
|
|||||||
private fun isScrolledToBottom(): Boolean {
|
private fun isScrolledToBottom(): Boolean {
|
||||||
val position = layoutManager?.findFirstVisibleItemPosition()
|
val position = layoutManager?.findFirstVisibleItemPosition()
|
||||||
if (position == -1) {
|
if (position == -1) {
|
||||||
Log.w(TAG, "FirstVisibleItemPosition was -1 but true is returned for isScrolledToBottom(). This can " +
|
Log.w(
|
||||||
"happen when the UI is not yet ready")
|
TAG,
|
||||||
|
"FirstVisibleItemPosition was -1 but true is returned for isScrolledToBottom(). This can " +
|
||||||
|
"happen when the UI is not yet ready"
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3294,7 +3296,7 @@ class ChatActivity :
|
|||||||
private fun isInfoMessageAboutDeletion(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isInfoMessageAboutDeletion(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.parentMessageId != null &&
|
currentMessage.value.parentMessageId != null &&
|
||||||
currentMessage.value.systemMessageType == ChatMessage
|
currentMessage.value.systemMessageType == ChatMessage
|
||||||
.SystemMessageType.MESSAGE_DELETED
|
.SystemMessageType.MESSAGE_DELETED
|
||||||
|
|
||||||
private fun isReactionsMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isReactionsMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION ||
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION ||
|
||||||
@ -3304,7 +3306,7 @@ class ChatActivity :
|
|||||||
private fun isEditMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isEditMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.parentMessageId != null &&
|
currentMessage.value.parentMessageId != null &&
|
||||||
currentMessage.value.systemMessageType == ChatMessage
|
currentMessage.value.systemMessageType == ChatMessage
|
||||||
.SystemMessageType.MESSAGE_EDITED
|
.SystemMessageType.MESSAGE_EDITED
|
||||||
|
|
||||||
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
private fun isPollVotedMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean =
|
||||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.POLL_VOTED
|
||||||
@ -3404,7 +3406,7 @@ class ChatActivity :
|
|||||||
this,
|
this,
|
||||||
message,
|
message,
|
||||||
conversationUser,
|
conversationUser,
|
||||||
currentConversation,
|
currentConversation
|
||||||
).show()
|
).show()
|
||||||
} else if (hasVisibleItems(message) &&
|
} else if (hasVisibleItems(message) &&
|
||||||
!isSystemMessage(message)
|
!isSystemMessage(message)
|
||||||
@ -3614,7 +3616,7 @@ class ChatActivity :
|
|||||||
val lon = data["longitude"]!!
|
val lon = data["longitude"]!!
|
||||||
metaData =
|
metaData =
|
||||||
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
|
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
|
||||||
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
shareToNotes(shareUri, roomToken, message, objectId, metaData)
|
shareToNotes(shareUri, roomToken, message, objectId, metaData)
|
||||||
|
@ -861,7 +861,6 @@ class MessageInputFragment : Fragment() {
|
|||||||
|
|
||||||
private fun sendMessage(message: String, replyTo: Int?, sendWithoutNotification: Boolean) {
|
private fun sendMessage(message: String, replyTo: Int?, sendWithoutNotification: Boolean) {
|
||||||
chatActivity.messageInputViewModel.sendChatMessage(
|
chatActivity.messageInputViewModel.sendChatMessage(
|
||||||
conversationInternalId,
|
|
||||||
chatActivity.conversationUser!!.getCredentials(),
|
chatActivity.conversationUser!!.getCredentials(),
|
||||||
ApiUtils.getUrlForChat(
|
ApiUtils.getUrlForChat(
|
||||||
chatActivity.chatApiVersion,
|
chatActivity.chatApiVersion,
|
||||||
|
@ -14,7 +14,6 @@ import com.nextcloud.talk.models.domain.ConversationModel
|
|||||||
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
|
|
||||||
interface ChatMessageRepository : LifecycleAwareManager {
|
interface ChatMessageRepository : LifecycleAwareManager {
|
||||||
|
|
||||||
@ -80,6 +79,7 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
|||||||
*/
|
*/
|
||||||
fun handleChatOnBackPress()
|
fun handleChatOnBackPress()
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
suspend fun sendChatMessage(
|
suspend fun sendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -90,6 +90,7 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
|||||||
referenceId: String
|
referenceId: String
|
||||||
): Flow<Result<ChatMessage?>>
|
): Flow<Result<ChatMessage?>>
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
suspend fun resendChatMessage(
|
suspend fun resendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -111,10 +112,7 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
|||||||
|
|
||||||
suspend fun editTempChatMessage(message: ChatMessage, editedMessageText: String): Flow<Boolean>
|
suspend fun editTempChatMessage(message: ChatMessage, editedMessageText: String): Flow<Boolean>
|
||||||
|
|
||||||
suspend fun sendTempChatMessages(
|
suspend fun sendTempChatMessages(credentials: String, url: String)
|
||||||
credentials: String,
|
|
||||||
url: String
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun deleteTempMessage(chatMessage: ChatMessage)
|
suspend fun deleteTempMessage(chatMessage: ChatMessage)
|
||||||
}
|
}
|
||||||
|
@ -115,9 +115,7 @@ data class ChatMessage(
|
|||||||
|
|
||||||
var openWhenDownloaded: Boolean = true,
|
var openWhenDownloaded: Boolean = true,
|
||||||
|
|
||||||
var isTemporary: Boolean = false, // TODO: replace logic from message drafts with logic from temp message sending
|
var isTemporary: Boolean = false,
|
||||||
|
|
||||||
// var tempMessageId: Int = -1, // TODO: replace logic from message drafts with logic from temp message sending
|
|
||||||
|
|
||||||
var referenceId: String? = null,
|
var referenceId: String? = null,
|
||||||
|
|
||||||
|
@ -795,6 +795,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
scope.cancel()
|
scope.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
override suspend fun sendChatMessage(
|
override suspend fun sendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -847,6 +848,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
override suspend fun resendChatMessage(
|
override suspend fun resendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -874,6 +876,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override suspend fun editChatMessage(
|
override suspend fun editChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
@ -892,13 +895,13 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun editTempChatMessage(
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
message: ChatMessage, editedMessageText: String
|
override suspend fun editTempChatMessage(message: ChatMessage, editedMessageText: String): Flow<Boolean> =
|
||||||
): Flow<Boolean> =
|
|
||||||
flow {
|
flow {
|
||||||
try {
|
try {
|
||||||
val messageToEdit = chatDao.getChatMessageForConversation(
|
val messageToEdit = chatDao.getChatMessageForConversation(
|
||||||
internalConversationId, message.jsonMessageId
|
internalConversationId,
|
||||||
|
message.jsonMessageId
|
||||||
.toLong()
|
.toLong()
|
||||||
).first()
|
).first()
|
||||||
messageToEdit.message = editedMessageText
|
messageToEdit.message = editedMessageText
|
||||||
@ -912,10 +915,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendTempChatMessages(
|
override suspend fun sendTempChatMessages(credentials: String, url: String) {
|
||||||
credentials: String,
|
|
||||||
url: String
|
|
||||||
) {
|
|
||||||
val tempMessages = chatDao.getTempMessagesForConversation(internalConversationId).first()
|
val tempMessages = chatDao.getTempMessagesForConversation(internalConversationId).first()
|
||||||
tempMessages.sortedBy { it.internalId }.onEach {
|
tempMessages.sortedBy { it.internalId }.onEach {
|
||||||
sendChatMessage(
|
sendChatMessage(
|
||||||
@ -974,7 +974,6 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
message: String,
|
message: String,
|
||||||
referenceId: String
|
referenceId: String
|
||||||
): ChatMessageEntity {
|
): ChatMessageEntity {
|
||||||
|
|
||||||
val currentTimeMillies = System.currentTimeMillis()
|
val currentTimeMillies = System.currentTimeMillis()
|
||||||
|
|
||||||
val currentTimeWithoutYear = SendMessageUtils().removeYearFromTimestamp(currentTimeMillies)
|
val currentTimeWithoutYear = SendMessageUtils().removeYearFromTimestamp(currentTimeMillies)
|
||||||
|
@ -117,7 +117,7 @@ class RetrofitChatNetwork(
|
|||||||
displayName,
|
displayName,
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
SendMessageUtils().generateReferenceId() // TODO add temp message before with ref id..
|
SendMessageUtils().generateReferenceId()
|
||||||
).map {
|
).map {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
@ -247,14 +247,9 @@ class ChatViewModel @Inject constructor(
|
|||||||
chatRepository.setData(conversationModel, credentials, urlForChatting)
|
chatRepository.setData(conversationModel, credentials, urlForChatting)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRoom(user: User, token: String) {
|
fun getRoom(token: String) {
|
||||||
_getRoomViewState.value = GetRoomStartState
|
_getRoomViewState.value = GetRoomStartState
|
||||||
conversationRepository.getRoom(token)
|
conversationRepository.getRoom(token)
|
||||||
|
|
||||||
// chatNetworkDataSource.getRoom(user, token)
|
|
||||||
// .subscribeOn(Schedulers.io())
|
|
||||||
// ?.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
// ?.subscribe(GetRoomObserver())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
|
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
|
||||||
@ -677,25 +672,6 @@ class ChatViewModel @Inject constructor(
|
|||||||
fun getPlaybackSpeedPreference(message: ChatMessage) =
|
fun getPlaybackSpeedPreference(message: ChatMessage) =
|
||||||
_voiceMessagePlaybackSpeedPreferences.value?.get(message.user.id) ?: PlaybackSpeed.NORMAL
|
_voiceMessagePlaybackSpeedPreferences.value?.get(message.user.id) ?: PlaybackSpeed.NORMAL
|
||||||
|
|
||||||
// inner class GetRoomObserver : Observer<ConversationModel> {
|
|
||||||
// override fun onSubscribe(d: Disposable) {
|
|
||||||
// // unused atm
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onNext(conversationModel: ConversationModel) {
|
|
||||||
// _getRoomViewState.value = GetRoomSuccessState(conversationModel)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onError(e: Throwable) {
|
|
||||||
// Log.e(TAG, "Error when fetching room")
|
|
||||||
// _getRoomViewState.value = GetRoomErrorState
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onComplete() {
|
|
||||||
// // unused atm
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
inner class JoinRoomObserver : Observer<ConversationModel> {
|
inner class JoinRoomObserver : Observer<ConversationModel> {
|
||||||
override fun onSubscribe(d: Disposable) {
|
override fun onSubscribe(d: Disposable) {
|
||||||
disposableSet.add(d)
|
disposableSet.add(d)
|
||||||
@ -800,10 +776,7 @@ class ChatViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resendMessage(
|
fun resendMessage(credentials: String, urlForChat: String, message: ChatMessage) {
|
||||||
credentials: String,
|
|
||||||
urlForChat: String,
|
|
||||||
message: ChatMessage) {
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
chatRepository.resendChatMessage(
|
chatRepository.resendChatMessage(
|
||||||
credentials,
|
credentials,
|
||||||
|
@ -14,23 +14,18 @@ import androidx.lifecycle.LifecycleOwner
|
|||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.asLiveData
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.nextcloud.talk.chat.data.ChatMessageRepository
|
import com.nextcloud.talk.chat.data.ChatMessageRepository
|
||||||
import com.nextcloud.talk.chat.data.io.AudioFocusRequestManager
|
import com.nextcloud.talk.chat.data.io.AudioFocusRequestManager
|
||||||
import com.nextcloud.talk.chat.data.io.AudioRecorderManager
|
import com.nextcloud.talk.chat.data.io.AudioRecorderManager
|
||||||
import com.nextcloud.talk.chat.data.io.MediaPlayerManager
|
import com.nextcloud.talk.chat.data.io.MediaPlayerManager
|
||||||
import com.nextcloud.talk.chat.data.model.ChatMessage
|
import com.nextcloud.talk.chat.data.model.ChatMessage
|
||||||
import com.nextcloud.talk.chat.data.network.ChatNetworkDataSource
|
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
||||||
import com.nextcloud.talk.utils.message.SendMessageUtils
|
import com.nextcloud.talk.utils.message.SendMessageUtils
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import com.stfalcon.chatkit.commons.models.IMessage
|
import com.stfalcon.chatkit.commons.models.IMessage
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
|
||||||
import kotlinx.coroutines.flow.update
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.lang.Thread.sleep
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MessageInputViewModel @Inject constructor(
|
class MessageInputViewModel @Inject constructor(
|
||||||
@ -51,7 +46,7 @@ class MessageInputViewModel @Inject constructor(
|
|||||||
lateinit var currentLifeCycleFlag: LifeCycleFlag
|
lateinit var currentLifeCycleFlag: LifeCycleFlag
|
||||||
val disposableSet = mutableSetOf<Disposable>()
|
val disposableSet = mutableSetOf<Disposable>()
|
||||||
|
|
||||||
fun setData(chatMessageRepository: ChatMessageRepository){
|
fun setData(chatMessageRepository: ChatMessageRepository) {
|
||||||
chatRepository = chatMessageRepository
|
chatRepository = chatMessageRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,9 +98,11 @@ class MessageInputViewModel @Inject constructor(
|
|||||||
object SendChatMessageStartState : ViewState
|
object SendChatMessageStartState : ViewState
|
||||||
class SendChatMessageSuccessState(val message: CharSequence) : ViewState
|
class SendChatMessageSuccessState(val message: CharSequence) : ViewState
|
||||||
class SendChatMessageErrorState(val message: CharSequence) : ViewState
|
class SendChatMessageErrorState(val message: CharSequence) : ViewState
|
||||||
|
|
||||||
private val _sendChatMessageViewState: MutableLiveData<ViewState> = MutableLiveData(SendChatMessageStartState)
|
private val _sendChatMessageViewState: MutableLiveData<ViewState> = MutableLiveData(SendChatMessageStartState)
|
||||||
val sendChatMessageViewState: LiveData<ViewState>
|
val sendChatMessageViewState: LiveData<ViewState>
|
||||||
get() = _sendChatMessageViewState
|
get() = _sendChatMessageViewState
|
||||||
|
|
||||||
object EditMessageErrorState : ViewState
|
object EditMessageErrorState : ViewState
|
||||||
class EditMessageSuccessState(val messageEdited: ChatOverallSingleMessage) : ViewState
|
class EditMessageSuccessState(val messageEdited: ChatOverallSingleMessage) : ViewState
|
||||||
|
|
||||||
@ -121,9 +118,7 @@ class MessageInputViewModel @Inject constructor(
|
|||||||
val callStartedFlow: LiveData<Pair<ChatMessage, Boolean>>
|
val callStartedFlow: LiveData<Pair<ChatMessage, Boolean>>
|
||||||
get() = _callStartedFlow
|
get() = _callStartedFlow
|
||||||
|
|
||||||
@Suppress("LongParameterList")
|
|
||||||
fun sendChatMessage(
|
fun sendChatMessage(
|
||||||
internalId: String,
|
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
message: String,
|
message: String,
|
||||||
@ -172,10 +167,7 @@ class MessageInputViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendTempMessages(
|
fun sendTempMessages(credentials: String, url: String) {
|
||||||
credentials: String,
|
|
||||||
url: String,
|
|
||||||
) {
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
chatRepository.sendTempChatMessages(
|
chatRepository.sendTempChatMessages(
|
||||||
credentials,
|
credentials,
|
||||||
|
@ -65,7 +65,6 @@ import com.nextcloud.talk.utils.preferences.AppPreferences
|
|||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
class RepositoryModule {
|
class RepositoryModule {
|
||||||
|
@ -66,6 +66,6 @@ data class ChatMessageEntity(
|
|||||||
@ColumnInfo(name = "referenceId") var referenceId: String? = null,
|
@ColumnInfo(name = "referenceId") var referenceId: String? = null,
|
||||||
@ColumnInfo(name = "sendingFailed") var sendingFailed: Boolean = false,
|
@ColumnInfo(name = "sendingFailed") var sendingFailed: Boolean = false,
|
||||||
@ColumnInfo(name = "systemMessage") var systemMessageType: ChatMessage.SystemMessageType,
|
@ColumnInfo(name = "systemMessage") var systemMessageType: ChatMessage.SystemMessageType,
|
||||||
@ColumnInfo(name = "timestamp") var timestamp: Long = 0,
|
@ColumnInfo(name = "timestamp") var timestamp: Long = 0
|
||||||
// missing/not needed: silent
|
// missing/not needed: silent
|
||||||
)
|
)
|
||||||
|
@ -87,7 +87,7 @@ class DirectReplyReceiver : BroadcastReceiver() {
|
|||||||
currentUser.displayName,
|
currentUser.displayName,
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
SendMessageUtils().generateReferenceId() // TODO add temp chatMessage before with ref id...
|
SendMessageUtils().generateReferenceId()
|
||||||
)
|
)
|
||||||
?.subscribeOn(Schedulers.io())
|
?.subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -58,19 +58,15 @@ class TempMessageActionsDialog(
|
|||||||
|
|
||||||
viewThemeUtils.material.colorBottomSheetBackground(binding.root)
|
viewThemeUtils.material.colorBottomSheetBackground(binding.root)
|
||||||
viewThemeUtils.material.colorBottomSheetDragHandle(binding.bottomSheetDragHandle)
|
viewThemeUtils.material.colorBottomSheetDragHandle(binding.bottomSheetDragHandle)
|
||||||
|
|
||||||
initMenuItemCopy(!message.isDeleted)
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(user!!, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1))
|
|
||||||
|
|
||||||
|
|
||||||
initMenuItems()
|
initMenuItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initMenuItems() {
|
private fun initMenuItems() {
|
||||||
this.lifecycleScope.launch {
|
this.lifecycleScope.launch {
|
||||||
initResendMessage(networkMonitor.isOnline.first())
|
initResendMessage(networkMonitor.isOnline.first())
|
||||||
initMenuEditMessage(true)
|
initMenuEditMessage()
|
||||||
initMenuDeleteMessage(true)
|
initMenuDeleteMessage()
|
||||||
|
initMenuItemCopy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,34 +95,25 @@ class TempMessageActionsDialog(
|
|||||||
binding.menuResendMessage.visibility = getVisibility(visible)
|
binding.menuResendMessage.visibility = getVisibility(visible)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initMenuDeleteMessage(visible: Boolean) {
|
private fun initMenuDeleteMessage() {
|
||||||
if (visible) {
|
binding.menuDeleteMessage.setOnClickListener {
|
||||||
binding.menuDeleteMessage.setOnClickListener {
|
chatActivity.chatViewModel.deleteTempMessage(message)
|
||||||
chatActivity.chatViewModel.deleteTempMessage(message)
|
dismiss()
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
binding.menuDeleteMessage.visibility = getVisibility(visible)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initMenuEditMessage(visible: Boolean) {
|
private fun initMenuEditMessage() {
|
||||||
binding.menuEditMessage.setOnClickListener {
|
binding.menuEditMessage.setOnClickListener {
|
||||||
chatActivity.messageInputViewModel.edit(message)
|
chatActivity.messageInputViewModel.edit(message)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.menuEditMessage.visibility = getVisibility(visible)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initMenuItemCopy(visible: Boolean) {
|
private fun initMenuItemCopy() {
|
||||||
if (visible) {
|
binding.menuCopyMessage.setOnClickListener {
|
||||||
binding.menuCopyMessage.setOnClickListener {
|
chatActivity.copyMessage(message)
|
||||||
chatActivity.copyMessage(message)
|
dismiss()
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.menuCopyMessage.visibility = getVisibility(visible)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getVisibility(visible: Boolean): Int {
|
private fun getVisibility(visible: Boolean): Int {
|
||||||
|
@ -17,7 +17,6 @@ import androidx.datastore.preferences.core.longPreferencesKey
|
|||||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||||
import androidx.datastore.preferences.preferencesDataStore
|
import androidx.datastore.preferences.preferencesDataStore
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel
|
|
||||||
import com.nextcloud.talk.ui.PlaybackSpeed
|
import com.nextcloud.talk.ui.PlaybackSpeed
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
|
Loading…
Reference in New Issue
Block a user