Search in sources :

Example 1 with InputConnectionWrapper

use of android.view.inputmethod.InputConnectionWrapper in project android_frameworks_base by ParanoidAndroid.

the class AbsListView method onCreateInputConnection.

/**
     * Return an InputConnection for editing of the filter text.
     */
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    if (isTextFilterEnabled()) {
        // XXX we need to have the text filter created, so we can get an
        // InputConnection to proxy to.  Unfortunately this means we pretty
        // much need to make it as soon as a list view gets focus.
        createTextFilter(false);
        if (mPublicInputConnection == null) {
            mDefInputConnection = new BaseInputConnection(this, false);
            mPublicInputConnection = new InputConnectionWrapper(mTextFilter.onCreateInputConnection(outAttrs), true) {

                @Override
                public boolean reportFullscreenMode(boolean enabled) {
                    // the "real" one the IME is talking with.
                    return mDefInputConnection.reportFullscreenMode(enabled);
                }

                @Override
                public boolean performEditorAction(int editorAction) {
                    // the one that does this.
                    if (editorAction == EditorInfo.IME_ACTION_DONE) {
                        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                        if (imm != null) {
                            imm.hideSoftInputFromWindow(getWindowToken(), 0);
                        }
                        return true;
                    }
                    return false;
                }

                @Override
                public boolean sendKeyEvent(KeyEvent event) {
                    // no ViewAncestor to dispatch events with.
                    return mDefInputConnection.sendKeyEvent(event);
                }
            };
        }
        outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_FILTER;
        outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
        return mPublicInputConnection;
    }
    return null;
}
Also used : BaseInputConnection(android.view.inputmethod.BaseInputConnection) KeyEvent(android.view.KeyEvent) InputConnectionWrapper(android.view.inputmethod.InputConnectionWrapper) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 2 with InputConnectionWrapper

use of android.view.inputmethod.InputConnectionWrapper in project XobotOS by xamarin.

the class AbsListView method onCreateInputConnection.

/**
     * Return an InputConnection for editing of the filter text.
     */
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    if (isTextFilterEnabled()) {
        // XXX we need to have the text filter created, so we can get an
        // InputConnection to proxy to.  Unfortunately this means we pretty
        // much need to make it as soon as a list view gets focus.
        createTextFilter(false);
        if (mPublicInputConnection == null) {
            mDefInputConnection = new BaseInputConnection(this, false);
            mPublicInputConnection = new InputConnectionWrapper(mTextFilter.onCreateInputConnection(outAttrs), true) {

                @Override
                public boolean reportFullscreenMode(boolean enabled) {
                    // the "real" one the IME is talking with.
                    return mDefInputConnection.reportFullscreenMode(enabled);
                }

                @Override
                public boolean performEditorAction(int editorAction) {
                    // the one that does this.
                    if (editorAction == EditorInfo.IME_ACTION_DONE) {
                        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                        if (imm != null) {
                            imm.hideSoftInputFromWindow(getWindowToken(), 0);
                        }
                        return true;
                    }
                    return false;
                }

                @Override
                public boolean sendKeyEvent(KeyEvent event) {
                    // no ViewAncestor to dispatch events with.
                    return mDefInputConnection.sendKeyEvent(event);
                }
            };
        }
        outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_FILTER;
        outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
        return mPublicInputConnection;
    }
    return null;
}
Also used : BaseInputConnection(android.view.inputmethod.BaseInputConnection) KeyEvent(android.view.KeyEvent) InputConnectionWrapper(android.view.inputmethod.InputConnectionWrapper) InputMethodManager(android.view.inputmethod.InputMethodManager)

Aggregations

KeyEvent (android.view.KeyEvent)2 BaseInputConnection (android.view.inputmethod.BaseInputConnection)2 InputConnectionWrapper (android.view.inputmethod.InputConnectionWrapper)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2