Skip to content

Commit

Permalink
Remove INTERNAL_STORAGE const from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrlzy committed Dec 27, 2024
1 parent c17719b commit 5f98d2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.core.os.bundleOf
import androidx.fragment.app.setFragmentResult
import androidx.lifecycle.lifecycleScope
import dev.arkbuilders.arklib.data.folders.FoldersRepo
import dev.arkbuilders.arklib.utils.INTERNAL_STORAGE
import dev.arkbuilders.components.utils.hasNestedRoot
import dev.arkbuilders.components.utils.isInternalStorage
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.nio.file.Path
Expand All @@ -18,7 +18,7 @@ class ArkRootPickerFragment : ArkFilePickerFragment() {
val folders = FoldersRepo.instance.provideFolders()
val roots = folders.keys

if (currentFolder.isInternalStorage() || currentFolder.hasNestedRoot(roots)) {
if (currentFolder == INTERNAL_STORAGE || currentFolder.hasNestedRoot(roots)) {
rootNotFavorite = true
binding.btnPick.text = getString(R.string.ark_file_picker_root)
binding.btnPick.isEnabled = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package dev.arkbuilders.components.utils

import java.nio.file.Path
import kotlin.io.path.Path

val INTERNAL_STORAGE = Path("/storage/emulated/0")

fun Path.hasNestedOrParentalRoot(roots: Iterable<Path>): Boolean {
val hasNestedRoot = roots.any { path ->
Expand All @@ -12,6 +9,4 @@ fun Path.hasNestedOrParentalRoot(roots: Iterable<Path>): Boolean {
return hasNestedRoot
}

fun Path.hasNestedRoot(roots: Iterable<Path>) = roots.any { it.startsWith(this) }

fun Path.isInternalStorage() = this == INTERNAL_STORAGE
fun Path.hasNestedRoot(roots: Iterable<Path>) = roots.any { it.startsWith(this) }

0 comments on commit 5f98d2d

Please sign in to comment.