Bug 940997: Reorganize primary controls in main menu. [r=mfinkle]
|
@ -2053,6 +2053,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
Tab tab = Tabs.getInstance().getSelectedTab();
|
||||
MenuItem bookmark = aMenu.findItem(R.id.bookmark);
|
||||
MenuItem back = aMenu.findItem(R.id.back);
|
||||
MenuItem forward = aMenu.findItem(R.id.forward);
|
||||
MenuItem share = aMenu.findItem(R.id.share);
|
||||
MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
|
||||
|
@ -2068,6 +2069,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
if (tab == null || tab.getURL() == null) {
|
||||
bookmark.setEnabled(false);
|
||||
back.setEnabled(false);
|
||||
forward.setEnabled(false);
|
||||
share.setEnabled(false);
|
||||
saveAsPDF.setEnabled(false);
|
||||
|
@ -2080,6 +2082,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
bookmark.setChecked(tab.isBookmark());
|
||||
bookmark.setIcon(tab.isBookmark() ? R.drawable.ic_menu_bookmark_remove : R.drawable.ic_menu_bookmark_add);
|
||||
|
||||
back.setEnabled(tab.canDoBack());
|
||||
forward.setEnabled(tab.canDoForward());
|
||||
desktopMode.setChecked(tab.getDesktopMode());
|
||||
desktopMode.setIcon(tab.getDesktopMode() ? R.drawable.ic_menu_desktop_mode_on : R.drawable.ic_menu_desktop_mode_off);
|
||||
|
@ -2209,6 +2212,13 @@ abstract public class BrowserApp extends GeckoApp
|
|||
return true;
|
||||
}
|
||||
|
||||
if (itemId == R.id.back) {
|
||||
tab = Tabs.getInstance().getSelectedTab();
|
||||
if (tab != null)
|
||||
tab.doBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemId == R.id.forward) {
|
||||
tab = Tabs.getInstance().getSelectedTab();
|
||||
if (tab != null)
|
||||
|
|
|
@ -98,7 +98,7 @@ public class GeckoMenu extends ListView
|
|||
}
|
||||
|
||||
public GeckoMenu(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, android.R.attr.listViewStyle);
|
||||
this(context, attrs, R.attr.geckoMenuListViewStyle);
|
||||
}
|
||||
|
||||
public GeckoMenu(Context context, AttributeSet attrs, int defStyle) {
|
||||
|
@ -498,6 +498,8 @@ public class GeckoMenu extends ListView
|
|||
// URL bar can register itself as a presenter, in case it has a different place to show them.
|
||||
public static class DefaultActionItemBar extends LinearLayout
|
||||
implements ActionItemBarPresenter {
|
||||
private final int mRowHeight;
|
||||
|
||||
public DefaultActionItemBar(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
@ -505,12 +507,22 @@ public class GeckoMenu extends ListView
|
|||
public DefaultActionItemBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mRowHeight = getResources().getDimensionPixelSize(R.dimen.menu_item_row_height);
|
||||
setWeightSum(3.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addActionItem(View actionItem) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(actionItem.getLayoutParams());
|
||||
ViewGroup.LayoutParams actualParams = actionItem.getLayoutParams();
|
||||
LinearLayout.LayoutParams params;
|
||||
|
||||
if (actualParams != null) {
|
||||
params = new LinearLayout.LayoutParams(actionItem.getLayoutParams());
|
||||
params.width = 0;
|
||||
} else {
|
||||
params = new LinearLayout.LayoutParams(0, mRowHeight);
|
||||
}
|
||||
|
||||
params.weight = 1.0f;
|
||||
actionItem.setLayoutParams(params);
|
||||
addView(actionItem);
|
||||
|
|
|
@ -26,9 +26,6 @@ public class MenuItemActionBar extends ImageButton
|
|||
|
||||
public MenuItemActionBar(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
int size = (int) (context.getResources().getDimension(R.dimen.browser_toolbar_height));
|
||||
setLayoutParams(new ViewGroup.LayoutParams(size, size));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,41 +8,30 @@ package org.mozilla.gecko.menu;
|
|||
import org.mozilla.gecko.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.RelativeLayout.LayoutParams;
|
||||
|
||||
/**
|
||||
* A popup to show the inflated MenuPanel. This has an arrow pointing to the anchor.
|
||||
* A popup to show the inflated MenuPanel.
|
||||
*/
|
||||
public class MenuPopup extends PopupWindow {
|
||||
private Resources mResources;
|
||||
|
||||
private ImageView mArrowTop;
|
||||
private ImageView mArrowBottom;
|
||||
private RelativeLayout mPanel;
|
||||
private LinearLayout mPanel;
|
||||
|
||||
private int mYOffset;
|
||||
private int mArrowMargin;
|
||||
private int mPopupWidth;
|
||||
private boolean mShowArrow;
|
||||
|
||||
public MenuPopup(Context context) {
|
||||
super(context);
|
||||
mResources = context.getResources();
|
||||
|
||||
setFocusable(true);
|
||||
|
||||
mYOffset = mResources.getDimensionPixelSize(R.dimen.menu_popup_offset);
|
||||
mArrowMargin = mResources.getDimensionPixelSize(R.dimen.menu_popup_arrow_margin);
|
||||
mPopupWidth = mResources.getDimensionPixelSize(R.dimen.menu_popup_width);
|
||||
mYOffset = context.getResources().getDimensionPixelSize(R.dimen.menu_popup_offset);
|
||||
mPopupWidth = context.getResources().getDimensionPixelSize(R.dimen.menu_popup_width);
|
||||
|
||||
// Setting a null background makes the popup to not close on touching outside.
|
||||
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
|
@ -50,13 +39,9 @@ public class MenuPopup extends PopupWindow {
|
|||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.menu_popup, null);
|
||||
setContentView(layout);
|
||||
mPanel = (LinearLayout) inflater.inflate(R.layout.menu_popup, null);
|
||||
setContentView(mPanel);
|
||||
|
||||
mArrowTop = (ImageView) layout.findViewById(R.id.menu_arrow_top);
|
||||
mArrowBottom = (ImageView) layout.findViewById(R.id.menu_arrow_bottom);
|
||||
mPanel = (RelativeLayout) layout.findViewById(R.id.menu_panel);
|
||||
mShowArrow = true;
|
||||
setAnimationStyle(R.style.PopupAnimation);
|
||||
}
|
||||
|
||||
|
@ -66,52 +51,18 @@ public class MenuPopup extends PopupWindow {
|
|||
* @param view The panel view with the menu to be shown.
|
||||
*/
|
||||
public void setPanelView(View view) {
|
||||
view.setLayoutParams(new LinearLayout.LayoutParams(mPopupWidth,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
mPanel.removeAllViews();
|
||||
mPanel.addView(view);
|
||||
mPanel.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show/hide the arrow pointing to the anchor.
|
||||
*
|
||||
* @param show Show/hide the arrow.
|
||||
*/
|
||||
public void showArrowToAnchor(boolean show) {
|
||||
mShowArrow = show;
|
||||
}
|
||||
|
||||
/**
|
||||
* A small little offset for the arrow to overlap the anchor.
|
||||
* A small little offset.
|
||||
*/
|
||||
@Override
|
||||
public void showAsDropDown(View anchor) {
|
||||
if (!mShowArrow) {
|
||||
mArrowTop.setVisibility(View.GONE);
|
||||
mArrowBottom.setVisibility(View.GONE);
|
||||
showAsDropDown(anchor, 0, -mYOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
int[] anchorLocation = new int[2];
|
||||
anchor.getLocationOnScreen(anchorLocation);
|
||||
|
||||
int screenWidth = mResources.getDisplayMetrics().widthPixels;
|
||||
int arrowWidth = mResources.getDimensionPixelSize(R.dimen.menu_popup_arrow_width);
|
||||
int arrowOffset = (anchor.getWidth() - arrowWidth)/2;
|
||||
|
||||
if (anchorLocation[0] + mPopupWidth <= screenWidth) {
|
||||
// left align
|
||||
((LayoutParams) mArrowTop.getLayoutParams()).rightMargin = mPopupWidth - anchor.getWidth() + arrowOffset;
|
||||
((LayoutParams) mArrowBottom.getLayoutParams()).rightMargin = mPopupWidth - anchor.getWidth() + arrowOffset;
|
||||
} else {
|
||||
// right align
|
||||
((LayoutParams) mArrowTop.getLayoutParams()).rightMargin = screenWidth - anchorLocation[0] - anchor.getWidth()/2 - arrowWidth/2;
|
||||
((LayoutParams) mArrowBottom.getLayoutParams()).rightMargin = mArrowMargin;
|
||||
}
|
||||
|
||||
// shown below anchor
|
||||
mArrowTop.setVisibility(View.VISIBLE);
|
||||
mArrowBottom.setVisibility(View.GONE);
|
||||
showAsDropDown(anchor, 0, -mYOffset);
|
||||
}
|
||||
}
|
||||
|
|
Двоичные данные
mobile/android/base/resources/drawable-hdpi-v11/ic_menu_back.png
До Ширина: | Высота: | Размер: 393 B После Ширина: | Высота: | Размер: 1.5 KiB |
Двоичные данные
mobile/android/base/resources/drawable-hdpi/ic_menu_share.png
До Ширина: | Высота: | Размер: 757 B После Ширина: | Высота: | Размер: 2.0 KiB |
После Ширина: | Высота: | Размер: 393 B |
После Ширина: | Высота: | Размер: 278 B |
После Ширина: | Высота: | Размер: 593 B |
Двоичные данные
mobile/android/base/resources/drawable-mdpi-v11/ic_menu_back.png
До Ширина: | Высота: | Размер: 278 B После Ширина: | Высота: | Размер: 1.3 KiB |
Двоичные данные
mobile/android/base/resources/drawable-mdpi/ic_menu_share.png
До Ширина: | Высота: | Размер: 573 B После Ширина: | Высота: | Размер: 1.6 KiB |
До Ширина: | Высота: | Размер: 593 B После Ширина: | Высота: | Размер: 1.7 KiB |
Двоичные данные
mobile/android/base/resources/drawable-xhdpi/ic_menu_share.png
До Ширина: | Высота: | Размер: 1.0 KiB После Ширина: | Высота: | Размер: 2.4 KiB |
|
@ -12,6 +12,4 @@
|
|||
android:layout_width="@dimen/menu_item_row_width"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:orientation="horizontal"
|
||||
android:divider="@drawable/divider_vertical"
|
||||
android:showDividers="middle"
|
||||
android:dividerPadding="0dip"/>
|
||||
android:background="#FFD6DEE4"/>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
android:layout_width="0dip"
|
||||
android:layout_height="@dimen/menu_item_row_height"
|
||||
android:layout_weight="1.0"
|
||||
android:padding="10dip"
|
||||
android:padding="8dip"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
|
|
@ -3,35 +3,14 @@
|
|||
- 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/. -->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/menu_panel"
|
||||
android:layout_width="@dimen/menu_popup_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:minWidth="@dimen/menu_popup_width"
|
||||
android:background="@drawable/menu_popup_bg">
|
||||
|
||||
<RelativeLayout android:id="@+id/menu_panel"
|
||||
android:layout_width="@dimen/menu_popup_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/menu_popup_bg">
|
||||
<!-- MenuPanel will be added here dynamically -->
|
||||
|
||||
<!-- MenuPanel will be added here dynamically -->
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView android:id="@+id/menu_arrow_top"
|
||||
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"
|
||||
android:src="@drawable/menu_popup_arrow_top"
|
||||
android:scaleType="fitXY"/>
|
||||
|
||||
<ImageView android:id="@+id/menu_arrow_bottom"
|
||||
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"
|
||||
android:layout_alignBottom="@id/menu_panel"
|
||||
android:src="@drawable/menu_popup_arrow_bottom"
|
||||
android:scaleType="fitXY"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -10,19 +10,24 @@
|
|||
android:title="@string/reload"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
<item android:id="@+id/back"
|
||||
android:icon="@drawable/ic_menu_back"
|
||||
android:title="@string/back"
|
||||
android:visible="false"/>
|
||||
|
||||
<item android:id="@+id/forward"
|
||||
android:icon="@drawable/ic_menu_forward"
|
||||
android:title="@string/forward"
|
||||
android:visible="false"/>
|
||||
|
||||
<item android:id="@+id/bookmark"
|
||||
android:icon="@drawable/ic_menu_bookmark_add"
|
||||
android:title="@string/bookmark"/>
|
||||
|
||||
<item android:id="@+id/share"
|
||||
android:icon="@drawable/ic_menu_share"
|
||||
android:title="@string/share" />
|
||||
|
||||
<item android:id="@+id/bookmark"
|
||||
android:icon="@drawable/ic_menu_bookmark_add"
|
||||
android:title="@string/bookmark"/>
|
||||
|
||||
<item android:id="@+id/new_tab"
|
||||
android:icon="@drawable/ic_menu_new_tab"
|
||||
android:title="@string/new_tab"/>
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:id="@+id/back"
|
||||
android:icon="@drawable/ic_menu_back"
|
||||
android:title="@string/back"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
<item android:id="@+id/forward"
|
||||
android:icon="@drawable/ic_menu_forward"
|
||||
android:title="@string/forward"
|
||||
|
@ -15,15 +20,14 @@
|
|||
android:title="@string/reload"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
<item android:id="@+id/bookmark"
|
||||
android:icon="@drawable/ic_menu_bookmark_add"
|
||||
android:title="@string/bookmark"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
<item android:id="@+id/share"
|
||||
android:icon="@drawable/ic_menu_share"
|
||||
android:title="@string/share" />
|
||||
|
||||
<item android:id="@+id/bookmark"
|
||||
android:icon="@drawable/ic_menu_bookmark_add"
|
||||
android:title="@string/bookmark"/>
|
||||
|
||||
<item android:id="@+id/new_tab"
|
||||
android:icon="@drawable/ic_menu_new_tab"
|
||||
android:title="@string/new_tab"/>
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
android:title="@string/reload"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
<item android:id="@+id/back"
|
||||
android:icon="@drawable/ic_menu_back"
|
||||
android:title="@string/back"
|
||||
android:visible="false"/>
|
||||
|
||||
<item android:id="@+id/forward"
|
||||
android:icon="@drawable/ic_menu_forward"
|
||||
android:title="@string/forward"
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
android:icon="@drawable/ic_menu_reload"
|
||||
android:title="@string/reload"/>
|
||||
|
||||
<item android:id="@+id/back"
|
||||
android:icon="@drawable/ic_menu_back"
|
||||
android:title="@string/back"
|
||||
android:visible="false"/>
|
||||
|
||||
<item android:id="@+id/forward"
|
||||
android:icon="@drawable/ic_menu_forward"
|
||||
android:title="@string/forward"/>
|
||||
|
|
|
@ -61,6 +61,14 @@
|
|||
<item name="android:paddingRight">0dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.MenuItemActionBar">
|
||||
<item name="android:layout_width">@dimen/browser_toolbar_height</item>
|
||||
<item name="android:layout_height">@dimen/browser_toolbar_height</item>
|
||||
<item name="android:padding">@dimen/browser_toolbar_button_padding</item>
|
||||
<item name="android:background">@drawable/action_bar_button</item>
|
||||
<item name="android:scaleType">fitCenter</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.BookmarksListView" parent="Widget.HomeListView">
|
||||
<item name="android:paddingTop">30dp</item>
|
||||
<item name="android:paddingLeft">32dp</item>
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
<item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
|
||||
<item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
|
||||
<item name="homeListViewStyle">@style/Widget.HomeListView</item>
|
||||
<item name="geckoMenuListViewStyle">@style/Widget.GeckoMenuListView</item>
|
||||
<item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
|
||||
<item name="android:actionModeStyle">@style/GeckoActionBar</item>
|
||||
<item name="android:actionButtonStyle">@style/GeckoActionBar.Button</item>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
<!-- Theme level attributes -->
|
||||
<declare-styleable name="GeckoTheme">
|
||||
|
||||
<!-- Style for GeckoMenu ListView -->
|
||||
<attr name="geckoMenuListViewStyle" format="reference"/>
|
||||
|
||||
<!-- Style for MenuItemActionBar -->
|
||||
<attr name="menuItemActionBarStyle" format="reference"/>
|
||||
|
||||
|
|
|
@ -74,8 +74,12 @@
|
|||
<item name="android:minWidth">@dimen/doorhanger_input_width</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.GeckoMenuListView" parent="Widget.ListView">
|
||||
<item name="android:divider">#FFC9D3DC</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.MenuItemActionBar">
|
||||
<item name="android:padding">@dimen/browser_toolbar_button_padding</item>
|
||||
<item name="android:padding">8dip</item>
|
||||
<item name="android:background">@drawable/action_bar_button</item>
|
||||
<item name="android:scaleType">fitCenter</item>
|
||||
</style>
|
||||
|
@ -88,7 +92,7 @@
|
|||
</style>
|
||||
|
||||
<style name="Widget.MenuItemShareActionButton">
|
||||
<item name="android:padding">10dip</item>
|
||||
<item name="android:padding">8dip</item>
|
||||
<item name="android:background">@drawable/action_bar_button</item>
|
||||
<item name="android:scaleType">centerInside</item>
|
||||
</style>
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
|
||||
<item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
|
||||
<item name="homeListViewStyle">@style/Widget.HomeListView</item>
|
||||
<item name="geckoMenuListViewStyle">@style/Widget.GeckoMenuListView</item>
|
||||
<item name="menuItemDefaultStyle">@style/Widget.MenuItemDefault</item>
|
||||
<item name="menuItemActionBarStyle">@style/Widget.MenuItemActionBar</item>
|
||||
<item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
|
||||
|
|
|
@ -137,15 +137,6 @@ public class GeckoPopupMenu implements GeckoMenu.Callback,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show/hide the arrow pointing to the anchor.
|
||||
*
|
||||
* @param show Show/hide the arrow.
|
||||
*/
|
||||
public void showArrowToAnchor(boolean show) {
|
||||
mMenuPopup.showArrowToAnchor(show);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(MenuItem item) {
|
||||
if (mClickListener != null)
|
||||
|
|