Bug 739412: Support custom menu for post-honeycomb devices. [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2012-05-31 11:12:24 -07:00
parent 0aea04dac9
commit 77ab15397d
95 changed files with 1645 additions and 316 deletions

View File

@ -5,33 +5,44 @@
package org.mozilla.gecko;
import java.util.List;
import java.util.ArrayList;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.animation.TranslateAnimation;
import android.view.Gravity;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewConfiguration;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import android.widget.TextSwitcher;
import android.widget.ViewSwitcher;
public class BrowserToolbar implements ViewSwitcher.ViewFactory {
public class BrowserToolbar implements ViewSwitcher.ViewFactory,
GeckoMenu.ActionItemBarPresenter {
private static final String LOGTAG = "GeckoToolbar";
private LinearLayout mLayout;
private Button mAwesomeBar;
@ -44,13 +55,20 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory {
private AnimationDrawable mProgressSpinner;
private TextSwitcher mTabsCount;
private ImageView mShadow;
private LayoutInflater mInflater;
private ImageButton mMenu;
private LinearLayout mActionItemBar;
private MenuPopup mMenuPopup;
private View mMenuPanel;
final private Context mContext;
private LayoutInflater mInflater;
private Handler mHandler;
private int mColor;
private int[] mPadding;
private boolean mTitleCanExpand;
private boolean mHasSoftMenuButton;
private static List<View> sActionItems;
private int mDuration;
private TranslateAnimation mSlideUpIn;
@ -63,6 +81,9 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory {
public BrowserToolbar(Context context) {
mContext = context;
mInflater = LayoutInflater.from(context);
mMenuPopup = new MenuPopup(mContext);
sActionItems = new ArrayList<View>();
}
public void from(LinearLayout layout) {
@ -172,6 +193,44 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory {
mSlideUpOut.setDuration(mDuration);
mSlideDownIn.setDuration(mDuration);
mSlideDownOut.setDuration(mDuration);
mMenu = (ImageButton) mLayout.findViewById(R.id.menu);
mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items);
mHasSoftMenuButton = false;
if (Build.VERSION.SDK_INT >= 11)
mHasSoftMenuButton = true;
if (Build.VERSION.SDK_INT >= 14) {
if(!ViewConfiguration.get(GeckoApp.mAppContext).hasPermanentMenuKey())
mHasSoftMenuButton = true;
else
mHasSoftMenuButton = false;
}
if (mHasSoftMenuButton) {
mMenu.setVisibility(View.VISIBLE);
mMenu.setOnClickListener(new Button.OnClickListener() {
public void onClick(View view) {
GeckoApp.mAppContext.openOptionsMenu();
}
});
mMenuPanel = GeckoApp.mAppContext.getMenuPanel();
// If mMenuPanel is null, the app is starting up for the first time;
// else, browser-toolbar is initialized on rotation,
// and we need to re-attach action-bar items.
if (mMenuPanel == null) {
GeckoApp.mAppContext.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null);
mMenuPanel = GeckoApp.mAppContext.getMenuPanel();
mMenuPopup.setPanelView(mMenuPanel);
} else if (sActionItems.size() > 0) {
for (View view : sActionItems)
addActionItem(view);
}
}
}
@Override
@ -338,6 +397,31 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory {
mForward.setEnabled(enabled);
}
public boolean hasSoftMenuButton() {
return mHasSoftMenuButton;
}
@Override
public void addActionItem(View actionItem) {
mActionItemBar.addView(actionItem);
if (!sActionItems.contains(actionItem))
sActionItems.add(actionItem);
}
@Override
public void removeActionItem(View actionItem) {
mActionItemBar.removeView(actionItem);
if (sActionItems.contains(actionItem))
sActionItems.remove(actionItem);
}
@Override
public int getActionItemsCount() {
return sActionItems.size();
}
public void show() {
if (Build.VERSION.SDK_INT >= 11)
GeckoActionBar.show(GeckoApp.mAppContext);
@ -366,4 +450,75 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory {
updateForwardButton(tab.canDoForward());
}
}
public void destroy() {
// The action-items views are reused on rotation.
// Remove them from their parent, so they can be re-attached to new parent.
mActionItemBar.removeAllViews();
}
public void openOptionsMenu() {
if (mMenuPopup != null && !mMenuPopup.isShowing())
mMenuPopup.show(mMenu);
}
public void closeOptionsMenu() {
if (mMenuPopup != null && mMenuPopup.isShowing())
mMenuPopup.dismiss();
}
// MenuPopup holds the MenuPanel in Honeycomb/ICS devices with no hardware key
public class MenuPopup extends PopupWindow {
private ImageView mArrow;
private RelativeLayout mPanel;
public MenuPopup(Context context) {
super(context);
setFocusable(true);
// Setting a null background makes the popup to not close on touching outside.
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = LayoutInflater.from(context);
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.menu_popup, null);
setContentView(layout);
mArrow = (ImageView) layout.findViewById(R.id.menu_arrow);
mPanel = (RelativeLayout) layout.findViewById(R.id.menu_panel);
}
public void setPanelView(View view) {
mPanel.removeAllViews();
mPanel.addView(view);
}
public void show(View anchor) {
showAsDropDown(anchor);
int location[] = new int[2];
anchor.getLocationOnScreen(location);
int menuButtonWidth = anchor.getWidth();
int arrowWidth = mArrow.getWidth();
int rightMostEdge = location[0] + menuButtonWidth;
DisplayMetrics metrics = new DisplayMetrics();
GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int leftMargin = (int)(240 * metrics.density) - (metrics.widthPixels - location[0] - menuButtonWidth/2);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mArrow.getLayoutParams();
RelativeLayout.LayoutParams newParams = new RelativeLayout.LayoutParams(params);
newParams.setMargins(leftMargin,
params.topMargin,
0,
params.bottomMargin);
// From the left of popup, the arrow should move half of (menuButtonWidth - arrowWidth)
mArrow.setLayoutParams(newParams);
}
}
}

View File

@ -89,6 +89,7 @@ abstract public class GeckoApp
public static SurfaceView cameraView;
public static GeckoApp mAppContext;
public static boolean mDOMFullScreen = false;
private MenuPanel mMenuPanel;
public static Menu sMenu;
private static GeckoThread sGeckoThread = null;
public Handler mMainHandler;
@ -122,6 +123,7 @@ abstract public class GeckoApp
public boolean onMenuItemClick(MenuItem item) {
Log.i(LOGTAG, "menu item clicked");
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Menu:Clicked", Integer.toString(id)));
((Activity) GeckoApp.mAppContext).closeOptionsMenu();
return true;
}
}
@ -360,8 +362,13 @@ abstract public class GeckoApp
public boolean onCreateOptionsMenu(Menu menu)
{
sMenu = menu;
// Inform the menu about the action-items bar.
if (menu instanceof GeckoMenu && isTablet())
((GeckoMenu) menu).setActionItemBarPresenter(mBrowserToolbar);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.gecko_menu, menu);
inflater.inflate(R.menu.gecko_menu, sMenu);
return true;
}
@ -450,6 +457,120 @@ abstract public class GeckoApp
return true;
}
@Override
public void openOptionsMenu() {
if (mBrowserToolbar.hasSoftMenuButton()) {
onPreparePanel(Window.FEATURE_OPTIONS_PANEL, mMenuPanel, sMenu);
mBrowserToolbar.openOptionsMenu();
} else {
super.openOptionsMenu();
}
}
@Override
public void closeOptionsMenu() {
if (mBrowserToolbar.hasSoftMenuButton())
mBrowserToolbar.closeOptionsMenu();
else
super.closeOptionsMenu();
}
@Override
public MenuInflater getMenuInflater() {
if (Build.VERSION.SDK_INT >= 11)
return new GeckoMenuInflater(mAppContext);
else
return super.getMenuInflater();
}
public View getMenuPanel() {
return mMenuPanel;
}
// MenuPanel holds the scrollable Menu
public static class MenuPanel extends ScrollView {
public MenuPanel(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getChildCount() == 0) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
int restrictedHeightSpec;
int childHeight = getChildAt(0).getHeight();
DisplayMetrics metrics = new DisplayMetrics();
((Activity) GeckoApp.mAppContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);
// heightPixels changes during rotation.
int preferredHeight = (int) (0.75 * metrics.heightPixels);
restrictedHeightSpec = MeasureSpec.makeMeasureSpec(childHeight <= preferredHeight ? childHeight : preferredHeight, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, restrictedHeightSpec);
}
}
@Override
public View onCreatePanelView(int featureId) {
if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL) {
if (mMenuPanel == null) {
mMenuPanel = new MenuPanel(mAppContext, null);
} else {
// Prepare the panel everytime before showing the menu.
onPreparePanel(featureId, mMenuPanel, sMenu);
}
return mMenuPanel;
}
return super.onCreatePanelView(featureId);
}
@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL) {
if (mMenuPanel == null) {
mMenuPanel = (MenuPanel) onCreatePanelView(featureId);
}
GeckoMenu gMenu = new GeckoMenu(mAppContext, null);
menu = gMenu;
mMenuPanel.addView(gMenu);
return onCreateOptionsMenu(menu);
}
return super.onCreatePanelMenu(featureId, menu);
}
@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL)
return onPrepareOptionsMenu(menu);
return super.onPreparePanel(featureId, view, menu);
}
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL) {
if (sMenu == null) {
onCreatePanelMenu(featureId, menu);
onPreparePanel(featureId, mMenuPanel, sMenu);
}
return true;
}
return super.onMenuOpened(featureId, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Tab tab = null;
@ -1595,24 +1716,10 @@ abstract public class GeckoApp
public void refreshActionBar() {
if (Build.VERSION.SDK_INT >= 11) {
LinearLayout actionBar = (LinearLayout) getLayoutInflater().inflate(R.layout.browser_toolbar, null);
mBrowserToolbar.destroy();
mBrowserToolbar.from(actionBar);
mBrowserToolbar.refresh();
invalidateOptionsMenu();
Drawable background;
// Version 11 and 12 doesn't support tiling of bitmap in action bar.
if (Build.VERSION.SDK_INT == 11 || Build.VERSION.SDK_INT == 12) {
BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.address_bar_texture_tablet));
bitmap.setTileModeX(android.graphics.Shader.TileMode.REPEAT);
background = bitmap;
} else if (isTablet()) {
background = getResources().getDrawable(R.drawable.address_bar_bg);
} else {
background = getResources().getDrawable(R.drawable.gecko_actionbar_bg);
}
GeckoActionBar.setBackgroundDrawable(this, background);
GeckoActionBar.setCustomView(this, actionBar);
}
}
@ -1675,11 +1782,6 @@ abstract public class GeckoApp
private void initialize() {
mInitialized = true;
// Version 11 & 12 doesn't support tiling of bitmaps in action bar.
// Refresh it to avoid corruption.
if (Build.VERSION.SDK_INT == 11 || Build.VERSION.SDK_INT == 12)
refreshActionBar();
mBrowserToolbar.updateBackButton(false);
mBrowserToolbar.updateForwardButton(false);
invalidateOptionsMenu();

View File

@ -0,0 +1,253 @@
/* 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/. */
package org.mozilla.gecko;
import java.util.List;
import java.util.ArrayList;
import android.content.Context;
import android.content.ComponentName;
import android.content.Intent;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
public class GeckoMenu extends LinearLayout
implements Menu, GeckoMenuItem.OnShowAsActionChangedListener {
private static final String LOGTAG = "GeckoMenu";
private Context mContext;
public static interface ActionItemBarPresenter {
public void addActionItem(View actionItem);
public void removeActionItem(View actionItem);
public int getActionItemsCount();
}
private static final int NO_ID = 0;
// Default list of items.
private List<GeckoMenuItem> mItems;
// List of indices of items in action-bar.
private List<Integer> mActionItems;
// Reference to action-items bar in action-bar.
private ActionItemBarPresenter mActionItemBarPresenter;
public GeckoMenu(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
setOrientation(VERTICAL);
mItems = new ArrayList<GeckoMenuItem>();
mActionItems = new ArrayList<Integer>();
}
@Override
public MenuItem add(CharSequence title) {
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, NO_ID);
menuItem.setTitle(title);
addItem(menuItem);
return menuItem;
}
@Override
public MenuItem add(int groupId, int itemId, int order, int titleRes) {
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, itemId, order);
menuItem.setTitle(titleRes);
addItem(menuItem);
return menuItem;
}
@Override
public MenuItem add(int titleRes) {
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, NO_ID);
menuItem.setTitle(titleRes);
addItem(menuItem);
return menuItem;
}
@Override
public MenuItem add(int groupId, int itemId, int order, CharSequence title) {
GeckoMenuItem menuItem = new GeckoMenuItem(mContext, itemId, order);
menuItem.setTitle(title);
addItem(menuItem);
return menuItem;
}
private void addItem(GeckoMenuItem menuItem) {
menuItem.setOnShowAsActionChangedListener(this);
// Insert it in proper order.
int index = 0;
for (GeckoMenuItem item : mItems) {
if (item.getOrder() > menuItem.getOrder()) {
mItems.add(index, menuItem);
// Account for the items in the action-bar.
if (mActionItemBarPresenter != null)
addView(menuItem.getLayout(), index - mActionItemBarPresenter.getActionItemsCount());
else
addView(menuItem.getLayout(), index);
return;
} else {
index++;
}
}
// Add the menuItem at the end.
mItems.add(menuItem);
addView(menuItem.getLayout());
}
private void addActionButtonItem(GeckoMenuItem menuItem) {
// Add the menuItem at the end.
mActionItems.add(mItems.size());
mItems.add(menuItem);
mActionItemBarPresenter.addActionItem(menuItem.getLayout());
}
@Override
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
return 0;
}
@Override
public SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title) {
return null;
}
@Override
public SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes) {
return null;
}
@Override
public SubMenu addSubMenu(CharSequence title) {
return null;
}
@Override
public SubMenu addSubMenu(int titleRes) {
return null;
}
@Override
public void clear() {
}
@Override
public void close() {
}
@Override
public MenuItem findItem(int id) {
for (GeckoMenuItem menuItem : mItems) {
if (menuItem.getItemId() == id)
return menuItem;
}
return null;
}
@Override
public MenuItem getItem(int index) {
if (index < mItems.size())
return mItems.get(index);
return null;
}
@Override
public boolean hasVisibleItems() {
for (GeckoMenuItem menuItem : mItems) {
if (menuItem.isVisible())
return true;
}
return false;
}
@Override
public boolean isShortcutKey(int keyCode, KeyEvent event) {
return true;
}
@Override
public boolean performIdentifierAction(int id, int flags) {
return false;
}
@Override
public boolean performShortcut(int keyCode, KeyEvent event, int flags) {
return false;
}
@Override
public void removeGroup(int groupId) {
}
@Override
public void removeItem(int id) {
for (GeckoMenuItem menuItem : mItems) {
if (menuItem.getItemId() == id) {
removeView(findViewById(id));
if (mActionItemBarPresenter != null)
mActionItemBarPresenter.removeActionItem(findViewById(id));
mItems.remove(menuItem);
return;
}
}
}
@Override
public void setGroupCheckable(int group, boolean checkable, boolean exclusive) {
}
@Override
public void setGroupEnabled(int group, boolean enabled) {
}
@Override
public void setGroupVisible(int group, boolean visible) {
}
@Override
public void setQwertyMode(boolean isQwerty) {
}
@Override
public int size() {
return mItems.size();
}
@Override
public void onShowAsActionChanged(GeckoMenuItem item) {
addItemAsActionButton(item);
}
public void addItemAsActionButton(MenuItem item) {
removeItem(item.getItemId());
addActionButtonItem((GeckoMenuItem) item);
}
public void setActionItemBarPresenter(ActionItemBarPresenter presenter) {
mActionItemBarPresenter = presenter;
}
}

