Example usage for android.view.inputmethod EditorInfo IME_ACTION_UNSPECIFIED

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

Introduction

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

Prototype

int IME_ACTION_UNSPECIFIED

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

Click Source Link

Document

Bits of #IME_MASK_ACTION : no specific action has been associated with this editor, let the editor come up with its own if it can.

Usage

From source file:com.grass.caishi.cc.activity.ChatActivity.java

/**
 * initView/* w  w  w. j  av  a2  s  .  c  om*/
 */
protected void initView() {
    recordingContainer = findViewById(R.id.recording_container);
    micImage = (ImageView) findViewById(R.id.mic_image);
    recordingHint = (TextView) findViewById(R.id.recording_hint);
    listView = (ListView) findViewById(R.id.list);
    mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
    buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
    buttonSend = findViewById(R.id.btn_send);
    buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
    expressionViewpager = (ViewPager) findViewById(R.id.vPager);
    expressionContainer = (LinearLayout) findViewById(R.id.ll_face_container);
    btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container);
    locationImgview = (ImageView) findViewById(R.id.btn_location);
    iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal);
    iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked);
    loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more);
    btnMore = (Button) findViewById(R.id.btn_more);
    iv_emoticons_normal.setVisibility(View.VISIBLE);
    iv_emoticons_checked.setVisibility(View.INVISIBLE);
    more = findViewById(R.id.more);
    edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);

    voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call);
    videoCallBtn = (ImageView) findViewById(R.id.btn_video_call);

    // ?,
    micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01),
            getResources().getDrawable(R.drawable.record_animate_02),
            getResources().getDrawable(R.drawable.record_animate_03),
            getResources().getDrawable(R.drawable.record_animate_04),
            getResources().getDrawable(R.drawable.record_animate_05),
            getResources().getDrawable(R.drawable.record_animate_06),
            getResources().getDrawable(R.drawable.record_animate_07),
            getResources().getDrawable(R.drawable.record_animate_08),
            getResources().getDrawable(R.drawable.record_animate_09),
            getResources().getDrawable(R.drawable.record_animate_10),
            getResources().getDrawable(R.drawable.record_animate_11),
            getResources().getDrawable(R.drawable.record_animate_12),
            getResources().getDrawable(R.drawable.record_animate_13),
            getResources().getDrawable(R.drawable.record_animate_14), };
    // list
    reslist = getExpressionRes(143);
    // ?viewpager
    List<View> views = getGridChildView();
    expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));
    edittext_layout.requestFocus();
    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());
    mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            } else {
                edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
            }

        }
    });
    mEditTextContent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
        }
    });
    // ?
    mEditTextContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                btnMore.setVisibility(View.GONE);
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                btnMore.setVisibility(View.VISIBLE);
                buttonSend.setVisibility(View.GONE);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

    mEditTextContent.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
            // TODO Auto-generated method stub
            if (arg1 == EditorInfo.IME_ACTION_UNSPECIFIED) {
                // String s = mEditTextContent.getText().toString();
                // sendText(s);
                // mEditTextContent.setText("");
                // Toast.makeText(ChatActivity.this, "",
                // Toast.LENGTH_SHORT).show();
            }

            return false;
        }

    });

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout);

    // swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);

    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) {
                        List<EMMessage> messages;
                        try {
                            if (chatType == CHATTYPE_SINGLE) {
                                messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(),
                                        pagesize);
                            } else {
                                messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(),
                                        pagesize);
                            }
                        } catch (Exception e1) {
                            swipeRefreshLayout.setRefreshing(false);
                            return;
                        }

                        if (messages.size() > 0) {
                            adapter.notifyDataSetChanged();
                            // adapter.refreshSeekTo(messages.size() - 1);
                            if (messages.size() != pagesize) {
                                haveMoreData = false;
                            }
                        } else {
                            haveMoreData = false;
                        }

                        isloading = false;

                    } else {
                        // Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show();
                    }
                    swipeRefreshLayout.setRefreshing(false);
                }
            }, 1000);
        }
    });

}

