Repository navigation
Allow copying every monospace text in a message with screen readers - #2062
Open
mehranlatifi83 wants to merge 1 commit into
Open
mehranlatifi83 wants to merge 1 commit into
mehranlatifi83 wants to merge 1 commit into
Conversation
mehranlatifi83
force-pushed
the
fix/talkback-mono-text-not-copyable
branch
from
September 18, 2026 09:50
45fd8d5 to
3e8efcd
Compare
mehranlatifi83
force-pushed
the
fix/talkback-mono-text-not-copyable
branch
from
September 27, 2026 10:45
3e8efcd to
2f8c5a1
Compare
A run of monospace text is copied by holding a press on it, and a block of code long enough to be given a copy button is copied by pressing that. A message can carry any number of both, in its text and in its caption. What a screen reader had was a single action called "Copy code", which copied whichever block of code came first in the text of the message. Every other block, every run of monospace text, and everything in a caption could not be copied at all, and the one action that did work did not say what it would copy. Give each of them an action of its own and put what it would copy in the name of the action, so which is which is known without pressing one and looking at the clipboard afterwards. They come after everything else the message offers. Copying goes through the very paths a press takes, so the same thing is put on the clipboard and the same word is said back about it. Where copying is not allowed nothing is offered, which is what the screen does: the button under a block of code is not drawn, and a press held on a run of monospace text quietly does nothing. The ids of the actions are taken from a fixed list of resource ids. Ids handed out for views are small numbers, and TalkBack lists a custom action only when its id is above 0x01FFFFFF, so actions with such ids were never shown. A block of code too short to get a copy button is offered as well, and so are the code and the monospace runs of a message laid out in blocks, which a tap copies.
mehranlatifi83
force-pushed
the
fix/talkback-mono-text-not-copyable
branch
2 times, most recently
from
October 1, 2026 23:01
72d527f to
417e410
Compare
mehranlatifi83
force-pushed
the
fix/talkback-mono-text-not-copyable
branch
from
October 3, 2026 17:51
417e410 to
bf1d752
Compare
mehranlatifi83
force-pushed
the
fix/talkback-mono-text-not-copyable
branch
from
October 13, 2026 11:39
bf1d752 to
23c858a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Monospace text is copied by long pressing it, and long code blocks have a copy button. A message can contain many of both, in its text and caption.
TalkBack only had one "Copy code" action, which copied the first code block in the message text and did not say what it would copy. Other code blocks, monospace text, and anything in a caption could not be copied.
Fix
In
ChatMessageCell, add a separate copy action for each code block and each monospace run, with the text to be copied in the action label. They are listed after the message's other actions, and use the same code paths as the long press and the copy button. Nothing is offered where copying is not allowed (as on screen).Action ids come from a fixed list of resource ids (
R.id.acc_action_...). TalkBack only lists a custom action when its id is above0x01FFFFFF(AccessibilityNodeInfoUtils.isCustomAction), so ids fromView.generateViewId()would never be shown. Short code blocks without a copy button, and code blocks and monospace runs in rich messages (RichMessageLayout.getAccessibilityCopyableTexts), are offered too.Testing
With TalkBack on, send a message with two code blocks and some monospace text, and open its actions.
Before: one "Copy code" action for the first block only. After: one action per block and run, each naming what it copies.