mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
Move TextContent class to api
package
It is used by the app. Make the extensions internal
This commit is contained in:
parent
dc092f889b
commit
83570dc24b
7 changed files with 36 additions and 14 deletions
|
@ -27,6 +27,7 @@ import org.junit.runner.RunWith
|
|||
import org.junit.runners.MethodSorters
|
||||
import org.matrix.android.sdk.InstrumentedTest
|
||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||
import org.matrix.android.sdk.api.util.TextContent
|
||||
import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
|
||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
||||
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* 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 org.matrix.android.sdk.api.util
|
||||
|
||||
/**
|
||||
* Contains a text and eventually a formatted text
|
||||
*/
|
||||
data class TextContent(
|
||||
val text: String,
|
||||
val formattedText: String? = null
|
||||
) {
|
||||
fun takeFormatted() = formattedText ?: text
|
||||
}
|
|
@ -46,6 +46,7 @@ import org.matrix.android.sdk.api.util.Cancelable
|
|||
import org.matrix.android.sdk.api.util.CancelableBag
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
import org.matrix.android.sdk.api.util.NoOpCancellable
|
||||
import org.matrix.android.sdk.api.util.TextContent
|
||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||
import org.matrix.android.sdk.internal.di.SessionId
|
||||
import org.matrix.android.sdk.internal.di.WorkManagerProvider
|
||||
|
|
|
@ -65,6 +65,7 @@ import org.matrix.android.sdk.api.session.room.model.relation.ReplyToContent
|
|||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.isReply
|
||||
import org.matrix.android.sdk.api.util.TextContent
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.session.content.ThumbnailExtractor
|
||||
import org.matrix.android.sdk.internal.session.permalinks.PermalinkFactory
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.room.send
|
|||
|
||||
import org.commonmark.parser.Parser
|
||||
import org.commonmark.renderer.html.HtmlRenderer
|
||||
import org.matrix.android.sdk.api.util.TextContent
|
||||
import org.matrix.android.sdk.internal.session.room.AdvancedCommonmarkParser
|
||||
import org.matrix.android.sdk.internal.session.room.SimpleCommonmarkParser
|
||||
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils
|
||||
|
|
|
@ -24,18 +24,9 @@ import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultCon
|
|||
import org.matrix.android.sdk.api.session.room.model.relation.ReplyToContent
|
||||
import org.matrix.android.sdk.api.util.ContentUtils.extractUsefulTextFromHtmlReply
|
||||
import org.matrix.android.sdk.api.util.ContentUtils.extractUsefulTextFromReply
|
||||
import org.matrix.android.sdk.api.util.TextContent
|
||||
|
||||
/**
|
||||
* Contains a text and eventually a formatted text
|
||||
*/
|
||||
data class TextContent(
|
||||
val text: String,
|
||||
val formattedText: String? = null
|
||||
) {
|
||||
fun takeFormatted() = formattedText ?: text
|
||||
}
|
||||
|
||||
fun TextContent.toMessageTextContent(msgType: String = MessageType.MSGTYPE_TEXT): MessageTextContent {
|
||||
internal fun TextContent.toMessageTextContent(msgType: String = MessageType.MSGTYPE_TEXT): MessageTextContent {
|
||||
return MessageTextContent(
|
||||
msgType = msgType,
|
||||
format = MessageFormat.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
|
||||
|
@ -49,7 +40,7 @@ fun TextContent.toMessageTextContent(msgType: String = MessageType.MSGTYPE_TEXT)
|
|||
* latestThreadEventId in order for the clients without threads enabled to render it appropriately
|
||||
* If latest event not found, we pass rootThreadEventId
|
||||
*/
|
||||
fun TextContent.toThreadTextContent(
|
||||
internal fun TextContent.toThreadTextContent(
|
||||
rootThreadEventId: String,
|
||||
latestThreadEventId: String,
|
||||
msgType: String = MessageType.MSGTYPE_TEXT): MessageTextContent {
|
||||
|
@ -68,7 +59,7 @@ fun TextContent.toThreadTextContent(
|
|||
)
|
||||
}
|
||||
|
||||
fun TextContent.removeInReplyFallbacks(): TextContent {
|
||||
internal fun TextContent.removeInReplyFallbacks(): TextContent {
|
||||
return copy(
|
||||
text = extractUsefulTextFromReply(this.text),
|
||||
formattedText = this.formattedText?.let { extractUsefulTextFromHtmlReply(it) }
|
|
@ -38,7 +38,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
|
|||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent
|
||||
import org.matrix.android.sdk.api.util.ContentUtils.extractUsefulTextFromReply
|
||||
import org.matrix.android.sdk.internal.session.room.send.TextContent
|
||||
import org.matrix.android.sdk.api.util.TextContent
|
||||
import java.util.Calendar
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
Loading…
Reference in a new issue