mirror of
https://github.com/nextcloud/talk-android
synced 2025-08-08 04:25:03 +01:00
clear reply ui when sending attachment as reply
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
6ce475dd72
commit
7c37514612
@ -2340,7 +2340,7 @@ class ChatActivity :
|
|||||||
BuildConfig.APPLICATION_ID,
|
BuildConfig.APPLICATION_ID,
|
||||||
File(file.absolutePath)
|
File(file.absolutePath)
|
||||||
)
|
)
|
||||||
chatViewModel.uploadFile(
|
uploadFile(
|
||||||
fileUri = shareUri.toString(),
|
fileUri = shareUri.toString(),
|
||||||
isVoiceMessage = false,
|
isVoiceMessage = false,
|
||||||
caption = "",
|
caption = "",
|
||||||
@ -2531,7 +2531,7 @@ class ChatActivity :
|
|||||||
private fun uploadFiles(files: MutableList<String>, caption: String = "") {
|
private fun uploadFiles(files: MutableList<String>, caption: String = "") {
|
||||||
for (i in 0 until files.size) {
|
for (i in 0 until files.size) {
|
||||||
if (i == files.size - 1) {
|
if (i == files.size - 1) {
|
||||||
chatViewModel.uploadFile(
|
uploadFile(
|
||||||
fileUri = files[i],
|
fileUri = files[i],
|
||||||
isVoiceMessage = false,
|
isVoiceMessage = false,
|
||||||
caption = caption,
|
caption = caption,
|
||||||
@ -2540,7 +2540,7 @@ class ChatActivity :
|
|||||||
displayName = currentConversation?.displayName!!
|
displayName = currentConversation?.displayName!!
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
chatViewModel.uploadFile(
|
uploadFile(
|
||||||
fileUri = files[i],
|
fileUri = files[i],
|
||||||
isVoiceMessage = false,
|
isVoiceMessage = false,
|
||||||
caption = "",
|
caption = "",
|
||||||
@ -3880,7 +3880,7 @@ class ChatActivity :
|
|||||||
val type = message.getCalculateMessageType()
|
val type = message.getCalculateMessageType()
|
||||||
when (type) {
|
when (type) {
|
||||||
ChatMessage.MessageType.VOICE_MESSAGE -> {
|
ChatMessage.MessageType.VOICE_MESSAGE -> {
|
||||||
chatViewModel.uploadFile(
|
uploadFile(
|
||||||
shareUri.toString(),
|
shareUri.toString(),
|
||||||
true,
|
true,
|
||||||
roomToken = roomToken,
|
roomToken = roomToken,
|
||||||
@ -3896,7 +3896,7 @@ class ChatActivity :
|
|||||||
if (null != shareUri) {
|
if (null != shareUri) {
|
||||||
try {
|
try {
|
||||||
context.contentResolver.openInputStream(shareUri)?.close()
|
context.contentResolver.openInputStream(shareUri)?.close()
|
||||||
chatViewModel.uploadFile(
|
uploadFile(
|
||||||
fileUri = shareUri.toString(),
|
fileUri = shareUri.toString(),
|
||||||
isVoiceMessage = false,
|
isVoiceMessage = false,
|
||||||
caption = caption!!,
|
caption = caption!!,
|
||||||
@ -3908,7 +3908,7 @@ class ChatActivity :
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "File corresponding to the uri does not exist $shareUri", e)
|
Log.w(TAG, "File corresponding to the uri does not exist $shareUri", e)
|
||||||
downloadFileToCache(message, false) {
|
downloadFileToCache(message, false) {
|
||||||
chatViewModel.uploadFile(
|
uploadFile(
|
||||||
fileUri = shareUri.toString(),
|
fileUri = shareUri.toString(),
|
||||||
isVoiceMessage = false,
|
isVoiceMessage = false,
|
||||||
caption = caption!!,
|
caption = caption!!,
|
||||||
@ -4329,6 +4329,33 @@ class ChatActivity :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun uploadFile(
|
||||||
|
fileUri: String,
|
||||||
|
isVoiceMessage: Boolean,
|
||||||
|
caption: String = "",
|
||||||
|
roomToken: String = "",
|
||||||
|
replyToMessageId: Int? = null,
|
||||||
|
displayName: String
|
||||||
|
) {
|
||||||
|
chatViewModel.uploadFile(
|
||||||
|
fileUri,
|
||||||
|
isVoiceMessage,
|
||||||
|
caption,
|
||||||
|
roomToken,
|
||||||
|
replyToMessageId,
|
||||||
|
displayName
|
||||||
|
)
|
||||||
|
cancelReply()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun cancelReply() {
|
||||||
|
messageInputViewModel.reply(null)
|
||||||
|
chatViewModel.messageDraft.quotedMessageText = null
|
||||||
|
chatViewModel.messageDraft.quotedDisplayName = null
|
||||||
|
chatViewModel.messageDraft.quotedImageUrl = null
|
||||||
|
chatViewModel.messageDraft.quotedJsonId = null
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = ChatActivity::class.simpleName
|
val TAG = ChatActivity::class.simpleName
|
||||||
private const val CONTENT_TYPE_CALL_STARTED: Byte = 1
|
private const val CONTENT_TYPE_CALL_STARTED: Byte = 1
|
||||||
|
@ -182,8 +182,12 @@ class MessageInputFragment : Fragment() {
|
|||||||
chatActivity.chatViewModel.messageDraft.quotedDisplayName = message.actorDisplayName
|
chatActivity.chatViewModel.messageDraft.quotedDisplayName = message.actorDisplayName
|
||||||
chatActivity.chatViewModel.messageDraft.quotedImageUrl = message.imageUrl
|
chatActivity.chatViewModel.messageDraft.quotedImageUrl = message.imageUrl
|
||||||
chatActivity.chatViewModel.messageDraft.quotedJsonId = message.jsonMessageId
|
chatActivity.chatViewModel.messageDraft.quotedJsonId = message.jsonMessageId
|
||||||
replyToMessage(message.text, message.actorDisplayName, message.imageUrl, message.jsonMessageId)
|
replyToMessage(
|
||||||
}
|
message.text,
|
||||||
|
message.actorDisplayName,
|
||||||
|
message.imageUrl
|
||||||
|
)
|
||||||
|
} ?: clearReplyUi()
|
||||||
}
|
}
|
||||||
|
|
||||||
chatActivity.messageInputViewModel.getEditChatMessage.observe(viewLifecycleOwner) { message ->
|
chatActivity.messageInputViewModel.getEditChatMessage.observe(viewLifecycleOwner) { message ->
|
||||||
@ -314,8 +318,7 @@ class MessageInputFragment : Fragment() {
|
|||||||
replyToMessage(
|
replyToMessage(
|
||||||
chatActivity.chatViewModel.messageDraft.quotedMessageText,
|
chatActivity.chatViewModel.messageDraft.quotedMessageText,
|
||||||
chatActivity.chatViewModel.messageDraft.quotedDisplayName,
|
chatActivity.chatViewModel.messageDraft.quotedDisplayName,
|
||||||
chatActivity.chatViewModel.messageDraft.quotedImageUrl,
|
chatActivity.chatViewModel.messageDraft.quotedImageUrl
|
||||||
chatActivity.chatViewModel.messageDraft.quotedJsonId ?: 0
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,6 +471,10 @@ class MessageInputFragment : Fragment() {
|
|||||||
binding.fragmentCallStarted.callStartedSecondaryText.visibility = if (collapsed) View.VISIBLE else View.GONE
|
binding.fragmentCallStarted.callStartedSecondaryText.visibility = if (collapsed) View.VISIBLE else View.GONE
|
||||||
setDropDown(collapsed)
|
setDropDown(collapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.fragmentMessageInputView.findViewById<ImageButton>(R.id.cancelReplyButton)?.setOnClickListener {
|
||||||
|
cancelReply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setDropDown(collapsed: Boolean) {
|
private fun setDropDown(collapsed: Boolean) {
|
||||||
@ -719,12 +726,7 @@ class MessageInputFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun replyToMessage(
|
private fun replyToMessage(quotedMessageText: String?, quotedActorDisplayName: String?, quotedImageUrl: String?) {
|
||||||
quotedMessageText: String?,
|
|
||||||
quotedActorDisplayName: String?,
|
|
||||||
quotedImageUrl: String?,
|
|
||||||
quotedJsonId: Int
|
|
||||||
) {
|
|
||||||
Log.d(TAG, "Reply")
|
Log.d(TAG, "Reply")
|
||||||
val view = binding.fragmentMessageInputView
|
val view = binding.fragmentMessageInputView
|
||||||
view.findViewById<ImageButton>(R.id.cancelReplyButton)?.visibility =
|
view.findViewById<ImageButton>(R.id.cancelReplyButton)?.visibility =
|
||||||
@ -955,10 +957,6 @@ class MessageInputFragment : Fragment() {
|
|||||||
private fun themeMessageInputView() {
|
private fun themeMessageInputView() {
|
||||||
binding.fragmentMessageInputView.button?.let { viewThemeUtils.platform.colorImageView(it, ColorRole.PRIMARY) }
|
binding.fragmentMessageInputView.button?.let { viewThemeUtils.platform.colorImageView(it, ColorRole.PRIMARY) }
|
||||||
|
|
||||||
binding.fragmentMessageInputView.findViewById<ImageButton>(R.id.cancelReplyButton)?.setOnClickListener {
|
|
||||||
cancelReply()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.fragmentMessageInputView.findViewById<ImageButton>(R.id.cancelReplyButton)?.let {
|
binding.fragmentMessageInputView.findViewById<ImageButton>(R.id.cancelReplyButton)?.let {
|
||||||
viewThemeUtils.platform
|
viewThemeUtils.platform
|
||||||
.themeImageButton(it)
|
.themeImageButton(it)
|
||||||
@ -1015,18 +1013,14 @@ class MessageInputFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun cancelReply() {
|
private fun cancelReply() {
|
||||||
// TODO set id in viewmodel to null
|
chatActivity.cancelReply()
|
||||||
val quote = binding.fragmentMessageInputView
|
clearReplyUi()
|
||||||
.findViewById<RelativeLayout>(R.id.quotedChatMessageView)
|
}
|
||||||
quote.visibility = View.GONE
|
|
||||||
quote.tag = null
|
|
||||||
binding.fragmentMessageInputView.findViewById<ImageButton>(R.id.attachmentButton)?.visibility = View.VISIBLE
|
|
||||||
chatActivity.messageInputViewModel.reply(null)
|
|
||||||
|
|
||||||
chatActivity.chatViewModel.messageDraft.quotedMessageText = null
|
private fun clearReplyUi() {
|
||||||
chatActivity.chatViewModel.messageDraft.quotedDisplayName = null
|
val quote = binding.fragmentMessageInputView.findViewById<RelativeLayout>(R.id.quotedChatMessageView)
|
||||||
chatActivity.chatViewModel.messageDraft.quotedImageUrl = null
|
quote.visibility = View.GONE
|
||||||
chatActivity.chatViewModel.messageDraft.quotedJsonId = null
|
binding.fragmentMessageInputView.findViewById<ImageButton>(R.id.attachmentButton)?.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isInReplyState(): Boolean {
|
private fun isInReplyState(): Boolean {
|
||||||
|
@ -445,6 +445,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
return loadFromServer
|
return loadFromServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
private fun getFieldMap(
|
private fun getFieldMap(
|
||||||
lookIntoFuture: Boolean,
|
lookIntoFuture: Boolean,
|
||||||
timeout: Int,
|
timeout: Int,
|
||||||
|
Loading…
Reference in New Issue
Block a user