diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2012-05-17 13:29:57 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-17 13:29:57 -0700 |
commit | 3bf737fc05131a05e7d5d5ef3cefdfaf7ee6124b (patch) | |
tree | 0dba75b2e360f1dcbbaed3c944a7445af6110711 | |
parent | 292e53064af95d4974e8927b320d2ae08e9de2e7 (diff) | |
parent | 501fa7284ae63fe28b8f81f403f24befa7c992dd (diff) | |
download | packages_apps_browser-3bf737fc05131a05e7d5d5ef3cefdfaf7ee6124b.zip packages_apps_browser-3bf737fc05131a05e7d5d5ef3cefdfaf7ee6124b.tar.gz packages_apps_browser-3bf737fc05131a05e7d5d5ef3cefdfaf7ee6124b.tar.bz2 |
am 501fa728: Merge "Added a menu item in Browser called Close other tabs"
* commit '501fa7284ae63fe28b8f81f403f24befa7c992dd':
Added a menu item in Browser called Close other tabs
-rw-r--r-- | res/menu/browser.xml | 3 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 18 | ||||
-rw-r--r-- | src/com/android/browser/PhoneUi.java | 8 | ||||
-rw-r--r-- | src/com/android/browser/UiController.java | 2 |
5 files changed, 33 insertions, 0 deletions
diff --git a/res/menu/browser.xml b/res/menu/browser.xml index b0c25ea..9d95e88 100644 --- a/res/menu/browser.xml +++ b/res/menu/browser.xml @@ -76,6 +76,9 @@ <group android:id="@+id/COMBO_MENU"> <item + android:id="@+id/close_other_tabs_id" + android:title="@string/close_other_tabs" /> + <item android:id="@+id/history_menu_id" android:title="@string/tab_history" android:alphabeticShortcut="h" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 7df2a91..6fd0555 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -197,6 +197,8 @@ <string name="goto_dot">Go</string> <!-- Menu item to switch to text selection mode for copy and paste. --> <string name="select_dot">Select text</string> + <!-- Menu item to close all other tabs [CHAR LIMIT=40] --> + <string name="close_other_tabs">Close other tabs</string> <!-- Menu item to open the bookmarks page. This is a shorter version that is displayed with an icon --> <string name="bookmarks">Bookmarks</string> diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 493583d..3b5f812 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -1553,6 +1553,10 @@ public class Controller openIncognitoTab(); break; + case R.id.close_other_tabs_id: + closeOtherTabs(); + break; + case R.id.goto_menu_id: editUrl(); break; @@ -2474,6 +2478,20 @@ public class Controller } } + /** + * Close all tabs except the current one + */ + @Override + public void closeOtherTabs() { + int inactiveTabs = mTabControl.getTabCount() - 1; + for (int i = inactiveTabs; i >= 0; i--) { + Tab tab = mTabControl.getTab(i); + if (tab != mTabControl.getCurrentTab()) { + removeTab(tab); + } + } + } + // Called when loading from context menu or LOAD_URL message protected void loadUrlFromContext(String url) { Tab tab = getCurrentTab(); diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index eb6032d..e3c22bd 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -182,6 +182,14 @@ public class PhoneUi extends BaseUi { if (incognito != null) { incognito.setVisible(showingNavScreen() || mUseQuickControls); } + MenuItem closeOthers = menu.findItem(R.id.close_other_tabs_id); + if (closeOthers != null) { + boolean isLastTab = true; + if (tab != null) { + isLastTab = (mTabControl.getTabCount() <= 1); + } + closeOthers.setEnabled(!isLastTab); + } if (showingNavScreen()) { menu.setGroupVisible(R.id.LIVE_MENU, false); menu.setGroupVisible(R.id.SNAPSHOT_MENU, false); diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java index b3d4631..a2946a7 100644 --- a/src/com/android/browser/UiController.java +++ b/src/com/android/browser/UiController.java @@ -59,6 +59,8 @@ public interface UiController { void closeTab(Tab tab); + void closeOtherTabs(); + void stopLoading(); Intent createBookmarkCurrentPageIntent(boolean canBeAnEdit); |