Bug 1028705 - Move new tab button back to the right. r=lucasr

This commit is contained in:
Chenxia Liu 2014-07-11 09:59:58 -07:00
parent de67a29cae
commit 3f89f2e244
4 changed files with 31 additions and 18 deletions

View File

@ -2299,8 +2299,10 @@ public class BrowserApp extends GeckoApp
@Override
public void openOptionsMenu() {
if (!hasTabsSideBar() && areTabsShown())
if (areTabsShown()) {
mTabsPanel.showMenu();
return;
}
// Scroll custom menu to the top
if (mMenuPanel != null)

View File

@ -24,6 +24,7 @@
android:padding="@dimen/browser_toolbar_button_padding"
android:src="@drawable/menu_tabs"
android:contentDescription="@string/menu"
android:background="@drawable/action_bar_button"/>
android:background="@drawable/action_bar_button"
android:visibility="gone"/>
</merge>

View File

@ -32,6 +32,7 @@
android:padding="@dimen/browser_toolbar_button_padding"
android:src="@drawable/menu_tabs"
android:contentDescription="@string/menu"
android:background="@drawable/action_bar_button"/>
android:background="@drawable/action_bar_button"
android:visibility="gone"/>
</merge>

View File

@ -17,6 +17,7 @@ import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.widget.GeckoPopupMenu;
import org.mozilla.gecko.widget.IconTabWidget;
@ -172,20 +173,23 @@ public class TabsPanel extends LinearLayout
mMenuButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View view) {
final Menu menu = mPopupMenu.getMenu();
// Each panel has a "+" shortcut button, so don't show it for that panel.
menu.findItem(R.id.new_tab).setVisible(mCurrentPanel != Panel.NORMAL_TABS);
menu.findItem(R.id.new_private_tab).setVisible(mCurrentPanel != Panel.PRIVATE_TABS);
// Only show "Clear * tabs" for current panel.
menu.findItem(R.id.close_all_tabs).setVisible(mCurrentPanel == Panel.NORMAL_TABS);
menu.findItem(R.id.close_private_tabs).setVisible(mCurrentPanel == Panel.PRIVATE_TABS);
mPopupMenu.show();
showMenu();
}
});
mPopupMenu.setAnchor(mMenuButton);
}
public void showMenu() {
final Menu menu = mPopupMenu.getMenu();
// Each panel has a "+" shortcut button, so don't show it for that panel.
menu.findItem(R.id.new_tab).setVisible(mCurrentPanel != Panel.NORMAL_TABS);
menu.findItem(R.id.new_private_tab).setVisible(mCurrentPanel != Panel.PRIVATE_TABS);
// Only show "Clear * tabs" for current panel.
menu.findItem(R.id.close_all_tabs).setVisible(mCurrentPanel == Panel.NORMAL_TABS);
menu.findItem(R.id.close_private_tabs).setVisible(mCurrentPanel == Panel.PRIVATE_TABS);
mPopupMenu.show();
}
private void addTab() {
@ -427,7 +431,7 @@ public class TabsPanel extends LinearLayout
mAddTab.setVisibility(View.INVISIBLE);
mMenuButton.setVisibility(View.INVISIBLE);
mMenuButton.setVisibility(View.GONE);
} else {
if (mFooter != null)
mFooter.setVisibility(View.VISIBLE);
@ -435,8 +439,13 @@ public class TabsPanel extends LinearLayout
mAddTab.setVisibility(View.VISIBLE);
mAddTab.setImageLevel(index);
mMenuButton.setVisibility(View.VISIBLE);
mMenuButton.setEnabled(true);
if (!HardwareUtils.hasMenuButton()) {
mMenuButton.setVisibility(View.VISIBLE);
mPopupMenu.setAnchor(mMenuButton);
} else {
mPopupMenu.setAnchor(mAddTab);
}
}
if (isSideBar()) {