Bug 1132747 - Set the padding for share in the context menu on Lollipop. r=mhaigh

This commit is contained in:
Michael Comella
2015-03-27 17:59:06 -07:00
parent 7d51d2992a
commit 71ca4ed285
6 changed files with 57 additions and 11 deletions

View File

@@ -38,7 +38,7 @@ public class MenuItemActionView extends LinearLayout
@TargetApi(14)
public MenuItemActionView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs);
super(context, attrs, defStyle);
LayoutInflater.from(context).inflate(R.layout.menu_item_action_view, this);
mMenuItem = (MenuItemDefault) findViewById(R.id.menu_item);
@@ -165,4 +165,18 @@ public class MenuItemActionView extends LinearLayout
listener.onClick(view);
}
}
/**
* Update the styles if this view is being used in the context menus.
*
* Ideally, we just use different layout files and styles to set this, but
* MenuItemActionView is too integrated into GeckoActionProvider to provide
* an easy separation so instead I provide this hack. I'm sorry.
*/
public void initContextMenuStyles() {
final int defaultContextMenuPadding = getContext().getResources().getDimensionPixelOffset(
R.dimen.context_menu_item_horizontal_padding);
mMenuItem.setPadding(defaultContextMenuPadding, getPaddingTop(),
defaultContextMenuPadding, getPaddingBottom());
}
}