1

Practially I want to develop a keyboard for my local language,and after studying the developers document on IME and playing with the sample app for Softkeyboard I came to conclusion that the qwerty xml file contains the keycodes that are sent to the input field. But the keycodes are allowed to be only ASCII character but mine local language is unicode character for more specific its a Devanagiri font . And so please can any one show me the way to do this from here. I thought of using switch case for each ASCII code and send respective Devanagiri I wish to the input field by committing text "क" for a ASCII code of q, but I don't think is the good Idea. Please if anyone have good idea.

My proposal for implementing this idea is as:

private void handleCharacter(int primaryCode, int[] keyCodes) {

    Log.v("*************","primary code is:"+primaryCode);
    if (isInputViewShown()) {
        if (mInputView.isShifted()) {
            primaryCode = Character.toUpperCase(primaryCode);
        }
    }
    if (isAlphabet(primaryCode) && mPredictionOn) {
        switch (primaryCode){
            case 113:
                mComposing.append("क");
                getCurrentInputConnection().setComposingText(mComposing,1);
                updateShiftKeyState(getCurrentInputEditorInfo());
                updateCandidates();
                break;
            default:
                mComposing.append((char) primaryCode);
                getCurrentInputConnection().setComposingText(mComposing, 1);
                updateShiftKeyState(getCurrentInputEditorInfo());
                updateCandidates();

        }

    } else {

        //changes made here
        getCurrentInputConnection().commitText(
                String.valueOf((char) primaryCode), 1);

        //getCurrentInputConnection().commitText("क",1);
    }
}

But this method doesn't look appropriate so please can i get some guidelines.

Homnath Bagale
  • 464
  • 1
  • 6
  • 32
Dilip Poudel
  • 329
  • 3
  • 11
  • 1
    create a key for that character and assign it a non-ascii key code and then use it. – Vivek Mishra Feb 03 '17 at 08:41
  • @Vivek Mishra So then I should use the switch case any way. – Dilip Poudel Feb 03 '17 at 09:16
  • 1
    yes you have to – Vivek Mishra Feb 03 '17 at 10:01
  • ok I will follow that . Thank you – Dilip Poudel Feb 03 '17 at 10:36
  • THe general way you do it is by not using any of the built in Keyboard or KeyboardView classes, so you aren't constrained by their design. None of the major keyboards use any of them, they directly subclass InputMethodService and use their own custom views and data structures. – Gabe Sechan Feb 04 '17 at 08:34
  • @Gabe Sechan Thank you for the comment , but here I am developing a translator keyboard , which translates k to क which both pronounce same or also can be called romanizer. So I think I would need those built in keyboard but should implement them in custom way. – Dilip Poudel Feb 05 '17 at 08:07
  • @DilipPoudel And I developed Swype, which looks like any other keyboard. It was still easier to do everything custom. The only way I'd use the built in keyboard classes was if I was working on an auto correct algorithm as a pure research project. Four anything else they're more pain to work with than useful. They're extremely limiting. – Gabe Sechan Feb 05 '17 at 14:06
  • @Gabe Sechan I also want to do same like auto correct with my local language and till now I am using default classes and editing them and I have choosen the way to use switch case with each AscII character and place my desired letter. And till now when I type black it gives me बलाचक and I am still working on it. – Dilip Poudel Feb 06 '17 at 16:29

0 Answers0