diff --git a/app-android/app/src/main/java/de/tutao/tutanota/MainActivity.kt b/app-android/app/src/main/java/de/tutao/tutanota/MainActivity.kt index d0148cdaf192..0628f2141942 100644 --- a/app-android/app/src/main/java/de/tutao/tutanota/MainActivity.kt +++ b/app-android/app/src/main/java/de/tutao/tutanota/MainActivity.kt @@ -8,6 +8,7 @@ import android.content.pm.PackageManager import android.graphics.Color import android.graphics.Rect import android.net.MailTo +import android.net.ParseException import android.net.Uri import android.os.Bundle import android.os.PowerManager @@ -573,11 +574,16 @@ class MainActivity : FragmentActivity() { } else { files = listOf() } - val mailToUrlString: String = if (intent.data != null && MailTo.isMailTo(intent.dataString)) { - intent.dataString ?: "" - } else { - "" + + val mailTo = try { + MailTo.parse(intent.dataString.orEmpty()) + } catch (e: ParseException) { + Log.w(TAG, e) + null } + + val mailToUrlString: String = if (mailTo != null && !mailTo.isEmpty) intent.dataString.orEmpty() else "" + try { commonNativeFacade.createMailEditor( files, diff --git a/app-android/app/src/main/java/de/tutao/tutanota/Utils.kt b/app-android/app/src/main/java/de/tutao/tutanota/Utils.kt index 7c808c8fe87b..45d14d5d81a8 100644 --- a/app-android/app/src/main/java/de/tutao/tutanota/Utils.kt +++ b/app-android/app/src/main/java/de/tutao/tutanota/Utils.kt @@ -4,6 +4,7 @@ package de.tutao.tutanota import android.content.Context import android.content.res.Resources +import android.net.MailTo import android.net.Uri import android.os.Build import android.provider.OpenableColumns @@ -145,3 +146,6 @@ fun HttpURLConnection.iterateDataAsLines(action: (line: String) -> Unit) = fun Int.toPx(): Int = (this * Resources.getSystem().displayMetrics.density).toInt() fun Int.toDp(): Int = (this / Resources.getSystem().displayMetrics.density).toInt() + +val MailTo.isEmpty: Boolean + get() = headers?.all { entry -> entry.value.isNullOrEmpty() } ?: true