This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
ARK-Retouch#75: ARK Filepicker enhancements #19
Closed
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
fcd0d3d
Forgetting roots and favorites
shubertm ed2ef71
Updating forget keys
shubertm ae5662d
Minor changes around forgetting roots and favorites
shubertm f5e3e8b
Adding actions to a group
shubertm efb7d1c
Adding actions to a group
shubertm dc8d0d5
Adding actions to a group
shubertm 3c3fb2a
Adding actions to a group
shubertm 008b368
Adding actions to a group
shubertm 6e685ae
Adding actions to a group
shubertm 528e798
Adding actions to a group
shubertm b95d11e
Adding actions to a group
shubertm fde52fe
Merge remote-tracking branch 'origin/grouping-root-and-fav-actions' i…
shubertm 0ccdfce
Fixing forget root
shubertm 606e34f
Fixing forget root
shubertm 4532acd
Fixing forget root
shubertm dfafb01
Fixing forget root
shubertm 5703d78
Fixing forget root
shubertm d5b9e8c
Fixing forget root
shubertm 6767700
Fixing forget root
shubertm 81b7946
Fixing forget root
shubertm 5b495a1
Fixing folder options
shubertm 7536fc4
Fixing folder options
shubertm 982098e
Minor fixes
mdrlzy db50f75
Merge remote-tracking branch 'origin/main' into grouping-root-and-fav…
shubertm 252f27e
Merge changes from main
shubertm 6a89236
Checking roots availability
shubertm ba67926
Merge remote-tracking branch 'origin/main' into roots-availability
shubertm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
arkfilepicker/src/main/java/space/taran/arkfilepicker/LogTags.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package space.taran.arkfilepicker | ||
|
||
object LogTags { | ||
const val FILES: String = "files" | ||
} |
41 changes: 41 additions & 0 deletions
41
arkfilepicker/src/main/java/space/taran/arkfilepicker/folders/RootsScan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package space.taran.arkfilepicker.folders | ||
|
||
import android.util.Log | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.ensureActive | ||
import kotlinx.coroutines.withContext | ||
import space.taran.arkfilepicker.FileUtils | ||
import space.taran.arkfilepicker.LogTags | ||
import space.taran.arkfilepicker.arkFolder | ||
import java.nio.file.Path | ||
import java.util.LinkedList | ||
import java.util.Queue | ||
import kotlin.io.path.exists | ||
import kotlin.io.path.isDirectory | ||
import kotlin.io.path.listDirectoryEntries | ||
|
||
class ArkRootsScan { | ||
|
||
private val roots = mutableListOf<Path>() | ||
private val queue: Queue<Path> = LinkedList() | ||
|
||
fun getRoots() = roots | ||
|
||
suspend fun scan(devices: List<Path>) = withContext(Dispatchers.IO) { | ||
queue.addAll(devices) | ||
|
||
while (queue.isNotEmpty()) { | ||
ensureActive() | ||
scanFolder(queue.poll()!!) | ||
} | ||
} | ||
|
||
private fun scanFolder(folder: Path) = try { | ||
if (folder.arkFolder().exists()) { | ||
roots.add(folder) | ||
} else | ||
queue.addAll(folder.listDirectoryEntries().filter(Path::isDirectory)) | ||
} catch (e: Exception) { | ||
Log.w(LogTags.FILES, "Can't scan $folder due to $e") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package space.taran.arkfilepicker.presentation.filepicker | |
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.util.TypedValue | ||
import android.view.KeyEvent | ||
import android.view.LayoutInflater | ||
|
@@ -28,6 +29,7 @@ import com.mikepenz.fastadapter.GenericItem | |
import com.mikepenz.fastadapter.adapters.ItemAdapter | ||
import com.mikepenz.fastadapter.binding.AbstractBindingItem | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.runBlocking | ||
import org.orbitmvi.orbit.viewmodel.observe | ||
import space.taran.arkfilepicker.ArkFilePickerConfig | ||
import space.taran.arkfilepicker.presentation.DevicesPopup | ||
|
@@ -206,7 +208,6 @@ open class ArkFilePickerFragment : | |
} | ||
} | ||
|
||
|
||
private fun displayPath(state: FilePickerState) = binding.apply { | ||
layoutPath.removeViews(1, layoutPath.childCount - 1) | ||
val pathWithoutDevice = | ||
|
@@ -310,7 +311,11 @@ open class ArkFilePickerFragment : | |
|
||
fun newInstance(config: ArkFilePickerConfig) = | ||
ArkFilePickerFragment().apply { | ||
setConfig(config) | ||
runBlocking { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mdrlzy is blocking fine here? |
||
val roots = FoldersRepo.instance.provideFolders() | ||
setConfig(config) | ||
showRoots = config.showRoots && roots.isNotEmpty() | ||
} | ||
} | ||
|
||
private const val DIALOG_WIDTH = 300f | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import org.orbitmvi.orbit.syntax.simple.postSideEffect | |
import org.orbitmvi.orbit.syntax.simple.reduce | ||
import org.orbitmvi.orbit.viewmodel.container | ||
import space.taran.arkfilepicker.FileUtils | ||
import space.taran.arkfilepicker.folders.ArkRootsScan | ||
import space.taran.arkfilepicker.listChildren | ||
import space.taran.arkfilepicker.folders.FoldersRepo | ||
import java.nio.file.Path | ||
|
@@ -29,6 +30,7 @@ internal data class FilePickerState( | |
val rootsWithFavs: Map<Path, List<Path>> | ||
) { | ||
val currentDevice get() = devices[selectedDevicePos] | ||
val arkRootsAvailable get() = rootsWithFavs.isNotEmpty() | ||
} | ||
|
||
internal sealed class FilePickerSideEffect { | ||
|
@@ -45,6 +47,8 @@ internal class ArkFilePickerViewModel( | |
|
||
private val foldersRepo = FoldersRepo.instance | ||
|
||
private val arkRootsScanner = ArkRootsScan() | ||
|
||
override val container: Container<FilePickerState, FilePickerSideEffect> = | ||
container(initialState()) | ||
|
||
|
@@ -107,6 +111,12 @@ internal class ArkFilePickerViewModel( | |
} | ||
} | ||
|
||
private fun onScanArkRoots() { | ||
viewModelScope.launch { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty coroutine? |
||
} | ||
} | ||
|
||
private fun onPathPicked(path: Path) = intent { | ||
postSideEffect(FilePickerSideEffect.NotifyPathPicked(path)) | ||
postSideEffect(FilePickerSideEffect.DismissDialog) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scanning in Filepicker should work like this:
Also, Navigator should call the code from Filepicker in order to avoid duplication.
@ShubertMunthali @mdrlzy does it work like this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user doesn't switch to ARK mode, scanning should not happen and should not be suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filepicker should also remember in which mode it was used last time.
If last time was ARK mode, the user should start in ARK mode next time.
If last time was classic mode, the user starts in classic mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it works that way now, only that user cannot choose to use ARK-Mode or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this? We need new preference for this, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes