about summary refs log tree commit diff
path: root/plugins
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-08-11 18:37:39 +0300
committerGitHub <noreply@github.com>2025-08-11 08:37:39 -0700
commitbb949e4f44c4ed1e19c7bddc5779515b419a7022 (patch)
tree9cb70c6573ee6c4224de38b625f91483e52a5983 /plugins
parent2a6172cbaf2db0eda2a7cd2afaeef4b60aadf3ba (diff)
downloadvoidsky-bb949e4f44c4ed1e19c7bddc5779515b419a7022.tar.zst
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/withAndroidManifestIntentQueriesPlugin.js30
-rw-r--r--plugins/withAndroidManifestLargeHeapPlugin.js (renamed from plugins/withAndroidManifestPlugin.js)0
2 files changed, 30 insertions, 0 deletions
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 <queries> 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
diff --git a/plugins/withAndroidManifestPlugin.js b/plugins/withAndroidManifestLargeHeapPlugin.js
index 55fd3f5ca..55fd3f5ca 100644
--- a/plugins/withAndroidManifestPlugin.js
+++ b/plugins/withAndroidManifestLargeHeapPlugin.js