From 7ad2a898571db9c0db95caf09cda8632660ff6dd Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 13 Jun 2019 17:19:25 -0700 Subject: Resolve file uri ourself for ringtones, resolves #1423 --- app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 00e9a1b9..8ad0d432 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -347,6 +347,18 @@ fun Context.frostUriFromFile(file: File): Uri = file ) +/** + * Gets uri from our own resolver if it's a file, or return the parsed uri otherwise + */ +fun Context.frostUri(entry: String): Uri { + val uri = Uri.parse(entry) + val path = uri.path + if (uri.scheme == "file" && path != null) { + return frostUriFromFile(File(path)) + } + return uri +} + inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) = sendFrostEmail(string(subjectId), builder) -- cgit v1.2.3