View File

@ -0,0 +1,137 @@
/* 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/. */
package org.mozilla.gecko;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
public class GeckoMenuInflater extends MenuInflater
implements MenuItem.OnMenuItemClickListener {
private static final String LOGTAG = "GeckoMenuInflater";
private static final String TAG_ITEM = "item";
private static final int NO_ID = 0;
private Context mContext;
// Private class to hold the parsed menu item.
private class ParsedItem {
public int id;
public int order;
public CharSequence title;
public int iconRes;
public boolean checkable;
public boolean checked;
public boolean visible;
public boolean enabled;
public boolean showAsAction;
}
public GeckoMenuInflater(Context context) {
super(context);
mContext = context;
}
public void inflate(int menuRes, Menu menu) {
// This is a very minimal parser for the custom menu.
// This assumes that there is only one menu tag in the resource file.
// This does not support sub-menus.
XmlResourceParser parser = null;
try {
parser = mContext.getResources().getXml(menuRes);
AttributeSet attrs = Xml.asAttributeSet(parser);
ParsedItem item = null;
String tag;
int eventType = parser.getEventType();
do {
tag = parser.getName();
switch (eventType) {
case XmlPullParser.START_TAG:
if (tag.equals(TAG_ITEM)) {
// Parse the menu item.
item = new ParsedItem();
parseItem(item, attrs);
}
break;
case XmlPullParser.END_TAG:
if (parser.getName().equals(TAG_ITEM)) {
// Add the item.
MenuItem menuItem = menu.add(NO_ID, item.id, item.order, item.title);
setValues(item, menuItem);
menuItem.setOnMenuItemClickListener(this);
}
break;
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);
} catch (XmlPullParserException e) {
throw new InflateException("Error inflating menu XML", e);
} catch (IOException e) {
throw new InflateException("Error inflating menu XML", e);
} finally {
if (parser != null)
parser.close();
}
}
@Override
public boolean onMenuItemClick(MenuItem item) {
Activity activity = (Activity) mContext;
boolean result = activity.onOptionsItemSelected(item);
activity.closeOptionsMenu();
return result;
}
public void parseItem(ParsedItem item, AttributeSet attrs) {
TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.MenuItem);
item.id = a.getResourceId(R.styleable.MenuItem_id, NO_ID);
item.order = a.getInt(R.styleable.MenuItem_orderInCategory, 0);
item.title = a.getText(R.styleable.MenuItem_title);
item.iconRes = a.getResourceId(R.styleable.MenuItem_icon, 0);
item.checkable = a.getBoolean(R.styleable.MenuItem_checkable, false);
item.checked = a.getBoolean(R.styleable.MenuItem_checked, false);
item.visible = a.getBoolean(R.styleable.MenuItem_visible, true);
item.enabled = a.getBoolean(R.styleable.MenuItem_enabled, true);
item.showAsAction = a.getBoolean(R.styleable.MenuItem_showAsAction, false);
a.recycle();
}
public void setValues(ParsedItem item, MenuItem menuItem) {
menuItem.setChecked(item.checked)
.setVisible(item.visible)
.setEnabled(item.enabled)
.setCheckable(item.checkable)
.setIcon(item.iconRes)
.setShowAsAction(item.showAsAction ? 1 : 0);
}
}

