summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/menu/browser.xml3
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/com/android/browser/Controller.java18
-rw-r--r--src/com/android/browser/PhoneUi.java8
-rw-r--r--src/com/android/browser/UiController.java2
5 files changed, 33 insertions, 0 deletions
diff --git a/res/menu/browser.xml b/res/menu/browser.xml
index bd40c51e..b8473163 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 6a1a6f1f..d1c97f59 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 8238d772..a53e3441 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1546,6 +1546,10 @@ public class Controller
openIncognitoTab();
break;
+ case R.id.close_other_tabs_id:
+ closeOtherTabs();
+ break;
+
case R.id.goto_menu_id:
editUrl();
break;
@@ -2419,6 +2423,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 4da0668a..9104095d 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -214,6 +214,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 e7a8953b..b97ae10b 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);