mobile/android/base/menu/MenuItemActionBar.java

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 package org.mozilla.gecko.menu;
     7 import org.mozilla.gecko.R;
     9 import android.content.Context;
    10 import android.graphics.drawable.Drawable;
    11 import android.util.AttributeSet;
    12 import android.widget.ImageButton;
    14 public class MenuItemActionBar extends ImageButton
    15                                implements GeckoMenuItem.Layout {
    16     private static final String LOGTAG = "GeckoMenuItemActionBar";
    18     public MenuItemActionBar(Context context) {
    19         this(context, null);
    20     }
    22     public MenuItemActionBar(Context context, AttributeSet attrs) {
    23         this(context, attrs, R.attr.menuItemActionBarStyle);
    24     }
    26     public MenuItemActionBar(Context context, AttributeSet attrs, int defStyle) {
    27         super(context, attrs, defStyle);
    28     }
    30     @Override
    31     public void initialize(GeckoMenuItem item) {
    32         if (item == null)
    33             return;
    35         setIcon(item.getIcon());
    36         setTitle(item.getTitle());
    37         setEnabled(item.isEnabled());
    38         setId(item.getItemId());
    39     }
    41     void setIcon(Drawable icon) {
    42         if (icon == null) {
    43             setVisibility(GONE);
    44         } else {
    45             setVisibility(VISIBLE);
    46             setImageDrawable(icon);
    47         }
    48     }
    50     void setIcon(int icon) {
    51         setIcon((icon == 0) ? null : getResources().getDrawable(icon));
    52     }
    54     void setTitle(CharSequence title) {
    55         // set accessibility contentDescription here
    56         setContentDescription(title);
    57     }
    59     @Override
    60     public void setEnabled(boolean enabled) {
    61         super.setEnabled(enabled);
    62         setColorFilter(enabled ? 0 : 0xFF999999);
    63     }
    65     @Override
    66     public void setShowIcon(boolean show) {
    67         // Do nothing.
    68     }
    69 }

mercurial