mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/13157: Filter out folder being edited from 'select folder' dialog
This commit is contained in:
parent
412ae60537
commit
f79c9733e1
@ -107,7 +107,12 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) {
|
|||||||
R.id.bookmarkEditFragment,
|
R.id.bookmarkEditFragment,
|
||||||
EditBookmarkFragmentDirections
|
EditBookmarkFragmentDirections
|
||||||
.actionBookmarkEditFragmentToBookmarkSelectFolderFragment(
|
.actionBookmarkEditFragmentToBookmarkSelectFolderFragment(
|
||||||
allowCreatingNewFolder = false
|
allowCreatingNewFolder = false,
|
||||||
|
// Don't allow moving folders into themselves.
|
||||||
|
hideFolderGuid = when (bookmarkNode!!.type) {
|
||||||
|
BookmarkNodeType.FOLDER -> bookmarkNode!!.guid
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,19 @@ import org.mozilla.fenix.library.bookmarks.selectfolder.SelectBookmarkFolderAdap
|
|||||||
class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedViewModel) :
|
class SelectBookmarkFolderAdapter(private val sharedViewModel: BookmarksSharedViewModel) :
|
||||||
ListAdapter<BookmarkNodeWithDepth, BookmarkFolderViewHolder>(DiffCallback) {
|
ListAdapter<BookmarkNodeWithDepth, BookmarkFolderViewHolder>(DiffCallback) {
|
||||||
|
|
||||||
fun updateData(tree: BookmarkNode?) {
|
fun updateData(tree: BookmarkNode?, hideFolderGuid: String?) {
|
||||||
val updatedData = tree
|
val updatedData = tree
|
||||||
?.convertToFolderDepthTree()
|
?.convertToFolderDepthTree()
|
||||||
?.drop(1)
|
?.drop(1)
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
submitList(updatedData)
|
|
||||||
|
val filteredData = if (hideFolderGuid != null && updatedData.isNotEmpty()) {
|
||||||
|
updatedData.filter { it.node.guid != hideFolderGuid }
|
||||||
|
} else {
|
||||||
|
updatedData
|
||||||
|
}
|
||||||
|
|
||||||
|
submitList(filteredData)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookmarkFolderViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookmarkFolderViewHolder {
|
||||||
|
@ -50,6 +50,8 @@ class SelectBookmarkFolderFragment : Fragment() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
showToolbar(getString(R.string.bookmark_select_folder_fragment_label))
|
showToolbar(getString(R.string.bookmark_select_folder_fragment_label))
|
||||||
|
|
||||||
|
val args: SelectBookmarkFolderFragmentArgs by navArgs()
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch(Main) {
|
viewLifecycleOwner.lifecycleScope.launch(Main) {
|
||||||
bookmarkNode = withContext(IO) {
|
bookmarkNode = withContext(IO) {
|
||||||
val context = requireContext()
|
val context = requireContext()
|
||||||
@ -59,7 +61,7 @@ class SelectBookmarkFolderFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
val adapter = SelectBookmarkFolderAdapter(sharedViewModel)
|
val adapter = SelectBookmarkFolderAdapter(sharedViewModel)
|
||||||
recylerViewBookmarkFolders.adapter = adapter
|
recylerViewBookmarkFolders.adapter = adapter
|
||||||
adapter.updateData(bookmarkNode)
|
adapter.updateData(bookmarkNode, args.hideFolderGuid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +308,11 @@
|
|||||||
android:name="allowCreatingNewFolder"
|
android:name="allowCreatingNewFolder"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
app:argType="boolean" />
|
app:argType="boolean" />
|
||||||
|
<argument
|
||||||
|
android:name="hideFolderGuid"
|
||||||
|
android:defaultValue="@null"
|
||||||
|
app:nullable="true"
|
||||||
|
app:argType="string" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
Loading…
Reference in New Issue
Block a user