diff options
| author | John Reck <jreck@google.com> | 2011-09-15 10:08:06 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-15 10:08:06 -0700 |
| commit | 13ec51769c2ee9f9e189050a510103226b6241de (patch) | |
| tree | c6780d6b399931742d48db39add29ecbf12807ca /src/com/android/browser/Controller.java | |
| parent | a47929ffd8bd8fdd54f45d6b147fd74a2233f8f4 (diff) | |
| parent | e1a03a366ff90ebcd8568a86b84a5917610cf512 (diff) | |
| download | packages_apps_Browser-13ec51769c2ee9f9e189050a510103226b6241de.tar.gz packages_apps_Browser-13ec51769c2ee9f9e189050a510103226b6241de.tar.bz2 packages_apps_Browser-13ec51769c2ee9f9e189050a510103226b6241de.zip | |
Merge "Cleanup menus"
Diffstat (limited to 'src/com/android/browser/Controller.java')
| -rw-r--r-- | src/com/android/browser/Controller.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 3533bf1d9..0a54a89cf 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -1245,10 +1245,6 @@ public class Controller } MenuInflater inflater = mActivity.getMenuInflater(); inflater.inflate(R.menu.browser, menu); - updateInLoadMenuItems(menu); - // hold on to the menu reference here; it is used by the page callbacks - // to update the menu based on loading state - mCachedMenu = menu; return true; } @@ -1432,6 +1428,10 @@ public class Controller } boolean onPrepareOptionsMenu(Menu menu) { + updateInLoadMenuItems(menu); + // hold on to the menu reference here; it is used by the page callbacks + // to update the menu based on loading state + mCachedMenu = menu; // Note: setVisible will decide whether an item is visible; while // setEnabled() will decide whether an item is enabled, which also means // whether the matching shortcut key will function. @@ -1462,11 +1462,13 @@ public class Controller boolean canGoForward = false; boolean isHome = false; boolean isDesktopUa = false; + boolean isLive = false; if (tab != null) { canGoBack = tab.canGoBack(); canGoForward = tab.canGoForward(); isHome = mSettings.getHomePage().equals(tab.getUrl()); isDesktopUa = mSettings.hasDesktopUseragent(tab.getWebView()); + isLive = !tab.isSnapshot(); } final MenuItem back = menu.findItem(R.id.back_menu_id); back.setEnabled(canGoBack); @@ -1483,6 +1485,7 @@ public class Controller dest.setTitle(source.getTitle()); dest.setIcon(source.getIcon()); } + menu.setGroupVisible(R.id.NAV_MENU, isLive); // decide whether to show the share link option PackageManager pm = mActivity.getPackageManager(); @@ -1503,6 +1506,8 @@ public class Controller counter.setEnabled(showDebugSettings); final MenuItem uaSwitcher = menu.findItem(R.id.ua_desktop_menu_id); uaSwitcher.setChecked(isDesktopUa); + menu.setGroupVisible(R.id.LIVE_MENU, isLive); + menu.setGroupVisible(R.id.SNAPSHOT_MENU, !isLive); mUi.updateMenuState(tab, menu); } @@ -1620,6 +1625,10 @@ public class Controller mPageDialogsHandler.showPageInfo(mTabControl.getCurrentTab(), false, null); break; + case R.id.snapshot_go_live: + goLive(); + return true; + case R.id.classic_history_menu_id: bookmarksOrHistoryPicker(true); break; @@ -1687,6 +1696,11 @@ public class Controller return true; } + private void goLive() { + Tab t = getCurrentTab(); + t.loadUrl(t.getUrl(), null); + } + public boolean onContextItemSelected(MenuItem item) { // Let the History and Bookmark fragments handle menus they created. if (item.getGroupId() == R.id.CONTEXT_MENU) { |
