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.arantius.tivocommander.Utils.java

@SuppressLint("NewApi")
final static void addToMenu(Menu menu, Activity activity, int itemId, int iconId, String title,
        int showAsAction) {
    if (Utils.activityForMenuId(itemId) == activity.getClass()) {
        return;/* w ww  .  ja  v  a  2  s  .com*/
    }
    MenuItem menuitem = menu.add(Menu.NONE, itemId, Menu.NONE, title);
    menuitem.setIcon(iconId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuitem.setShowAsAction(showAsAction);
    }
}

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

@Override
public List<ContextMenuItem> getMenuItemsForNode(TalkBackService 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_SET_SELECTION,
                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));
            moveToBeginning.setSkipRefocusEvents(true);
            items.add(moveToBeginning);//from w w w .  j a v  a 2 s  .co m
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy,
                AccessibilityNodeInfoCompat.ACTION_SET_SELECTION,
                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));
            moveToEnd.setSkipRefocusEvents(true);
            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));
            cut.setSkipRefocusEvents(true);
            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));
            copy.setSkipRefocusEvents(true);
            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));
            paste.setSkipRefocusEvents(true);
            items.add(paste);
        }

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

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            // Text selection APIs are available in API 18+
            // TODO 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));
            }

            selectionMode.setSkipRefocusEvents(true);
            items.add(selectionMode);
        }
    }

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

    return items;
}

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

@Override
public List<ContextMenuItem> getMenuItemsForNode(ScreenSpeakService service,
        ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) {
    final SpannableString spannable = (SpannableString) node.getText();
    final URLSpan[] urlSpans = spannable.getSpans(0, spannable.length(), URLSpan.class);
    final LinkedList<ContextMenuItem> result = new LinkedList<>();

    if ((urlSpans == null) || (urlSpans.length == 0)) {
        return result;
    }//from  ww w .  ja  v  a2 s . c  o m

    for (int i = 0; i < urlSpans.length; i++) {
        final URLSpan urlSpan = urlSpans[i];
        final String url = urlSpan.getURL();
        final int start = spannable.getSpanStart(urlSpan);
        final int end = spannable.getSpanEnd(urlSpan);
        final CharSequence label = spannable.subSequence(start, end);
        if (TextUtils.isEmpty(url) || TextUtils.isEmpty(label)) {
            continue;
        }

        final Uri uri = Uri.parse(url);
        if (uri.isRelative()) {
            // Generally, only absolute URIs are resolvable to an activity
            continue;
        }

        final ContextMenuItem item = menuItemBuilder.createMenuItem(service, Menu.NONE, i, Menu.NONE, label);
        item.setOnMenuItemClickListener(new SpannableMenuClickListener(service, uri));
        result.add(item);
    }

    return result;
}

From source file:at.alladin.rmbt.android.sync.RMBTSyncRequestCodeFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo contextMenuInfo) {
    if (view instanceof TextView && view == codeText)
        menu.add(Menu.NONE, view.getId(), Menu.NONE, R.string.sync_request_code_context_copy);
    else//from  ww  w  .j av  a 2  s.  c  o  m
        super.onCreateContextMenu(menu, view, contextMenuInfo);
}

From source file:com.commonsware.cwac.loaderex.demo.ConstantsBrowserACL.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, DELETE_ID, Menu.NONE, "Delete").setAlphabeticShortcut('d');
}

From source file:cz.msebera.unbound.dns.fragments.UnboundCheckConf.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, MENU_RUN, Menu.NONE, R.string.checkconf_menu_run_check)
            .setIcon(android.R.drawable.ic_media_play).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    super.onCreateOptionsMenu(menu, inflater);
}

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

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

    AccessibilityNodeInfoCompat rootNode = null;
    AccessibilityNodeInfoCompat pagerNode = null;

    try {/*from www.  j  a v a 2s .c  o m*/
        rootNode = AccessibilityNodeInfoUtils.getRoot(node);
        if (rootNode == null) {
            return items;
        }

        pagerNode = AccessibilityNodeInfoUtils.searchFromBfs(rootNode, FILTER_PAGED);
        if (pagerNode == null) {
            return items;
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(pagerNode,
                AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD)) {
            final ContextMenuItem prevPage = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.viewpager_breakout_prev_page, Menu.NONE,
                    service.getString(R.string.title_viewpager_breakout_prev_page));
            items.add(prevPage);
        }

        if (AccessibilityNodeInfoUtils.supportsAnyAction(pagerNode,
                AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD)) {
            final ContextMenuItem nextPage = menuItemBuilder.createMenuItem(service, Menu.NONE,
                    R.id.viewpager_breakout_next_page, Menu.NONE,
                    service.getString(R.string.title_viewpager_breakout_next_page));
            items.add(nextPage);
        }

        if (items.isEmpty()) {
            return items;
        }

        final AccessibilityNodeInfoCompat pagerNodeClone = AccessibilityNodeInfoCompat.obtain(pagerNode);
        final ViewPagerItemClickListener itemClickListener = new ViewPagerItemClickListener(pagerNodeClone);
        for (ContextMenuItem item : items) {
            item.setOnMenuItemClickListener(itemClickListener);
        }

        return items;
    } finally {
        AccessibilityNodeInfoUtils.recycleNodes(rootNode, pagerNode);
    }
}

From source file:com.gh4a.activities.IssueListBaseActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem item = menu.add(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.actions)
            .setIcon(R.drawable.abc_ic_menu_moreoverflow_mtrl_alpha);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    return super.onCreateOptionsMenu(menu);
}

From source file:org.kochka.android.weightlogger.WeightLoggerActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.mListView) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        menu.setHeaderTitle(((Measurement) mList.getItemAtPosition(info.position)).getFormatedRecordedAt());
        menu.add(Menu.NONE, 0, 0, R.string.edit);
        menu.add(Menu.NONE, 1, 1, R.string.delete);
    }/*  w  ww  .  ja v  a 2  s. c  o m*/
}

From source file:com.example.ScreenSlideActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_previous, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? "Finalizar" : "Siguiente");
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;//from   ww w  .j a va  2s .  c om
}