mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
Merge pull request #4854 from nextcloud/issue-4815-markdown-table
🧮 Markdown Tables
This commit is contained in:
commit
7d1308b718
@ -291,6 +291,7 @@ dependencies {
|
||||
implementation "io.noties.markwon:core:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-tasklist:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-tables:$markwonVersion"
|
||||
|
||||
implementation 'com.github.nextcloud-deps:ImagePicker:2.1.0.2'
|
||||
implementation 'io.github.elye:loaderviewlibrary:3.0.0'
|
||||
|
@ -18,6 +18,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.toSpanned
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
@ -103,10 +104,33 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
val spansFromString: Array<Any> = processedMessageText!!.getSpans(
|
||||
0,
|
||||
processedMessageText.length,
|
||||
Any::class.java
|
||||
)
|
||||
|
||||
if (spansFromString.isNotEmpty()) {
|
||||
binding.bubble.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
binding.messageText.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
} else {
|
||||
binding.bubble.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.WRAP_CONTENT
|
||||
}
|
||||
binding.messageText.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.WRAP_CONTENT
|
||||
}
|
||||
}
|
||||
|
||||
processedMessageText = messageUtils.processMessageParameters(
|
||||
binding.messageText.context,
|
||||
viewThemeUtils,
|
||||
processedMessageText!!,
|
||||
processedMessageText,
|
||||
message,
|
||||
itemView
|
||||
)
|
||||
|
@ -116,10 +116,33 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
false,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
val spansFromString: Array<Any> = processedMessageText!!.getSpans(
|
||||
0,
|
||||
processedMessageText.length,
|
||||
Any::class.java
|
||||
)
|
||||
|
||||
if (spansFromString.isNotEmpty()) {
|
||||
binding.bubble.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
binding.messageText.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
} else {
|
||||
binding.bubble.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.WRAP_CONTENT
|
||||
}
|
||||
binding.messageText.layoutParams.apply {
|
||||
width = FlexboxLayout.LayoutParams.WRAP_CONTENT
|
||||
}
|
||||
}
|
||||
|
||||
processedMessageText = messageUtils.processMessageParameters(
|
||||
binding.messageText.context,
|
||||
viewThemeUtils,
|
||||
processedMessageText!!,
|
||||
processedMessageText,
|
||||
message,
|
||||
itemView
|
||||
)
|
||||
|
@ -230,6 +230,7 @@ import java.util.concurrent.ExecutionException
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class ChatActivity :
|
||||
BaseActivity(),
|
||||
@ -989,8 +990,10 @@ class ChatActivity :
|
||||
val newString = state.messageEdited.ocs?.data?.parentMessage?.message ?: "(null)"
|
||||
val id = state.messageEdited.ocs?.data?.parentMessage?.id.toString()
|
||||
val index = adapter?.getMessagePositionById(id) ?: 0
|
||||
val message = adapter?.items?.get(index)?.item as ChatMessage
|
||||
setMessageAsEdited(message, newString)
|
||||
val item = adapter?.items?.get(index)?.item
|
||||
item?.let {
|
||||
setMessageAsEdited(item as ChatMessage, newString)
|
||||
}
|
||||
}
|
||||
|
||||
is MessageInputViewModel.EditMessageErrorState -> {
|
||||
|
@ -25,6 +25,7 @@ import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.MarkwonConfiguration
|
||||
import io.noties.markwon.core.MarkwonTheme
|
||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin
|
||||
import io.noties.markwon.ext.tables.TablePlugin
|
||||
import io.noties.markwon.ext.tasklist.TaskListDrawable
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin
|
||||
|
||||
@ -195,6 +196,7 @@ class MessageUtils(val context: Context) {
|
||||
}
|
||||
})
|
||||
.usePlugin(TaskListPlugin.create(drawable))
|
||||
.usePlugin(TablePlugin.create { _ -> })
|
||||
.usePlugin(StrikethroughPlugin.create()).build()
|
||||
return markwon.toMarkdown(markdown)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user