don't create a CW when sharing text to Tusky (#1836)

main
Konrad Pozniak 5 years ago committed by Alibek Omarov
parent 092e629a7f
commit d3910e618b
  1. 33
      app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt

@ -256,25 +256,22 @@ class ComposeActivity : BaseActivity(),
for (uri in uriList) { for (uri in uriList) {
pickMedia(uri) pickMedia(uri)
} }
} else if (type == "text/plain") { } else if (type == "text/plain" && intent.action == Intent.ACTION_SEND) {
val action = intent.action
if (action != null && action == Intent.ACTION_SEND) {
val subject = intent.getStringExtra(Intent.EXTRA_SUBJECT)
val text = intent.getStringExtra(Intent.EXTRA_TEXT)
val shareBody = text ?: subject
if (shareBody != null) {
if (!subject.isNullOrBlank() && subject !in shareBody) {
composeContentWarningField.setText(subject)
viewModel.showContentWarning.value = true
}
val start = composeEditField.selectionStart.coerceAtLeast(0) val subject = intent.getStringExtra(Intent.EXTRA_SUBJECT)
val end = composeEditField.selectionEnd.coerceAtLeast(0) val text = intent.getStringExtra(Intent.EXTRA_TEXT).orEmpty()
val left = min(start, end) val shareBody = if (!subject.isNullOrBlank() && subject !in text) {
val right = max(start, end) subject + '\n' + text
composeEditField.text.replace(left, right, shareBody, 0, shareBody.length) } else {
} text
}
if (shareBody.isNotBlank()) {
val start = composeEditField.selectionStart.coerceAtLeast(0)
val end = composeEditField.selectionEnd.coerceAtLeast(0)
val left = min(start, end)
val right = max(start, end)
composeEditField.text.replace(left, right, shareBody, 0, shareBody.length)
} }
} }
} }

Loading…
Cancel
Save