GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): Android chip taps open the chip from either half (#33126) · adampeterhiggins/t3code@61629df

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor
    • T3ComposerEditorView.kt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt‎

Copy file name to clipboardExpand all lines: apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt
+21-2Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
134134
val token =
135135
tokens.firstOrNull {
136136
(it.type == "context" || it.type == "mention" || it.type == "skill") &&
137-
offset >= it.start &&
138-
offset < it.end
137+
offset in it.start..it.end &&
138+
it.end <= editor.length() &&
139+
chipContains(it, event.x, event.y)
139140
}
140141
?: return false
141142
if (token.end <= editor.length() &&
@@ -453,6 +454,24 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
453454
)
454455
}
455456

457+
// A chip is one replacement span, so a tap on its right half reports the offset at its end,
458+
// and a tap below the last line clamps to it; only the chip's drawn bounds count.
459+
private fun chipContains(token: ComposerToken, viewX: Float, viewY: Float): Boolean {
460+
val layout = editor.layout ?: return false
461+
val x = viewX - editor.totalPaddingLeft + editor.scrollX
462+
val y = viewY - editor.totalPaddingTop + editor.scrollY
463+
val line = layout.getLineForOffset(token.start)
464+
val left = layout.getPrimaryHorizontal(token.start)
465+
val right =
466+
if (layout.getLineForOffset(token.end) == line) {
467+
layout.getPrimaryHorizontal(token.end)
468+
} else {
469+
layout.getLineRight(line)
470+
}
471+
return y >= layout.getLineTop(line) && y <= layout.getLineBottom(line) &&
472+
x >= minOf(left, right) && x <= maxOf(left, right)
473+
}
474+
456475
private fun applyTokenSpans() {
457476
val editable = editor.text ?: return
458477
editable.getSpans(

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.