From bda31b2c6d62652c742e800b692dffd926f8284b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 14 Nov 2023 10:57:18 +0800 Subject: [PATCH] Properly merge EXTRA_EMAIL content with mailto URIs * java/org/gnu/emacs/EmacsOpenActivity.java (onCreate): EXTRA_EMAIL is an array rather than a string, so insert its first element into an empty mailto URI. --- java/org/gnu/emacs/EmacsOpenActivity.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/java/org/gnu/emacs/EmacsOpenActivity.java b/java/org/gnu/emacs/EmacsOpenActivity.java index a5e8be2f238..5cca6cfcdff 100644 --- a/java/org/gnu/emacs/EmacsOpenActivity.java +++ b/java/org/gnu/emacs/EmacsOpenActivity.java @@ -414,6 +414,7 @@ public final class EmacsOpenActivity extends Activity String subjectString, textString, attachmentString; CharSequence tem; String tem1; + String[] emails; StringBuilder builder; List list; @@ -466,16 +467,16 @@ public final class EmacsOpenActivity extends Activity /* If fileName is merely mailto: (absent either an email address or content), then the program launching Emacs conceivably provided such an URI to exclude non-email - programs from being enumerated within the Share dialog; - whereupon Emacs should replace it with any address - provided as EXTRA_EMAIL. */ + programs from the Share dialog. Intents created thus + might hold the recipient email as a string array, which + is non-standard behavior. */ if (fileName.equals ("mailto:") || fileName.equals ("mailto://")) { - tem = intent.getCharSequenceExtra (Intent.EXTRA_EMAIL); + emails = intent.getStringArrayExtra (Intent.EXTRA_EMAIL); - if (tem != null) - fileName = "mailto:" + tem; + if (emails[0] != null && emails.length > 0) + fileName = "mailto:" + emails[0]; } /* Subsequently, escape fileName such that it is rendered -- 2.39.2