2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-09 19:10:42 +00:00

For #1968 - Adds menu option to add new folder in BookmarkFragment menu

This commit is contained in:
Emily Kager 2019-06-27 13:11:25 -07:00 committed by Emily Kager
parent 606e66219c
commit 9142e2279c
4 changed files with 48 additions and 2 deletions

View File

@ -131,7 +131,7 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
activity?.run { activity?.run {
ViewModelProviders.of(this).get(BookmarksSharedViewModel::class.java) ViewModelProviders.of(this).get(BookmarksSharedViewModel::class.java)
}!!.selectedFolder = null }!!.selectedFolder = currentRoot
} }
} }
} }
@ -152,7 +152,7 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
when (val mode = (bookmarkComponent.uiView as BookmarkUIView).mode) { when (val mode = (bookmarkComponent.uiView as BookmarkUIView).mode) {
BookmarkState.Mode.Normal -> { BookmarkState.Mode.Normal -> {
inflater.inflate(R.menu.library_menu, menu) inflater.inflate(R.menu.bookmarks_menu, menu)
} }
is BookmarkState.Mode.Selecting -> { is BookmarkState.Mode.Selecting -> {
inflater.inflate(R.menu.bookmarks_select_multi, menu) inflater.inflate(R.menu.bookmarks_select_multi, menu)
@ -326,6 +326,14 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
.popBackStack(R.id.libraryFragment, true) .popBackStack(R.id.libraryFragment, true)
true true
} }
R.id.add_bookmark_folder -> {
nav(
R.id.bookmarkFragment,
BookmarkFragmentDirections
.actionBookmarkFragmentToBookmarkAddFolderFragment()
)
true
}
R.id.open_bookmarks_in_new_tabs_multi_select -> { R.id.open_bookmarks_in_new_tabs_multi_select -> {
getSelectedBookmarks().forEach { node -> getSelectedBookmarks().forEach { node ->
node.url?.let { node.url?.let {

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?primaryText"
android:pathData="M19.5,6h-6.76l-2.53,-2.34A2.53,2.53 0,0 0,8.51 3h-4A2.5,2.5 0,0 0,2 5.5v12A2.5,2.5 0,0 0,4.5 20L13,20a1,1 0,0 0,0 -2L4.5,18a0.5,0.5 0,0 1,-0.5 -0.5L4,8h15.5a0.5,0.5 0,0 1,0.5 0.5L20,15a1,1 0,1 0,2 0L22,8.5A2.5,2.5 0,0 0,19.5 6zM4,7L4,5.5a0.5,0.5 0,0 1,0.5 -0.5h4a0.51,0.51 0,0 1,0.34 0.13l2,1.87zM21.5,18L19,18v-2.5a0.5,0.5 0,0 0,-1 0L18,18h-2.5a0.5,0.5 0,0 0,0 1L18,19v2.5a0.5,0.5 0,0 0,1 0L19,19h2.5a0.5,0.5 0,0 0,0 -1z"/>
</vector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/add_bookmark_folder"
android:icon="@drawable/ic_folder_new"
android:iconTint="?primaryText"
android:title="@string/bookmark_add_folder"
app:showAsAction="ifRoom"
tools:targetApi="o" />
<item
android:id="@+id/libraryClose"
android:icon="@drawable/ic_close"
android:iconTint="?primaryText"
android:title="@string/content_description_close_button"
app:showAsAction="ifRoom"
tools:targetApi="o" />
</menu>

View File

@ -201,6 +201,9 @@
<action <action
android:id="@+id/action_bookmarkFragment_to_shareFragment" android:id="@+id/action_bookmarkFragment_to_shareFragment"
app:destination="@id/shareFragment" /> app:destination="@id/shareFragment" />
<action
android:id="@+id/action_bookmarkFragment_to_bookmarkAddFolderFragment"
app:destination="@id/bookmarkAddFolderFragment" />
</fragment> </fragment>
<fragment <fragment