I'm newbie in Android programming and learning to make my own Android custom keyboard from sample HackersKeyboard and SoftKeyboard. I'm facing with auto-caps problem and have no idea how to overcome this: when user taps somewhere in input screen to move cursor to a beginning point of a sentence, keyboard should be auto-shifted.
Example: First, this is a sentence. Second, this is also a sentence. Third, this is a sentence too. When user taps to beginning of "Second" (after period and space from first sentence), keyboard should be shifted automatically.
For normal typing, when user reaches an end of a sentence (marked with sentence separator such as period or question mark), I've make it with below code in onKey method (in main class that extends InputMethodService):
@Override
public void onKey(int primaryCode, int[] keyCodes) {
    InputConnection ic = getCurrentInputConnection();
    switch(primaryCode){
        case Keyboard.KEYCODE_DELETE :
            CharSequence selectedText = ic.getSelectedText(0);
            if (TextUtils.isEmpty(selectedText)) {
                ic.deleteSurroundingText(1, 0);
            } else {
                ic.commitText("", 1);
            }
            break;
        case Keyboard.KEYCODE_SHIFT:
            bCaps = !bCaps;
            myKeyboard.setShifted(bCaps);
            myKeyboardView.invalidateAllKeys();
            break;
        case Keyboard.KEYCODE_DONE:
            ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
            break;
        default:
            char code = (char)primaryCode;
            if(Character.isLetter(code) && bCaps){
                code = Character.toUpperCase(code);
            }
            ic.commitText(String.valueOf(code),1);
            //--------------------------------------------
            //Detect end of a sentence then shift keyboard.
            //This is not done yet. It should turned back to lower after typing first letter of sentence.
            //--------------------------------------------
            CharSequence lastTwo = ic.getTextBeforeCursor(2, 0);
            if (lastTwo == null || lastTwo.length()<=0 ||
               (lastTwo.charAt(1) == ASCII_SPACE && isSentenceSeparator(lastTwo.charAt(0)))) {
                bCaps = true;
                myKeyboard.setShifted(bCaps);
                myKeyboardView.invalidateAllKeys();
            }
    }
}
I couldn't find any parts of sample HackersKeyboard and SoftKeyboard related to this auto-caps matter. Any help is really appreciated. Thanks very much.
Edit: this is not similar with First letter capitalization for EditText. Android custom keyboard is working at service level, and mainly aim to work globally with all kind of EditText.
 
    