diff options
author | Allan Wang <me@allanwang.ca> | 2019-06-13 17:19:25 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-06-13 17:19:25 -0700 |
commit | 7ad2a898571db9c0db95caf09cda8632660ff6dd (patch) | |
tree | b956e8354030f9be7bbf48fcb8ea8c7acc685481 /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | 682227c17b46ff7957f9399b7f610d52f06c1428 (diff) | |
download | frost-7ad2a898571db9c0db95caf09cda8632660ff6dd.tar.gz frost-7ad2a898571db9c0db95caf09cda8632660ff6dd.tar.bz2 frost-7ad2a898571db9c0db95caf09cda8632660ff6dd.zip |
Resolve file uri ourself for ringtones, resolves #1423
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 12 |
1 files changed, 12 insertions, 0 deletions
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) |