Java Code Examples for android.view.MenuItem#SHOW_AS_ACTION_WITH_TEXT

The following examples show how to use android.view.MenuItem#SHOW_AS_ACTION_WITH_TEXT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactToolbar.java    From react-native-GPay with MIT License 6 votes vote down vote up
void setActions(@Nullable ReadableArray actions) {
  Menu menu = getMenu();
  menu.clear();
  mActionsHolder.clear();
  if (actions != null) {
    for (int i = 0; i < actions.size(); i++) {
      ReadableMap action = actions.getMap(i);

      MenuItem item = menu.add(Menu.NONE, Menu.NONE, i, action.getString(PROP_ACTION_TITLE));

      if (action.hasKey(PROP_ACTION_ICON)) {
        setMenuItemIcon(item, action.getMap(PROP_ACTION_ICON));
      }

      int showAsAction = action.hasKey(PROP_ACTION_SHOW)
          ? action.getInt(PROP_ACTION_SHOW)
          : MenuItem.SHOW_AS_ACTION_NEVER;
      if (action.hasKey(PROP_ACTION_SHOW_WITH_TEXT) &&
          action.getBoolean(PROP_ACTION_SHOW_WITH_TEXT)) {
        showAsAction = showAsAction | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
      }
      item.setShowAsAction(showAsAction);
    }
  }
}
 
Example 2
Source File: Button.java    From react-native-navigation with MIT License 6 votes vote down vote up
private static Number parseShowAsAction(JSONObject json) {
    final Text showAsAction = TextParser.parse(json, "showAsAction");
    if (!showAsAction.hasValue()) {
        return new Number(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    switch (showAsAction.get()) {
        case "always":
            return new Number(MenuItem.SHOW_AS_ACTION_ALWAYS);
        case "never":
            return new Number(MenuItem.SHOW_AS_ACTION_NEVER);
        case "withText":
            return new Number(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        case "ifRoom":
        default:
            return new Number(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}
 
Example 3
Source File: ListUnit.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	gridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE);
	gridView.clearChoices();
	mode.setTitle(instance.context.getString(R.string.text_selected_format, 0));
	int selectAllResId = ResourceUtils.getSystemSelectionIcon(instance.context, "actionModeSelectAllDrawable",
			"ic_menu_selectall_holo_dark");
	int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
	ActionIconSet set = new ActionIconSet(instance.context);
	menu.add(0, ACTION_MENU_SELECT_ALL, 0, R.string.action_select_all)
			.setIcon(selectAllResId).setShowAsAction(flags);
	menu.add(0, ACTION_MENU_DOWNLOAD_FILES, 0, R.string.action_download_files)
			.setIcon(set.getId(R.attr.actionDownload)).setShowAsAction(flags);
	return true;
}
 
Example 4
Source File: PostsPage.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	PageHolder pageHolder = getPageHolder();
	ChanConfiguration configuration = getChanConfiguration();
	getAdapter().setSelectionModeEnabled(true);
	mode.setTitle(getString(R.string.text_selected_format, 0));
	int pasteResId = ResourceUtils.getSystemSelectionIcon(getActivity(), "actionModePasteDrawable",
			"ic_menu_paste_holo_dark");
	int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
	ChanConfiguration.Board board = configuration.safe().obtainBoard(pageHolder.boardName);
	menu.add(0, ACTION_MENU_MAKE_THREADSHOT, 0, R.string.action_make_threadshot)
			.setIcon(obtainIcon(R.attr.actionMakeThreadshot)).setShowAsAction(flags);
	if (replyable != null) {
		menu.add(0, ACTION_MENU_REPLY, 0, R.string.action_reply).setIcon(pasteResId).setShowAsAction(flags);
	}
	if (board.allowDeleting) {
		ChanConfiguration.Deleting deleting = configuration.safe().obtainDeleting(pageHolder.boardName);
		if (deleting != null && deleting.multiplePosts) {
			menu.add(0, ACTION_MENU_DELETE_POSTS, 0, R.string.action_delete)
					.setIcon(obtainIcon(R.attr.actionDelete)).setShowAsAction(flags);
		}
	}
	if (board.allowReporting) {
		ChanConfiguration.Reporting reporting = configuration.safe().obtainReporting(pageHolder.boardName);
		if (reporting != null && reporting.multiplePosts) {
			menu.add(0, ACTION_MENU_SEND_REPORT, 0, R.string.action_report)
					.setIcon(obtainIcon(R.attr.actionReport)).setShowAsAction(flags);
		}
	}
	return true;
}
 
Example 5
Source File: CommentTextView.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	currentActionMode = mode;
	currentActionModeMenu = menu;
	setSelectionMode(true);
	int pasteResId = ResourceUtils.getSystemSelectionIcon(getContext(), "actionModePasteDrawable",
			"ic_menu_paste_holo_dark");
	ActionIconSet set = new ActionIconSet(getContext());
	int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
	if (C.API_MARSHMALLOW && mode.getType() == ActionMode.TYPE_FLOATING) {
		int order = 1; // Only "cut" menu item uses this order which doesn't present in non-editable TextView
		if (replyable != null) {
			menu.add(0, android.R.id.button1, order, R.string.action_quote)
					.setIcon(pasteResId).setShowAsAction(flags);
		}
		menu.add(0, android.R.id.button2, order, R.string.action_browser)
				.setIcon(set.getId(R.attr.actionForward)).setShowAsAction(flags);
	} else {
		if (replyable != null) {
			menu.add(0, android.R.id.button1, 0, R.string.action_quote).setIcon(pasteResId)
					.setShowAsAction(flags);
		}
		menu.add(0, android.R.id.button2, 0, R.string.action_browser).setIcon(set.getId(R.attr.actionForward))
				.setShowAsAction(flags);
	}
	// Stop selection fixation after creating action mode
	restoreSelectionRunnable = null;
	return true;
}