Reuse search result item viewmodels

This commit is contained in:
MM20
2023-04-21 13:37:00 +02:00
parent d1482ad112
commit df1aa8c119
29 changed files with 658 additions and 481 deletions
@@ -129,6 +129,11 @@ interface File : SavableSearchable {
val isDeletable: Boolean
get() = false
val canShare: Boolean
get() = false
fun share(context: Context) {}
suspend fun delete(context: Context) {}
}
@@ -335,4 +335,20 @@ data class LocalFile(
return metaData
}
}
override val canShare: Boolean
get() = !isDirectory
override fun share(context: Context) {
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val uri = FileProvider.getUriForFile(
context,
context.applicationContext.packageName + ".fileprovider",
java.io.File(path)
)
shareIntent.putExtra(Intent.EXTRA_STREAM, uri)
shareIntent.type = mimeType
context.startActivity(Intent.createChooser(shareIntent, null))
}
}