View File

@ -0,0 +1,330 @@
/* 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/. */
package org.mozilla.gecko;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ActionProvider;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
public class GeckoMenuItem implements MenuItem, View.OnClickListener {
private static final String LOGTAG = "GeckoMenuItem";
public static interface Layout {
public void setId(int id);
public void setIcon(Drawable icon);
public void setIcon(int iconRes);
public void setTitle(CharSequence title);
public void setEnabled(boolean enabled);
public void setCheckable(boolean checkable);
public void setChecked(boolean checked);
public void setOnClickListener(View.OnClickListener listener);
public void setVisibility(int visible);
public View getLayout();
}
public static interface OnShowAsActionChangedListener {
public void onShowAsActionChanged(GeckoMenuItem item);
}
private Context mContext;
private int mId;
private int mOrder;
private GeckoMenuItem.Layout mLayout;
private CharSequence mTitle;
private CharSequence mTitleCondensed;
private boolean mCheckable;
private boolean mChecked;
private boolean mVisible;
private boolean mEnabled;
private Drawable mIcon;
private int mIconRes;
private MenuItem.OnMenuItemClickListener mMenuItemClickListener;
private OnShowAsActionChangedListener mShowAsActionChangedListener;
public GeckoMenuItem(Context context, int id) {
mContext = context;
mLayout = new MenuItemDefault(context, null);
mLayout.setId(id);
mId = id;
mOrder = 0;
mVisible = true;
mEnabled = true;
mCheckable = true;
mChecked = false;
mMenuItemClickListener = null;
mLayout.setOnClickListener(this);
}
public GeckoMenuItem(Context context, int id, int order) {
this(context, id);
mOrder = order;
}
@Override
public boolean collapseActionView() {
return false;
}
@Override
public boolean expandActionView() {
return false;
}
@Override
public ActionProvider getActionProvider() {
return null;
}
@Override
public View getActionView() {
return null;
}
@Override
public char getAlphabeticShortcut() {
return 0;
}
@Override
public int getGroupId() {
return 0;
}
@Override
public Drawable getIcon() {
return null;
}
@Override
public Intent getIntent() {
return null;
}
@Override
public int getItemId() {
return mId;
}
public View getLayout() {
return mLayout.getLayout();
}
@Override
public ContextMenu.ContextMenuInfo getMenuInfo() {
return null;
}
@Override
public char getNumericShortcut() {
return 0;
}
@Override
public int getOrder() {
return mOrder;
}
@Override
public SubMenu getSubMenu() {
return null;
}
@Override
public CharSequence getTitle() {
return mTitle;
}
@Override
public CharSequence getTitleCondensed() {
return mTitleCondensed;
}
@Override
public boolean hasSubMenu() {
return false;
}
@Override
public boolean isActionViewExpanded() {
return false;
}
@Override
public boolean isCheckable() {
return mCheckable;
}
@Override
public boolean isChecked() {
return mChecked;
}
@Override
public boolean isEnabled() {
return mEnabled;
}
@Override
public boolean isVisible() {
return mVisible;
}
@Override
public MenuItem setActionProvider(ActionProvider actionProvider) {
return this;
}
@Override
public MenuItem setActionView(int resId) {
return this;
}
@Override
public MenuItem setActionView(View view) {
return this;
}
@Override
public MenuItem setAlphabeticShortcut(char alphaChar) {
return this;
}
@Override
public MenuItem setCheckable(boolean checkable) {
mCheckable = checkable;
mLayout.setCheckable(checkable);
return this;
}
@Override
public MenuItem setChecked(boolean checked) {
mChecked = checked;
mLayout.setChecked(checked);
return this;
}
@Override
public MenuItem setEnabled(boolean enabled) {
mEnabled = enabled;
mLayout.setEnabled(enabled);
return this;
}
@Override
public MenuItem setIcon(Drawable icon) {
mIcon = icon;
mLayout.setIcon(icon);
return this;
}
@Override
public MenuItem setIcon(int iconRes) {
mIconRes = iconRes;
mLayout.setIcon(iconRes);
return this;
}
@Override
public MenuItem setIntent(Intent intent) {
return this;
}
@Override
public MenuItem setNumericShortcut(char numericChar) {
return this;
}
@Override
public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener listener) {
return this;
}
@Override
public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener) {
mMenuItemClickListener = menuItemClickListener;
return this;
}
@Override
public MenuItem setShortcut(char numericChar, char alphaChar) {
return this;
}
@Override
public void setShowAsAction(int actionEnum) {
if (actionEnum == 1) {
// Change the type to just an icon
mLayout = new MenuItemActionBar(mContext, null);
mLayout.setId(mId);
setVisible(mVisible);
setEnabled(mEnabled);
setCheckable(mCheckable);
setChecked(mChecked);
if (mIcon == null)
setIcon(mIconRes);
else
setIcon(mIcon);
mLayout.setOnClickListener(this);
if (mShowAsActionChangedListener != null)
mShowAsActionChangedListener.onShowAsActionChanged(this);
}
}
@Override
public MenuItem setShowAsActionFlags(int actionEnum) {
return this;
}
@Override
public MenuItem setTitle(CharSequence title) {
mTitle = title;
mLayout.setTitle(mTitle);
return this;
}
@Override
public MenuItem setTitle(int title) {
mTitle = mContext.getResources().getString(title);
mLayout.setTitle(mTitle);
return this;
}
@Override
public MenuItem setTitleCondensed(CharSequence title) {
mTitleCondensed = title;
return this;
}
@Override
public MenuItem setVisible(boolean visible) {
mVisible = visible;
mLayout.setVisibility(visible ? View.VISIBLE : View.GONE);
return this;
}
@Override
public void onClick(View view) {
if (mMenuItemClickListener != null)
mMenuItemClickListener.onMenuItemClick(this);
}
public void setOnShowAsActionChangedListener(OnShowAsActionChangedListener listener) {
mShowAsActionChangedListener = listener;
}
}

View File

