2012-05-31 23:01:50 +00:00
|
|
|
/* 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.graphics.drawable.Drawable;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.ImageButton;
|
2012-07-28 00:53:54 +00:00
|
|
|
import android.widget.ImageView;
|
2012-05-31 23:01:50 +00:00
|
|
|
|
2012-07-18 00:54:54 +00:00
|
|
|
public class MenuItemActionBar extends ImageButton
|
|
|
|
implements GeckoMenuItem.Layout {
|
2012-05-31 23:01:50 +00:00
|
|
|
private static final String LOGTAG = "GeckoMenuItemActionBar";
|
|
|
|
|
|
|
|
public MenuItemActionBar(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
|
2012-07-28 06:13:34 +00:00
|
|
|
int size = (int) (context.getResources().getDimension(R.dimen.browser_toolbar_height));
|
|
|
|
setLayoutParams(new ViewGroup.LayoutParams(size, size));
|
2012-05-31 23:01:50 +00:00
|
|
|
|
2012-07-28 06:13:34 +00:00
|
|
|
int padding = size / 4;
|
2012-05-31 23:01:50 +00:00
|
|
|
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) {
|
2012-07-31 10:02:53 +00:00
|
|
|
// set accessibility contentDescription here
|
|
|
|
setContentDescription(title);
|
2012-05-31 23:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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) {
|
|
|
|
}
|
|
|
|
}
|