Skip to content

[Android] Respect custom system-wide text selection toolbar buttons #139361

@bleroux

Description

@bleroux

Edit

This feature is implemented. It is directly available in newly created Flutter project since Flutter 3.19.
For older project, the following section should be added to the Android manifest file:

 <!--  Required to query activities that can process text, see:
       https://developer.android.com/training/package-visibility and
       https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

       In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin.  -->
<queries>
  <intent>
    <action android:name="android.intent.action.PROCESS_TEXT"/>
    <data android:mimeType="text/plain"/>
  </intent>
</queries>

Use case

On Android, it's possible to write an app that adds a custom button to the system-wide text selection toolbar. For example, here the Android app AnkiDroid has added the "Anki Card" button to my text selection toolbar, and it appears in any app, such as the Google app here.

Proposal

Flutter should respect these added buttons, so that in any Flutter app running on Android, the buttons that the user has added to their device show up in the default text selection toolbar just like in any native app.

This is the Android part of #107603 which is broad (all plaforms).
Creating this issue to make it easier to follow.

Implementation steps

# Status Description Related Work
1 Done Engine - Add Android support for querying and invoking text processing actions. flutter/engine#44579
2 Done Framework - Add ProcessTextService to intereact with the engine #137145
3 Done fluttter_tools - Add queries section to Android manifest file #137207
4 Done Framework - Add queried text processing actions to the text selection toolbar for EditableText #139738
5 Done Framework - Add queried text processing actions to the text selection toolbar for SelectionRegion #141103

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: fidelityMatching the OEM platforms bettera: text inputEntering text in a text field or keyboard related problemsc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions