Skip to content

Commit

Permalink
For mozilla-mobile#1968 - Adds menu option to add new folder in Bookm…
Browse files Browse the repository at this point in the history
…arkFragment menu
  • Loading branch information
ekager committed Jun 27, 2019
1 parent 606e662 commit 9142e22
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {

activity?.run {
ViewModelProviders.of(this).get(BookmarksSharedViewModel::class.java)
}!!.selectedFolder = null
}!!.selectedFolder = currentRoot
}
}
}
Expand All @@ -152,7 +152,7 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
when (val mode = (bookmarkComponent.uiView as BookmarkUIView).mode) {
BookmarkState.Mode.Normal -> {
inflater.inflate(R.menu.library_menu, menu)
inflater.inflate(R.menu.bookmarks_menu, menu)
}
is BookmarkState.Mode.Selecting -> {
inflater.inflate(R.menu.bookmarks_select_multi, menu)
Expand Down Expand Up @@ -326,6 +326,14 @@ class BookmarkFragment : Fragment(), BackHandler, AccountObserver {
.popBackStack(R.id.libraryFragment, true)
true
}
R.id.add_bookmark_folder -> {
nav(
R.id.bookmarkFragment,
BookmarkFragmentDirections
.actionBookmarkFragmentToBookmarkAddFolderFragment()
)
true
}
R.id.open_bookmarks_in_new_tabs_multi_select -> {
getSelectedBookmarks().forEach { node ->
node.url?.let {
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_folder_new.xml
Original file line number Diff line number Diff line change
@@ -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>
22 changes: 22 additions & 0 deletions app/src/main/res/menu/bookmarks_menu.xml
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 3 additions & 0 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
<action
android:id="@+id/action_bookmarkFragment_to_shareFragment"
app:destination="@id/shareFragment" />
<action
android:id="@+id/action_bookmarkFragment_to_bookmarkAddFolderFragment"
app:destination="@id/bookmarkAddFolderFragment" />
</fragment>

<fragment
Expand Down

0 comments on commit 9142e22

Please sign in to comment.