diff --git a/html-text/build.gradle b/html-text/build.gradle
index c258323..fccdf1d 100644
--- a/html-text/build.gradle
+++ b/html-text/build.gradle
@@ -8,7 +8,7 @@ apply from: '../buildCompose.gradle'
ext {
PUBLISH_GROUP_ID = 'de.charlex.compose'
- PUBLISH_VERSION = '1.3.0'
+ PUBLISH_VERSION = '1.3.1'
PUBLISH_ARTIFACT_ID = 'html-text'
}
diff --git a/html-text/src/main/java/de/charlex/compose/HtmlText.kt b/html-text/src/main/java/de/charlex/compose/HtmlText.kt
index fb701e4..422bac0 100644
--- a/html-text/src/main/java/de/charlex/compose/HtmlText.kt
+++ b/html-text/src/main/java/de/charlex/compose/HtmlText.kt
@@ -76,12 +76,13 @@ fun HtmlText(
) {
val context = LocalContext.current
val annotatedString = context.resources.getText(textId).toAnnotatedString(urlSpanStyle, colorMapping)
+ val clickable = annotatedString.getStringAnnotations(0, annotatedString.length-1).any { it.tag == "url" }
val uriHandler = LocalUriHandler.current
val layoutResult = remember { mutableStateOf(null) }
Text(
- modifier = modifier.pointerInput(Unit) {
+ modifier = modifier.then(if(clickable) Modifier.pointerInput(Unit) {
detectTapGestures(onTap = { pos ->
layoutResult.value?.let { layoutResult ->
val position = layoutResult.getOffsetForPosition(pos)
@@ -94,7 +95,7 @@ fun HtmlText(
}
}
})
- },
+ } else Modifier),
text = annotatedString,
color = color,
fontSize = fontSize,
@@ -164,11 +165,13 @@ fun HtmlText(
Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)
}.toAnnotatedString(urlSpanStyle, colorMapping)
+ val clickable = annotatedString.getStringAnnotations(0, annotatedString.length-1).any { it.tag == "url" }
+
val uriHandler = LocalUriHandler.current
val layoutResult = remember { mutableStateOf(null) }
Text(
- modifier = modifier.pointerInput(Unit) {
+ modifier = modifier.then(if(clickable) Modifier.pointerInput(Unit) {
detectTapGestures(onTap = { pos ->
layoutResult.value?.let { layoutResult ->
val position = layoutResult.getOffsetForPosition(pos)
@@ -181,7 +184,7 @@ fun HtmlText(
}
}
})
- },
+ } else Modifier),
text = annotatedString,
color = color,
fontSize = fontSize,