From: csagan5 <32685696+csagan5@users.noreply.github.com> Date: Sat, 9 Apr 2022 23:01:55 +0200 Subject: Bookmarks select all menu entry License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../java/res/menu/bookmark_toolbar_menu.xml | 7 +++++++ .../res/menu/bookmark_toolbar_menu_improved.xml | 7 +++++++ .../chrome/browser/bookmarks/BookmarkToolbar.java | 15 +++++++++++++++ .../ui/android/strings/android_chrome_strings.grd | 3 +++ 4 files changed, 32 insertions(+) diff --git a/chrome/android/java/res/menu/bookmark_toolbar_menu.xml b/chrome/android/java/res/menu/bookmark_toolbar_menu.xml --- a/chrome/android/java/res/menu/bookmark_toolbar_menu.xml +++ b/chrome/android/java/res/menu/bookmark_toolbar_menu.xml @@ -23,6 +23,13 @@ found in the LICENSE file. android:visible="false" app:showAsAction="ifRoom" app:iconTint="@color/default_icon_color_secondary_tint_list" /> + + void setCurrentFolder(BookmarkId folder) { mCurrentFolder = mBookmarkModel.getBookmarkById(folder); + getMenu().findItem(R.id.select_all_menu_id).setVisible(true); getMenu().findItem(R.id.import_menu_id).setVisible(true); getMenu().findItem(R.id.export_menu_id).setVisible(true); } @@ -211,6 +214,17 @@ public class BookmarkToolbar extends SelectableListToolbar mExportBookmarkRunnable.run(); return true; } + if (menuItem.getItemId() == R.id.select_all_menu_id) { + if (mBookmarkModel.isBookmarkModelLoaded()) { + List items = mBookmarkModel.getBookmarksForFolder(mCurrentFolder.getId()); + HashSet ids = new HashSet<>(items.size()); + for (BookmarkItem item : items) { + ids.add(item.getId()); + } + mSelectionDelegate.setSelectedItems(ids); + } + return true; + } return mMenuIdClickedFunction.apply(menuItem.getItemId()); } @@ -233,6 +247,7 @@ public class BookmarkToolbar extends SelectableListToolbar getMenu().findItem(R.id.import_menu_id).setVisible(mCurrentFolder != null); getMenu().findItem(R.id.export_menu_id).setVisible(mCurrentFolder != null); + getMenu().findItem(R.id.select_all_menu_id).setVisible(mCurrentFolder != null); // SelectableListToolbar will show/hide the entire group. setSearchButtonVisible(mSearchButtonVisible); diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd --- a/chrome/browser/ui/android/strings/android_chrome_strings.grd +++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd @@ -245,6 +245,9 @@ CHAR_LIMIT guidelines: Sites + + Select all + Import -- 2.25.1