Bug 817706: Tablets should have a drop-down tabs-switcher. [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2012-12-18 16:45:55 -08:00
parent c2a7bc048d
commit d9059a59a2
7 changed files with 81 additions and 2 deletions

View File

@ -1012,6 +1012,7 @@ 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)

View File

@ -61,6 +61,7 @@ public class TabsPanel extends TabHost
private static ImageButton mMenuButton;
private static ImageButton mAddTab;
private TabWidget mTabWidget;
private Button mTabsMenuButton;
private Panel mCurrentPanel;
private boolean mIsSideBar;
@ -70,6 +71,9 @@ public class TabsPanel extends TabHost
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;
@ -90,6 +94,11 @@ public class TabsPanel extends TabHost
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);
}
@ -163,6 +172,15 @@ public class TabsPanel extends TabHost
}
});
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) {
@ -217,17 +235,38 @@ public class TabsPanel extends TabHost
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();

View File

@ -29,6 +29,10 @@
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"

View File

@ -29,6 +29,11 @@
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"

View File

@ -10,8 +10,16 @@
<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"

View File

@ -29,6 +29,11 @@
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"

View File

@ -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>