File search: improve handling of launcher theme and launcher backup file types
This commit is contained in:
@@ -51,7 +51,7 @@ class LocalFileDeserializer(
|
||||
if (!java.io.File(path).exists()) return null
|
||||
val directory = java.io.File(path).isDirectory
|
||||
val id = cursor.getLong(0)
|
||||
val mimeType = cursor.getStringOrNull(3)
|
||||
val mimeType = cursor.getStringOrNull(3).takeIf { it != "application/octet-stream" }
|
||||
?: if (directory) "resource/folder" else LocalFile.getMimetypeByFileExtension(
|
||||
path.substringAfterLast(
|
||||
'.'
|
||||
|
||||
@@ -44,7 +44,7 @@ internal class LocalFileProvider(
|
||||
val path = cursor.getString(3)
|
||||
if (!java.io.File(path).exists()) continue
|
||||
val directory = java.io.File(path).isDirectory
|
||||
val mimeType = (cursor.getStringOrNull(4)
|
||||
val mimeType = (cursor.getStringOrNull(4).takeIf { it != "application/octet-stream" }
|
||||
?: if (directory) "resource/folder" else LocalFile.getMimetypeByFileExtension(
|
||||
path.substringAfterLast(
|
||||
'.'
|
||||
|
||||
@@ -49,6 +49,8 @@ interface File : SavableSearchable {
|
||||
"application/vnd.android.package-archive" -> R.drawable.ic_file_android to R.color.lightgreen
|
||||
"application/vnd.google-apps.form" -> R.drawable.ic_file_form to R.color.deeppurple
|
||||
"application/vnd.google-apps.drawing" -> R.drawable.ic_file_picture to R.color.teal
|
||||
"application/vnd.de.mm20.launcher2.backup" -> R.drawable.ic_file_backup to R.color.brown
|
||||
"application/vnd.de.mm20.launcher2.theme" -> R.drawable.ic_file_theme to R.color.amber
|
||||
else -> R.drawable.ic_file_generic to R.color.bluegrey
|
||||
}
|
||||
}
|
||||
@@ -64,12 +66,18 @@ interface File : SavableSearchable {
|
||||
|
||||
fun getFileType(context: Context): String {
|
||||
if (isDirectory) return context.getString(R.string.file_type_directory)
|
||||
if (mimeType == "application/vendor.de.mm20.launcher2.backup") {
|
||||
if (mimeType == "application/vnd.de.mm20.launcher2.backup") {
|
||||
return context.getString(
|
||||
R.string.file_type_launcherbackup,
|
||||
context.getString(R.string.app_name)
|
||||
)
|
||||
}
|
||||
if (mimeType == "application/vnd.de.mm20.launcher2.theme") {
|
||||
return context.getString(
|
||||
R.string.file_type_launchertheme,
|
||||
context.getString(R.string.app_name)
|
||||
)
|
||||
}
|
||||
val resource = when (mimeType) {
|
||||
"application/zip",
|
||||
"application/x-zip-compressed",
|
||||
@@ -118,10 +126,6 @@ interface File : SavableSearchable {
|
||||
}
|
||||
if (resource == R.string.file_type_none && label.matches(Regex(".+\\..+"))) {
|
||||
val extension = label.substringAfterLast(".").uppercase(Locale.getDefault())
|
||||
if (extension == "kvaesitso") return context.getString(
|
||||
R.string.file_type_launcherbackup,
|
||||
context.getString(R.string.app_name)
|
||||
)
|
||||
return context.getString(R.string.file_type_generic, extension)
|
||||
}
|
||||
return context.getString(resource)
|
||||
|
||||
@@ -223,7 +223,8 @@ data class LocalFile(
|
||||
"ogg" -> "audio/ogg"
|
||||
"wav" -> "audio/wav"
|
||||
"mp4" -> "video/mp4"
|
||||
"kvaesitso" -> "application/vendor.de.mm20.launcher2.backup"
|
||||
"kvaesitso" -> "application/vnd.de.mm20.launcher2.backup"
|
||||
"kvtheme" -> "application/vnd.de.mm20.launcher2.theme"
|
||||
else -> "application/octet-stream"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user