IME_ACTION_GO源码实例Demo

android.view.inputmethod.EditorInfo#IME_ACTION_GO源码实例Demo

下面列出了android.view.inputmethod.EditorInfo#IME_ACTION_GO 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: remotekeyboard   文件: CtrlInputAction.java
/**
 * Figure out how we are connected to the edittext and what it expects the
 * enter key to do.
 */
private void handleEnterKey(InputConnection con) {
	EditorInfo ei = myService.getCurrentInputEditorInfo();
	if (ei != null
			&& ((ei.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
		int[] acts = { EditorInfo.IME_ACTION_DONE, EditorInfo.IME_ACTION_SEARCH,
				EditorInfo.IME_ACTION_GO, EditorInfo.IME_ACTION_NEXT };

		for (int i : acts) {
			if ((ei.imeOptions & i) == i) {
				con.performEditorAction(i);
				return;
			}
		}
	}
	typeKey(con, KeyEvent.KEYCODE_ENTER);
}
 
public static String imeActionName(final int imeOptions) {
    final int actionId = imeOptions & EditorInfo.IME_MASK_ACTION;
    switch (actionId) {
    case EditorInfo.IME_ACTION_UNSPECIFIED:
        return "actionUnspecified";
    case EditorInfo.IME_ACTION_NONE:
        return "actionNone";
    case EditorInfo.IME_ACTION_GO:
        return "actionGo";
    case EditorInfo.IME_ACTION_SEARCH:
        return "actionSearch";
    case EditorInfo.IME_ACTION_SEND:
        return "actionSend";
    case EditorInfo.IME_ACTION_NEXT:
        return "actionNext";
    case EditorInfo.IME_ACTION_DONE:
        return "actionDone";
    case EditorInfo.IME_ACTION_PREVIOUS:
        return "actionPrevious";
    default:
        return "actionUnknown(" + actionId + ")";
    }
}
 
源代码3 项目: FirefoxReality   文件: KeyboardWidget.java
private void handleDone() {
    if (mComposingDisplayText.length() > 0) {
        // Finish current composing
        mComposingText = "";
        postInputCommand(() -> {
            displayComposingText(StringUtils.removeSpaces(mComposingDisplayText), ComposingAction.FINISH);
            postUICommand(this::updateCandidates);
        });
        return;
    }
    final InputConnection connection = mInputConnection;
    final int action = mEditorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
    postInputCommand(() -> connection.performEditorAction(action));

    boolean hide = (action == EditorInfo.IME_ACTION_DONE) || (action == EditorInfo.IME_ACTION_GO) ||
            (action == EditorInfo.IME_ACTION_SEARCH) || (action == EditorInfo.IME_ACTION_SEND);

    if (hide && mFocusedView != null) {
        mFocusedView.clearFocus();
    }
}
 
源代码4 项目: FirefoxReality   文件: BaseKeyboard.java
@Override
public String getEnterKeyText(int aIMEOptions, String aComposingText) {
    Locale locale = getLocale();
    switch (aIMEOptions & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            return StringUtils.getStringByLocale(mContext, R.string.keyboard_go_label, locale);
        case EditorInfo.IME_ACTION_NEXT:
            return StringUtils.getStringByLocale(mContext, R.string.keyboard_next_label, locale);
        case EditorInfo.IME_ACTION_SEARCH:
            return StringUtils.getStringByLocale(mContext, R.string.keyboard_search_label, locale);
        case EditorInfo.IME_ACTION_SEND:
            return StringUtils.getStringByLocale(mContext, R.string.keyboard_send_label, locale);
        default:
            return StringUtils.getStringByLocale(mContext, R.string.keyboard_enter_label, locale);
    }
}
 
源代码5 项目: Xndroid   文件: BrowserActivity.java
@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
    // hide the keyboard and search the web when the enter key
    // button is pressed
    if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
        || actionId == EditorInfo.IME_ACTION_NEXT
        || actionId == EditorInfo.IME_ACTION_SEND
        || actionId == EditorInfo.IME_ACTION_SEARCH
        || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
        searchTheWeb(mSearch.getText().toString());
        final LightningView currentView = mTabsManager.getCurrentTab();
        if (currentView != null) {
            currentView.requestFocus();
        }
        return true;
    }
    return false;
}
 