From source file:com.duy.pascal.ui.view.console.ConsoleView.java

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    outAttrs.inputType = InputType.TYPE_NULL;
    //        outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
    return new InputConnection() {
        /**/*w  w  w . j  av a 2s . c  o m*/
         * Used to handle composing text requests
         */
        private int mCursor;
        private int mComposingTextStart;
        private int mComposingTextEnd;
        private int mSelectedTextStart = 0;
        private int mSelectedTextEnd = 0;
        private boolean mInBatchEdit;

        private void sendText(CharSequence text) {
            DLog.d(TAG, "sendText: " + text);
            int n = text.length();
            for (int i = 0; i < n; i++) {
                mKeyBuffer.push(text.charAt(i));
                putString(Character.toString(text.charAt(i)));
            }
        }

        @Override
        public boolean performEditorAction(int actionCode) {
            DLog.d(TAG, "performEditorAction: " + actionCode);
            if (actionCode == EditorInfo.IME_ACTION_DONE || actionCode == EditorInfo.IME_ACTION_GO
                    || actionCode == EditorInfo.IME_ACTION_NEXT || actionCode == EditorInfo.IME_ACTION_SEND
                    || actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) {
                sendText("\n");
                return true;
            }
            return false;
        }

        public boolean beginBatchEdit() {
            {
                DLog.w(TAG, "beginBatchEdit");
            }
            setImeBuffer("");
            mCursor = 0;
            mComposingTextStart = 0;
            mComposingTextEnd = 0;
            mInBatchEdit = true;
            return true;
        }

        public boolean clearMetaKeyStates(int arg0) {
            {
                DLog.w(TAG, "clearMetaKeyStates " + arg0);
            }
            return false;
        }

        public boolean commitCompletion(CompletionInfo arg0) {
            {
                DLog.w(TAG, "commitCompletion " + arg0);
            }
            return false;
        }

        @Override
        public boolean commitCorrection(CorrectionInfo correctionInfo) {
            return false;
        }

        public boolean endBatchEdit() {
            {
                DLog.w(TAG, "endBatchEdit");
            }
            mInBatchEdit = false;
            return true;
        }

        public boolean finishComposingText() {
            {
                DLog.w(TAG, "finishComposingText");
            }
            sendText(mImeBuffer);
            setImeBuffer("");
            mComposingTextStart = 0;
            mComposingTextEnd = 0;
            mCursor = 0;
            return true;
        }

        public int getCursorCapsMode(int arg0) {
            {
                DLog.w(TAG, "getCursorCapsMode(" + arg0 + ")");
            }
            return 0;
        }

        public ExtractedText getExtractedText(ExtractedTextRequest arg0, int arg1) {
            {
                DLog.w(TAG, "getExtractedText" + arg0 + "," + arg1);
            }
            return null;
        }

        public CharSequence getTextAfterCursor(int n, int flags) {
            {
                DLog.w(TAG, "getTextAfterCursor(" + n + "," + flags + ")");
            }
            int len = Math.min(n, mImeBuffer.length() - mCursor);
            if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) {
                return "";
            }
            return mImeBuffer.substring(mCursor, mCursor + len);
        }

        public CharSequence getTextBeforeCursor(int n, int flags) {
            {
                DLog.w(TAG, "getTextBeforeCursor(" + n + "," + flags + ")");
            }
            int len = Math.min(n, mCursor);
            if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) {
                return "";
            }
            return mImeBuffer.substring(mCursor - len, mCursor);
        }

        public boolean performContextMenuAction(int arg0) {
            {
                DLog.w(TAG, "performContextMenuAction" + arg0);
            }
            return true;
        }

        public boolean performPrivateCommand(String arg0, Bundle arg1) {
            {
                DLog.w(TAG, "performPrivateCommand" + arg0 + "," + arg1);
            }
            return true;
        }

        @Override
        public boolean requestCursorUpdates(int cursorUpdateMode) {
            return false;
        }

        @Override
        public Handler getHandler() {
            return null;
        }

        @Override
        public void closeConnection() {

        }

        @Override
        public boolean commitContent(@NonNull InputContentInfo inputContentInfo, int flags, Bundle opts) {
            return false;
        }

        public boolean reportFullscreenMode(boolean arg0) {
            {
                DLog.w(TAG, "reportFullscreenMode" + arg0);
            }
            return true;
        }

        public boolean commitText(CharSequence text, int newCursorPosition) {
            {
                DLog.w(TAG, "commitText(\"" + text + "\", " + newCursorPosition + ")");
            }
            char[] characters = text.toString().toCharArray();
            for (char character : characters) {
                mKeyBuffer.push(character);
            }
            clearComposingText();
            sendText(text);
            setImeBuffer("");
            mCursor = 0;
            return true;
        }

        private void clearComposingText() {
            setImeBuffer(
                    mImeBuffer.substring(0, mComposingTextStart) + mImeBuffer.substring(mComposingTextEnd));
            if (mCursor < mComposingTextStart) {
                // do nothing
            } else if (mCursor < mComposingTextEnd) {
                mCursor = mComposingTextStart;
            } else {
                mCursor -= mComposingTextEnd - mComposingTextStart;
            }
            mComposingTextEnd = mComposingTextStart = 0;
        }

        public boolean deleteSurroundingText(int leftLength, int rightLength) {
            {
                DLog.w(TAG, "deleteSurroundingText(" + leftLength + "," + rightLength + ")");
            }
            if (leftLength > 0) {
                for (int i = 0; i < leftLength; i++) {
                    sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
                }
            } else if ((leftLength == 0) && (rightLength == 0)) {
                // Delete key held down / repeating
                sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }
            // TODO: handle forward deletes.
            return true;
        }

        @Override
        public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) {
            return false;
        }

        public boolean sendKeyEvent(KeyEvent event) {
            {
                DLog.w(TAG, "sendKeyEvent(" + event + ")");
            }
            // Some keys are sent here rather than to commitText.
            // In particular, del and the digit keys are sent here.
            // (And I have reports that the HTC Magic also sends Return here.)
            // As a bit of defensive programming, handle every key.
            dispatchKeyEvent(event);
            return true;
        }

        public boolean setComposingText(CharSequence text, int newCursorPosition) {
            {
                DLog.w(TAG, "setComposingText(\"" + text + "\", " + newCursorPosition + ")");
            }

            setImeBuffer(mImeBuffer.substring(0, mComposingTextStart) + text
                    + mImeBuffer.substring(mComposingTextEnd));
            mComposingTextEnd = mComposingTextStart + text.length();
            mCursor = newCursorPosition > 0 ? mComposingTextEnd + newCursorPosition - 1
                    : mComposingTextStart - newCursorPosition;
            return true;
        }

        public boolean setSelection(int start, int end) {
            {
                DLog.w(TAG, "setSelection" + start + "," + end);
            }
            int length = mImeBuffer.length();
            if (start == end && start > 0 && start < length) {
                mSelectedTextStart = mSelectedTextEnd = 0;
                mCursor = start;
            } else if (start < end && start > 0 && end < length) {
                mSelectedTextStart = start;
                mSelectedTextEnd = end;
                mCursor = start;
            }
            return true;
        }

        public boolean setComposingRegion(int start, int end) {
            {
                DLog.w(TAG, "setComposingRegion " + start + "," + end);
            }
            if (start < end && start > 0 && end < mImeBuffer.length()) {
                clearComposingText();
                mComposingTextStart = start;
                mComposingTextEnd = end;
            }
            return true;
        }

        public CharSequence getSelectedText(int flags) {
            try {

                {
                    DLog.w(TAG, "getSelectedText " + flags);
                }

                if (mImeBuffer.length() < 1) {
                    return "";
                }

                return mImeBuffer.substring(mSelectedTextStart, mSelectedTextEnd + 1);

            } catch (Exception ignored) {

            }

            return "";
        }

    };
}

