From 766dc1f90712e075c628ceceb450d16ce8fecf10 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Wed, 28 Aug 2024 17:46:39 +0200 Subject: [PATCH] fix: Render hashtags, mentions, and initial paras correctly in RTL (#906) Previous code didn't set the textDirection for the status content, so the first para of RTL text might be rendered incorrectly. In addition, mentions and tags weren't BIDI wrapped, so would appear as "foo@" and "foo#" in RTL statuses, instead of "@foo" and "#foo". Fix both of these issues. Fixes #870 --- app/src/main/res/layout/item_conversation.xml | 3 ++- app/src/main/res/layout/item_status.xml | 3 ++- app/src/main/res/layout/item_status_detailed.xml | 3 ++- core/ui/src/main/kotlin/app/pachli/core/ui/LinkHelper.kt | 8 +++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/item_conversation.xml b/app/src/main/res/layout/item_conversation.xml index 862b71175..13d754220 100644 --- a/app/src/main/res/layout/item_conversation.xml +++ b/app/src/main/res/layout/item_conversation.xml @@ -9,7 +9,8 @@ android:clipChildren="false" android:clipToPadding="false" android:paddingStart="12dp" - android:paddingEnd="14dp"> + android:paddingEnd="14dp" + android:textDirection="anyRtl"> + android:focusable="true" + android:textDirection="anyRtl"> + android:clipToPadding="false" + android:textDirection="anyRtl"> getCustomSpanForTag(text, tags, span, listener) @@ -153,7 +158,8 @@ fun setClickableText( } removeSpan(span) - setSpan(customSpan, start, end, flags) + replace(start, end, wrappedText) + setSpan(customSpan, start, end + 1, flags) } @VisibleForTesting