Example usage for android.view Menu NONE

List of usage examples for android.view Menu NONE

Introduction

In this page you can find the example usage for android.view Menu NONE.

Prototype

int NONE

To view the source code for android.view Menu NONE.

Click Source Link

Document

Value to use for group and item identifier integers when you don't care about them.

Usage

From source file:com.android.screenspeak.menurules.RuleEditText.java

@Override
public List<ContextMenuItem> getMenuItemsForNode(ScreenSpeakService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) {
    final AccessibilityNodeInfoCompat nodeCopy = AccessibilityNodeInfoCompat.obtain(node);
    final CursorController cursorController = service.getCursorController();
    final List<ContextMenuItem> items = new LinkedList<>();

    // This action has inconsistencies with EditText nodes that have
    // contentDescription attributes.
    if (TextUtils.isEmpty(nodeCopy.getContentDescription())) {
        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy,
                AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY)) {
            ContextMenuItem moveToBeginning = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.edittext_breakout_move_to_beginning, Menu.NONE,
                    service.getString(R.string.title_edittext_breakout_move_to_beginning));
            items.add(moveToBeginning);//from   w  ww . j  a  v a 2  s. c om
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy,
                AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY)) {
            ContextMenuItem moveToEnd = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.edittext_breakout_move_to_end, Menu.NONE,
                    service.getString(R.string.title_edittext_breakout_move_to_end));
            items.add(moveToEnd);
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_CUT)) {
            ContextMenuItem cut = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_cut,
                    Menu.NONE, service.getString(android.R.string.cut));
            items.add(cut);
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_COPY)) {
            ContextMenuItem copy = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.edittext_breakout_copy, Menu.NONE, service.getString(android.R.string.copy));
            items.add(copy);
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_PASTE)) {
            ContextMenuItem paste = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.edittext_breakout_paste, Menu.NONE, service.getString(android.R.string.paste));
            items.add(paste);
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy,
                AccessibilityNodeInfoCompat.ACTION_SET_SELECTION)) {
            ContextMenuItem select = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.edittext_breakout_select_all, Menu.NONE,
                    service.getString(android.R.string.selectAll));
            items.add(select);
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            // Text selection APIs are available in API 18+
            // TODO(CB) Use a checkable menu item once supported.
            final ContextMenuItem selectionMode;
            if (cursorController.isSelectionModeActive()) {
                selectionMode = menuItemBuilder.createMenuItem(service, Menu.NONE,
                        R.id.edittext_breakout_end_selection_mode, Menu.NONE,
                        service.getString(R.string.title_edittext_breakout_end_selection_mode));
            } else {
                selectionMode = menuItemBuilder.createMenuItem(service, Menu.NONE,
                        R.id.edittext_breakout_start_selection_mode, Menu.NONE,
                        service.getString(R.string.title_edittext_breakout_start_selection_mode));
            }

            items.add(selectionMode);
        }
    }

    for (ContextMenuItem item : items) {
        item.setOnMenuItemClickListener(new EditTextMenuItemClickListener(service, nodeCopy));
    }

    return items;
}

From source file:org.alfresco.mobile.android.application.fragments.actions.NodeIdActions.java

protected void getMenu(FragmentActivity activity, Menu menu) {
    SubMenu createMenu;//  ww w.j ava2 s  .  c o m

    // SYNC
    if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync);
        createMenu.setIcon(R.drawable.ic_sync_light);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_SYNC);

        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync);
        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync);
    }

    // FAVORITES
    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 2, R.string.favorite);
    createMenu.setIcon(R.drawable.ic_favorite_light);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
            ConfigurableActionHelper.ACTION_NODE_FAVORITE);

    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite);
    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite);

    // LIKE
    AlfrescoSession alfSession = SessionUtils.getSession(activity);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 3, R.string.like);
        createMenu.setIcon(R.drawable.ic_like);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        hideActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_LIKE);

        createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like);
        createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike);
    }
}

From source file:com.android.talkback.menurules.RuleGranularity.java