From source file:com.ieeton.agency.activity.ChatActivity.java

/**
 * initView/*from  ww w.  j  a va2  s. c  om*/
 */
protected void initView() {
    recordingContainer = findViewById(R.id.recording_container);
    micImage = (ImageView) findViewById(R.id.mic_image);
    recordingHint = (TextView) findViewById(R.id.recording_hint);
    listView = (ListView) findViewById(R.id.list);
    mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
    buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
    mBtnQuick = (Button) findViewById(R.id.btn_quick_reply);
    buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
    expressionViewpager = (ViewPager) findViewById(R.id.vPager);
    expressionContainer = (LinearLayout) findViewById(R.id.ll_face_container);
    btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container);
    locationImgview = (ImageView) findViewById(R.id.btn_location);
    //iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal);
    //iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked);
    loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more);
    buttonSend = findViewById(R.id.btn_send);
    //btnMore = (Button) findViewById(R.id.btn_more);
    //iv_emoticons_normal.setVisibility(View.VISIBLE);
    //iv_emoticons_checked.setVisibility(View.INVISIBLE);
    more = findViewById(R.id.more);
    //edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);

    mTitleName = (TextView) findViewById(R.id.name);
    mBtnAdd = (ImageButton) findViewById(R.id.iv_add);
    mBtnAdd.setOnClickListener(this);
    mBtnCall = (ImageButton) findViewById(R.id.iv_call);
    mBtnCall.setOnClickListener(this);
    mBtnShare = (ImageButton) findViewById(R.id.iv_share);
    mBtnShare.setOnClickListener(this);
    mBtnPhoto = (Button) findViewById(R.id.btn_photo);
    mBtnPhoto.setOnClickListener(this);
    mBtnQuick.setOnClickListener(this);
    buttonSend.setOnClickListener(this);
    mBackBtn = (LinearLayout) findViewById(R.id.ll_back);
    mBackBtn.setOnClickListener(this);

    // ?,
    micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01),
            getResources().getDrawable(R.drawable.record_animate_02),
            getResources().getDrawable(R.drawable.record_animate_03),
            getResources().getDrawable(R.drawable.record_animate_04),
            getResources().getDrawable(R.drawable.record_animate_05),
            getResources().getDrawable(R.drawable.record_animate_06),
            getResources().getDrawable(R.drawable.record_animate_07),
            getResources().getDrawable(R.drawable.record_animate_08),
            getResources().getDrawable(R.drawable.record_animate_09),
            getResources().getDrawable(R.drawable.record_animate_10),
            getResources().getDrawable(R.drawable.record_animate_11),
            getResources().getDrawable(R.drawable.record_animate_12),
            getResources().getDrawable(R.drawable.record_animate_13),
            getResources().getDrawable(R.drawable.record_animate_14), };
    // list
    reslist = getExpressionRes(35);
    // ?viewpager
    List<View> views = new ArrayList<View>();
    View gv1 = getGridChildView(1);
    View gv2 = getGridChildView(2);
    views.add(gv1);
    views.add(gv2);
    expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));
    edittext_layout.requestFocus();
    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());
    //      mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() {
    //
    //         @Override
    //         public void onFocusChange(View v, boolean hasFocus) {
    //            if (hasFocus) {
    //               edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
    //            } else {
    //               edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
    //            }
    //
    //         }
    //      });
    mEditTextContent.setImeOptions(EditorInfo.IME_ACTION_SEND);
    mEditTextContent.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            switch (actionId) {
            case EditorInfo.IME_ACTION_UNSPECIFIED:
            case EditorInfo.IME_ACTION_SEND:
                String s = mEditTextContent.getText().toString();
                sendText(s);
                return true;
            default:
                return false;
            }
        }
    });

    mEditTextContent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            more.setVisibility(View.GONE);
            //iv_emoticons_normal.setVisibility(View.VISIBLE);
            //iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
        }
    });
    // ?
    mEditTextContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                mBtnQuick.setVisibility(View.GONE);
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                mBtnQuick.setVisibility(View.VISIBLE);
                buttonSend.setVisibility(View.GONE);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java

