Java Code Examples for android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION

The following examples show how to use android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION . 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: TypefacedEditText.java    From buddycloud-android with Apache License 2.0 6 votes vote down vote up
@Override
	public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
	    InputConnection connection = super.onCreateInputConnection(outAttrs);
	    int imeActions = outAttrs.imeOptions&EditorInfo.IME_MASK_ACTION;
//	    if ((imeActions&EditorInfo.IME_ACTION_DONE) != 0) {
//	        // clear the existing action
//	        outAttrs.imeOptions ^= imeActions;
//	        // set the DONE action
//	        outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
//	    }
	    
	    if ((outAttrs.imeOptions&EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
	        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
	    }
	    return connection;
	}
 
Example 2
Source File: TextChipsEditView.java    From talk-android with MIT License 6 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection connection = super.onCreateInputConnection(outAttrs);
    int imeActions = outAttrs.imeOptions & EditorInfo.IME_MASK_ACTION;
    if ((imeActions & EditorInfo.IME_ACTION_DONE) != 0) {
        // clear the existing action
        outAttrs.imeOptions ^= imeActions;
        // set the DONE action
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
    }
    if ((outAttrs.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    }

    outAttrs.actionId = EditorInfo.IME_ACTION_DONE;
    outAttrs.actionLabel = getContext().getString(R.string.done);
    return connection;
}
 
Example 3
Source File: TokenCompleteTextView.java    From SocialTokenAutoComplete with Apache License 2.0 6 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    //Override normal multiline text handling of enter/done and force a done button
    TokenInputConnection connection = new TokenInputConnection(super.onCreateInputConnection(outAttrs), true);
    int imeActions = outAttrs.imeOptions&EditorInfo.IME_MASK_ACTION;
    if ((imeActions&EditorInfo.IME_ACTION_DONE) != 0) {
        // clear the existing action
        outAttrs.imeOptions ^= imeActions;
        // set the DONE action
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_DONE;
    }
    if ((outAttrs.imeOptions&EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    }
    return connection;
}
 
Example 4
Source File: BaseKeyboard.java    From FirefoxReality with Mozilla Public License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 5
Source File: EditorInfoCompatUtils.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public static String imeOptionsName(final int imeOptions) {
    final String action = imeActionName(imeOptions);
    final StringBuilder flags = new StringBuilder();
    if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        flags.append("flagNoEnterAction|");
    }
    if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0) {
        flags.append("flagNavigateNext|");
    }
    if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS) != 0) {
        flags.append("flagNavigatePrevious|");
    }
    if (hasFlagForceAscii(imeOptions)) {
        flags.append("flagForceAscii|");
    }
    return (action != null) ? flags + action : flags.toString();
}
 
Example 6
Source File: ReactTextInputPropertyTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testBlurMultiline() {
  ReactEditText view = mManager.createViewInstance(mThemedContext);

  mManager.updateProperties(view, buildStyles("multiline", true));
  mManager.updateProperties(view, buildStyles("blurOnSubmit", true));

  EditorInfo editorInfo = new EditorInfo();
  editorInfo.imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_ENTER_ACTION;
  view.onCreateInputConnection(editorInfo);

  assertThat(editorInfo.imeOptions).isEqualTo(EditorInfo.IME_ACTION_DONE);
}
 
Example 7
Source File: ComposeText.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
  InputConnection inputConnection = super.onCreateInputConnection(editorInfo);

  if(Prefs.isEnterSendsEnabled(getContext())) {
    editorInfo.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
  }

  if (Build.VERSION.SDK_INT < 21) return inputConnection;
  if (mediaListener == null)      return inputConnection;
  if (inputConnection == null)    return null;

  EditorInfoCompat.setContentMimeTypes(editorInfo, new String[] {"image/jpeg", "image/png", "image/gif"});
  return InputConnectionCompat.createWrapper(inputConnection, editorInfo, new CommitContentListener(mediaListener));
}
 
