From 8c4bea1aff87e8372f9a404f9d0db3309d389b35 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Thu, 21 Jan 2021 12:46:30 +0100 Subject: [PATCH] File extensions case insensitive --- app/build.gradle | 3 +-- .../main/java/sushi/hardcore/droidfs/ConstValues.kt | 13 +++++++++---- build.gradle | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7f6cd3c..e9eeaf9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -44,7 +44,7 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "androidx.core:core-ktx:1.3.2" implementation "androidx.appcompat:appcompat:1.2.0" implementation "androidx.constraintlayout:constraintlayout:2.0.4" @@ -63,5 +63,4 @@ dependencies { implementation "androidx.camera:camera-lifecycle:$camerax_version" implementation "androidx.camera:camera-view:1.0.0-alpha20" implementation "androidx.camera:camera-extensions:1.0.0-alpha20" - } diff --git a/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt b/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt index 9e8ba28..1696997 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt @@ -2,6 +2,7 @@ package sushi.hardcore.droidfs import android.net.Uri import java.io.File +import java.util.* class ConstValues { companion object { @@ -20,17 +21,21 @@ class ConstValues { Pair("text", listOf("txt", "json", "conf", "log", "xml", "java", "kt", "py", "pl", "rb", "go", "c", "h", "cpp", "hpp", "sh", "bat", "js", "html", "css", "php", "yml", "yaml", "ini", "md")) ) + private fun isExtensionType(extensionType: String, path: String): Boolean { + return fileExtensions[extensionType]?.contains(File(path).extension.toLowerCase(Locale.ROOT)) ?: false + } + fun isImage(path: String): Boolean { - return fileExtensions["image"]?.contains(File(path).extension) ?: false + return isExtensionType("image", path) } fun isVideo(path: String): Boolean { - return fileExtensions["video"]?.contains(File(path).extension) ?: false + return isExtensionType("video", path) } fun isAudio(path: String): Boolean { - return fileExtensions["audio"]?.contains(File(path).extension) ?: false + return isExtensionType("audio", path) } fun isText(path: String): Boolean { - return fileExtensions["text"]?.contains(File(path).extension) ?: false + return isExtensionType("text", path) } fun getAssociatedDrawable(path: String): Int { return when { diff --git a/build.gradle b/build.gradle index 1590fed..085dea5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.10" + ext.kotlin_version = "1.4.21" repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' + classpath 'com.android.tools.build:gradle:4.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } }