Tables work

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2025-04-08 15:21:05 -05:00 committed by Marcel Hibbe
parent 39b7931534
commit 62d9a47c37
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 57 additions and 4 deletions

View File

@ -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'

View File

@ -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
)

View File

@ -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
)

View File

@ -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 -> {

View File

@ -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)
}