@Override
public List<ContextMenuItem> getMenuItemsForNode(TalkBackService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) {
    final CursorController cursorController = service.getCursorController();
    final CursorGranularity current = cursorController.getGranularityAt(node);
    final List<ContextMenuItem> items = new LinkedList<>();
    final List<CursorGranularity> granularities = CursorGranularityManager.getSupportedGranularities(service,
            node);/*  w w  w .  jav  a2s.  c  o  m*/
    final boolean hasWebContent = WebInterfaceUtils.hasNavigableWebContent(service, node);

    // Don't populate the menu if only object is supported.
    if (granularities.size() == 1) {
        return items;
    }

    final GranularityMenuItemClickListener clickListener = new GranularityMenuItemClickListener(service, node,
            hasWebContent);

    for (CursorGranularity granularity : granularities) {
        ContextMenuItem item = menuItemBuilder.createMenuItem(service, Menu.NONE, granularity.resourceId,
                Menu.NONE, service.getString(granularity.resourceId));
        item.setOnMenuItemClickListener(clickListener);
        item.setCheckable(true);
        item.setChecked(granularity.equals(current));

        // Items are added in "natural" order, e.g. object first.
        items.add(item);
    }

    if (hasWebContent) {
        // Web content support navigation at a pseudo granularity for
        // entering special content like math or tables. This must be
        // special cased as it doesn't fit the semantics of an actual
        // granularity.
        ContextMenuItem specialContent = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.pseudo_web_special_content, Menu.NONE,
                service.getString(R.string.granularity_pseudo_web_special_content));
        specialContent.setOnMenuItemClickListener(clickListener);
        items.add(specialContent);
    }

    return items;
}

From source file:id.ridon.keude.SearchResults.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    super.onCreateOptionsMenu(menu);
    MenuItem search = menu.add(Menu.NONE, SEARCH, 1, R.string.menu_search)
            .setIcon(android.R.drawable.ic_menu_search);
    MenuItemCompat.setShowAsAction(search, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    return true;//  ww  w .  j a  va 2 s .  c o  m
}

From source file:com.android.screenspeak.menurules.RuleUnlabeledImage.java

@Override
public List<ContextMenuItem> getMenuItemsForNode(ScreenSpeakService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) {
    List<ContextMenuItem> items = new LinkedList<>();
    CustomLabelManager labelManager = service.getLabelManager();
    if (labelManager == null) {
        return items;
    }//from   ww w .  j a v a 2s. c om

    AccessibilityNodeInfoCompat nodeCopy = AccessibilityNodeInfoCompat.obtain(node);
    Label viewLabel = labelManager.getLabelForViewIdFromCache(nodeCopy.getViewIdResourceName());
    if (viewLabel == null) {
        final ContextMenuItem addLabel = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.labeling_breakout_add_label, Menu.NONE,
                service.getString(R.string.label_dialog_title_add));
        items.add(addLabel);
    } else {
        ContextMenuItem editLabel = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.labeling_breakout_edit_label, Menu.NONE,
                service.getString(R.string.label_dialog_title_edit));
        ContextMenuItem removeLabel = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.labeling_breakout_remove_label, Menu.NONE,
                service.getString(R.string.label_dialog_title_remove));
        items.add(editLabel);
        items.add(removeLabel);
    }

    for (ContextMenuItem item : items) {
        item.setOnMenuItemClickListener(new UnlabeledImageMenuItemClickListener(service, nodeCopy, viewLabel));
    }

    return items;
}

From source file:org.puder.trs80.browser.FileBrowserActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItemCompat.setShowAsAction(/* w ww  .ja  v a  2  s  .c  o  m*/
            menu.add(Menu.NONE, MENU_OPTION_EJECT, Menu.NONE, this.getString(R.string.menu_eject))
                    .setIcon(R.drawable.eject_icon),
            MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat
            .setShowAsAction(menu.add(Menu.NONE, MENU_OPTION_ADD, Menu.NONE, this.getString(R.string.menu_add))
                    .setIcon(R.drawable.add_icon), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    return true;
}

From source file:com.android.screenspeak.menurules.RuleGranularity.java

@Override
public List<ContextMenuItem> getMenuItemsForNode(ScreenSpeakService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) {
    final CursorController cursorController = service.getCursorController();
    final CursorGranularity current = cursorController.getGranularityAt(node);
    final List<ContextMenuItem> items = new LinkedList<>();
    final List<CursorGranularity> granularities = CursorGranularityManager.getSupportedGranularities(service,
            node);/*from  w w  w . java 2  s . c  o  m*/
    final boolean hasWebContent = WebInterfaceUtils.hasNavigableWebContent(service, node);

    // Don't populate the menu if only object is supported.
    if (granularities.size() == 1) {
        return items;
    }

    final GranularityMenuItemClickListener clickListener = new GranularityMenuItemClickListener(service, node,
            hasWebContent);

    for (CursorGranularity granularity : granularities) {
        ContextMenuItem item = menuItemBuilder.createMenuItem(service, Menu.NONE, granularity.resourceId,
                Menu.NONE, service.getString(granularity.resourceId));
        item.setOnMenuItemClickListener(clickListener);
        item.setCheckable(true);
        item.setChecked(granularity.equals(current));

        // Items are added in "natural" order, e.g. object first.
        items.add(item);
    }

    if (hasWebContent) {
        // Web content support navigation at a pseudo granularity for
        // entering special content like math or tables. This must be
        // special cased as it doesn't fit the semantics of an actual
        // granularity.
        ContextMenuItem specialContent = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.pseudo_web_special_content, Menu.NONE,
                service.getString(R.string.granularity_pseudo_web_special_content));
        specialContent.setOnMenuItemClickListener(clickListener);
        items.add(specialContent);
    }

    return items;
}

