[Android] Changes for BookmarkBridge

Chromium change:
https://github.com/chromium/chromium/commit/840e50894d4c8275ff0a6accd0ec685b7db6c4b4

[Read Later] Add menu items for bookmarks and reading list
Bug: 1257406, 1252228
This commit is contained in:
samartnik
2021-12-07 14:45:27 -05:00
committed by mkarolin
parent e2251cf782
commit 84d41c3e29
@@ -47,7 +47,8 @@ import org.chromium.ui.modaldialog.ModalDialogManager;
public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertiesDelegate {
private Menu mMenu;
AppMenuDelegate mAppMenuDelegate;
private AppMenuDelegate mAppMenuDelegate;
private ObservableSupplier<BookmarkBridge> mBookmarkBridgeSupplier;
public BraveTabbedAppMenuPropertiesDelegate(Context context,
ActivityTabProvider activityTabProvider,
@@ -65,6 +66,7 @@ public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertie
snackbarManager);
mAppMenuDelegate = appMenuDelegate;
mBookmarkBridgeSupplier = bookmarkBridgeSupplier;
}
@Override
@@ -158,11 +160,11 @@ public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertie
shareItem.setIcon(AppCompatResources.getDrawable(mContext, R.drawable.share_icon));
}
// By this we forcibly initialize mBookmarkBridge
// By this we forcibly initialize BookmarkBridge
MenuItem bookmarkItem = menu.findItem(R.id.bookmark_this_page_id);
Tab currentTab = mActivityTabProvider.get();
if (bookmarkItem != null && currentTab != null) {
updateBookmarkMenuItem(bookmarkItem, currentTab);
updateBookmarkMenuItemShortcut(bookmarkItem, currentTab);
}
}
@@ -181,7 +183,7 @@ public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertie
@Override
public void onFooterViewInflated(AppMenuHandler appMenuHandler, View view) {
// If it's still null, just hide the whole view
if (mBookmarkBridge == null) {
if (mBookmarkBridgeSupplier.get() == null) {
if (view != null) {
view.setVisibility(View.GONE);
}
@@ -193,8 +195,8 @@ public class BraveTabbedAppMenuPropertiesDelegate extends TabbedAppMenuPropertie
if (view instanceof AppMenuIconRowFooter) {
((AppMenuIconRowFooter) view)
.initialize(appMenuHandler, mBookmarkBridge, mActivityTabProvider.get(),
mAppMenuDelegate);
.initialize(appMenuHandler, mBookmarkBridgeSupplier.get(),
mActivityTabProvider.get(), mAppMenuDelegate);
}
// Hide bookmark button if bottom toolbar is enabled