Make File path property optional

This commit is contained in:
MM20 2024-07-26 17:33:20 +02:00
parent 330b9f673a
commit cdf824ac2e
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
5 changed files with 13 additions and 11 deletions

View File

@ -136,13 +136,15 @@ fun FileItem(
style = MaterialTheme.typography.bodySmall style = MaterialTheme.typography.bodySmall
) )
} }
Text( if (file.path != null) {
text = stringResource( Text(
R.string.file_meta_path, text = stringResource(
file.path R.string.file_meta_path,
), file.path!!
style = MaterialTheme.typography.bodySmall, ),
) style = MaterialTheme.typography.bodySmall,
)
}
if (!file.isDirectory) { if (!file.isDirectory) {
Text( Text(
text = stringResource( text = stringResource(

View File

@ -10,7 +10,7 @@ import kotlinx.collections.immutable.ImmutableMap
import java.util.Locale import java.util.Locale
interface File : SavableSearchable { interface File : SavableSearchable {
val path: String val path: String?
val mimeType: String val mimeType: String
val size: Long val size: Long
val isDirectory: Boolean val isDirectory: Boolean

View File

@ -26,7 +26,7 @@ import kotlinx.coroutines.withContext
data class PluginFile( data class PluginFile(
val id: String, val id: String,
override val path: String, override val path: String?,
override val mimeType: String, override val mimeType: String,
override val size: Long, override val size: Long,
override val metaData: ImmutableMap<FileMetaType, String>, override val metaData: ImmutableMap<FileMetaType, String>,

View File

@ -46,7 +46,7 @@ class PluginFileProvider(
results.add( results.add(
PluginFile( PluginFile(
id = cursor[FileColumns.Id] ?: continue, id = cursor[FileColumns.Id] ?: continue,
path = cursor[FileColumns.Path] ?: "", path = cursor[FileColumns.Path],
mimeType = cursor[FileColumns.MimeType] ?: "application/octet-stream", mimeType = cursor[FileColumns.MimeType] ?: "application/octet-stream",
size = cursor[FileColumns.Size] ?: 0L, size = cursor[FileColumns.Size] ?: 0L,
metaData = buildMap { metaData = buildMap {

View File

@ -76,7 +76,7 @@ data class File(
* A path to this file. This is shown to the user purely for informational purposes. * A path to this file. This is shown to the user purely for informational purposes.
* It is not used to open the file. * It is not used to open the file.
*/ */
val path: String, val path: String?,
/** /**
* Whether this file is a directory. If set, a folder icon will be shown instead of a file icon. * Whether this file is a directory. If set, a folder icon will be shown instead of a file icon.
*/ */