Loading legacy/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java +9 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package com.fsck.k9.activity; import java.io.File; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; Loading Loading @@ -401,10 +402,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, messageContentView.setText(CrLfConverter.toLf(intentData.getExtraText())); } if (intentData.getExtraStream() != null) { attachmentPresenter.addExternalAttachment(intentData.getExtraStream(), intentData.getIntentType()); List<Uri> uriList = intentData.getExtraStream(); String intentType = intentData.getIntentType(); if (intentType != null) { for (Uri uri : uriList) { attachmentPresenter.addExternalAttachment(uri, intentType); } } if (intentData.getSubject() != null && subjectView.getText().length() == 0) { subjectView.setText(intentData.getSubject()); } Loading legacy/ui/legacy/src/main/java/com/fsck/k9/ui/compose/IntentDataMapper.kt +28 −28 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import org.openintents.openpgp.util.OpenPgpApi @Suppress("NestedBlockDepth", "MaxLineLength") class IntentDataMapper { @Suppress("CyclomaticComplexMethod") fun initFromIntent(intent: Intent): IntentData { val action: String? = intent.action var intentData = IntentData() Loading @@ -25,45 +26,44 @@ class IntentDataMapper { } } if (( if ( Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action || Intent.ACTION_SENDTO == action || Intent.ACTION_VIEW == action ) ) { intentData = intentData.copy( startedByExternalIntent = true, extraText = intent.getCharSequenceExtra(Intent.EXTRA_TEXT), intentType = intent.type, subject = intent.getStringExtra(Intent.EXTRA_SUBJECT), shouldInitFromSendOrViewIntent = true, ) if ((Intent.ACTION_SEND == action)) { val extraStream = IntentCompat.getParcelableExtra( val extraStreams = when (action) { Intent.ACTION_SEND -> { IntentCompat.getParcelableExtra( intent, Intent.EXTRA_STREAM, Uri::class.java, ) intentData = intentData.copy(extraStream = extraStream) } else { val list: List<Parcelable>? = IntentCompat.getParcelableArrayListExtra( )?.let { listOf(it) } ?: emptyList() } Intent.ACTION_SEND_MULTIPLE -> { IntentCompat.getParcelableArrayListExtra<Parcelable>( intent, Intent.EXTRA_STREAM, Parcelable::class.java, ) list?.let { for (parcelable in it) { intentData = intentData.copy(extraStream = parcelable as Uri) } )?.filterIsInstance<Uri>() ?: emptyList() } else -> emptyList() } intentData = intentData.copy( subject = intent.getStringExtra(Intent.EXTRA_SUBJECT), shouldInitFromSendOrViewIntent = true, ) intentData = intentData.copy(extraStream = extraStreams) } if ((MessageCompose.ACTION_AUTOCRYPT_PEER == action)) { if (MessageCompose.ACTION_AUTOCRYPT_PEER == action) { intentData = intentData.copy( trustId = intent.getStringExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID), startedByExternalIntent = true, Loading @@ -79,7 +79,7 @@ data class IntentData( val mailToUri: Uri? = null, val extraText: CharSequence? = null, val intentType: String? = null, val extraStream: Uri? = null, val extraStream: List<Uri> = emptyList(), val subject: String? = null, val trustId: String? = null, ) Loading
legacy/ui/legacy/src/main/java/com/fsck/k9/activity/MessageCompose.java +9 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package com.fsck.k9.activity; import java.io.File; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; Loading Loading @@ -401,10 +402,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, messageContentView.setText(CrLfConverter.toLf(intentData.getExtraText())); } if (intentData.getExtraStream() != null) { attachmentPresenter.addExternalAttachment(intentData.getExtraStream(), intentData.getIntentType()); List<Uri> uriList = intentData.getExtraStream(); String intentType = intentData.getIntentType(); if (intentType != null) { for (Uri uri : uriList) { attachmentPresenter.addExternalAttachment(uri, intentType); } } if (intentData.getSubject() != null && subjectView.getText().length() == 0) { subjectView.setText(intentData.getSubject()); } Loading
legacy/ui/legacy/src/main/java/com/fsck/k9/ui/compose/IntentDataMapper.kt +28 −28 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import org.openintents.openpgp.util.OpenPgpApi @Suppress("NestedBlockDepth", "MaxLineLength") class IntentDataMapper { @Suppress("CyclomaticComplexMethod") fun initFromIntent(intent: Intent): IntentData { val action: String? = intent.action var intentData = IntentData() Loading @@ -25,45 +26,44 @@ class IntentDataMapper { } } if (( if ( Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action || Intent.ACTION_SENDTO == action || Intent.ACTION_VIEW == action ) ) { intentData = intentData.copy( startedByExternalIntent = true, extraText = intent.getCharSequenceExtra(Intent.EXTRA_TEXT), intentType = intent.type, subject = intent.getStringExtra(Intent.EXTRA_SUBJECT), shouldInitFromSendOrViewIntent = true, ) if ((Intent.ACTION_SEND == action)) { val extraStream = IntentCompat.getParcelableExtra( val extraStreams = when (action) { Intent.ACTION_SEND -> { IntentCompat.getParcelableExtra( intent, Intent.EXTRA_STREAM, Uri::class.java, ) intentData = intentData.copy(extraStream = extraStream) } else { val list: List<Parcelable>? = IntentCompat.getParcelableArrayListExtra( )?.let { listOf(it) } ?: emptyList() } Intent.ACTION_SEND_MULTIPLE -> { IntentCompat.getParcelableArrayListExtra<Parcelable>( intent, Intent.EXTRA_STREAM, Parcelable::class.java, ) list?.let { for (parcelable in it) { intentData = intentData.copy(extraStream = parcelable as Uri) } )?.filterIsInstance<Uri>() ?: emptyList() } else -> emptyList() } intentData = intentData.copy( subject = intent.getStringExtra(Intent.EXTRA_SUBJECT), shouldInitFromSendOrViewIntent = true, ) intentData = intentData.copy(extraStream = extraStreams) } if ((MessageCompose.ACTION_AUTOCRYPT_PEER == action)) { if (MessageCompose.ACTION_AUTOCRYPT_PEER == action) { intentData = intentData.copy( trustId = intent.getStringExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID), startedByExternalIntent = true, Loading @@ -79,7 +79,7 @@ data class IntentData( val mailToUri: Uri? = null, val extraText: CharSequence? = null, val intentType: String? = null, val extraStream: Uri? = null, val extraStream: List<Uri> = emptyList(), val subject: String? = null, val trustId: String? = null, )