Example usage for android.view.inputmethod EditorInfo IME_FLAG_NAVIGATE_NEXT

List of usage examples for android.view.inputmethod EditorInfo IME_FLAG_NAVIGATE_NEXT

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_FLAG_NAVIGATE_NEXT.

Prototype

int IME_FLAG_NAVIGATE_NEXT

To view the source code for android.view.inputmethod EditorInfo IME_FLAG_NAVIGATE_NEXT.

Click Source Link

Document

Flag of #imeOptions : used to specify that there is something interesting that a forward navigation can focus on.

Usage

From source file:com.irccloud.android.ActionEditText.java

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection ic = super.onCreateInputConnection(outAttrs);
    if (ic == null)
        return null;

    if (Build.VERSION.SDK_INT >= 19 && getEmojiEditTextHelper() != null)
        ic = getEmojiEditTextHelper().onCreateInputConnection(ic, outAttrs);

    outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
    outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NAVIGATE_NEXT;
    if (IRCCloudApplication.getInstance().getApplicationContext().getResources().getBoolean(R.bool.isTablet)
            || PreferenceManager//from   w  w w .j  av  a2  s. co  m
                    .getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext())
                    .getBoolean("kb_send", false)) {
        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
        outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
    } else {
        outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    }
    if (PreferenceManager.getDefaultSharedPreferences(IRCCloudApplication.getInstance().getApplicationContext())
            .getBoolean("kb_caps", true)) {
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES;
    } else {
        outAttrs.inputType &= ~EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }
    EditorInfoCompat.setContentMimeTypes(outAttrs, new String[] { "image/*" });

    final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() {
        @Override
        public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
            // read and display inputContentInfo asynchronously
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1
                    && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
                try {
                    inputContentInfo.requestPermission();
                } catch (Exception e) {
                    return false; // return false if failed
                }
            }

            if (imageListener != null) {
                boolean result = imageListener.onIMEImageReceived(inputContentInfo);
                inputContentInfo.releasePermission();
                return result;
            }
            return false;
        }
    };
    return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
}