private Drawable getIconForKeyCode(int keyCode) {
    Drawable icon = getDrawableForKeyCode(keyCode);
    // maybe a drawable state is required
    if (icon != null) {
        switch (keyCode) {
        case KeyCodes.ENTER:
            Logger.d(TAG, "Action key action ID is %d", mKeyboardActionType);
            switch (mKeyboardActionType) {
            case EditorInfo.IME_ACTION_DONE:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_DONE);
                break;
            case EditorInfo.IME_ACTION_GO:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_GO);
                break;
            case EditorInfo.IME_ACTION_SEARCH:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_SEARCH);
                break;
            case EditorInfo.IME_ACTION_NONE:
            case EditorInfo.IME_ACTION_UNSPECIFIED:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_NORMAL);
                break;
            }/*w w  w  .  j  a va2  s .c  o m*/
            break;
        case KeyCodes.SHIFT:
            if (mKeyboard.isShiftLocked())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_LOCKED);
            else if (mKeyboard.isShifted())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        case KeyCodes.CTRL:
            if (mKeyboard.isControl())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        }
    }
    return icon;
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

public void setKeyboardActionType(final int imeOptions) {
    Log.d(TAG, "setKeyboardActionType imeOptions:" + imeOptions + " action:"
            + (imeOptions & EditorInfo.IME_MASK_ACTION));
    if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0)// this is
        // usually a
        // multi-line
        // edittext
        // box// w  w w. ja  v a2 s . co m
        mKeyboardActionType = EditorInfo.IME_ACTION_UNSPECIFIED;
    else
        mKeyboardActionType = (imeOptions & EditorInfo.IME_MASK_ACTION);

    // setting the icon/text
    setSpecialKeysIconsAndLabels();
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

private Drawable getIconForKeyCode(int keyCode) {
    Drawable icon = mKeysIcons.get(keyCode);

    if (icon == null) {
        // building needed icon
        Log.d(TAG, "Building icon for key-code %d", keyCode);
        DrawableBuilder builder = mKeysIconBuilders.get(keyCode);
        if (builder == null)
            return null;
        icon = builder.buildDrawable();//from  ww w . j a  v  a  2  s .  c  o m
        mKeysIcons.put(keyCode, icon);
        Log.d(TAG, "Current drawable cache size is %d", mKeysIcons.size());
    }
    // maybe a drawable state is required
    if (icon != null) {
        switch (keyCode) {
        case KeyCodes.ENTER:
            Log.d(TAG, "Action key action ID is %d", mKeyboardActionType);
            switch (mKeyboardActionType) {
            case EditorInfo.IME_ACTION_DONE:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_DONE);
                break;
            case EditorInfo.IME_ACTION_GO:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_GO);
                break;
            case EditorInfo.IME_ACTION_SEARCH:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_SEARCH);
                break;
            case EditorInfo.IME_ACTION_NONE:
            case EditorInfo.IME_ACTION_UNSPECIFIED:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_NORMAL);
                break;
            }
            break;
        case KeyCodes.SHIFT:
            if (mKeyboard.isShiftLocked())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_LOCKED);
            else if (mKeyboard.isShifted())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        case KeyCodes.CTRL:
            if (mKeyboard.isControl())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        }
    }
    return icon;
}