Bug 818238: A GeckoPopupMenu for tabs-tray. [r=mfinkle]

--HG--
rename : mobile/android/base/resources/drawable-hdpi-v11/ic_menu_close_all_tabs.png => mobile/android/base/resources/drawable-hdpi/ic_menu_close_all_tabs.png
rename : mobile/android/base/resources/drawable-hdpi-v11/ic_menu_synced_tabs.png => mobile/android/base/resources/drawable-hdpi/ic_menu_synced_tabs.png
rename : mobile/android/base/resources/drawable-xhdpi-v11/ic_menu_close_all_tabs.png => mobile/android/base/resources/drawable-xhdpi/ic_menu_close_all_tabs.png
rename : mobile/android/base/resources/drawable-xhdpi-v11/ic_menu_synced_tabs.png => mobile/android/base/resources/drawable-xhdpi/ic_menu_synced_tabs.png
rename : mobile/android/base/resources/drawable-mdpi-v11/ic_menu_close_all_tabs.png => mobile/android/base/resources/drawable/ic_menu_close_all_tabs.png
rename : mobile/android/base/resources/drawable-mdpi-v11/ic_menu_synced_tabs.png => mobile/android/base/resources/drawable/ic_menu_synced_tabs.png
extra : rebase_source : 1021520012fa821a283f4dfab780a73503f4d49e
This commit is contained in:
Sriram Ramasubramanian 2012-12-04 13:13:24 -08:00
parent 7628c5cd08
commit 7de3057cc6
25 changed files with 156 additions and 104 deletions

View File