源代码6 项目: android-card-form   文件: ErrorEditText.java
/**
 * Request focus for the next view.
 */
@SuppressWarnings("WrongConstant")
public View focusNextView() {
    if (getImeActionId() == EditorInfo.IME_ACTION_GO) {
        return null;
    }

    View next;
    try {
        next = focusSearch(View.FOCUS_FORWARD);
    } catch (IllegalArgumentException e) {
        // View.FOCUS_FORWARD results in a crash in some versions of Android
        // https://github.com/braintree/braintree_android/issues/20
        next = focusSearch(View.FOCUS_DOWN);
    }
    if (next != null && next.requestFocus()) {
        return next;
    }

    return null;
}
 
源代码7 项目: Indic-Keyboard   文件: EditorInfoCompatUtils.java
public static String imeActionName(final int imeOptions) {
    final int actionId = imeOptions & EditorInfo.IME_MASK_ACTION;
    switch (actionId) {
    case EditorInfo.IME_ACTION_UNSPECIFIED:
        return "actionUnspecified";
    case EditorInfo.IME_ACTION_NONE:
        return "actionNone";
    case EditorInfo.IME_ACTION_GO:
        return "actionGo";
    case EditorInfo.IME_ACTION_SEARCH:
        return "actionSearch";
    case EditorInfo.IME_ACTION_SEND:
        return "actionSend";
    case EditorInfo.IME_ACTION_NEXT:
        return "actionNext";
    case EditorInfo.IME_ACTION_DONE:
        return "actionDone";
    case EditorInfo.IME_ACTION_PREVIOUS:
        return "actionPrevious";
    default:
        return "actionUnknown(" + actionId + ")";
    }
}
 
源代码8 项目: Tok-Android   文件: LoginActivity.java
@Override
public void onKeyboardAction(TextView textView, int actionId) {
    if (actionId == EditorInfo.IME_ACTION_GO) {
        mLoginPresenter.login(mUsernameEt.getText().toString().trim(),
            mPwdEt.getText().toString().trim());
    }
}
 
源代码9 项目: SoloPi   文件: AdbIME.java
@Subscriber(value = @Param(value = IME_SEARCH_MESSAGE, sticky = false), thread = RunningThread.MAIN_THREAD)
public boolean inputSearchText(String text) {
    if (text != null) {
        InputConnection ic = getCurrentInputConnection();
        if (ic != null) {
            ic.commitText(text, 1);

            // 需要额外点击发送
            EditorInfo editorInfo = getCurrentInputEditorInfo();
            if (editorInfo != null) {
                int options = editorInfo.imeOptions;
                final int actionId = options & EditorInfo.IME_MASK_ACTION;

                switch (actionId) {
                    case EditorInfo.IME_ACTION_SEARCH:
                        sendDefaultEditorAction(true);
                        break;
                    case EditorInfo.IME_ACTION_GO:
                        sendDefaultEditorAction(true);
                        break;
                    case EditorInfo.IME_ACTION_SEND:
                        sendDefaultEditorAction(true);
                        break;
                    default:
                        ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
                }
            }
            return true;
        }
    }
    return false;
}
 
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO) {
        verifyPassword();
        return true;
    }
    return false;
}
 
源代码11 项目: VCL-Android   文件: MRLPanelFragment.java
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (keyCode == EditorInfo.IME_ACTION_DONE ||
        keyCode == EditorInfo.IME_ACTION_GO ||
        event.getAction() == KeyEvent.ACTION_DOWN &&
        event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
        return processUri();
    }
    return false;
}
 
