Skip to content

Commit

Permalink
Merge pull request #6023 from brave/android_crash_fix
Browse files Browse the repository at this point in the history
[Android] Fix for crash on menu footer initialization
  • Loading branch information
samartnik authored Jul 8, 2020
2 parents 9d36141 + 0885b17 commit 99e9bb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher;
import org.chromium.chrome.browser.notifications.BraveSetDefaultBrowserNotificationService;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabbed_mode.TabbedAppMenuPropertiesDelegate;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.ToolbarManager;
Expand Down Expand Up @@ -80,6 +81,13 @@ public void prepareMenu(Menu menu, AppMenuHandler handler) {
shareItem.setTitle(mContext.getString(R.string.share));
shareItem.setIcon(AppCompatResources.getDrawable(mContext, R.drawable.share_icon));
}

// By this we forcibly initialize mBookmarkBridge
MenuItem bookmarkItem = menu.findItem(R.id.bookmark_this_page_id);
Tab currentTab = mActivityTabProvider.get();
if (bookmarkItem != null && currentTab != null) {
updateBookmarkMenuItem(bookmarkItem, currentTab);
}
}

@Override
Expand All @@ -93,6 +101,15 @@ public void onMenuDismissed() {

@Override
public void onFooterViewInflated(AppMenuHandler appMenuHandler, View view) {
// If it's still null, just hide the whole view
if (mBookmarkBridge == null) {
if (view != null) {
view.setVisibility(View.GONE);
}
// Normally it should not happen
assert false;
return;
}
super.onFooterViewInflated(appMenuHandler, view);

// Hide bookmark button if bottom toolbar is enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.os.Bundle;

import org.chromium.chrome.browser.BraveHelper;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration;

/**
Expand All @@ -19,6 +20,9 @@ public class BraveLauncherActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Disable key checker to avoid asserts on Brave keys in debug
SharedPreferencesManager.getInstance().disableKeyCheckerForTesting();

BottomToolbarConfiguration.isBottomToolbarEnabled();
BraveHelper.DisableFREDRP();
}
Expand Down

0 comments on commit 99e9bb1

Please sign in to comment.