Browse Source

File extensions case insensitive

master
Hardcore Sushi 3 months ago
parent
commit
8c4bea1aff
Signed by: hardcoresushi GPG Key ID: 007F84120107191E
  1. 3
      app/build.gradle
  2. 13
      app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt
  3. 4
      build.gradle

3
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"
}

13
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 {

4
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"
}
}

Loading…
Cancel
Save