gecko-dev/mobile/android/base/menu/MenuItemActionBar.java
Sriram Ramasubramanian bbe96d9b8b Bug 869123: Make a "menu" package for menu related stuff. [r=wesj]
--HG--
rename : mobile/android/base/GeckoMenu.java => mobile/android/base/menu/GeckoMenu.java
rename : mobile/android/base/GeckoMenuInflater.java => mobile/android/base/menu/GeckoMenuInflater.java
rename : mobile/android/base/GeckoMenuItem.java => mobile/android/base/menu/GeckoMenuItem.java
rename : mobile/android/base/GeckoSubMenu.java => mobile/android/base/menu/GeckoSubMenu.java
rename : mobile/android/base/MenuItemActionBar.java => mobile/android/base/menu/MenuItemActionBar.java
rename : mobile/android/base/MenuItemDefault.java => mobile/android/base/menu/MenuItemDefault.java
rename : mobile/android/base/MenuPanel.java => mobile/android/base/menu/MenuPanel.java
rename : mobile/android/base/MenuPopup.java => mobile/android/base/menu/MenuPopup.java
rename : mobile/android/base/Divider.java => mobile/android/base/widget/Divider.java
rename : mobile/android/base/GeckoPopupMenu.java => mobile/android/base/widget/GeckoPopupMenu.java
extra : rebase_source : 3b51b8af8318e346fe41b3ab7c18421d67b1359b
2013-05-15 10:41:25 -07:00

82 lines
2.2 KiB
Java

/* 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.menu;
import org.mozilla.gecko.R;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
public class MenuItemActionBar extends ImageButton
implements GeckoMenuItem.Layout {
private static final String LOGTAG = "GeckoMenuItemActionBar";
public MenuItemActionBar(Context context, AttributeSet attrs) {
super(context, attrs);
int size = (int) (context.getResources().getDimension(R.dimen.browser_toolbar_height));
setLayoutParams(new ViewGroup.LayoutParams(size, size));
int padding = (int) (context.getResources().getDimension(R.dimen.browser_toolbar_button_padding));
setPadding(padding, padding, padding, padding);
setBackgroundResource(R.drawable.action_bar_button);
setScaleType(ImageView.ScaleType.FIT_CENTER);
}
@Override
public View getView() {
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) {
// set accessibility contentDescription here
setContentDescription(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) {
}
@Override
public void setSubMenuIndicator(boolean hasSubMenu) {
}
}