Bug 817706: Tablets should have a drop-down tabs-switcher. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Tue, 18 Dec 2012 16:45:55 -0800
changeset 125826 7998f3adb4c5ba142c65e0759b7779b9ed05c3de
parent 125825 296cc3ea6e9e4cec791933e481aef825760a6430
child 125827 53952a6be9cfa10f4c9a68604d6ea353dbb5e9a0
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs817706
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 817706: Tablets should have a drop-down tabs-switcher. [r=mfinkle]
mobile/android/base/Makefile.in
mobile/android/base/TabsPanel.java
mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar_menu.xml
mobile/android/base/resources/layout-large-v11/tabs_panel_toolbar_menu.xml
mobile/android/base/resources/layout-xlarge-v11/tabs_panel_toolbar_menu.xml
mobile/android/base/resources/layout/tabs_panel_toolbar_menu.xml
mobile/android/base/resources/menu/tabs_switcher_menu.xml
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -1007,16 +1007,17 @@ RES_COLOR = \
   res/color/select_item_multichoice.xml \
   res/color/tabs_counter_color.xml \
   $(NULL)
 
 RES_MENU = \
   res/menu/awesomebar_contextmenu.xml \
   res/menu/gecko_app_menu.xml \
   res/menu/tabs_menu.xml \
+  res/menu/tabs_switcher_menu.xml \
   res/menu/titlebar_contextmenu.xml \
   res/menu-v11/tabs_menu.xml \
   $(NULL)
 
 JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
 
 ifdef MOZ_CRASHREPORTER
 FENNEC_PP_JAVA_FILES += CrashReporter.java
--- a/mobile/android/base/TabsPanel.java
+++ b/mobile/android/base/TabsPanel.java
@@ -56,25 +56,29 @@ public class TabsPanel extends TabHost
     private GeckoApp mActivity;
     private PanelView mPanel;
     private TabsPanelToolbar mToolbar;
     private TabsLayoutChangeListener mLayoutChangeListener;
 
     private static ImageButton mMenuButton;
     private static ImageButton mAddTab;
     private TabWidget mTabWidget;
+    private Button mTabsMenuButton;
 
     private Panel mCurrentPanel;
     private boolean mIsSideBar;
     private boolean mVisible;
     private boolean mInflated;
 
     private GeckoPopupMenu mPopupMenu;
     private Menu mMenu;
 
+    private GeckoPopupMenu mTabsPopupMenu;
+    private Menu mTabsMenu;
+
     private static final int REMOTE_TABS_HIDDEN = 1;
     private static final int REMOTE_TABS_SHOWN = 2;
 
     public TabsPanel(Context context, AttributeSet attrs) {
         super(context, attrs);
         mContext = context;
         mActivity = (GeckoApp) context;
 
@@ -85,16 +89,21 @@ public class TabsPanel extends TabHost
         mIsSideBar = a.getBoolean(R.styleable.TabsPanel_sidebar, false);
         a.recycle();
 
         mPopupMenu = new GeckoPopupMenu(context);
         mPopupMenu.inflate(R.menu.tabs_menu);
         mPopupMenu.setOnMenuItemClickListener(this);
         mMenu = mPopupMenu.getMenu();
 
+        mTabsPopupMenu = new GeckoPopupMenu(context);
+        mTabsPopupMenu.inflate(R.menu.tabs_switcher_menu);
+        mTabsPopupMenu.setOnMenuItemClickListener(this);
+        mTabsMenu = mTabsPopupMenu.getMenu();
+
         LayoutInflater.from(context).inflate(R.layout.tabs_panel, this);
     }
 
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
 
         // HACK: Without this, the onFinishInflate is called twice
@@ -158,16 +167,25 @@ public class TabsPanel extends TabHost
         mAddTab = (ImageButton) mToolbar.findViewById(R.id.add_tab);
         mAddTab.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
                 mActivity.addTab();
                 mActivity.autoHideTabs();
             }
         });
 
+        mTabsMenuButton = (Button) mToolbar.findViewById(R.id.tabs_menu);
+        mTabsMenuButton.setOnClickListener(new Button.OnClickListener() {
+            public void onClick(View view) {
+                TabsPanel.this.openTabsSwitcherMenu();
+            }
+        });
+
+        mTabsPopupMenu.setAnchor(mTabsMenuButton);
+
         mMenuButton = (ImageButton) mToolbar.findViewById(R.id.menu);
         mMenuButton.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View view) {
                 TabsPanel.this.openTabsMenu();
             }
         });
 
         // Set a touch delegate to Add-Tab button, so the touch events on its tail
@@ -212,27 +230,48 @@ public class TabsPanel extends TabHost
             }
         }.execute(context);
     }
 
     public void enableRemoteTabs(boolean enable) {
         mMenu.findItem(R.id.synced_tabs).setEnabled(enable);
     }
 
