Skip to content

Commit

Permalink
#76: Disallow File pinning (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuancoltech authored Mar 16, 2024
1 parent 8713304 commit 2656bc2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ open class ArkFilePickerFragment :
pagesAdapter.set(getPages())
activity?.toast(R.string.ark_file_picker_pinned_as_root)
}

FilePickerSideEffect.CannotPinFile -> {
activity?.toast(R.string.ark_file_picker_pin_folder_only)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ internal sealed class FilePickerSideEffect {
data object PinAsFavorite : FilePickerSideEffect()
data object AlreadyFavorite : FilePickerSideEffect()
data object PinAsFirstRoot : FilePickerSideEffect()
data object CannotPinFile : FilePickerSideEffect()

}

Expand Down Expand Up @@ -180,6 +181,11 @@ internal class ArkFilePickerViewModel(
}

fun pinFile(file: Path) = intent {
if (!file.isDirectory()) {
postSideEffect(FilePickerSideEffect.CannotPinFile)
return@intent
}

val rootsWithFavorites = container.stateFlow.value.rootsWithFavs
val roots = rootsWithFavorites.keys
val root = roots.find { root -> file.startsWith(root) }
Expand Down
1 change: 1 addition & 0 deletions filepicker/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<string name="ark_file_picker_pinned_as_root">Pinned as a Root folder!</string>
<string name="ark_file_picker_already_a_favorite">Already be a Favorite folder!</string>
<string name="ark_file_picker_already_be_a_root">Already be a Root folder!</string>
<string name="ark_file_picker_pin_folder_only">Only folder can be pinned.</string>
<string name="ark_file_picker_pin">Pin</string>
<plurals name="ark_file_picker_items">
<item quantity="one">%d item</item>
Expand Down

0 comments on commit 2656bc2

Please sign in to comment.