gt:         char shortcut = getShortcut();
context: /*
   * Copyright (C) 2006 The Android Open Source Project
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package com.actionbarsherlock.internal.view.menu;
  
  import android.content.ActivityNotFoundException;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.drawable.Drawable;
  import android.util.Log;
  import android.view.ContextMenu.ContextMenuInfo;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewDebug;
  import android.widget.LinearLayout;
  
  import com.actionbarsherlock.view.ActionProvider;
  import com.actionbarsherlock.view.MenuItem;
  import com.actionbarsherlock.view.SubMenu;
  
  /**
   * @hide
   */
  public final class MenuItemImpl implements MenuItem {
      private static final String TAG = "MenuItemImpl";
  
      private static final int SHOW_AS_ACTION_MASK = SHOW_AS_ACTION_NEVER |
              SHOW_AS_ACTION_IF_ROOM |
              SHOW_AS_ACTION_ALWAYS;
  
      private final int mId;
      private final int mGroup;
      private final int mCategoryOrder;
      private final int mOrdering;
      private CharSequence mTitle;
      private CharSequence mTitleCondensed;
      private Intent mIntent;
      private char mShortcutNumericChar;
      private char mShortcutAlphabeticChar;
  
      /** The icon's drawable which is only created as needed */
      private Drawable mIconDrawable;
      /**
       * The icon's resource ID which is used to get the Drawable when it is
       * needed (if the Drawable isn't already obtained--only one of the two is
       * needed).
       */
      private int mIconResId = NO_ICON;
  
      /** The menu to which this item belongs */
      private MenuBuilder mMenu;
      /** If this item should launch a sub menu, this is the sub menu to launch */
      private SubMenuBuilder mSubMenu;
  
      private Runnable mItemCallback;
      private OnMenuItemClickListener mClickListener;
  
      private int mFlags = ENABLED;
      private static final int CHECKABLE      = 0x00000001;
      private static final int CHECKED        = 0x00000002;
      private static final int EXCLUSIVE      = 0x00000004;
      private static final int HIDDEN         = 0x00000008;
      private static final int ENABLED        = 0x00000010;
      private static final int IS_ACTION      = 0x00000020;
  
      private int mShowAsAction = SHOW_AS_ACTION_NEVER;
  
      private View mActionView;
      private ActionProvider mActionProvider;
      private OnActionExpandListener mOnActionExpandListener;
      private boolean mIsActionViewExpanded = false;
  
      /** Used for the icon resource ID if this item does not have an icon */
      static final int NO_ICON = 0;
  
      /**
       * Current use case is for context menu: Extra information linked to the
       * View that added this item to the context menu.
       */
      private ContextMenuInfo mMenuInfo;
  
      private static String sPrependShortcutLabel;
      private static String sEnterShortcutLabel;
      private static String sDeleteShortcutLabel;
      private static String sSpaceShortcutLabel;
  
  
      /**
       * Instantiates this menu item.
       *
       * @param menu
       * @param group Item ordering grouping control. The item will be added after
       *            all other items whose order is <= this number, and before any
       *            that are larger than it. This can also be used to define
       *            groups of items for batch state changes. Normally use 0.
       * @param id Unique item ID. Use 0 if you do not need a unique ID.
       * @param categoryOrder The ordering for this item.
       * @param title The text to display for the item.
       */
      MenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering,
              CharSequence title, int showAsAction) {
  
          /* TODO if (sPrependShortcutLabel == null) {
              // This is instantiated from the UI thread, so no chance of sync issues
              sPrependShortcutLabel = menu.getContext().getResources().getString(
                      com.android.internal.R.string.prepend_shortcut_label);
              sEnterShortcutLabel = menu.getContext().getResources().getString(
                      com.android.internal.R.string.menu_enter_shortcut_label);
              sDeleteShortcutLabel = menu.getContext().getResources().getString(
                      com.android.internal.R.string.menu_delete_shortcut_label);
              sSpaceShortcutLabel = menu.getContext().getResources().getString(
                      com.android.internal.R.string.menu_space_shortcut_label);
          }*/
  
          mMenu = menu;
          mId = id;
          mGroup = group;
          mCategoryOrder = categoryOrder;
          mOrdering = ordering;
          mTitle = title;
          mShowAsAction = showAsAction;
      }
  
      /**
       * Invokes the item by calling various listeners or callbacks.
       *
       * @return true if the invocation was handled, false otherwise
       */
      public boolean invoke() {
          if (mClickListener != null &&
              mClickListener.onMenuItemClick(this)) {
              return true;
          }
  
          if (mMenu.dispatchMenuItemSelected(mMenu.getRootMenu(), this)) {
              return true;
          }
  
          if (mItemCallback != null) {
              mItemCallback.run();
              return true;
          }
  
          if (mIntent != null) {
              try {
                  mMenu.getContext().startActivity(mIntent);
                  return true;
              } catch (ActivityNotFoundException e) {
                  Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
              }
          }
  
          if (mActionProvider != null && mActionProvider.onPerformDefaultAction()) {
              return true;
          }
  
          return false;
      }
  
      public boolean isEnabled() {
          return (mFlags & ENABLED) != 0;
      }
  
      public MenuItem setEnabled(boolean enabled) {
          if (enabled) {
              mFlags |= ENABLED;
          } else {
              mFlags &= ~ENABLED;
          }
  
          mMenu.onItemsChanged(false);
  
          return this;
      }
  
      public int getGroupId() {
          return mGroup;
      }
  
      @ViewDebug.CapturedViewProperty
      public int getItemId() {
          return mId;
      }
  
      public int getOrder() {
          return mCategoryOrder;
      }
  
      public int getOrdering() {
          return mOrdering;
      }
  
      public Intent getIntent() {
          return mIntent;
      }
  
      public MenuItem setIntent(Intent intent) {
          mIntent = intent;
          return this;
      }
  
      Runnable getCallback() {
          return mItemCallback;
      }
  
      public MenuItem setCallback(Runnable callback) {
          mItemCallback = callback;
          return this;
      }
  
      public char getAlphabeticShortcut() {
          return mShortcutAlphabeticChar;
      }
  
      public MenuItem setAlphabeticShortcut(char alphaChar) {
          if (mShortcutAlphabeticChar == alphaChar) return this;
  
          mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
  
          mMenu.onItemsChanged(false);
  
          return this;
      }
  
      public char getNumericShortcut() {
          return mShortcutNumericChar;
      }
  
      public MenuItem setNumericShortcut(char numericChar) {
          if (mShortcutNumericChar == numericChar) return this;
  
          mShortcutNumericChar = numericChar;
  
          mMenu.onItemsChanged(false);
  
          return this;
      }
  
      public MenuItem setShortcut(char numericChar, char alphaChar) {
          mShortcutNumericChar = numericChar;
          mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
  
          mMenu.onItemsChanged(false);
  
          return this;
      }
  
      /**
       * @return The active shortcut (based on QWERTY-mode of the menu).
       */
      char getShortcut() {
          return (mMenu.isQwertyMode() ? mShortcutAlphabeticChar : mShortcutNumericChar);
      }
  
      /**
       * @return The label to show for the shortcut. This includes the chording
       *         key (for example 'Menu+a'). Also, any non-human readable
       *         characters should be human readable (for example 'Menu+enter').
       */
      String getShortcutLabel() {
  
  