Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mobile): make chat text selectable on Android #8779

MergedSunkenInTime(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/8779/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHub

Showing 10 changed files with 125 additions and 5 deletions (loading 6).

x
0 of 10 viewed, 10 left
93 additions and 0 deletionsapps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.ktAdded
View file
@@ -0,0 +1,93 @@
+package expo.modules.t3markdowntext
+​
+import android.content.ClipData
+import android.content.ClipboardManager
+import android.content.Context
+import android.text.Spanned
+import android.text.style.ReplacementSpan
+import android.view.ActionMode
+import android.view.Menu
+import android.view.MenuItem
+import android.widget.TextView
+import com.facebook.react.bridge.ReactContext
+import com.facebook.react.uimanager.UIManagerHelper
+import expo.modules.kotlin.modules.Module
+import expo.modules.kotlin.modules.ModuleDefinition
+import kotlin.math.max
+import kotlin.math.min
+​
+private const val OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"
+​
+private fun copyTextWithoutInlineImages(
+ text: CharSequence,
+ start: Int,
+ end: Int
+): String {
+ if (text !is Spanned) return text.subSequence(start, end).toString()
+​
+ return buildString {
+ for (index in start until end) {
+ val isInlineImage =