Loading app/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ dependencies { implementation 'io.noties.markwon:core:4.6.2' implementation 'io.noties.markwon:image-picasso:4.6.2' implementation 'io.noties.markwon:image:4.6.2' implementation 'io.noties.markwon:linkify:4.6.2' implementation 'io.noties.markwon:ext-tables:4.6.2' implementation 'io.noties.markwon:ext-strikethrough:4.6.2' } app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt +8 −2 Original line number Diff line number Diff line Loading @@ -112,10 +112,16 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope: val context = itemView.context val unmatchedTags = unmatchedTags(splitTags(notification.tags)) val message = maybeAppendActionErrors(formatMessage(notification), notification) dateView.text = formatDateShort(notification.timestamp) messageView.text = maybeAppendActionErrors(maybeMarkdown(formatMessage(notification), notification), notification) messageView.autoLinkMask = if (notification.isMarkdown()) 0 else Linkify.WEB_URLS if (notification.isMarkdown()) { messageView.autoLinkMask = 0 markwon.setMarkdown(messageView, message.toString()) } else { messageView.autoLinkMask = Linkify.WEB_URLS messageView.text = message } messageView.movementMethod = BetterLinkMovementMethod.getInstance() messageView.setOnClickListener { // Click & Long-click listeners on the text as well, because "autoLink=web" makes them Loading app/src/main/java/io/heckel/ntfy/util/MarkwonFactory.kt +16 −8 Original line number Diff line number Diff line Loading @@ -3,18 +3,18 @@ package io.heckel.ntfy.util import android.content.Context import android.graphics.Color import android.graphics.Typeface import android.text.method.LinkMovementMethod import android.text.style.* import android.text.util.Linkify import androidx.core.content.ContextCompat import io.heckel.ntfy.R import io.noties.markwon.* import io.noties.markwon.core.CorePlugin import io.noties.markwon.core.CoreProps import io.noties.markwon.core.MarkwonTheme import io.noties.markwon.core.spans.LinkSpan import io.noties.markwon.ext.strikethrough.StrikethroughPlugin import io.noties.markwon.ext.tables.TableAwareMovementMethod import io.noties.markwon.ext.tables.TablePlugin import io.noties.markwon.ext.tables.TableTheme import io.noties.markwon.image.ImagesPlugin import io.noties.markwon.linkify.LinkifyPlugin import io.noties.markwon.movement.MovementMethodPlugin import me.saket.bettermovementmethod.BetterLinkMovementMethod import org.commonmark.ext.gfm.tables.TableCell Loading @@ -30,14 +30,22 @@ internal object MarkwonFactory { return Markwon.builder(context) .usePlugin(CorePlugin.create()) .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.getInstance())) // .usePlugin(PicassoImagesPlugin.create(picasso)) .usePlugin(ImagesPlugin.create()) .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)) .usePlugin(StrikethroughPlugin.create()) //.usePlugin(TablePlugin.create(context)) .usePlugin(object : AbstractMarkwonPlugin() { override fun configureTheme(builder: MarkwonTheme.Builder) { builder.linkColor(ContextCompat.getColor(context, R.color.teal)) builder .linkColor(ContextCompat.getColor(context, R.color.teal)) .isLinkUnderlined(true) .blockMargin(0) } override fun configureConfiguration(builder: MarkwonConfiguration.Builder) { builder .linkResolver(LinkResolverDef()) } override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) { builder .setFactory(Heading::class.java) { _, props: RenderProps? -> Loading @@ -52,7 +60,7 @@ internal object MarkwonFactory { .setFactory(Code::class.java) { _, _ -> arrayOf<Any>( BackgroundColorSpan(Color.LTGRAY), TypefaceSpan("monospace") //TypefaceSpan("monospace") ) } .setFactory(ListItem::class.java) { _, _ -> BulletSpan(bulletGapWidth) } Loading Loading
app/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ dependencies { implementation 'io.noties.markwon:core:4.6.2' implementation 'io.noties.markwon:image-picasso:4.6.2' implementation 'io.noties.markwon:image:4.6.2' implementation 'io.noties.markwon:linkify:4.6.2' implementation 'io.noties.markwon:ext-tables:4.6.2' implementation 'io.noties.markwon:ext-strikethrough:4.6.2' }
app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt +8 −2 Original line number Diff line number Diff line Loading @@ -112,10 +112,16 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope: val context = itemView.context val unmatchedTags = unmatchedTags(splitTags(notification.tags)) val message = maybeAppendActionErrors(formatMessage(notification), notification) dateView.text = formatDateShort(notification.timestamp) messageView.text = maybeAppendActionErrors(maybeMarkdown(formatMessage(notification), notification), notification) messageView.autoLinkMask = if (notification.isMarkdown()) 0 else Linkify.WEB_URLS if (notification.isMarkdown()) { messageView.autoLinkMask = 0 markwon.setMarkdown(messageView, message.toString()) } else { messageView.autoLinkMask = Linkify.WEB_URLS messageView.text = message } messageView.movementMethod = BetterLinkMovementMethod.getInstance() messageView.setOnClickListener { // Click & Long-click listeners on the text as well, because "autoLink=web" makes them Loading
app/src/main/java/io/heckel/ntfy/util/MarkwonFactory.kt +16 −8 Original line number Diff line number Diff line Loading @@ -3,18 +3,18 @@ package io.heckel.ntfy.util import android.content.Context import android.graphics.Color import android.graphics.Typeface import android.text.method.LinkMovementMethod import android.text.style.* import android.text.util.Linkify import androidx.core.content.ContextCompat import io.heckel.ntfy.R import io.noties.markwon.* import io.noties.markwon.core.CorePlugin import io.noties.markwon.core.CoreProps import io.noties.markwon.core.MarkwonTheme import io.noties.markwon.core.spans.LinkSpan import io.noties.markwon.ext.strikethrough.StrikethroughPlugin import io.noties.markwon.ext.tables.TableAwareMovementMethod import io.noties.markwon.ext.tables.TablePlugin import io.noties.markwon.ext.tables.TableTheme import io.noties.markwon.image.ImagesPlugin import io.noties.markwon.linkify.LinkifyPlugin import io.noties.markwon.movement.MovementMethodPlugin import me.saket.bettermovementmethod.BetterLinkMovementMethod import org.commonmark.ext.gfm.tables.TableCell Loading @@ -30,14 +30,22 @@ internal object MarkwonFactory { return Markwon.builder(context) .usePlugin(CorePlugin.create()) .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.getInstance())) // .usePlugin(PicassoImagesPlugin.create(picasso)) .usePlugin(ImagesPlugin.create()) .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)) .usePlugin(StrikethroughPlugin.create()) //.usePlugin(TablePlugin.create(context)) .usePlugin(object : AbstractMarkwonPlugin() { override fun configureTheme(builder: MarkwonTheme.Builder) { builder.linkColor(ContextCompat.getColor(context, R.color.teal)) builder .linkColor(ContextCompat.getColor(context, R.color.teal)) .isLinkUnderlined(true) .blockMargin(0) } override fun configureConfiguration(builder: MarkwonConfiguration.Builder) { builder .linkResolver(LinkResolverDef()) } override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) { builder .setFactory(Heading::class.java) { _, props: RenderProps? -> Loading @@ -52,7 +60,7 @@ internal object MarkwonFactory { .setFactory(Code::class.java) { _, _ -> arrayOf<Any>( BackgroundColorSpan(Color.LTGRAY), TypefaceSpan("monospace") //TypefaceSpan("monospace") ) } .setFactory(ListItem::class.java) { _, _ -> BulletSpan(bulletGapWidth) } Loading