From source file:com.android.talkback.menurules.RuleCustomAction.java

/**
 * Populates a menu with the context menu items for a node, searching up its ancestor
 * hierarchy if the current node has no custom actions.
 *///from   w ww.  j a  v a 2s . co  m
private void recursivelyPopulateMenuItemsForNode(TalkBackService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node, List<ContextMenuItem> menu) {
    if (node == null) {
        return;
    }

    for (AccessibilityActionCompat action : AccessibilityNodeInfoUtils.getCustomActions(node)) {
        CharSequence label = action.getLabel();
        int id = action.getId();
        if (TextUtils.isEmpty(label)) {
            continue;
        }

        ContextMenuItem item = menuItemBuilder.createMenuItem(service, Menu.NONE, id, Menu.NONE, label);
        item.setOnMenuItemClickListener(new CustomMenuItem(id, AccessibilityNodeInfoCompat.obtain(node)));
        item.setCheckable(false);
        menu.add(item);
    }

    if (menu.isEmpty()) {
        recursivelyPopulateMenuItemsForNode(service, menuItemBuilder, node.getParent(), menu);
    }
}

From source file:org.mariotaku.twidere.menu.AccountToggleProvider.java

@Override
public void onPrepareSubMenu(final SubMenu subMenu) {
    subMenu.removeGroup(MENU_GROUP);//from   w ww.  ja  va2s .com
    if (mAccounts == null)
        return;
    for (int i = 0, j = mAccounts.length; i < j; i++) {
        final ParcelableAccount account = mAccounts[i];
        final MenuItem item = subMenu.add(MENU_GROUP, Menu.NONE, i, account.name);
        final Intent intent = new Intent();
        intent.putExtra(EXTRA_ACCOUNT, account);
        item.setIntent(intent);
    }
    subMenu.setGroupCheckable(MENU_GROUP, true, mExclusive);
    for (int i = 0, j = subMenu.size(); i < j; i++) {
        final MenuItem item = subMenu.getItem(i);
        if (mAccounts[i].is_activated) {
            item.setChecked(true);
        }
    }
}

From source file:com.android.talkback.menurules.RuleUnlabeledImage.java

@Override
public List<ContextMenuItem> getMenuItemsForNode(TalkBackService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) {
    List<ContextMenuItem> items = new LinkedList<>();
    CustomLabelManager labelManager = service.getLabelManager();
    if (labelManager == null) {
        return items;
    }/*  www.  j a  v  a2 s  .  c  o  m*/

    AccessibilityNodeInfoCompat nodeCopy = AccessibilityNodeInfoCompat.obtain(node);
    Label viewLabel = labelManager.getLabelForViewIdFromCache(nodeCopy.getViewIdResourceName());
    if (viewLabel == null) {
        final ContextMenuItem addLabel = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.labeling_breakout_add_label, Menu.NONE,
                service.getString(R.string.label_dialog_title_add));
        items.add(addLabel);
    } else {
        ContextMenuItem editLabel = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.labeling_breakout_edit_label, Menu.NONE,
                service.getString(R.string.label_dialog_title_edit));
        ContextMenuItem removeLabel = menuItemBuilder.createMenuItem(service, Menu.NONE,
                R.id.labeling_breakout_remove_label, Menu.NONE,
                service.getString(R.string.label_dialog_title_remove));
        items.add(editLabel);
        items.add(removeLabel);
    }

    for (ContextMenuItem item : items) {
        item.setOnMenuItemClickListener(new UnlabeledImageMenuItemClickListener(service, nodeCopy, viewLabel));

        // Prevent re-speaking the node description right before showing the dialog.
        item.setSkipRefocusEvents(true);
    }

    return items;
}