fix: use package name in core's FileExtensions

This commit is contained in:
jmir1 2023-06-06 16:03:35 +02:00
parent a17aa902bf
commit c2a89dfdd5
2 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,19 @@
package eu.kanade.tachiyomi.util.storage
import android.content.Context
import android.net.Uri
import android.os.Build
import com.arthenica.ffmpegkit.FFmpegKitConfig
import java.io.File
fun String.toFFmpegString(context: Context): String {
return File(this).getUriCompat(context).toFFmpegString(context)
}
fun Uri.toFFmpegString(context: Context): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && this.scheme == "content") {
FFmpegKitConfig.getSafParameter(context, this, "rw")
} else {
this.path!!
}.replace("\"", "\\\"")
}

View file

@ -0,0 +1,24 @@
package eu.kanade.tachiyomi.util.storage
import android.content.Context
import android.net.Uri
import android.os.Build
import androidx.core.content.FileProvider
import androidx.core.net.toUri
import java.io.File
val Context.cacheImageDir: File
get() = File(cacheDir, "shared_image")
/**
* Returns the uri of a file
*
* @param context context of application
*/
fun File.getUriCompat(context: Context): Uri {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
FileProvider.getUriForFile(context, context.packageName + ".provider", this)
} else {
this.toUri()
}
}