This commit is contained in:
kunfei
2023-01-25 17:54:19 +08:00
parent 6d3048c0f5
commit 4d8e005964
4 changed files with 33 additions and 5 deletions
@@ -0,0 +1,28 @@
package io.legado.app.help
import android.net.Uri
import androidx.annotation.Keep
import java.io.File
@Keep
object IntentType {
fun from(uri: Uri): String? {
return from(uri.toString())
}
fun from(file: File): String? {
return from(file.absolutePath)
}
fun from(path: String?): String? {
return when (path?.substringAfterLast(".")?.lowercase()) {
"m4a", "mp3", "mid", "xmf", "ogg", "wav" -> "video/*"
"3gp", "mp4" -> "audio/*"
"jpg", "gif", "png", "jpeg", "bmp" -> "image/*"
"txt", "json" -> "text/plain"
else -> null
}
}
}