+    public void openTabsSwitcherMenu() {
+        mTabsPopupMenu.show();
+    }
+
     @Override
     public boolean onMenuItemClick(MenuItem item) {
         switch (item.getItemId()) {
+            case R.id.tabs_normal:
+                mTabsMenuButton.setText(R.string.tabs_normal);
+                show(Panel.NORMAL_TABS);
+                return true;
+
+            case R.id.tabs_private:
+                mTabsMenuButton.setText(R.string.tabs_private);
+                show(Panel.PRIVATE_TABS);
+                return true;
+
+            case R.id.tabs_synced:
+                mTabsMenuButton.setText(R.string.tabs_synced);
+                show(Panel.REMOTE_TABS);
+                return true;
+
             case R.id.synced_tabs:
                 show(Panel.REMOTE_TABS);
                 return true;
+
             case R.id.close_all_tabs:
                 for (Tab tab : Tabs.getInstance().getTabsInOrder()) {
                     Tabs.getInstance().closeTab(tab);
                 }
                 return true;
+
             case R.id.new_tab:
             case R.id.new_private_tab:
                 hide();
             // fall through
             default:
                 return mActivity.onOptionsItemSelected(item);
         }
     }  
--- a/mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar_menu.xml
+++ b/mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar_menu.xml
@@ -24,16 +24,20 @@
                       android:layout_height="fill_parent"
                       android:layout_marginRight="15dip">
 
             <TabWidget android:id="@android:id/tabs"
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1.0"/>
 
+            <Button android:id="@+id/tabs_menu"
+                    android:layout_width="0dip"
+                    android:layout_height="0dip"
+                    android:visibility="gone"/>
 
             <org.mozilla.gecko.TabsPanelButton android:id="@+id/add_tab"
                                                android:layout_width="63dip"
                                                android:layout_height="@dimen/browser_toolbar_height"
                                                android:gravity="center_vertical"
                                                android:paddingLeft="10dip"
                                                android:paddingRight="33dip"
                                                android:src="@drawable/tab_new"
--- a/mobile/android/base/resources/layout-large-v11/tabs_panel_toolbar_menu.xml
+++ b/mobile/android/base/resources/layout-large-v11/tabs_panel_toolbar_menu.xml
@@ -24,16 +24,21 @@
                       android:layout_height="fill_parent"
                       android:layout_marginRight="28dip">
 
             <TabWidget android:id="@android:id/tabs"
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1.0"/>
 
+            <Button android:id="@+id/tabs_menu"
+                    android:layout_width="0dip"
+                    android:layout_height="0dip"
+                    android:visibility="gone"/>
+
             <org.mozilla.gecko.TabsPanelButton android:id="@+id/add_tab"
                                                android:layout_width="85dip"
                                                android:layout_height="@dimen/browser_toolbar_height"
                                                android:gravity="center_vertical"
                                                android:paddingLeft="14dip"
                                                android:paddingRight="43dip"
                                                android:src="@drawable/tab_new"
                                                android:contentDescription="@string/new_tab"
--- a/mobile/android/base/resources/layout-xlarge-v11/tabs_panel_toolbar_menu.xml
+++ b/mobile/android/base/resources/layout-xlarge-v11/tabs_panel_toolbar_menu.xml
@@ -5,18 +5,26 @@
 
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
 
     <LinearLayout android:layout_width="fill_parent"
                   android:layout_height="fill_parent">
 
         <TabWidget android:id="@android:id/tabs"
                    android:layout_width="0dip"
-                   android:layout_height="fill_parent"
-                   android:layout_weight="1.0"/>
+                   android:layout_height="0dip"
+                   android:visibility="gone"/>
+
+        <Button android:id="@+id/tabs_menu"
+                android:layout_width="0dip"
+                android:layout_height="fill_parent"
+                android:layout_weight="1.0"
+                android:text="@string/tabs_normal"
+                android:textColor="@color/tabs_counter_color"
+                android:background="@drawable/action_bar_button"/>
 
         <ImageButton android:id="@+id/add_tab"
                      android:layout_width="@dimen/browser_toolbar_height"
                      android:layout_height="@dimen/browser_toolbar_height"
                      android:paddingTop="15dip"
                      android:paddingBottom="15dip"
                      android:paddingLeft="20dip"
                      android:paddingRight="20dip"
--- a/mobile/android/base/resources/layout/tabs_panel_toolbar_menu.xml
+++ b/mobile/android/base/resources/layout/tabs_panel_toolbar_menu.xml
@@ -24,16 +24,21 @@
                       android:layout_height="fill_parent"
                       android:layout_marginRight="22dip">
 
             <TabWidget android:id="@android:id/tabs"
                        android:layout_width="0dip"
                        android:layout_height="fill_parent"
                        android:layout_weight="1.0"/>
 
+            <Button android:id="@+id/tabs_menu"
+                    android:layout_width="0dip"
+                    android:layout_height="0dip"
+                    android:visibility="gone"/>
+
             <org.mozilla.gecko.TabsPanelButton android:id="@+id/add_tab"
                                                android:layout_width="75dip"
                                                android:layout_height="@dimen/browser_toolbar_height"
                                                android:gravity="center_vertical"
                                                android:paddingLeft="12dip"
                                                android:paddingRight="39dip"
                                                android:src="@drawable/tab_new"
                                                android:contentDescription="@string/new_tab"
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/menu/tabs_switcher_menu.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@+id/tabs_normal"
+          android:title="@string/tabs_normal"/>
+
+    <item android:id="@+id/tabs_private"
+          android:title="@string/tabs_private"/>
+
+    <item android:id="@+id/tabs_synced"
+          android:title="@string/tabs_synced"/>
+
+</menu>