diff options
author | Afzal Najam <afzal411+android@gmail.com> | 2012-04-26 01:54:01 -0400 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2012-05-17 12:30:15 -0700 |
commit | d4e3331a3cfa368e8e26f18700ed3474a24ff553 (patch) | |
tree | 36214ab3b297eeba99e6e2b1c52982a06c41ab5f /src/com/android/browser | |
parent | d6c13e1635ddb4cb42d120c2dfdca1ada6d1a7b2 (diff) | |
download | packages_apps_Browser-d4e3331a3cfa368e8e26f18700ed3474a24ff553.zip packages_apps_Browser-d4e3331a3cfa368e8e26f18700ed3474a24ff553.tar.gz packages_apps_Browser-d4e3331a3cfa368e8e26f18700ed3474a24ff553.tar.bz2 |
Added a menu item in Browser called Close other tabs
This closes all other tabs except the current one (only for the phone interface)
Will submit patch for tablet interface once this is approved.
It solves the problem of mass closing unneeded tabs to a certain extent.
Preferred method would be to select multiple tabs like list items.
Change-Id: I5af00f1c19043104987375f1da396eb6fefb5dd4
Diffstat (limited to 'src/com/android/browser')
-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 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 8238d77..a53e344 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 4da0668..9104095 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 e7a8953..b97ae10 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); |