From bb949e4f44c4ed1e19c7bddc5779515b419a7022 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 11 Aug 2025 18:37:39 +0300 Subject: Fix translations on Android using PROCESS_TEXT intent (#8486) * use intents to translate text on android * clean up config plugins * restore day night plugin just to be safe * leave a comment for why we can't open translate directly * add todo * fix lockfile lint --- plugins/withAndroidManifestIntentQueriesPlugin.js | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 plugins/withAndroidManifestIntentQueriesPlugin.js (limited to 'plugins/withAndroidManifestIntentQueriesPlugin.js') diff --git a/plugins/withAndroidManifestIntentQueriesPlugin.js b/plugins/withAndroidManifestIntentQueriesPlugin.js new file mode 100644 index 000000000..04237b059 --- /dev/null +++ b/plugins/withAndroidManifestIntentQueriesPlugin.js @@ -0,0 +1,30 @@ +const {withAndroidManifest} = require('@expo/config-plugins') + +const withProcessTextQuery = config => + // eslint-disable-next-line no-shadow + withAndroidManifest(config, config => { + const manifest = config.modResults.manifest + + // Ensure stub exists + if (!manifest.queries) manifest.queries = [{}] + const queries = manifest.queries[0] + + queries.intent = queries.intent || [] + + const exists = queries.intent.some( + i => + i.action?.[0]?.$?.['android:name'] === + 'android.intent.action.PROCESS_TEXT', + ) + + if (!exists) { + queries.intent.push({ + action: [{$: {'android:name': 'android.intent.action.PROCESS_TEXT'}}], + data: [{$: {'android:mimeType': 'text/plain'}}], + }) + } + + return config + }) + +module.exports = withProcessTextQuery -- cgit 1.4.1