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
main
lenchan139 6 years ago committed by Konrad Pozniak
parent e67127f39d
commit 491af07b68
  1. 14
      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());
}
}
}

Loading…
Cancel
Save