<How to create your own dictionary plugged in B16x2 Keyboard>
Any third party developers, to provide words list and spelling check, can create their own dictionaries plugged in B16x2 Keyboard as below.
The dictionary you create is a completely separate app you distribute for fee or for free in your possession.
Following description is based on the developing environment of Eclipse with the ADT Plugin.
1. The entire project and Manifest file
"b16kb.chinese" is the internal name of the dictionary and displayed in selecting a dictionary at B16x2 Keyboard. You should replace it with the name of your dictionary. The other part of each long name must not be changed. Also, you must keep rectangle as it is in Manifest file. (A hanja dictionary must additionally include 'hnj' tag like 'com.bestcashbook.an.plugin.hnj.b16hanja' and the others must not include '.hnj.' in the name.
2. IDctService.aidl
"com.bestcashbook.plugin" and "IDctService.aidl" inside it must be kept as they are. You must not make any change of them.
3. The skeleton of DctService.java
"DctService.java" is your main coding file. You must keep the name as it is.
- Here, we utilize SQLiteHelper for SQL. You can make your own configurations according to how you utilize SQL.
- You will need to copy your DB if there is not.
- In addition, as shown in the first rectangle, you will need to create user DB to handle "addUsDb" and "delUsDb".
- The second rectangle is the main coding part.
- You must keep the entire skeleton as they are.
4. CandidateList - return the list of words
B16x2 Keyboard, whenever there is keyboard input or text change, calls "CandidateList". CandidateList returns a list of words. This is the core part. Any others exist for this.
- beforecursor : string before cursor. maximum is 32.
- aftercursor : string after cursor. maximum is 32.
- composing : string under composing. They are underlined in the text screen. It is "" just after selecting a word at candidate view or pressing space.
- numofreturn : the number of words that users want, selected by users at setting.
- mode : 1 if Kanji mode(3rd menu key is one pressed), 2 if Kundoku mode(3rd menu key is two pressed), else 0 in case of Japanese, otherwise 0 if simplified mode, else if traditional mode.
- Return : CandidateList returns numofreturn+2 -> changed since v5.0
- The first word is one of "0", "1", "a".
- "0" means there is no spelling error.
- "1" means there is an spelling error and the list is red.
- "a" means there is an spelling error and the list is red and will be always corrected.
- The second word is the word to replace current composing text under auto correction. You should provide this word even in case of "0" to automatically complete an uncompleted word under auto correction on. "0" and "1" will work only with auto correction on. And "a" will always work regardless of auto correction on or off.
- The other words are listed to be selected. Normally, 3rd word(1st of list) is intended for the same as typed and 4th word(2nd of list) is recommended, bold in list, and expected to be the same as above second word. But under predictive state(just after pick or press space), 3rd word(1st of list) is recommended and bold in list.
Here, you can freely deploy your own ideas. What to return with the parameters delivered is entirely up to you.
5. addUsDb(String cr, String bf, int mo, int md)
Whenever users commit text, B16x2 Keyboard sends this function.
- mo : 1 if adding to MyDictionary, 2 for Japanese additional case, otherwise 0.
- md : 1 if add UsDb stop, otherwise 0.
- cr: composing text in case of mo=1, otherwise currently committed word.
- bf: selected word from list in case of mo=1, otherwise word before cr.
6. delUsDb(String com, String sel)
When users delete a word by long press a word of list, B16x2 Keyboard sends this function. com: currently composing text, sel: selected word from list. return 0 if failed in deleting, otherwise return 1.
7. How to show yourself on the keyboard
In addition to displaying candidate words, you can show yourself on the keyboard.
- You can display your company or your product on 3rd menu key if blank.
- 2nd of GetData() List : Your logo letter shown at 3rd menu key
- 3rd : Background color. It must be like "#F0F0F0".
- 4th : Font color. It must be like "#F0F0F0".
- 5th : Font size.
- 6th : Font TypeFace. 0:default, 1:MonoSpace, 2:Sans-Serif, 3:Serif
If your logo letter is not "", you need to return validate data from 3rd to 6th. Otherwise it causes an error.
- You can configure and send your own arrangements of letters, numbers and symbols. Of course, the intellectual properties, if any, of your arrangements entirely belong to you.
- 7th of GetData() List : Letters
- 8th : Pandent letters
- 9th : Numbers
- 10th : Symbols
We also have the plan to reflect your image background in the future.
8 sendKeys(String keys);
When a user type at first, B16x2 Keyboard sends this function. With this you can know keys arrangement currently used.
9. Tip for Debugging
- At your dictionary project, write "android.os.Debug.waitForDebugger();" somewhere before you want to debug. And then add breakpoint.
- debug your project.
- At B16x2 Keyboard, select your dictionary according as described in its help.
- At B16x2 Keyboard, type or try any key, then you can go to the breakpoint of your project.
- Good luck -