summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-07-14 14:18:12 -0700
committerMichael Kolb <kolby@google.com>2011-07-14 14:18:17 -0700
commit4bf7971ed99aa273dc8ea9cf610cd6fa168c5dcb (patch)
tree61ebfb8a0bcdcdfebd0dcaba46585f8631e6a729 /src
parent629b22ce19f44e38ee470687cd2d9218d2066f85 (diff)
downloadpackages_apps_Browser-4bf7971ed99aa273dc8ea9cf610cd6fa168c5dcb.zip
packages_apps_Browser-4bf7971ed99aa273dc8ea9cf610cd6fa168c5dcb.tar.gz
packages_apps_Browser-4bf7971ed99aa273dc8ea9cf610cd6fa168c5dcb.tar.bz2
add navigation to menu again
Bug: 5021497 re-enabled the navigation menu items adjust state based on current tab Change-Id: If396829f280fdb7831ade97180c38342e4f483a3
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Controller.java90
-rw-r--r--src/com/android/browser/NavScreen.java2
-rw-r--r--src/com/android/browser/NavigationBarPhone.java2
-rw-r--r--src/com/android/browser/UiController.java7
4 files changed, 54 insertions, 47 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 5b00179..323e0f3 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -67,7 +67,6 @@ import android.view.View;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.HttpAuthHandler;
-import android.webkit.SearchBox;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
@@ -1463,54 +1462,59 @@ public class Controller
menu.setGroupEnabled(R.id.MAIN_MENU, true);
menu.setGroupEnabled(R.id.MAIN_SHORTCUT_MENU, true);
}
- final Tab t = getCurrentTab();
- boolean canGoBack = false;
- boolean canGoForward = false;
- boolean isHome = false;
- if (t != null) {
- canGoBack = t.canGoBack();
- canGoForward = t.canGoForward();
- isHome = mSettings.getHomePage().equals(t.getUrl());
- }
- final MenuItem back = menu.findItem(R.id.back_menu_id);
- back.setEnabled(canGoBack);
-
- final MenuItem home = menu.findItem(R.id.homepage_menu_id);
- home.setEnabled(!isHome);
-
- final MenuItem forward = menu.findItem(R.id.forward_menu_id);
- forward.setEnabled(canGoForward);
-
- // decide whether to show the share link option
- PackageManager pm = mActivity.getPackageManager();
- Intent send = new Intent(Intent.ACTION_SEND);
- send.setType("text/plain");
- ResolveInfo ri = pm.resolveActivity(send,
- PackageManager.MATCH_DEFAULT_ONLY);
- menu.findItem(R.id.share_page_menu_id).setVisible(ri != null);
-
- boolean isNavDump = mSettings.enableNavDump();
- final MenuItem nav = menu.findItem(R.id.dump_nav_menu_id);
- nav.setVisible(isNavDump);
- nav.setEnabled(isNavDump);
-
- boolean showDebugSettings = mSettings.isDebugEnabled();
- final MenuItem counter = menu.findItem(R.id.dump_counters_menu_id);
- counter.setVisible(showDebugSettings);
- counter.setEnabled(showDebugSettings);
-
- final MenuItem newtab = menu.findItem(R.id.new_tab_menu_id);
- newtab.setEnabled(getTabControl().canCreateNewTab());
-
- MenuItem saveSnapshot = menu.findItem(R.id.save_snapshot_menu_id);
- Tab tab = getCurrentTab();
- saveSnapshot.setVisible(tab != null && !tab.isSnapshot());
+ updateMenuState(getCurrentTab(), menu);
break;
}
mCurrentMenuState = mMenuState;
return mUi.onPrepareOptionsMenu(menu);
}
+ @Override
+ public void updateMenuState(Tab tab, Menu menu) {
+ boolean canGoBack = false;
+ boolean canGoForward = false;
+ boolean isHome = false;
+ if (tab != null) {
+ canGoBack = tab.canGoBack();
+ canGoForward = tab.canGoForward();
+ isHome = mSettings.getHomePage().equals(tab.getUrl());
+ }
+ final MenuItem back = menu.findItem(R.id.back_menu_id);
+ back.setEnabled(canGoBack);
+
+ final MenuItem home = menu.findItem(R.id.homepage_menu_id);
+ home.setEnabled(!isHome);
+
+ final MenuItem forward = menu.findItem(R.id.forward_menu_id);
+ forward.setEnabled(canGoForward);
+
+ final MenuItem source = menu.findItem(mInLoad ? R.id.stop_menu_id : R.id.reload_menu_id);
+ final MenuItem dest = menu.findItem(R.id.stop_reload_menu_id);
+ dest.setTitle(source.getTitle());
+ dest.setIcon(source.getIcon());
+
+ // decide whether to show the share link option
+ PackageManager pm = mActivity.getPackageManager();
+ Intent send = new Intent(Intent.ACTION_SEND);
+ send.setType("text/plain");
+ ResolveInfo ri = pm.resolveActivity(send,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ menu.findItem(R.id.share_page_menu_id).setVisible(ri != null);
+
+ boolean isNavDump = mSettings.enableNavDump();
+ final MenuItem nav = menu.findItem(R.id.dump_nav_menu_id);
+ nav.setVisible(isNavDump);
+ nav.setEnabled(isNavDump);
+
+ boolean showDebugSettings = mSettings.isDebugEnabled();
+ final MenuItem counter = menu.findItem(R.id.dump_counters_menu_id);
+ counter.setVisible(showDebugSettings);
+ counter.setEnabled(showDebugSettings);
+
+ MenuItem saveSnapshot = menu.findItem(R.id.save_snapshot_menu_id);
+ saveSnapshot.setVisible(tab != null && !tab.isSnapshot());
+ }
+
public boolean onOptionsItemSelected(MenuItem item) {
if (mOptionsMenuHandler != null &&
mOptionsMenuHandler.onOptionsItemSelected(item)) {
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java
index 6a51e87..d03da6b 100644
--- a/src/com/android/browser/NavScreen.java
+++ b/src/com/android/browser/NavScreen.java
@@ -77,7 +77,7 @@ public class NavScreen extends RelativeLayout
PopupMenu popup = new PopupMenu(mContext, mMore);
Menu menu = popup.getMenu();
popup.getMenuInflater().inflate(R.menu.browser, menu);
- menu.setGroupVisible(R.id.NAV_MENU, false);
+ mUiController.updateMenuState(mScroller.getSelectedItem(), menu);
popup.setOnMenuItemClickListener(this);
popup.show();
}
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java
index 7dcf7b5..684f986 100644
--- a/src/com/android/browser/NavigationBarPhone.java
+++ b/src/com/android/browser/NavigationBarPhone.java
@@ -171,7 +171,7 @@ public class NavigationBarPhone extends NavigationBarBase implements
PopupMenu popup = new PopupMenu(mContext, anchor);
Menu menu = popup.getMenu();
popup.getMenuInflater().inflate(R.menu.browser, menu);
- menu.setGroupVisible(R.id.NAV_MENU, false);
+ mUiController.updateMenuState(mBaseUi.getActiveTab(), menu);
popup.setOnMenuItemClickListener(this);
popup.setOnDismissListener(this);
popup.show();
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index 421dc14..10821cd 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -16,12 +16,13 @@
package com.android.browser;
-import com.android.browser.UI.DropdownChangeListener;
-
import android.content.Intent;
+import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
+import com.android.browser.UI.DropdownChangeListener;
+
import java.util.List;
@@ -93,6 +94,8 @@ public interface UiController extends BookmarksHistoryCallbacks {
void unregisterOptionsMenuHandler(OptionsMenuHandler handler);
+ void updateMenuState(Tab tab, Menu menu);
+
void registerDropdownChangeListener(DropdownChangeListener d);
boolean onOptionsItemSelected(MenuItem item);