mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: keep deferred back inside selected drive root
This commit is contained in:
1 parent
cb153ece87
commit
3b1dfadcf9
2 files changed
+29
-2
No files matched your search
@@ -101,6 +101,9 @@ import java.util.Date
|
||||
|
||||
private enum class FileManagerNavigation { EXIT, RETURN_TO_START, BACK }
|
||||
|
||||
internal fun canNavigateUp(currentDir: File, currentRoot: File): Boolean =
|
||||
currentDir != currentRoot && currentDir.parentFile?.exists() == true
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun FileManagerScreen(
|
||||
@@ -192,6 +195,7 @@ fun FileManagerScreen(
|
||||
var listingJob by remember { mutableStateOf<Job?>(null) }
|
||||
|
||||
fun loadDirectory(dir: File, resetScroll: Boolean = true) {
|
||||
if (cancellingNavigation) return
|
||||
currentDir = dir
|
||||
if (pickMode) pickPrefs.edit().putString("lastFilePickerDir", dir.absolutePath).apply()
|
||||
listingJob?.cancel()
|
||||
@@ -216,11 +220,13 @@ fun FileManagerScreen(
|
||||
}
|
||||
|
||||
fun openDrive(dir: File) {
|
||||
if (cancellingNavigation) return
|
||||
currentRoot = dir
|
||||
loadDirectory(dir)
|
||||
}
|
||||
|
||||
fun returnToStart() {
|
||||
if (cancellingNavigation) return
|
||||
val dir = launchDir ?: return
|
||||
if (!dir.isDirectory) {
|
||||
Toast.makeText(context, R.string.fm_start_unavailable, Toast.LENGTH_SHORT).show()
|
||||
@@ -240,12 +246,13 @@ fun FileManagerScreen(
|
||||
val operationActive = isOperationActive()
|
||||
|
||||
fun navigate(action: FileManagerNavigation) {
|
||||
if (cancellingNavigation) return
|
||||
when (action) {
|
||||
FileManagerNavigation.EXIT -> onExit?.invoke()
|
||||
FileManagerNavigation.RETURN_TO_START -> returnToStart()
|
||||
FileManagerNavigation.BACK -> {
|
||||
if (showFavorites) showFavorites = false
|
||||
else if (canGoUp) currentDir.parentFile?.let { loadDirectory(it) }
|
||||
else if (canNavigateUp(currentDir, currentRoot)) currentDir.parentFile?.let { loadDirectory(it) }
|
||||
else onExit?.invoke()
|
||||
}
|
||||
}
|
||||
@@ -284,8 +291,8 @@ fun FileManagerScreen(
|
||||
pendingConflict = null
|
||||
isOperationRunning = false
|
||||
operationDeterminate = false
|
||||
if (action != FileManagerNavigation.EXIT) loadDirectory(currentDir, resetScroll = false)
|
||||
cancellingNavigation = false
|
||||
if (action != FileManagerNavigation.EXIT) loadDirectory(currentDir, resetScroll = false)
|
||||
navigate(action)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user