源代码12 项目: kboard   文件: KBoard.java
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
源代码13 项目: react-native-GPay   文件: ReactEditText.java
private void updateImeOptions() {
  // Default to IME_ACTION_DONE
  int returnKeyFlag = EditorInfo.IME_ACTION_DONE;
  if (mReturnKeyType != null) {
    switch (mReturnKeyType) {
      case "go":
        returnKeyFlag = EditorInfo.IME_ACTION_GO;
        break;
      case "next":
        returnKeyFlag = EditorInfo.IME_ACTION_NEXT;
        break;
      case "none":
        returnKeyFlag = EditorInfo.IME_ACTION_NONE;
        break;
      case "previous":
        returnKeyFlag = EditorInfo.IME_ACTION_PREVIOUS;
        break;
      case "search":
        returnKeyFlag = EditorInfo.IME_ACTION_SEARCH;
        break;
      case "send":
        returnKeyFlag = EditorInfo.IME_ACTION_SEND;
        break;
      case "done":
        returnKeyFlag = EditorInfo.IME_ACTION_DONE;
        break;
    }
  }

  if (mDisableFullscreen) {
    setImeOptions(returnKeyFlag | EditorInfo.IME_FLAG_NO_FULLSCREEN);
  } else {
    setImeOptions(returnKeyFlag);
  }
}
 
源代码14 项目: CSipSimple   文件: DialerFragment.java
@Override
public boolean onEditorAction(TextView tv, int action, KeyEvent arg2) {
    if (action == EditorInfo.IME_ACTION_GO) {
        placeCall();
        return true;
    }
    return false;
}
 
源代码15 项目: android-card-form   文件: CardForm.java
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO && mOnCardFormSubmitListener != null) {
        mOnCardFormSubmitListener.onCardFormSubmit();
        return true;
    }
    return false;
}
 
源代码16 项目: ucar-weex-core   文件: AbstractEditComponent.java
@WXComponentProp(name = Constants.Name.RETURN_KEY_TYPE)
public void setReturnKeyType(String type) {
  if (getHostView() == null) {
    return;
  }
  mReturnKeyType = type;
  switch (type) {
    case ReturnTypes.DEFAULT:
      mEditorAction = EditorInfo.IME_ACTION_UNSPECIFIED;
      break;
    case ReturnTypes.GO:
      mEditorAction = EditorInfo.IME_ACTION_GO;
      break;
    case ReturnTypes.NEXT:
      mEditorAction = EditorInfo.IME_ACTION_NEXT;
      break;
    case ReturnTypes.SEARCH:
      mEditorAction = EditorInfo.IME_ACTION_SEARCH;
      break;
    case ReturnTypes.SEND:
      mEditorAction = EditorInfo.IME_ACTION_SEND;
      break;
    case ReturnTypes.DONE:
      mEditorAction = EditorInfo.IME_ACTION_DONE;
      break;
    default:
      break;
  }

  //remove focus and hide keyboard first, the ImeOptions will take effect when show keyboard next time
  blur();
  getHostView().setImeOptions(mEditorAction);
}
 
源代码17 项目: Indic-Keyboard   文件: KeyCodeDescriptionMapper.java
/**
 * Returns a context-sensitive description of the "Enter" action key.
 *
 * @param context The package's context.
 * @param keyboard The keyboard on which the key resides.
 * @param key The key to describe.
 * @return Returns a context-sensitive description of the "Enter" action key.
 */
