LeOSium_webview/LeOS/patches/Bookmarks-select-all-menu-e...

108 lines
5.4 KiB
Diff
Raw Normal View History

2023-11-18 11:46:19 +01:00
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" />
+ <item
+ android:id="@+id/select_all_menu_id"
+ android:icon="@drawable/ic_done_blue"
+ android:title="@string/select_all_bookmarks"
+ android:visible="true"
+ app:showAsAction="ifRoom"
+ app:iconTint="@color/default_icon_color_tint_list" />
<item
android:id="@+id/import_menu_id"
android:icon="@drawable/ic_folder_blue_24dp"
diff --git a/chrome/android/java/res/menu/bookmark_toolbar_menu_improved.xml b/chrome/android/java/res/menu/bookmark_toolbar_menu_improved.xml
--- a/chrome/android/java/res/menu/bookmark_toolbar_menu_improved.xml
+++ b/chrome/android/java/res/menu/bookmark_toolbar_menu_improved.xml
@@ -51,6 +51,13 @@ found in the LICENSE file.
android:title="@string/create_new_folder"
app:showAsAction="ifRoom"
app:iconTint="@color/default_icon_color_secondary_tint_list" />
+ <item
+ android:id="@+id/select_all_menu_id"
+ android:icon="@drawable/ic_done_blue"
+ android:title="@string/select_all_bookmarks"
+ android:visible="true"
+ app:showAsAction="ifRoom"
+ app:iconTint="@color/default_icon_color_tint_list" />
<item
android:id="@+id/import_menu_id"
android:icon="@drawable/ic_folder_blue_24dp"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkToolbar.java b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkToolbar.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkToolbar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkToolbar.java
@@ -27,6 +27,8 @@ import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelega
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
+import java.util.HashSet;
+
/**
* Main toolbar of bookmark UI. It is responsible for displaying title and buttons
* associated with the current context.
@@ -183,6 +185,7 @@ public class BookmarkToolbar extends SelectableListToolbar<BookmarkId>
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<BookmarkId>
mExportBookmarkRunnable.run();
return true;
}
+ if (menuItem.getItemId() == R.id.select_all_menu_id) {
+ if (mBookmarkModel.isBookmarkModelLoaded()) {
+ List<BookmarkItem> items = mBookmarkModel.getBookmarksForFolder(mCurrentFolder.getId());
+ HashSet<BookmarkId> 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<BookmarkId>
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:
<message name="IDS_NOTIFICATION_CATEGORY_SITES" desc="Label for notifications from websites, within a list of notification categories. [CHAR_LIMIT=32]">
Sites
</message>
+ <message name="IDS_SELECT_ALL_BOOKMARKS" desc="The label for the select all bookmarks button.">
+ Select all
+ </message>
<message name="IDS_IMPORT_BOOKMARKS" desc="The label for the import bookmarks button.">
Import
</message>
--
2.25.1