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:
parent
63952813c8
commit
5876fbeb29
1 changed files with 12 additions and 2 deletions
|
@ -617,13 +617,23 @@ public final class ComposeActivity
|
||||||
} else if (type.equals("text/plain")) {
|
} else if (type.equals("text/plain")) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action != null && action.equals(Intent.ACTION_SEND)) {
|
if (action != null && action.equals(Intent.ACTION_SEND)) {
|
||||||
|
String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
||||||
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
|
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 start = Math.max(textEditor.getSelectionStart(), 0);
|
||||||
int end = Math.max(textEditor.getSelectionEnd(), 0);
|
int end = Math.max(textEditor.getSelectionEnd(), 0);
|
||||||
int left = Math.min(start, end);
|
int left = Math.min(start, end);
|
||||||
int right = Math.max(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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue