Support content URIs in showSendFileScreen

This commit is contained in:
Alinson S. Xavier 2026-04-11 19:22:35 -05:00
parent 78770dd2d2
commit 4383b3ed03

View File

@ -28,6 +28,7 @@ import android.graphics.Color
import android.graphics.Paint
import android.graphics.PointF
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Handler
import android.os.SystemClock
import android.view.LayoutInflater
@ -118,8 +119,13 @@ fun Activity.showMessage(msg: String) {
}
fun Activity.showSendFileScreen(archiveFilename: String) {
val file = File(archiveFilename)
val fileUri = FileProvider.getUriForFile(this, "org.isoron.uhabits", file)
val uri = Uri.parse(archiveFilename)
val fileUri = if (uri.scheme == "content") {
uri
} else {
val file = if (uri.scheme == "file") File(uri.path!!) else File(archiveFilename)
FileProvider.getUriForFile(this, "org.isoron.uhabits", file)
}
this.startActivitySafely(
Intent().apply {
action = Intent.ACTION_SEND