From 491af07b68da75e72df417a2238b92ade6ec43d9 Mon Sep 17 00:00:00 2001 From: lenchan139 Date: Wed, 6 Feb 2019 03:12:37 +0800 Subject: [PATCH] Attach subject when composing with shared content from other apps (#1020) * +attach subject when composing with shared content from other apps * Update strings.xml * Update preferences.xml * Update strings.xml * remove option for add subject of shared to composeActivity * Update preferences.xml --- .../com/keylesspalace/tusky/ComposeActivity.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 3b7c00d9..8fb3cff6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -617,13 +617,23 @@ public final class ComposeActivity } else if (type.equals("text/plain")) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_SEND)) { + String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); String text = intent.getStringExtra(Intent.EXTRA_TEXT); - if (text != null) { + String shareBody = null; + if(subject != null && text != null){ + shareBody = String.format("%s\n%s", subject, text); + }else if(text != null){ + shareBody = text; + }else if(subject != null){ + shareBody = subject; + } + + if (shareBody != null) { int start = Math.max(textEditor.getSelectionStart(), 0); int end = Math.max(textEditor.getSelectionEnd(), 0); int left = Math.min(start, end); int right = Math.max(start, end); - textEditor.getText().replace(left, right, text, 0, text.length()); + textEditor.getText().replace(left, right, shareBody, 0, shareBody.length()); } } }