mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-31 03:17:13 +01:00
Create data class instead of Pair
This commit is contained in:
parent
0a54801fcc
commit
92e3a02389
@ -265,13 +265,13 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
stringProvider.getString(R.string.message_reply_to_prefix),
|
stringProvider.getString(R.string.message_reply_to_prefix),
|
||||||
userLink,
|
userLink,
|
||||||
userId,
|
userId,
|
||||||
body.second ?: body.first,
|
body.takeFormatted(),
|
||||||
replyText
|
replyText
|
||||||
)
|
)
|
||||||
//
|
//
|
||||||
// > <@alice:example.org> This is the original body
|
// > <@alice:example.org> This is the original body
|
||||||
//
|
//
|
||||||
val lines = body.first.split("\n")
|
val lines = body.text.split("\n")
|
||||||
val replyFallback = StringBuffer("><$userId>")
|
val replyFallback = StringBuffer("><$userId>")
|
||||||
lines.forEachIndexed { index, s ->
|
lines.forEachIndexed { index, s ->
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
@ -297,7 +297,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
* Returns a pair of <Plain Text, Formatted Text?> used for the fallback event representation
|
* Returns a pair of <Plain Text, Formatted Text?> used for the fallback event representation
|
||||||
* in a reply message.
|
* in a reply message.
|
||||||
*/
|
*/
|
||||||
private fun bodyForReply(content: MessageContent?): Pair<String, String?> {
|
private fun bodyForReply(content: MessageContent?): TextContent {
|
||||||
when (content?.type) {
|
when (content?.type) {
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
@ -309,13 +309,13 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
|||||||
formattedText = content.formattedBody
|
formattedText = content.formattedBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return content.body to formattedText
|
return TextContent(content.body, formattedText)
|
||||||
}
|
}
|
||||||
MessageType.MSGTYPE_FILE -> return stringProvider.getString(R.string.reply_to_a_file) to null
|
MessageType.MSGTYPE_FILE -> return TextContent(stringProvider.getString(R.string.reply_to_a_file))
|
||||||
MessageType.MSGTYPE_AUDIO -> return stringProvider.getString(R.string.reply_to_an_audio_file) to null
|
MessageType.MSGTYPE_AUDIO -> return TextContent(stringProvider.getString(R.string.reply_to_an_audio_file))
|
||||||
MessageType.MSGTYPE_IMAGE -> return stringProvider.getString(R.string.reply_to_an_image) to null
|
MessageType.MSGTYPE_IMAGE -> return TextContent(stringProvider.getString(R.string.reply_to_an_image))
|
||||||
MessageType.MSGTYPE_VIDEO -> return stringProvider.getString(R.string.reply_to_a_video) to null
|
MessageType.MSGTYPE_VIDEO -> return TextContent(stringProvider.getString(R.string.reply_to_a_video))
|
||||||
else -> return (content?.body ?: "") to null
|
else -> return TextContent(content?.body ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.internal.session.room.send
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a text and eventually a formatted text
|
||||||
|
*/
|
||||||
|
data class TextContent(
|
||||||
|
val text: String,
|
||||||
|
|
||||||
|
val formattedText: String? = null
|
||||||
|
) {
|
||||||
|
fun takeFormatted() = formattedText ?: text
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user