@ -408,7 +408,6 @@ RES_LAYOUT = \
res/layout/remote_tabs_group.xml \
res/layout/tabs_counter.xml \
res/layout/tabs_panel.xml \
res/layout/tabs_panel_toolbar.xml \
res/layout/tabs_panel_toolbar_menu.xml \
res/layout/tabs_row.xml \
res/layout/tabs_tray.xml \
@ -425,7 +424,6 @@ RES_LAYOUT = \
$(NULL)
RES_LAYOUT_LAND_V14 = \
res/layout-land-v14/tabs_panel_toolbar.xml \
res/layout-land-v14/tabs_panel_toolbar_menu.xml \
$(NULL)
@ -529,12 +527,15 @@ RES_DRAWABLE_BASE = \
res/drawable/ic_menu_back.xml \
res/drawable/ic_menu_bookmark_add.png \
res/drawable/ic_menu_bookmark_remove.png \
res/drawable/ic_menu_close_all_tabs.png \
res/drawable/ic_menu_desktop_mode_off.xml \
res/drawable/ic_menu_desktop_mode_on.xml \
res/drawable/ic_menu_forward.png \
res/drawable/ic_menu_new_private_tab.png \
res/drawable/ic_menu_new_tab.png \
res/drawable/ic_menu_new_private_tab_small.png \
res/drawable/ic_menu_new_tab_small.png \
res/drawable/ic_menu_reload.png \
res/drawable/ic_menu_synced_tabs.png \
res/drawable/ic_menu_quit.xml \
res/drawable/ic_status_logo.png \
res/drawable/remote_tabs_off.png \
@ -616,10 +617,14 @@ RES_DRAWABLE_HDPI = \
res/drawable-hdpi/ic_awesomebar_star.png \
res/drawable-hdpi/ic_menu_bookmark_add.png \
res/drawable-hdpi/ic_menu_bookmark_remove.png \
res/drawable-hdpi/ic_menu_close_all_tabs.png \
res/drawable-hdpi/ic_menu_forward.png \
res/drawable-hdpi/ic_menu_new_private_tab.png \
res/drawable-hdpi/ic_menu_new_private_tab_small.png \
res/drawable-hdpi/ic_menu_new_tab.png \
res/drawable-hdpi/ic_menu_new_tab_small.png \
res/drawable-hdpi/ic_menu_reload.png \
res/drawable-hdpi/ic_menu_synced_tabs.png \
res/drawable-hdpi/ic_status_logo.png \
res/drawable-hdpi/remote_tabs_off.png \
res/drawable-hdpi/remote_tabs_on.png \
@ -698,10 +703,14 @@ RES_DRAWABLE_XHDPI = \
res/drawable-xhdpi/ic_awesomebar_star.png \
res/drawable-xhdpi/ic_menu_bookmark_add.png \
res/drawable-xhdpi/ic_menu_bookmark_remove.png \
res/drawable-xhdpi/ic_menu_close_all_tabs.png \
res/drawable-xhdpi/ic_menu_forward.png \
res/drawable-xhdpi/ic_menu_new_private_tab.png \
res/drawable-xhdpi/ic_menu_new_private_tab_small.png \
res/drawable-xhdpi/ic_menu_new_tab.png \
res/drawable-xhdpi/ic_menu_new_tab_small.png \
res/drawable-xhdpi/ic_menu_reload.png \
res/drawable-xhdpi/ic_menu_synced_tabs.png \
res/drawable-xhdpi/ic_status_logo.png \
res/drawable-xhdpi/tab_new.png \
res/drawable-xhdpi/tab_close.png \
@ -750,7 +759,6 @@ RES_DRAWABLE_MDPI_V11 = \
res/drawable-mdpi-v11/ic_menu_back.png \
res/drawable-mdpi-v11/ic_menu_bookmark_add.png \
res/drawable-mdpi-v11/ic_menu_bookmark_remove.png \
res/drawable-mdpi-v11/ic_menu_close_all_tabs.png \
res/drawable-mdpi-v11/ic_menu_desktop_mode_off.png \
res/drawable-mdpi-v11/ic_menu_desktop_mode_on.png \
res/drawable-mdpi-v11/ic_menu_downloads.png \
@ -762,7 +770,6 @@ RES_DRAWABLE_MDPI_V11 = \
res/drawable-mdpi-v11/ic_menu_save_as_pdf.png \
res/drawable-mdpi-v11/ic_menu_settings.png \
res/drawable-mdpi-v11/ic_menu_share.png \
res/drawable-mdpi-v11/ic_menu_synced_tabs.png \
res/drawable-mdpi-v11/ic_menu_tools.png \
res/drawable-mdpi-v11/ic_menu_quit.png \
res/drawable-mdpi-v11/ic_status_logo.png \
@ -777,7 +784,6 @@ RES_DRAWABLE_HDPI_V11 = \
res/drawable-hdpi-v11/ic_menu_back.png \
res/drawable-hdpi-v11/ic_menu_bookmark_add.png \
res/drawable-hdpi-v11/ic_menu_bookmark_remove.png \
res/drawable-hdpi-v11/ic_menu_close_all_tabs.png \
res/drawable-hdpi-v11/ic_menu_desktop_mode_off.png \
res/drawable-hdpi-v11/ic_menu_desktop_mode_on.png \
res/drawable-hdpi-v11/ic_menu_downloads.png \
@ -789,7 +795,6 @@ RES_DRAWABLE_HDPI_V11 = \
res/drawable-hdpi-v11/ic_menu_save_as_pdf.png \
res/drawable-hdpi-v11/ic_menu_settings.png \
res/drawable-hdpi-v11/ic_menu_share.png \
res/drawable-hdpi-v11/ic_menu_synced_tabs.png \
res/drawable-hdpi-v11/ic_menu_tools.png \
res/drawable-hdpi-v11/ic_menu_quit.png \
res/drawable-hdpi-v11/ic_status_logo.png \
@ -804,7 +809,6 @@ RES_DRAWABLE_XHDPI_V11 = \
res/drawable-xhdpi-v11/ic_menu_back.png \
res/drawable-xhdpi-v11/ic_menu_bookmark_add.png \
res/drawable-xhdpi-v11/ic_menu_bookmark_remove.png \
res/drawable-xhdpi-v11/ic_menu_close_all_tabs.png \
res/drawable-xhdpi-v11/ic_menu_desktop_mode_off.png \
res/drawable-xhdpi-v11/ic_menu_desktop_mode_on.png \
res/drawable-xhdpi-v11/ic_menu_downloads.png \
@ -816,7 +820,6 @@ RES_DRAWABLE_XHDPI_V11 = \
res/drawable-xhdpi-v11/ic_menu_save_as_pdf.png \
res/drawable-xhdpi-v11/ic_menu_settings.png \
res/drawable-xhdpi-v11/ic_menu_share.png \
res/drawable-xhdpi-v11/ic_menu_synced_tabs.png \
res/drawable-xhdpi-v11/ic_menu_tools.png \
res/drawable-xhdpi-v11/ic_menu_quit.png \
res/drawable-xhdpi-v11/ic_status_logo.png \
@ -1017,7 +1020,9 @@ RES_COLOR = \
RES_MENU = \
res/menu/awesomebar_contextmenu.xml \
res/menu/gecko_app_menu.xml \
res/menu/tabs_menu.xml \
res/menu/titlebar_contextmenu.xml \
res/menu-v11/tabs_menu.xml \
$(NULL)
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar

View File

