Merge pull request #1729 from Hafizzle/Fixes#1674

Enable external links
This commit is contained in:
Phillip Thelen 2022-03-28 18:12:59 +02:00 committed by GitHub
commit cfeecd1450
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 3 deletions

View file

@ -62,6 +62,8 @@ dependencies {
implementation "io.noties.markwon:ext-strikethrough:4.6.2"
implementation "io.noties.markwon:image:4.6.2"
implementation "io.noties.markwon:recycler:4.6.2"
implementation "io.noties.markwon:linkify:4.6.2"
// IAP Handling / Verification
implementation "com.android.billingclient:billing-ktx:4.0.0"

View file

@ -3,6 +3,7 @@ package com.habitrpg.android.habitica.ui.activities
import android.content.Context
import android.graphics.Typeface
import android.os.Bundle
import android.text.method.LinkMovementMethod
import android.view.*
import android.widget.*
import androidx.core.content.ContextCompat
@ -213,6 +214,7 @@ class FullProfileActivity : BaseActivity() {
val blurbText = profile.blurb
if (blurbText != null && blurbText.isNotEmpty()) {
binding.blurbTextView.setMarkdown(blurbText)
binding.blurbTextView.movementMethod = LinkMovementMethod.getInstance()
}
user.authentication?.timestamps?.createdAt?.let { binding.joinedView.text = dateFormatter.format(it) }

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.ui.adapter.social
import android.text.method.LinkMovementMethod
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
@ -91,6 +92,7 @@ class ChallengesListViewAdapter(private val viewUserChallengesOnly: Boolean, pri
binding.challengeName.text = EmojiParser.parseEmojis(challenge.name?.trim { it <= ' ' })
binding.challengeShorttext.text = challenge.summary
binding.challengeShorttext.movementMethod = LinkMovementMethod.getInstance()
binding.officialChallengeView.visibility = if (challenge.official) View.VISIBLE else View.GONE

View file

@ -69,6 +69,7 @@ class GuildDetailFragment : BaseFragment<FragmentGuildDetailBinding>() {
viewModel?.getIsMemberData()?.observe(viewLifecycleOwner, { updateMembership(it) })
binding?.guildDescription?.movementMethod = LinkMovementMethod.getInstance()
binding?.guildSummary?.movementMethod = LinkMovementMethod.getInstance()
binding?.guildBankIcon?.setImageBitmap(HabiticaIconsHelper.imageOfGem())
binding?.leaveButton?.setOnClickListener {
leaveGuild()

View file

@ -7,6 +7,7 @@ import android.net.Uri
import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.util.Linkify
import android.widget.TextView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.handleUrlClicks
@ -21,6 +22,7 @@ import io.noties.markwon.image.ImageSizeResolverDef
import io.noties.markwon.image.ImagesPlugin
import io.noties.markwon.image.file.FileSchemeHandler
import io.noties.markwon.image.network.OkHttpNetworkSchemeHandler
import io.noties.markwon.linkify.LinkifyPlugin
import io.noties.markwon.movement.MovementMethodPlugin
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Single
@ -42,6 +44,7 @@ object MarkdownParser {
)
.usePlugin(this.createImageSizeResolverScaleDpiPlugin(context))
.usePlugin(MovementMethodPlugin.create(LinkMovementMethod.getInstance()))
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
.build()
}

View file

@ -177,6 +177,7 @@ class ChatRecyclerMessageViewHolder(itemView: View, private var userId: String,
itemView.setPadding(16.dpToPx(context), itemView.paddingTop, itemView.paddingRight, itemView.paddingBottom)
}
binding.messageText.setParsedMarkdown(chatMessage?.parsedText)
if (msg.parsedText == null) {
binding.messageText.text = chatMessage?.text

View file

@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.ui.viewHolders.tasks
import android.content.Context
import android.text.TextUtils
import android.text.method.LinkMovementMethod
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
@ -88,9 +89,8 @@ abstract class BaseTaskViewHolder constructor(itemView: View, var scoreTaskFunc:
notesTextView?.setOnClickListener { onTouch(it, null) }
errorIconView?.setOnClickListener { errorButtonClicked?.run() }
// Re enable when we find a way to only react when a link is tapped.
// notesTextView.movementMethod = LinkMovementMethod.getInstance()
// titleTextView.movementMethod = LinkMovementMethod.getInstance()
notesTextView?.movementMethod = LinkMovementMethod.getInstance()
titleTextView.movementMethod = LinkMovementMethod.getInstance()
expandNotesButton?.setOnClickListener { expandTask() }
iconViewChallenge?.setOnClickListener {