Merge pull request #1914 from Hafizzle/Fiz/handle-external-application-linkclick

Attempt to open webpage or application versus query for external packages
This commit is contained in:
Phillip Thelen 2023-01-27 13:05:52 +01:00 committed by GitHub
commit 71665a000f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -139,7 +139,6 @@ abstract class ChecklistedViewHolder(
val parsedText = MarkdownParser.parseMarkdown(item.text ?: "")
withContext(Dispatchers.Main) {
textView?.setParsedMarkdown(parsedText)
textView?.movementMethod = LinkMovementMethod.getInstance()
}
}
}

View file

@ -1,5 +1,6 @@
package com.habitrpg.common.habitica.helpers
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.graphics.Rect
@ -170,7 +171,9 @@ private fun handleUrlClicks(context: Context, url: String) {
}
}
val intent = Intent(Intent.ACTION_VIEW, webpage)
if (intent.resolveActivity(context.packageManager) != null) {
try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
// No application can handle the link
}
}