Example 8
Source File: KBoard.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example 9
Source File: ComposeText.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
  InputConnection inputConnection = super.onCreateInputConnection(editorInfo);

  if (SilencePreferences.getEnterKeyType(getContext()).equals("send")) {
    editorInfo.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
  }

  if (Build.VERSION.SDK_INT <= 13) return inputConnection;
  if (mediaListener == null)       return inputConnection;

  EditorInfoCompat.setContentMimeTypes(editorInfo, new String[] {"image/jpeg", "image/png", "image/gif"});
  return InputConnectionCompat.createWrapper(inputConnection, editorInfo, new CommitContentListener(mediaListener));
}
 
Example 10
Source File: LatinKeyboard.java    From AndroidKeyboard with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
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_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.ic_search_45dp);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.ic_check_circle_45dp);
            mEnterKey.label = null;
            break;
    }
}
 
Example 11
Source File: InputTypeUtils.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public static int getImeOptionsActionIdFromEditorInfo(final EditorInfo editorInfo) {
    if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        return EditorInfo.IME_ACTION_NONE;
    } else if (editorInfo.actionLabel != null) {
        return IME_ACTION_CUSTOM_LABEL;
    } else {
        // Note: this is different from editorInfo.actionId, hence "ImeOptionsActionId"
        return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
    }
}
 
Example 12
Source File: InputTypeUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public static int getImeOptionsActionIdFromEditorInfo(final EditorInfo editorInfo) {
    if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        return EditorInfo.IME_ACTION_NONE;
    } else if (editorInfo.actionLabel != null) {
        return IME_ACTION_CUSTOM_LABEL;
    } else {
        // Note: this is different from editorInfo.actionId, hence "ImeOptionsActionId"
        return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
    }
}
 
Example 13
Source File: InputTypeUtils.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public static int getImeOptionsActionIdFromEditorInfo(final EditorInfo editorInfo) {
    if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        return EditorInfo.IME_ACTION_NONE;
    } else if (editorInfo.actionLabel != null) {
        return IME_ACTION_CUSTOM_LABEL;
    } else {
        // Note: this is different from editorInfo.actionId, hence "ImeOptionsActionId"
        return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
    }
}
 
Example 14
Source File: ReactEditText.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
  ReactContext reactContext = (ReactContext) getContext();
  InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
  if (inputConnection != null && mOnKeyPress) {
    inputConnection = new ReactEditTextInputConnectionWrapper(inputConnection, reactContext, this);
  }

  if (isMultiline() && getBlurOnSubmit()) {
    // Remove IME_FLAG_NO_ENTER_ACTION to keep the original IME_OPTION
    outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
  }
  return inputConnection;
}
 
Example 15
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    outAttrs.inputType = InputType.TYPE_CLASS_TEXT
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION
            | EditorInfo.IME_ACTION_DONE
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    if (_inputConnection == null) {
        _inputConnection = this.new TextFieldInputConnection(this);
    } else {
        _inputConnection.resetComposingState();
    }
    return _inputConnection;
}
 
Example 16
Source File: LatinKeyboard.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    int valnorm = KeyEvent.KEYCODE_ENTER;

    switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            mEnterKey.codes = TERMINAL_ENTER;
            break;
    }
}
 
Example 17
Source File: TokenCompleteTextView.java    From TokenAutoComplete with Apache License 2.0 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) {
    InputConnection superConn = super.onCreateInputConnection(outAttrs);
    if (superConn != null) {
        TokenInputConnection conn = new TokenInputConnection(superConn, true);
        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
        outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI;
        return conn;
    } else {
        return null;
    }
}
 
Example 18
Source File: InputTypeUtils.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
public static int getImeOptionsActionIdFromEditorInfo(final EditorInfo editorInfo) {
    if ((editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        return EditorInfo.IME_ACTION_NONE;
    } else if (editorInfo.actionLabel != null) {
        return IME_ACTION_CUSTOM_LABEL;
    } else {
        // Note: this is different from editorInfo.actionId, hence "ImeOptionsActionId"
        return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
    }
}
 
Example 19
Source File: KBoard.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
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;
    }
}
 
Example 20
Source File: BaldInputMethodService.java    From BaldPhone with Apache License 2.0 4 votes vote down vote up
public static boolean defaultEditorActionExists(final int imeOptions) {
    return ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0) &&
            (imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE;

}