@ -74,7 +74,10 @@ FENNEC_JAVA_FILES = \
GeckoHalDefines.java \
GeckoInputConnection.java \
GeckoJarReader.java \
GeckoMessageReceiver.java \
GeckoMenu.java \
GeckoMenuInflater.java \
GeckoMenuItem.java \
GeckoMessageReceiver.java \
GeckoPreferences.java \
GeckoProfile.java \
GeckoStateListDrawable.java \
@ -83,7 +86,9 @@ FENNEC_JAVA_FILES = \
GeckoViewsFactory.java \
LinkPreference.java \
LinkTextView.java \
NSSBridge.java \
MenuItemActionBar.java \
MenuItemDefault.java \
NSSBridge.java \
ProfileMigrator.java \
PromptService.java \
sqlite/ByteBufferInputStream.java \
@ -165,6 +170,7 @@ FENNEC_PP_JAVA_FILES = \
FENNEC_PP_XML_FILES = \
res/layout/abouthome_content.xml \
res/menu/gecko_menu.xml \
res/menu-v11/gecko_menu.xml \
res/menu-xlarge/gecko_menu.xml \
res/menu-sw600dp/gecko_menu.xml \
$(NULL)
@ -259,6 +265,8 @@ RES_LAYOUT = \
res/layout/gecko_app.xml \
res/layout/launch_app_list.xml \
res/layout/launch_app_listitem.xml \
res/layout/menu_item.xml \
res/layout/menu_popup.xml \
res/layout/notification_icon_text.xml \
res/layout/notification_progress.xml \
res/layout/notification_progress_text.xml \
@ -313,16 +321,6 @@ RES_VALUES_V11 = \
res/values-v11/themes.xml \
$(NULL)
RES_VALUES_XLARGE = \
res/values-xlarge/styles.xml \
res/values-xlarge/themes.xml \
$(NULL)
RES_VALUES_SW600DP = \
res/values-sw600dp/styles.xml \
res/values-sw600dp/themes.xml \
$(NULL)
RES_VALUES_LAND_V14 = \
res/values-land-v14/dimens.xml \
$(NULL)
@ -401,6 +399,10 @@ RES_DRAWABLE_BASE = \
res/drawable/find_prev.png \
res/drawable/larry_blue.png \
res/drawable/larry_green.png \
res/drawable/menu.xml \
res/drawable/menu_item_bg.xml \
res/drawable/menu_item_default.xml \
res/drawable/menu_item_pressed.xml \
res/drawable/site_security_identified.png \
res/drawable/site_security_verified.png \
res/drawable/urlbar_stop.png \
@ -483,12 +485,19 @@ 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_clear_site_settings.png \
res/drawable-mdpi-v11/ic_menu_find_in_page.png \
res/drawable-mdpi-v11/ic_menu_reload.png \
res/drawable-mdpi-v11/ic_menu_save_as_pdf.png \
res/drawable-mdpi-v11/ic_menu_share.png \
res/drawable-mdpi-v11/ic_menu_forward.png \
res/drawable-mdpi-v11/menu.png \
res/drawable-mdpi-v11/menu_panel_bg.9.png \
res/drawable-mdpi-v11/menu_popup_bg.9.png \
res/drawable-mdpi-v11/menu_popup_arrow.png \
res/drawable-mdpi-v11/menu_item_texture.png \
res/drawable-mdpi-v11/menu_item_pressed_texture.png \
res/drawable-mdpi-v11/menu_item_check.png \
$(NULL)
RES_DRAWABLE_HDPI_V11 = \
@ -498,12 +507,19 @@ 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_clear_site_settings.png \
res/drawable-hdpi-v11/ic_menu_find_in_page.png \
res/drawable-hdpi-v11/ic_menu_reload.png \
res/drawable-hdpi-v11/ic_menu_save_as_pdf.png \
res/drawable-hdpi-v11/ic_menu_share.png \
res/drawable-hdpi-v11/ic_menu_forward.png \
res/drawable-hdpi-v11/menu.png \
res/drawable-hdpi-v11/menu_panel_bg.9.png \
res/drawable-hdpi-v11/menu_popup_bg.9.png \
res/drawable-hdpi-v11/menu_popup_arrow.png \
res/drawable-hdpi-v11/menu_item_texture.png \
res/drawable-hdpi-v11/menu_item_pressed_texture.png \
res/drawable-hdpi-v11/menu_item_check.png \
$(NULL)
RES_DRAWABLE_XHDPI_V11 = \
@ -529,11 +545,11 @@ 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_clear_site_settings.png \
res/drawable-xhdpi-v11/ic_menu_find_in_page.png \
res/drawable-xhdpi-v11/ic_menu_reload.png \
res/drawable-xhdpi-v11/ic_menu_save_as_pdf.png \
res/drawable-xhdpi-v11/ic_menu_share.png \
res/drawable-xhdpi-v11/menu.png \
res/drawable-xhdpi-v11/tab_new.png \
res/drawable-xhdpi-v11/tab_close.png \
res/drawable-xhdpi-v11/tab_thumbnail_default.png \
@ -557,9 +573,15 @@ RES_DRAWABLE_XHDPI_V11 = \
res/drawable-xhdpi-v11/urlbar_stop.png \
res/drawable-xhdpi-v11/larry_blue.png \
res/drawable-xhdpi-v11/larry_green.png \
res/drawable-xhdpi-v11/menu.png \
res/drawable-xhdpi-v11/menu_panel_bg.9.png \
res/drawable-xhdpi-v11/menu_popup_bg.9.png \
res/drawable-xhdpi-v11/menu_popup_arrow.png \
res/drawable-xhdpi-v11/menu_item_texture.png \
res/drawable-xhdpi-v11/menu_item_pressed_texture.png \
res/drawable-xhdpi-v11/menu_item_check.png \
res/drawable-xhdpi-v11/site_security_identified.png \
res/drawable-xhdpi-v11/site_security_verified.png \
res/drawable-xhdpi-v11/tabs_button_tail.9.png \
res/drawable-xhdpi-v11/validation_arrow.png \
res/drawable-xhdpi-v11/validation_arrow_inverted.png \
res/drawable-xhdpi-v11/validation_bg.9.png \
@ -616,7 +638,6 @@ RES_DRAWABLE_LAND_XHDPI_V14 = \
res/drawable-land-xhdpi-v14/urlbar_stop.png \
res/drawable-land-xhdpi-v14/site_security_identified.png \
res/drawable-land-xhdpi-v14/site_security_verified.png \
res/drawable-land-xhdpi-v14/tabs_button_tail.9.png \
$(NULL)
RES_DRAWABLE_XLARGE_MDPI = \
@ -626,6 +647,11 @@ RES_DRAWABLE_XLARGE_MDPI = \
res/drawable-xlarge-mdpi/address_bar_pressed_texture_tablet.png \
res/drawable-xlarge-mdpi/address_bar_back_button_bg.png \
res/drawable-xlarge-mdpi/address_bar_back_button_pressed_bg.png \
res/drawable-xlarge-mdpi/menu.png \
res/drawable-xlarge-mdpi/ic_menu_bookmark_add.png \
res/drawable-xlarge-mdpi/ic_menu_bookmark_remove.png \
res/drawable-xlarge-mdpi/ic_menu_reload.png \
res/drawable-xlarge-mdpi/ic_menu_forward.png \
res/drawable-xlarge-mdpi/tabs_normal.png \
res/drawable-xlarge-mdpi/tabs_pressed.png \
res/drawable-xlarge-mdpi/tabs_more.png \
@ -638,6 +664,11 @@ RES_DRAWABLE_XLARGE_HDPI = \
res/drawable-xlarge-hdpi/address_bar_pressed_texture_tablet.png \
res/drawable-xlarge-hdpi/address_bar_back_button_bg.png \
res/drawable-xlarge-hdpi/address_bar_back_button_pressed_bg.png \
res/drawable-xlarge-hdpi/menu.png \
res/drawable-xlarge-hdpi/ic_menu_bookmark_add.png \
res/drawable-xlarge-hdpi/ic_menu_bookmark_remove.png \
res/drawable-xlarge-hdpi/ic_menu_reload.png \
res/drawable-xlarge-hdpi/ic_menu_forward.png \
res/drawable-xlarge-hdpi/tabs_normal.png \
res/drawable-xlarge-hdpi/tabs_pressed.png \
res/drawable-xlarge-hdpi/tabs_more.png \
@ -650,6 +681,11 @@ RES_DRAWABLE_XLARGE_XHDPI = \
res/drawable-xlarge-xhdpi/address_bar_pressed_texture_tablet.png \
res/drawable-xlarge-xhdpi/address_bar_back_button_bg.png \
res/drawable-xlarge-xhdpi/address_bar_back_button_pressed_bg.png \
res/drawable-xlarge-xhdpi/menu.png \
res/drawable-xlarge-xhdpi/ic_menu_bookmark_add.png \
res/drawable-xlarge-xhdpi/ic_menu_bookmark_remove.png \
res/drawable-xlarge-xhdpi/ic_menu_reload.png \
res/drawable-xlarge-xhdpi/ic_menu_forward.png \
res/drawable-xlarge-xhdpi/tabs_normal.png \
res/drawable-xlarge-xhdpi/tabs_pressed.png \
res/drawable-xlarge-xhdpi/tabs_more.png \
@ -663,6 +699,11 @@ RES_DRAWABLE_SW600DP_MDPI = \
res/drawable-sw600dp-mdpi/address_bar_pressed_texture_tablet.png \
res/drawable-sw600dp-mdpi/address_bar_back_button_bg.png \
res/drawable-sw600dp-mdpi/address_bar_back_button_pressed_bg.png \
res/drawable-sw600dp-mdpi/menu.png \
res/drawable-sw600dp-mdpi/ic_menu_bookmark_add.png \
res/drawable-sw600dp-mdpi/ic_menu_bookmark_remove.png \
res/drawable-sw600dp-mdpi/ic_menu_reload.png \
res/drawable-sw600dp-mdpi/ic_menu_forward.png \
res/drawable-sw600dp-mdpi/tabs_normal.png \
res/drawable-sw600dp-mdpi/tabs_pressed.png \
res/drawable-sw600dp-mdpi/tabs_more.png \
@ -675,6 +716,11 @@ RES_DRAWABLE_SW600DP_HDPI = \
res/drawable-sw600dp-hdpi/address_bar_pressed_texture_tablet.png \
res/drawable-sw600dp-hdpi/address_bar_back_button_bg.png \
res/drawable-sw600dp-hdpi/address_bar_back_button_pressed_bg.png \
res/drawable-sw600dp-hdpi/menu.png \
res/drawable-sw600dp-hdpi/ic_menu_bookmark_add.png \
res/drawable-sw600dp-hdpi/ic_menu_bookmark_remove.png \
res/drawable-sw600dp-hdpi/ic_menu_reload.png \
res/drawable-sw600dp-hdpi/ic_menu_forward.png \
res/drawable-sw600dp-hdpi/tabs_normal.png \
res/drawable-sw600dp-hdpi/tabs_pressed.png \
res/drawable-sw600dp-hdpi/tabs_more.png \
@ -687,6 +733,11 @@ RES_DRAWABLE_SW600DP_XHDPI = \
res/drawable-sw600dp-xhdpi/address_bar_pressed_texture_tablet.png \
res/drawable-sw600dp-xhdpi/address_bar_back_button_bg.png \
res/drawable-sw600dp-xhdpi/address_bar_back_button_pressed_bg.png \
res/drawable-sw600dp-xhdpi/menu.png \
res/drawable-sw600dp-xhdpi/ic_menu_bookmark_add.png \
res/drawable-sw600dp-xhdpi/ic_menu_bookmark_remove.png \
res/drawable-sw600dp-xhdpi/ic_menu_reload.png \
res/drawable-sw600dp-xhdpi/ic_menu_forward.png \
res/drawable-sw600dp-xhdpi/tabs_normal.png \
res/drawable-sw600dp-xhdpi/tabs_pressed.png \
res/drawable-sw600dp-xhdpi/tabs_more.png \
@ -695,7 +746,9 @@ RES_DRAWABLE_SW600DP_XHDPI = \
$(NULL)
RES_COLOR = \
res/color/awesomebar_tab_text.xml
res/color/awesomebar_tab_text.xml \
res/color/menu_item_title.xml \
$(NULL)
RES_MENU = \
res/menu/awesomebar_contextmenu.xml \
@ -728,7 +781,6 @@ MOZ_ANDROID_DRAWABLES += \
mobile/android/base/resources/drawable/awesomebar_tab_selected.xml \
mobile/android/base/resources/drawable/awesomebar_tab_unselected.xml \
mobile/android/base/resources/drawable/desktop_notification.png \
mobile/android/base/resources/drawable/gecko_actionbar_bg.xml \
mobile/android/base/resources/drawable/progress_spinner.xml \
mobile/android/base/resources/drawable/progress_spinner_1.png \
mobile/android/base/resources/drawable/progress_spinner_2.png \
@ -746,7 +798,6 @@ MOZ_ANDROID_DRAWABLES += \
mobile/android/base/resources/drawable/start.png \
mobile/android/base/resources/drawable/site_security_level.xml \
mobile/android/base/resources/drawable/tabs_button.xml \
mobile/android/base/resources/drawable/tabs_button_tail.xml \
mobile/android/base/resources/drawable/tabs_level.xml \
mobile/android/base/resources/drawable/tabs_tray_bg_repeat.xml \
mobile/android/base/resources/drawable/tabs_tray_pressed_bg_repeat.xml \
@ -758,7 +809,7 @@ MOZ_ANDROID_DRAWABLES += \
MOZ_ANDROID_DRAWABLES += $(shell if test -e $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/android-resources.mn; then cat $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/android-resources.mn | tr '\n' ' '; fi)
RESOURCES=$(RES_LAYOUT) $(RES_LAYOUT_V11) $(RES_LAYOUT_LAND_V14) $(RES_LAYOUT_XLARGE) $(RES_LAYOUT_SW600DP) $(RES_VALUES) $(RES_VALUES_V11) $(RES_VALUES_XLARGE) $(RES_VALUES_SW600DP) $(RES_VALUES_LAND_V14) $(RES_VALUES_SW600DP_V14) $(RES_XML) $(RES_ANIM) $(RES_DRAWABLE_NODPI) $(RES_DRAWABLE_BASE) $(RES_DRAWABLE_LDPI) $(RES_DRAWABLE_HDPI) $(RES_DRAWABLE_MDPI_V11) $(RES_DRAWABLE_HDPI_V11) $(RES_DRAWABLE_XHDPI_V11) $(RES_DRAWABLE_LAND_V14) $(RES_DRAWABLE_LAND_MDPI_V14) $(RES_DRAWABLE_LAND_HDPI_V14) $(RES_DRAWABLE_LAND_XHDPI_V14) $(RES_DRAWABLE_XLARGE_MDPI) $(RES_DRAWABLE_XLARGE_HDPI) $(RES_DRAWABLE_XLARGE_XHDPI) $(RES_DRAWABLE_SW600DP_MDPI) $(RES_DRAWABLE_SW600DP_HDPI) $(RES_DRAWABLE_SW600DP_XHDPI) $(RES_COLOR) $(RES_MENU)
RESOURCES=$(RES_LAYOUT) $(RES_LAYOUT_V11) $(RES_LAYOUT_LAND_V14) $(RES_LAYOUT_XLARGE) $(RES_LAYOUT_SW600DP) $(RES_VALUES) $(RES_VALUES_V11) $(RES_VALUES_LAND_V14) $(RES_VALUES_SW600DP_V14) $(RES_XML) $(RES_ANIM) $(RES_DRAWABLE_NODPI) $(RES_DRAWABLE_BASE) $(RES_DRAWABLE_LDPI) $(RES_DRAWABLE_HDPI) $(RES_DRAWABLE_MDPI_V11) $(RES_DRAWABLE_HDPI_V11) $(RES_DRAWABLE_XHDPI_V11) $(RES_DRAWABLE_LAND_V14) $(RES_DRAWABLE_LAND_MDPI_V14) $(RES_DRAWABLE_LAND_HDPI_V14) $(RES_DRAWABLE_LAND_XHDPI_V14) $(RES_DRAWABLE_XLARGE_MDPI) $(RES_DRAWABLE_XLARGE_HDPI) $(RES_DRAWABLE_XLARGE_XHDPI) $(RES_DRAWABLE_SW600DP_MDPI) $(RES_DRAWABLE_SW600DP_HDPI) $(RES_DRAWABLE_SW600DP_XHDPI) $(RES_COLOR) $(RES_MENU)
RES_DIRS= \
res/layout \
@ -768,8 +819,6 @@ RES_DIRS= \
res/layout-sw600dp \
res/values \
res/values-v11 \
res/values-xlarge \
res/values-sw600dp \
res/values-land-v14 \
res/values-sw600dp-v14 \
res/xml \
@ -796,6 +845,7 @@ RES_DIRS= \
res/drawable-sw600dp-xhdpi \
res/color \
res/menu \
res/menu-v11 \
res/menu-xlarge \
res/menu-sw600dp \
$(NULL)

