Bookmark UI update
Change-Id: Ibdf7f93f7c5863d7108044dcd40d3866ff02518a
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index fe19927..6c6fe0b 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -137,6 +137,7 @@
private TabControl mTabControl;
private BrowserSettings mSettings;
private WebViewFactory mFactory;
+ private OptionsMenuHandler mOptionsMenuHandler = null;
private WakeLock mWakeLock;
@@ -1186,6 +1187,10 @@
// TODO: maybe put into separate handler
protected boolean onCreateOptionsMenu(Menu menu) {
+ if (mOptionsMenuHandler != null) {
+ return mOptionsMenuHandler.onCreateOptionsMenu(menu);
+ }
+
if (mMenuState == EMPTY_MENU) {
return false;
}
@@ -1379,7 +1384,10 @@
}
}
- boolean prepareOptionsMenu(Menu menu) {
+ boolean onPrepareOptionsMenu(Menu menu) {
+ if (mOptionsMenuHandler != null) {
+ return mOptionsMenuHandler.onPrepareOptionsMenu(menu);
+ }
// This happens when the user begins to hold down the menu key, so
// allow them to chord to get a shortcut.
mCanChord = true;
@@ -1436,8 +1444,8 @@
counter.setVisible(showDebugSettings);
counter.setEnabled(showDebugSettings);
- // allow the ui to adjust state based settings
- mUi.onPrepareOptionsMenu(menu);
+ final MenuItem newtab = menu.findItem(R.id.new_tab_menu_id);
+ newtab.setEnabled(getTabControl().canCreateNewTab());
break;
}
@@ -1446,6 +1454,11 @@
}
public boolean onOptionsItemSelected(MenuItem item) {
+ if (mOptionsMenuHandler != null &&
+ mOptionsMenuHandler.onOptionsItemSelected(item)) {
+ return true;
+ }
+
if (item.getGroupId() != R.id.CONTEXT_MENU) {
// menu remains active, so ensure comboview is dismissed
// if main menu option is selected
@@ -2517,4 +2530,17 @@
mAutoFillSetupMessage = message;
mActivity.startActivityForResult(intent, AUTOFILL_SETUP);
}
+
+ @Override
+ public void registerOptionsMenuHandler(OptionsMenuHandler handler) {
+ mOptionsMenuHandler = handler;
+ }
+
+ @Override
+ public void unregisterOptionsMenuHandler(OptionsMenuHandler handler) {
+ if (mOptionsMenuHandler == handler) {
+ mOptionsMenuHandler = null;
+ }
+ }
+
}