private static String getDescriptionForActionKey(final Context context, final Keyboard keyboard,
        final Key key) {
    final KeyboardId keyboardId = keyboard.mId;
    final int actionId = keyboardId.imeAction();
    final int resId;

    // Always use the label, if available.
    if (!TextUtils.isEmpty(key.getLabel())) {
        return key.getLabel().trim();
    }

    // Otherwise, use the action ID.
    switch (actionId) {
    case EditorInfo.IME_ACTION_SEARCH:
        resId = R.string.spoken_description_search;
        break;
    case EditorInfo.IME_ACTION_GO:
        resId = R.string.label_go_key;
        break;
    case EditorInfo.IME_ACTION_SEND:
        resId = R.string.label_send_key;
        break;
    case EditorInfo.IME_ACTION_NEXT:
        resId = R.string.label_next_key;
        break;
    case EditorInfo.IME_ACTION_DONE:
        resId = R.string.label_done_key;
        break;
    case EditorInfo.IME_ACTION_PREVIOUS:
        resId = R.string.label_previous_key;
        break;
    default:
        resId = R.string.spoken_description_return;
    }
    return context.getString(resId);
}
 
/**
 * Returns a context-sensitive description of the "Enter" action key.
 *
 * @param context The package's context.
 * @param keyboard The keyboard on which the key resides.
 * @param key The key to describe.
 * @return Returns a context-sensitive description of the "Enter" action key.
 */
private static String getDescriptionForActionKey(final Context context, final Keyboard keyboard,
        final Key key) {
    final KeyboardId keyboardId = keyboard.mId;
    final int actionId = keyboardId.imeAction();
    final int resId;

    // Always use the label, if available.
    if (!TextUtils.isEmpty(key.getLabel())) {
        return key.getLabel().trim();
    }

    // Otherwise, use the action ID.
    switch (actionId) {
    case EditorInfo.IME_ACTION_SEARCH:
        resId = R.string.spoken_description_search;
        break;
    case EditorInfo.IME_ACTION_GO:
        resId = R.string.label_go_key;
        break;
    case EditorInfo.IME_ACTION_SEND:
        resId = R.string.label_send_key;
        break;
    case EditorInfo.IME_ACTION_NEXT:
        resId = R.string.label_next_key;
        break;
    case EditorInfo.IME_ACTION_DONE:
        resId = R.string.label_done_key;
        break;
    case EditorInfo.IME_ACTION_PREVIOUS:
        resId = R.string.label_previous_key;
        break;
    default:
        resId = R.string.spoken_description_return;
    }
    return context.getString(resId);
}
 
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO) {
        verifyPassword();
        return true;
    }
    return false;
}
 
源代码20 项目: bither-android   文件: EntryKeyboardView.java
private void configureDoneButton() {
    View currentFocusView = getRootView().findFocus();
    if (currentFocusView == null) {
        return;
    }
    if (currentFocusView instanceof EditText) {
        EditText currentFocusEt = (EditText) currentFocusView;
        if (!Utils.isEmpty(currentFocusEt.getImeActionLabel() == null ? null :
                currentFocusEt.getImeActionLabel().toString())) {
            setEnterKeyText(currentFocusEt.getImeActionLabel());
        } else if (currentFocusEt.getImeActionId() > 0) {
            switch (currentFocusEt.getImeActionId()) {
                case EditorInfo.IME_ACTION_DONE:
                case EditorInfo.IME_ACTION_GO:
                case EditorInfo.IME_ACTION_SEND:
                    setEnterKeyText(getResources().getString(R.string.password_keyboard_done));
                    break;
                case EditorInfo.IME_ACTION_NEXT:
                    setEnterKeyText(getResources().getString(R.string.password_keyboard_next));
                    break;
                default:
                    break;
            }
        } else {
            View nextFocusView = currentFocusEt.focusSearch(View.FOCUS_DOWN);
            if (nextFocusView != null) {
                setEnterKeyText(getResources().getString(R.string.password_keyboard_next));
            } else {
                setEnterKeyText(getResources().getString(R.string.password_keyboard_done));
            }
        }
        EntryKeyboard keyboard = (EntryKeyboard) getKeyboard();
        invalidateKey(keyboard.getEnterKeyIndex());
    }
}