View File

@ -0,0 +1,83 @@
/* 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/. */
package org.mozilla.gecko;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ImageButton;
public class MenuItemActionBar extends ImageButton
implements GeckoMenuItem.Layout {
private static final String LOGTAG = "GeckoMenuItemActionBar";
private Context mContext;
public MenuItemActionBar(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
DisplayMetrics metrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
setLayoutParams(new ViewGroup.LayoutParams((int) (56 * metrics.density),
(int) (56 * metrics.density)));
int padding = (int) (14 * metrics.density);
setPadding(padding, padding, padding, padding);
setBackgroundResource(R.drawable.action_bar_button);
setScaleType(ImageView.ScaleType.FIT_XY);
}
@Override
public View getLayout() {
return this;
}
@Override
public void setIcon(Drawable icon) {
if (icon != null) {
setImageDrawable(icon);
setVisibility(VISIBLE);
} else {
setVisibility(GONE);
}
}
@Override
public void setIcon(int icon) {
if (icon != 0) {
setImageResource(icon);
setVisibility(VISIBLE);
} else {
setVisibility(GONE);
}
}
@Override
public void setTitle(CharSequence title) {
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
setColorFilter(enabled ? 0 : 0xFF999999);
}
@Override
public void setCheckable(boolean checkable) {
}
@Override
public void setChecked(boolean checked) {
}
}