@ -17,6 +17,8 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@ -26,7 +28,8 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
public class TabsPanel extends LinearLayout
implements LightweightTheme.OnChangeListener {
implements GeckoPopupMenu.OnMenuItemClickListener,
LightweightTheme.OnChangeListener {
private static final String LOGTAG = "GeckoTabsPanel";
public static enum Panel {
@ -52,6 +55,7 @@ public class TabsPanel extends LinearLayout
private TabsListContainer mListContainer;
private TabsLayoutChangeListener mLayoutChangeListener;
private ImageButton mMenuButton;
private static ImageButton mRemoteTabs;
private TextView mTitle;
@ -59,6 +63,9 @@ public class TabsPanel extends LinearLayout
private boolean mIsSideBar;
private boolean mVisible;
private GeckoPopupMenu mPopupMenu;
private Menu mMenu;
private static final int REMOTE_TABS_HIDDEN = 1;
private static final int REMOTE_TABS_SHOWN = 2;
@ -80,6 +87,11 @@ public class TabsPanel extends LinearLayout
mToolbar = (TabsPanelToolbar) findViewById(R.id.toolbar);
mListContainer = (TabsListContainer) findViewById(R.id.list_container);
mPopupMenu = new GeckoPopupMenu(context);
mPopupMenu.inflate(R.menu.tabs_menu);
mPopupMenu.setOnMenuItemClickListener(this);
mMenu = mPopupMenu.getMenu();
initToolbar();
}
@ -102,8 +114,66 @@ public class TabsPanel extends LinearLayout
mActivity.showRemoteTabs();
}
});
mMenuButton = (ImageButton) mToolbar.findViewById(R.id.menu);
mMenuButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View view) {
TabsPanel.this.openTabsMenu();
}
});
mPopupMenu.setAnchor(mMenuButton);
}
public void openTabsMenu() {
if (mCurrentPanel == Panel.REMOTE_TABS)
mMenu.findItem(R.id.close_all_tabs).setEnabled(false);
else
mMenu.findItem(R.id.close_all_tabs).setEnabled(true);
mPopupMenu.show();
final Context context = mContext;
new SyncAccounts.AccountsExistTask() {
@Override
protected void onPostExecute(Boolean result) {
if (!result.booleanValue()) {
return;
}
TabsAccessor.areClientsAvailable(context, new TabsAccessor.OnClientsAvailableListener() {
@Override
public void areAvailable(boolean available) {
TabsPanel.this.enableRemoteTabs(available);
}
});
}
}.execute(context);
}
public void enableRemoteTabs(boolean enable) {
mMenu.findItem(R.id.synced_tabs).setEnabled(enable);
}
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
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);
}
}
private static int getTabContainerHeight(View view) {
Context context = view.getContext();
@ -183,20 +253,12 @@ public class TabsPanel extends LinearLayout
public TabsPanelToolbar(Context context, AttributeSet attrs) {
super(context, attrs);
mActivity = (BrowserApp) context;
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
(int) context.getResources().getDimension(R.dimen.browser_toolbar_height)));
int panelToolbarRes;
if (!GeckoApp.mAppContext.hasPermanentMenuKey())
panelToolbarRes = R.layout.tabs_panel_toolbar_menu;
else
panelToolbarRes = R.layout.tabs_panel_toolbar;
LayoutInflater.from(context).inflate(panelToolbarRes, this);
mActivity = (BrowserApp) context;
LayoutInflater.from(context).inflate(R.layout.tabs_panel_toolbar_menu, this);
}
@Override
@ -291,6 +353,7 @@ public class TabsPanel extends LinearLayout
public void hide() {
if (mVisible) {
mVisible = false;
mPopupMenu.dismiss();
dispatchLayoutChange(0, 0);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,39 +0,0 @@
<?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/. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
style="@style/TabRowTextAppearance"
android:gravity="center_vertical"
android:padding="10dip"
android:textSize="13sp"/>
<ImageButton android:id="@+id/remote_tabs"
android:layout_width="@dimen/browser_toolbar_height"
android:layout_height="@dimen/browser_toolbar_height"
android:padding="10dip"
android:src="@drawable/remote_tabs_level"
android:contentDescription="@string/remote_tabs"
android:background="@drawable/action_bar_button"
android:visibility="gone"/>
<ImageButton android:id="@+id/add_tab"
android:layout_width="@dimen/browser_toolbar_height"
android:layout_height="@dimen/browser_toolbar_height"
android:padding="10dip"
android:src="@drawable/tab_new"
android:contentDescription="@string/new_tab"
android:background="@drawable/action_bar_button"/>
</LinearLayout>
</merge>

View File

@ -15,7 +15,7 @@
android:gravity="center_vertical"
android:src="@drawable/menu"
android:contentDescription="@string/menu"
android:background="@android:color/black"
android:background="@drawable/menu_button"
android:paddingLeft="35dip"
android:paddingRight="10dip"
android:enabled="false"/>

View File

@ -15,7 +15,7 @@
android:gravity="center_vertical"
android:src="@drawable/menu"
android:contentDescription="@string/menu"
android:background="@android:color/black"
android:background="@drawable/menu_button"
android:paddingLeft="48dip"
android:paddingRight="14dip"
android:enabled="false"/>

View File

@ -36,6 +36,17 @@
android:layout_height="wrap_content"
android:visibility="gone"/>
<ImageButton android:id="@+id/menu"
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"
android:src="@drawable/menu"
android:contentDescription="@string/menu"
android:background="@drawable/action_bar_button"/>
</LinearLayout>
</merge>

View File

@ -18,7 +18,7 @@
</RelativeLayout>
<ImageView android:id="@+id/menu_arrow"
android:layout_width="40dip"
android:layout_width="@dimen/menu_popup_arrow_width"
android:layout_height="12dip"
android:layout_marginRight="@dimen/menu_popup_arrow_margin"
android:layout_alignRight="@id/menu_panel"

View File

@ -1,39 +0,0 @@
<?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/. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
style="@style/TabRowTextAppearance"
android:gravity="center_vertical"
android:padding="10dip"
android:textSize="16sp"/>
<ImageButton android:id="@+id/remote_tabs"
android:layout_width="@dimen/browser_toolbar_height"
android:layout_height="@dimen/browser_toolbar_height"
android:padding="12dip"
android:src="@drawable/remote_tabs_level"
android:contentDescription="@string/remote_tabs"
android:background="@drawable/action_bar_button"
android:visibility="gone"/>
<ImageButton android:id="@+id/add_tab"
android:layout_width="@dimen/browser_toolbar_height"
android:layout_height="@dimen/browser_toolbar_height"
android:padding="12dip"
android:src="@drawable/tab_new"
android:contentDescription="@string/new_tab"
android:background="@drawable/action_bar_button"/>
</LinearLayout>
</merge>

View File

@ -15,7 +15,7 @@
android:gravity="center_vertical"
android:src="@drawable/menu"
android:contentDescription="@string/menu"
android:background="@android:color/black"
android:background="@drawable/menu_button"
android:paddingLeft="42dip"
android:paddingRight="12dip"
android:enabled="false"/>

View File

@ -0,0 +1,25 @@
<?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/new_tab"
android:icon="@drawable/ic_menu_new_tab"
android:title="@string/new_tab"/>
<item android:id="@+id/new_private_tab"
android:icon="@drawable/ic_menu_new_private_tab"
android:title="@string/new_private_tab"/>
<item android:id="@+id/synced_tabs"
android:icon="@drawable/ic_menu_synced_tabs"
android:title="@string/synced_tabs"
android:enabled="false"/>
<item android:id="@+id/close_all_tabs"
android:icon="@drawable/ic_menu_close_all_tabs"
android:title="@string/close_all_tabs"/>
</menu>

View File

@ -0,0 +1,25 @@
<?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/new_tab"
android:icon="@drawable/ic_menu_new_tab_small"
android:title="@string/new_tab"/>
<item android:id="@+id/new_private_tab"
android:icon="@drawable/ic_menu_new_private_tab_small"
android:title="@string/new_private_tab"/>
<item android:id="@+id/synced_tabs"
android:icon="@drawable/ic_menu_synced_tabs"
android:title="@string/synced_tabs"
android:enabled="false"/>
<item android:id="@+id/close_all_tabs"
android:icon="@drawable/ic_menu_close_all_tabs"
android:title="@string/close_all_tabs"/>
</menu>

View File

@ -6,7 +6,6 @@
<resources>
<dimen name="tabs_counter_size">22sp</dimen>
<dimen name="menu_popup_arrow_margin">5dip</dimen>
<dimen name="widget_padding">0dp</dimen>
</resources>

View File

@ -29,8 +29,10 @@
<dimen name="local_tab_row_height">108dp</dimen>
<dimen name="menu_item_row_height">44dp</dimen>
<dimen name="menu_item_row_width">240dp</dimen>
<dimen name="menu_popup_width">256dp</dimen>
<dimen name="menu_popup_arrow_margin">5dip</dimen>
<dimen name="menu_popup_arrow_width">40dip</dimen>
<dimen name="menu_popup_offset">8dp</dimen>
<dimen name="menu_popup_width">256dp</dimen>
<dimen name="nav_button_border_width">1dp</dimen>
<dimen name="prompt_service_group_padding_size">32dp</dimen>
<dimen name="prompt_service_icon_size">72dp</dimen>