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
This commit is contained in:
lenchan139 2019-02-06 03:12:37 +08:00 committed by Konrad Pozniak
parent 63952813c8
commit 5876fbeb29
1 changed files with 12 additions and 2 deletions

View File

@ -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());
}
}
}