View File

@ -0,0 +1,95 @@
/* 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/. */
package org.mozilla.gecko;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import android.widget.ImageView;
public class MenuItemDefault extends LinearLayout
implements GeckoMenuItem.Layout {
private static final String LOGTAG = "GeckoMenuItemDefault";
private Context mContext;
private ImageView mIcon;
private TextView mTitle;
private ImageView mCheck;
public MenuItemDefault(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
DisplayMetrics metrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
setLayoutParams(new LayoutParams((int) (240 * metrics.density),
(int) (44 * metrics.density)));
setBackgroundResource(R.drawable.menu_item_bg);
inflate(context, R.layout.menu_item, this);
mIcon = (ImageView) findViewById(R.id.icon);
mTitle = (TextView) findViewById(R.id.title);
mCheck = (ImageView) findViewById(R.id.check);
}
@Override
public View getLayout() {
return this;
}
@Override
public void setIcon(Drawable icon) {
if (icon != null) {
mIcon.setImageDrawable(icon);
mIcon.setVisibility(VISIBLE);
} else {
mIcon.setVisibility(GONE);
}
}
@Override
public void setIcon(int icon) {
if (icon != 0) {
mIcon.setImageResource(icon);
mIcon.setVisibility(VISIBLE);
} else {
mIcon.setVisibility(GONE);
}
}
@Override
public void setTitle(CharSequence title) {
mTitle.setText(title);
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
mTitle.setEnabled(enabled);
mCheck.setEnabled(enabled);
mIcon.setColorFilter(enabled ? 0 : 0xFF999999);
}
@Override
public void setCheckable(boolean checkable) {
mCheck.setVisibility(checkable ? VISIBLE : GONE);
}
@Override
public void setChecked(boolean checked) {
mCheck.setVisibility(checked ? VISIBLE : GONE);
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="#999999" />
<item android:color="#222222"/>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -3,13 +3,7 @@
- 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/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="34dp">
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_texture_land"
android:tileMode="repeat"
android:dither="false"/>
</item>
</layer-list>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_texture_land"
android:tileMode="repeat"
android:dither="false"/>

View File

@ -3,13 +3,7 @@
- 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/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="34dp">
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_pressed_texture_land"
android:tileMode="repeat"
android:dither="false"/>
</item>
</layer-list>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_pressed_texture_land"
android:tileMode="repeat"
android:dither="false"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3,13 +3,7 @@
- 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/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="34dp">
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_texture_port"
android:tileMode="repeat"
android:dither="false"/>
</item>
</layer-list>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_texture_port"
android:tileMode="repeat"
android:dither="false"/>

View File

@ -3,13 +3,7 @@
- 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/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="34dp">
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_pressed_texture_port"
android:tileMode="repeat"
android:dither="false"/>
</item>
</layer-list>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/address_bar_pressed_texture_port"
android:tileMode="repeat"
android:dither="false"/>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#000000"/>
</shape>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:state_pressed="true"
android:drawable="@drawable/menu_item_pressed"/>
<item android:drawable="@drawable/menu_item_default"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/menu_item_texture"
android:tileMode="repeat"
android:dither="false"/>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/menu_item_pressed_texture"
android:tileMode="repeat"
android:dither="false"/>

View File

@ -16,32 +16,27 @@
<ImageButton android:id="@+id/forward"
style="@style/AddressBar.ImageButton.Unused"/>
<Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="44dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:singleLine="true"
android:gravity="center_vertical|left"
android:hint="@string/awesomebar_default_text"
android:textColor="#222222"
android:paddingLeft="35dip"
android:paddingRight="7dip"/>
<ImageButton android:id="@+id/favicon"
<LinearLayout android:id="@+id/menu_items"
android:layout_width="0dip"
android:layout_height="0dip"
android:visibility="gone"/>
<ImageView android:id="@+id/spacer"
style="@style/AddressBar.ImageButton"
android:layout_width="44dip"
android:layout_alignParentRight="true"/>
<ImageButton android:id="@+id/menu"
style="@style/AddressBar.ImageButton"
android:layout_width="21.33dip"
android:layout_height="21.33dip"
android:layout_marginLeft="7dip"
android:layout_centerVertical="true"
android:src="@drawable/favicon"
android:layout_alignLeft="@id/awesome_bar"/>
android:layout_width="28.5dip"
android:layout_toLeftOf="@id/spacer"
android:gravity="center_vertical"
android:src="@drawable/menu"
android:background="@drawable/action_bar_button"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:visibility="gone"/>
<ImageButton android:id="@+id/tabs"
style="@style/AddressBar.ImageButton"
@ -62,6 +57,33 @@
android:layout_alignRight="@id/tabs"
android:gravity="center_horizontal"
android:visibility="gone"/>
<Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/menu"
android:layout_centerVertical="true"
android:singleLine="true"
android:gravity="center_vertical|left"
android:hint="@string/awesomebar_default_text"
android:textColor="#222222"
android:paddingLeft="35dip"
android:paddingRight="7dip"/>
<ImageButton android:id="@+id/favicon"
style="@style/AddressBar.ImageButton"
android:layout_width="21.33dip"
android:layout_height="21.33dip"
android:layout_marginLeft="7dip"
android:layout_centerVertical="true"
android:src="@drawable/favicon"
android:layout_alignLeft="@id/awesome_bar"/>
<ImageButton android:id="@+id/stop"
style="@style/AddressBar.ImageButton"

View File

@ -9,7 +9,7 @@
<RelativeLayout android:id="@+id/address_bar"
style="@style/AddressBar"
android:background="@android:color/transparent">
android:background="@drawable/address_bar_bg">
<ImageButton android:id="@+id/tabs"
style="@style/AddressBar.ImageButton"
@ -30,6 +30,23 @@
android:layout_alignLeft="@id/tabs"
android:gravity="center_horizontal"
android:visibility="gone"/>
<ImageButton android:id="@+id/menu"
style="@style/AddressBar.ImageButton"
android:layout_width="56dip"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:src="@drawable/menu"
android:background="@drawable/action_bar_button"
android:paddingLeft="14dip"
android:paddingRight="14dip"
android:visibility="gone"/>
<LinearLayout android:id="@+id/menu_items"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_toLeftOf="@id/menu"/>
<Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button"
@ -39,6 +56,7 @@
android:layout_marginBottom="6dp"
android:layout_marginRight="6dp"
android:layout_toRightOf="@id/tabs"
android:layout_toLeftOf="@id/menu_items"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:background="@drawable/address_bar_url_default"

View File

@ -9,7 +9,7 @@
<RelativeLayout android:id="@+id/address_bar"
style="@style/AddressBar"
android:background="@android:color/transparent">
android:background="@drawable/address_bar_bg">
<ImageButton android:id="@+id/tabs"
style="@style/AddressBar.ImageButton"
@ -30,6 +30,23 @@
android:layout_alignLeft="@id/tabs"
android:gravity="center_horizontal"
android:visibility="gone"/>
<ImageButton android:id="@+id/menu"
style="@style/AddressBar.ImageButton"
android:layout_width="56dip"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:src="@drawable/menu"
android:background="@drawable/action_bar_button"
android:paddingLeft="14dip"
android:paddingRight="14dip"
android:visibility="gone"/>
<LinearLayout android:id="@+id/menu_items"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_toLeftOf="@id/menu"/>
<Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button"
@ -39,6 +56,7 @@
android:layout_marginBottom="6dp"
android:layout_marginRight="6dp"
android:layout_toRightOf="@id/tabs"
android:layout_toLeftOf="@id/menu_items"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:background="@drawable/address_bar_url_default"

View File

@ -16,33 +16,27 @@
<ImageButton android:id="@+id/forward"
style="@style/AddressBar.ImageButton.Unused"/>
<Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:background="@drawable/address_bar_url_default"
android:singleLine="true"
android:gravity="center_vertical|left"
android:hint="@string/awesomebar_default_text"
android:textColor="#222222"
android:paddingLeft="41dip"
android:paddingRight="10dip"/>
<ImageButton android:id="@+id/favicon"
<LinearLayout android:id="@+id/menu_items"
android:layout_width="0dip"
android:layout_height="0dip"
android:visibility="gone"/>
<ImageView android:id="@+id/spacer"
style="@style/AddressBar.ImageButton"
android:layout_width="50dip"
android:layout_alignParentRight="true"/>
<ImageButton android:id="@+id/menu"
style="@style/AddressBar.ImageButton"
android:layout_width="21.33dip"
android:layout_height="21.33dip"
android:layout_marginLeft="10dip"
android:layout_centerVertical="true"
android:src="@drawable/favicon"
android:layout_alignLeft="@id/awesome_bar"/>
android:layout_width="36dip"
android:layout_toLeftOf="@id/spacer"
android:gravity="center_vertical"
android:src="@drawable/menu"
android:background="@drawable/action_bar_button"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:visibility="gone"/>
<ImageButton android:id="@+id/tabs"
style="@style/AddressBar.ImageButton"
@ -63,6 +57,34 @@
android:layout_alignRight="@id/tabs"
android:gravity="center_horizontal"
android:visibility="gone"/>
<Button android:id="@+id/awesome_bar"
style="@style/AddressBar.Button"
android:layout_width="fill_parent"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/menu"
android:layout_centerVertical="true"
android:background="@drawable/address_bar_url_default"
android:singleLine="true"
android:gravity="center_vertical|left"
android:hint="@string/awesomebar_default_text"
android:textColor="#222222"
android:paddingLeft="41dip"
android:paddingRight="10dip"/>
<ImageButton android:id="@+id/favicon"
style="@style/AddressBar.ImageButton"
android:layout_width="21.33dip"
android:layout_height="21.33dip"
android:layout_marginLeft="10dip"
android:layout_centerVertical="true"
android:src="@drawable/favicon"
android:layout_alignLeft="@id/awesome_bar"/>
<ImageButton android:id="@+id/stop"
style="@style/AddressBar.ImageButton"

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<View android:layout_width="14dp"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"/>
<ImageView android:id="@+id/icon"
android:layout_width="24dp"
android:layout_height="18dp"
android:paddingRight="6dp"
android:layout_gravity="center_vertical"
android:visibility="gone"/>
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:textSize="16sp"
android:textColor="@color/menu_item_title"
android:singleLine="true"
android:ellipsize="middle"
android:layout_gravity="center_vertical"/>
<ImageView android:id="@+id/check"
android:layout_width="20dp"
android:layout_height="14dp"
android:paddingLeft="6dp"
android:layout_gravity="center_vertical"
android:src="@drawable/menu_item_check"
android:visibility="gone"/>
<View android:layout_width="14dp"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"/>
</merge>

View File

@ -0,0 +1,27 @@
<?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/. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout android:id="@+id/menu_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/menu_popup_bg">
<!-- MenuPanel will be added here dynamically -->
</RelativeLayout>
<ImageView android:id="@+id/menu_arrow"
android:layout_width="28dip"
android:layout_height="10dip"
android:layout_marginTop="2dip"
android:layout_alignParentRight="true"
android:src="@drawable/menu_popup_arrow"
android:scaleType="fitXY"/>
</RelativeLayout>

View File

@ -1,58 +1,60 @@
#filter substitution
<?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">
<menu xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
<item android:id="@+id/bookmark"
android:icon="@drawable/ic_menu_bookmark_add"
android:title="@string/bookmark"
android:showAsAction="ifRoom"/>
<item gecko:id="@+id/reload"
gecko:icon="@drawable/ic_menu_reload"
gecko:title="@string/reload"
gecko:showAsAction="true"/>
<item android:id="@+id/reload"
android:icon="@drawable/ic_menu_reload"
android:title="@string/reload"
android:showAsAction="ifRoom"/>
<item gecko:id="@+id/forward"
gecko:icon="@drawable/ic_menu_forward"
gecko:title="@string/forward"
gecko:visible="false"/>
<item android:id="@+id/forward"
android:icon="@drawable/ic_menu_forward"
android:title="@string/forward"
android:visible="false"/>
<item gecko:id="@+id/bookmark"
gecko:icon="@drawable/ic_menu_bookmark_add"
gecko:title="@string/bookmark"
gecko:showAsAction="true"/>
<item android:id="@+id/share"
android:icon="@drawable/ic_menu_share"
android:title="@string/share" />
<item gecko:id="@+id/share"
gecko:icon="@drawable/ic_menu_share"
gecko:title="@string/share" />
<item android:id="@+id/save_as_pdf"
android:icon="@drawable/ic_menu_save_as_pdf"
android:title="@string/save_as_pdf" />
<item gecko:id="@+id/save_as_pdf"
gecko:icon="@drawable/ic_menu_save_as_pdf"
gecko:title="@string/save_as_pdf" />
<item android:id="@+id/find_in_page"
android:title="@string/find_in_page" />
<item gecko:id="@+id/find_in_page"
gecko:title="@string/find_in_page" />
<item android:id="@+id/site_settings"
android:title="@string/site_settings_title" />
<item gecko:id="@+id/site_settings"
gecko:icon="@drawable/ic_menu_clear_site_settings"
gecko:title="@string/site_settings_title" />
<item android:id="@+id/addons"
android:title="@string/addons"/>
<item gecko:id="@+id/addons"
gecko:title="@string/addons"/>
<item android:id="@+id/downloads"
android:title="@string/downloads"/>
<item gecko:id="@+id/downloads"
gecko:title="@string/downloads"/>
<item android:id="@+id/char_encoding"
android:visible="false"
android:title="@string/char_encoding"/>
<item gecko:id="@+id/char_encoding"
gecko:visible="false"
gecko:title="@string/char_encoding"/>
<item android:id="@+id/settings"
android:title="@string/settings" />
<item gecko:id="@+id/settings"
gecko:title="@string/settings" />
#ifdef MOZ_PROFILING
<item android:id="@+id/toggle_profiling"
android:title="@string/toggle_profiling" />
<item gecko:id="@+id/toggle_profiling"
gecko:title="@string/toggle_profiling" />
#endif
<item android:id="@+id/quit"
android:title="@string/quit"
android:orderInCategory="10" />
<item gecko:id="@+id/quit"
gecko:title="@string/quit"
gecko:orderInCategory="10" />
</menu>

View File

@ -0,0 +1,57 @@
#filter substitution
<?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:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
<item gecko:id="@+id/reload"
gecko:icon="@drawable/ic_menu_reload"
gecko:title="@string/reload"/>
<item gecko:id="@+id/forward"
gecko:icon="@drawable/ic_menu_forward"
gecko:title="@string/forward"/>
<item gecko:id="@+id/bookmark"
gecko:icon="@drawable/ic_menu_bookmark_add"
gecko:title="@string/bookmark"/>
<item gecko:id="@+id/share"
gecko:icon="@drawable/ic_menu_share"
gecko:title="@string/share" />
<item gecko:id="@+id/save_as_pdf"
gecko:icon="@drawable/ic_menu_save_as_pdf"
gecko:title="@string/save_as_pdf" />
<item gecko:id="@+id/find_in_page"
gecko:title="@string/find_in_page" />
<item gecko:id="@+id/site_settings"
gecko:icon="@drawable/ic_menu_clear_site_settings"
gecko:title="@string/site_settings_title" />
<item gecko:id="@+id/addons"
gecko:title="@string/addons"/>
<item gecko:id="@+id/downloads"
gecko:title="@string/downloads"/>
<item gecko:id="@+id/char_encoding"
gecko:visible="false"
gecko:title="@string/char_encoding"/>
<item gecko:id="@+id/settings"
gecko:title="@string/settings" />
#ifdef MOZ_PROFILING
<item gecko:id="@+id/toggle_profiling"
gecko:title="@string/toggle_profiling" />
#endif
<item gecko:id="@+id/quit"
gecko:title="@string/quit"
gecko:orderInCategory="10" />
</menu>

View File

@ -1,58 +1,60 @@
#filter substitution
<?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">
<menu xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
<item android:id="@+id/bookmark"
android:icon="@drawable/ic_menu_bookmark_add"
android:title="@string/bookmark"
android:showAsAction="ifRoom"/>
<item gecko:id="@+id/reload"
gecko:icon="@drawable/ic_menu_reload"
gecko:title="@string/reload"
gecko:showAsAction="true"/>
<item android:id="@+id/reload"
android:icon="@drawable/ic_menu_reload"
android:title="@string/reload"
android:showAsAction="ifRoom"/>
<item gecko:id="@+id/forward"
gecko:icon="@drawable/ic_menu_forward"
gecko:title="@string/forward"
gecko:visible="false"/>
<item android:id="@+id/forward"
android:icon="@drawable/ic_menu_forward"
android:title="@string/forward"
android:visible="false"/>
<item gecko:id="@+id/bookmark"
gecko:icon="@drawable/ic_menu_bookmark_add"
gecko:title="@string/bookmark"
gecko:showAsAction="true"/>
<item android:id="@+id/share"
android:icon="@drawable/ic_menu_share"
android:title="@string/share" />
<item gecko:id="@+id/share"
gecko:icon="@drawable/ic_menu_share"
gecko:title="@string/share" />
<item android:id="@+id/save_as_pdf"
android:icon="@drawable/ic_menu_save_as_pdf"
android:title="@string/save_as_pdf" />
<item gecko:id="@+id/save_as_pdf"
gecko:icon="@drawable/ic_menu_save_as_pdf"
gecko:title="@string/save_as_pdf" />
<item android:id="@+id/find_in_page"
android:title="@string/find_in_page" />
<item gecko:id="@+id/find_in_page"
gecko:title="@string/find_in_page" />
<item android:id="@+id/site_settings"
android:title="@string/site_settings_title" />
<item gecko:id="@+id/site_settings"
gecko:icon="@drawable/ic_menu_clear_site_settings"
gecko:title="@string/site_settings_title" />
<item android:id="@+id/addons"
android:title="@string/addons"/>
<item gecko:id="@+id/addons"
gecko:title="@string/addons"/>
<item android:id="@+id/downloads"
android:title="@string/downloads"/>
<item gecko:id="@+id/downloads"
gecko:title="@string/downloads"/>
<item android:id="@+id/char_encoding"
android:visible="false"
android:title="@string/char_encoding"/>
<item gecko:id="@+id/char_encoding"
gecko:visible="false"
gecko:title="@string/char_encoding"/>
<item android:id="@+id/settings"
android:title="@string/settings" />
<item gecko:id="@+id/settings"
gecko:title="@string/settings" />
#ifdef MOZ_PROFILING
<item android:id="@+id/toggle_profiling"
android:title="@string/toggle_profiling" />
<item gecko:id="@+id/toggle_profiling"
gecko:title="@string/toggle_profiling" />
#endif
<item android:id="@+id/quit"
android:title="@string/quit"
android:orderInCategory="10" />
<item gecko:id="@+id/quit"
gecko:title="@string/quit"
gecko:orderInCategory="10" />
</menu>

View File

@ -1,32 +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/. -->
<resources>
<!--
Only overriden styles for tablets are specified here.
-->
<!-- GeckoApp ActionBar -->
<style name="ActionBar.GeckoApp">
<item name="android:background">@drawable/address_bar_bg</item>
<item name="android:displayOptions">showCustom</item>
<item name="android:customNavigationLayout">@layout/browser_toolbar</item>
</style>
<!-- GeckoApp ActionBar ActionButton -->
<style name="ActionBar.GeckoApp.ActionButton" parent="@android:style/Widget.Holo.ActionButton">
<item name="android:background">@drawable/action_bar_button</item>
<item name="android:padding">14dip</item>
<item name="android:minWidth">56dip</item>
<item name="android:minHeight">56dip</item>
</style>
<!-- GeckoApp ActionBar OverflowButton -->
<style name="ActionBar.GeckoApp.OverflowButton" parent="ActionBar.GeckoApp.ActionButton">
<item name="android:src">@drawable/menu</item>
</style>
</resources>

View File

@ -1,20 +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/. -->
<resources>
<!--
Only overriden themes for tablets are specified here.
-->
<style name="Gecko.App">
<item name="android:windowBackground">@drawable/abouthome_bg_repeat</item>
<item name="android:actionBarStyle">@style/ActionBar.GeckoApp</item>
<item name="android:actionButtonStyle">@style/ActionBar.GeckoApp.ActionButton</item>
<item name="android:actionOverflowButtonStyle">@style/ActionBar.GeckoApp.OverflowButton</item>
<item name="android:actionBarDivider">@android:color/transparent</item>
</style>
</resources>

View File

@ -14,7 +14,7 @@
<style name="BrowserToolbar">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:orientation">vertical</item>
<item name="android:orientation">horizontal</item>
</style>
<!-- Address bar -->
@ -38,7 +38,7 @@
<!-- GeckoApp ActionBar -->
<style name="ActionBar.GeckoApp">
<item name="android:background">@drawable/gecko_actionbar_bg</item>
<item name="android:background">#000000</item>
<item name="android:displayOptions">showCustom</item>
<item name="android:customNavigationLayout">@layout/browser_toolbar</item>
</style>

View File

@ -35,6 +35,7 @@
<style name="Gecko.App">
<item name="android:windowBackground">@drawable/abouthome_bg_repeat</item>
<item name="android:actionBarStyle">@style/ActionBar.GeckoApp</item>
<item name="android:panelBackground">@drawable/menu_panel_bg</item>
</style>
<style name="Gecko.Light.AwesomeBar">

View File

@ -1,32 +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/. -->
<resources>
<!--
Only overriden styles for tablets are specified here.
-->
<!-- GeckoApp ActionBar -->
<style name="ActionBar.GeckoApp">
<item name="android:background">@drawable/address_bar_bg</item>
<item name="android:displayOptions">showCustom</item>
<item name="android:customNavigationLayout">@layout/browser_toolbar</item>
</style>
<!-- GeckoApp ActionBar ActionButton -->
<style name="ActionBar.GeckoApp.ActionButton" parent="@android:style/Widget.Holo.ActionButton">
<item name="android:background">@drawable/action_bar_button</item>
<item name="android:padding">14dip</item>
<item name="android:minWidth">56dip</item>
<item name="android:minHeight">56dip</item>
</style>
<!-- GeckoApp ActionBar OverflowButton -->
<style name="ActionBar.GeckoApp.OverflowButton" parent="ActionBar.GeckoApp.ActionButton">
<item name="android:src">@drawable/menu</item>
</style>
</resources>

View File

@ -1,20 +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/. -->
<resources>
<!--
Only overriden themes for tablets are specified here.
-->
<style name="Gecko.App">
<item name="android:windowBackground">@drawable/abouthome_bg_repeat</item>
<item name="android:actionBarStyle">@style/ActionBar.GeckoApp</item>
<item name="android:actionButtonStyle">@style/ActionBar.GeckoApp.ActionButton</item>
<item name="android:actionOverflowButtonStyle">@style/ActionBar.GeckoApp.OverflowButton</item>
<item name="android:actionBarDivider">@android:color/transparent</item>
</style>
</resources>

View File

@ -11,4 +11,16 @@
<attr name="more_text" format="string"/>
</declare-styleable>
<declare-styleable name="MenuItem">
<attr name="id" format="string"/>
<attr name="orderInCategory" format="string"/>
<attr name="title"/>
<attr name="icon" format="string"/>
<attr name="checkable" format="boolean"/>
<attr name="checked" format="boolean"/>
<attr name="visible" format="string"/>
<attr name="enabled" format="string"/>
<attr name="showAsAction" format="boolean"/>
</declare-styleable>
</resources>

View File

@ -35,7 +35,7 @@
<style name="BrowserToolbar">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">vertical</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">#000000</item>
</style>