2 * Copyright (C) 2008,2009 OMRON SOFTWARE Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 package com.hiroshica.android.input.nicownn2.JAJP;
21 import android.view.KeyEvent;
22 import android.view.inputmethod.EditorInfo;
23 import android.view.inputmethod.InputConnection;
24 import android.inputmethodservice.Keyboard;
25 import android.util.Log;
26 import android.view.View;
27 import android.content.SharedPreferences;
28 import android.content.Intent;
30 import android.app.Activity;
32 import android.inputmethodservice.InputMethodService;
33 import android.view.WindowManager;
34 import android.content.Context;
35 import android.view.View;
36 import android.view.KeyEvent;
37 import android.content.SharedPreferences;
38 import android.preference.PreferenceManager;
39 import android.content.pm.PackageManager;
40 import android.util.Log;
42 import android.view.inputmethod.*;
43 import android.content.res.Configuration;
44 import android.graphics.*;
45 import android.graphics.drawable.*;
46 import android.view.MotionEvent;
47 import android.app.Activity;
48 import android.content.Intent;
51 import java.lang.Object;
52 import java.util.HashMap;
53 import java.util.Locale;
54 import java.util.List;
55 import java.lang.Math;
57 import com.hiroshica.android.input.nicownn2.*;
60 * The default Software Keyboard class for Japanese IME.
62 * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD. All Rights Reserved.
64 public class DefaultSoftKeyboardJAJP extends DefaultSoftKeyboard {
65 private static final String GETACTION_INTERCEPT = "com.hiroshica.android.input.nicownn2.ACTION_INTERCEPT";
66 private static final String REPLACE_KEY = "replace_key";
67 private static final String INPUTCONNECTION_KEY = "inputconnection_key";
69 /** Enable English word prediction on half-width alphabet mode */
70 private static final boolean USE_ENGLISH_PREDICT = true;
72 /** Key code for switching to full-width HIRAGANA mode */
73 private static final int KEYCODE_SWITCH_FULL_HIRAGANA = -301;
75 /** Key code for switching to full-width KATAKANA mode */
76 private static final int KEYCODE_SWITCH_FULL_KATAKANA = -302;
78 /** Key code for switching to full-width alphabet mode */
79 private static final int KEYCODE_SWITCH_FULL_ALPHABET = -303;
81 /** Key code for switching to full-width number mode */
82 private static final int KEYCODE_SWITCH_FULL_NUMBER = -304;
84 /** Key code for switching to half-width KATAKANA mode */
85 private static final int KEYCODE_SWITCH_HALF_KATAKANA = -306;
87 /** Key code for switching to half-width alphabet mode */
88 private static final int KEYCODE_SWITCH_HALF_ALPHABET = -307;
90 /** Key code for switching to half-width number mode */
91 private static final int KEYCODE_SWITCH_HALF_NUMBER = -308;
93 /** Key code for case toggle key */
94 private static final int KEYCODE_SELECT_CASE = -309;
96 /** Key code for EISU-KANA conversion */
97 private static final int KEYCODE_EISU_KANA = -305;
99 /** Key code for switching to full-width Nikotouch mode */
100 private static final int KEYCODE_SWITCH_FULL_NIKO = -400;
102 /** Key code for NOP (no-operation) */
103 private static final int KEYCODE_NOP = -310;
106 /** Input mode toggle cycle table */
107 private static final int[] JP_MODE_CYCLE_TABLE = {
108 KEYMODE_JA_FULL_NIKO, KEYMODE_JA_FULL_HIRAGANA, KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER,
111 /** Definition for {@code mInputType} (toggle) */
112 private static final int INPUT_TYPE_TOGGLE = 1;
114 /** Definition for {@code mInputType} (commit instantly) */
115 private static final int INPUT_TYPE_INSTANT = 2;
117 /** Max key number of the 12 key keyboard (depends on the definition of keyboards) */
118 private static final int KEY_NUMBER_12KEY = 20;
120 /** Toggle cycle table for full-width HIRAGANA */
121 private static final String[][] JP_FULL_HIRAGANA_CYCLE_TABLE = {
122 {"\u3042", "\u3044", "\u3046", "\u3048", "\u304a", "\u3041", "\u3043", "\u3045", "\u3047", "\u3049"},
123 {"\u304b", "\u304d", "\u304f", "\u3051", "\u3053"},
124 {"\u3055", "\u3057", "\u3059", "\u305b", "\u305d"},
125 {"\u305f", "\u3061", "\u3064", "\u3066", "\u3068", "\u3063"},
126 {"\u306a", "\u306b", "\u306c", "\u306d", "\u306e"},
127 {"\u306f", "\u3072", "\u3075", "\u3078", "\u307b"},
128 {"\u307e", "\u307f", "\u3080", "\u3081", "\u3082"},
129 {"\u3084", "\u3086", "\u3088", "\u3083", "\u3085", "\u3087"},
130 {"\u3089", "\u308a", "\u308b", "\u308c", "\u308d"},
131 {"\u308f", "\u3092", "\u3093", "\u308e", "\u30fc"},
132 {"\u3001", "\u3002", "\uff1f", "\uff01", "\u30fb", "\u3000"},
135 /** Replace table for full-width HIRAGANA */
136 private static final HashMap<String, String> JP_FULL_HIRAGANA_REPLACE_TABLE = new HashMap<String, String>() {{
137 put("\u3042", "\u3041"); put("\u3044", "\u3043"); put("\u3046", "\u3045"); put("\u3048", "\u3047"); put("\u304a", "\u3049");
138 put("\u3041", "\u3042"); put("\u3043", "\u3044"); put("\u3045", "\u30f4"); put("\u3047", "\u3048"); put("\u3049", "\u304a");
139 put("\u304b", "\u304c"); put("\u304d", "\u304e"); put("\u304f", "\u3050"); put("\u3051", "\u3052"); put("\u3053", "\u3054");
140 put("\u304c", "\u304b"); put("\u304e", "\u304d"); put("\u3050", "\u304f"); put("\u3052", "\u3051"); put("\u3054", "\u3053");
141 put("\u3055", "\u3056"); put("\u3057", "\u3058"); put("\u3059", "\u305a"); put("\u305b", "\u305c"); put("\u305d", "\u305e");
142 put("\u3056", "\u3055"); put("\u3058", "\u3057"); put("\u305a", "\u3059"); put("\u305c", "\u305b"); put("\u305e", "\u305d");
143 put("\u305f", "\u3060"); put("\u3061", "\u3062"); put("\u3064", "\u3063"); put("\u3066", "\u3067"); put("\u3068", "\u3069");
144 put("\u3060", "\u305f"); put("\u3062", "\u3061"); put("\u3063", "\u3065"); put("\u3067", "\u3066"); put("\u3069", "\u3068");
145 put("\u3065", "\u3064"); put("\u30f4", "\u3046");
146 put("\u306f", "\u3070"); put("\u3072", "\u3073"); put("\u3075", "\u3076"); put("\u3078", "\u3079"); put("\u307b", "\u307c");
147 put("\u3070", "\u3071"); put("\u3073", "\u3074"); put("\u3076", "\u3077"); put("\u3079", "\u307a"); put("\u307c", "\u307d");
148 put("\u3071", "\u306f"); put("\u3074", "\u3072"); put("\u3077", "\u3075"); put("\u307a", "\u3078"); put("\u307d", "\u307b");
149 put("\u3084", "\u3083"); put("\u3086", "\u3085"); put("\u3088", "\u3087");
150 put("\u3083", "\u3084"); put("\u3085", "\u3086"); put("\u3087", "\u3088");
151 put("\u308f", "\u308e");
152 put("\u308e", "\u308f");
153 put("\u309b", "\u309c");
154 put("\u309c", "\u309b");
157 /** Toggle cycle table for full-width KATAKANA */
158 private static final String[][] JP_FULL_KATAKANA_CYCLE_TABLE = {
159 {"\u30a2", "\u30a4", "\u30a6", "\u30a8", "\u30aa", "\u30a1", "\u30a3",
160 "\u30a5", "\u30a7", "\u30a9"},
161 {"\u30ab", "\u30ad", "\u30af", "\u30b1", "\u30b3"},
162 {"\u30b5", "\u30b7", "\u30b9", "\u30bb", "\u30bd"},
163 {"\u30bf", "\u30c1", "\u30c4", "\u30c6", "\u30c8", "\u30c3"},
164 {"\u30ca", "\u30cb", "\u30cc", "\u30cd", "\u30ce"},
165 {"\u30cf", "\u30d2", "\u30d5", "\u30d8", "\u30db"},
166 {"\u30de", "\u30df", "\u30e0", "\u30e1", "\u30e2"},
167 {"\u30e4", "\u30e6", "\u30e8", "\u30e3", "\u30e5", "\u30e7"},
168 {"\u30e9", "\u30ea", "\u30eb", "\u30ec", "\u30ed"},
169 {"\u30ef", "\u30f2", "\u30f3", "\u30ee", "\u30fc"},
170 {"\u3001", "\u3002", "\uff1f", "\uff01", "\u30fb", "\u3000"}
173 /** Replace table for full-width KATAKANA */
174 private static final HashMap<String,String> JP_FULL_KATAKANA_REPLACE_TABLE = new HashMap<String,String>() {{
175 put("\u30a2", "\u30a1"); put("\u30a4", "\u30a3"); put("\u30a6", "\u30a5"); put("\u30a8", "\u30a7"); put("\u30aa", "\u30a9");
176 put("\u30a1", "\u30a2"); put("\u30a3", "\u30a4"); put("\u30a5", "\u30f4"); put("\u30a7", "\u30a8"); put("\u30a9", "\u30aa");
177 put("\u30ab", "\u30ac"); put("\u30ad", "\u30ae"); put("\u30af", "\u30b0"); put("\u30b1", "\u30b2"); put("\u30b3", "\u30b4");
178 put("\u30ac", "\u30ab"); put("\u30ae", "\u30ad"); put("\u30b0", "\u30af"); put("\u30b2", "\u30b1"); put("\u30b4", "\u30b3");
179 put("\u30b5", "\u30b6"); put("\u30b7", "\u30b8"); put("\u30b9", "\u30ba"); put("\u30bb", "\u30bc"); put("\u30bd", "\u30be");
180 put("\u30b6", "\u30b5"); put("\u30b8", "\u30b7"); put("\u30ba", "\u30b9"); put("\u30bc", "\u30bb"); put("\u30be", "\u30bd");
181 put("\u30bf", "\u30c0"); put("\u30c1", "\u30c2"); put("\u30c4", "\u30c3"); put("\u30c6", "\u30c7"); put("\u30c8", "\u30c9");
182 put("\u30c0", "\u30bf"); put("\u30c2", "\u30c1"); put("\u30c3", "\u30c5"); put("\u30c7", "\u30c6"); put("\u30c9", "\u30c8");
183 put("\u30c5", "\u30c4"); put("\u30f4", "\u30a6");
184 put("\u30cf", "\u30d0"); put("\u30d2", "\u30d3"); put("\u30d5", "\u30d6"); put("\u30d8", "\u30d9"); put("\u30db", "\u30dc");
185 put("\u30d0", "\u30d1"); put("\u30d3", "\u30d4"); put("\u30d6", "\u30d7"); put("\u30d9", "\u30da"); put("\u30dc", "\u30dd");
186 put("\u30d1", "\u30cf"); put("\u30d4", "\u30d2"); put("\u30d7", "\u30d5"); put("\u30da", "\u30d8"); put("\u30dd", "\u30db");
187 put("\u30e4", "\u30e3"); put("\u30e6", "\u30e5"); put("\u30e8", "\u30e7");
188 put("\u30e3", "\u30e4"); put("\u30e5", "\u30e6"); put("\u30e7", "\u30e8");
189 put("\u30ef", "\u30ee");
190 put("\u30ee", "\u30ef");
193 /** Toggle cycle table for half-width KATAKANA */
194 private static final String[][] JP_HALF_KATAKANA_CYCLE_TABLE = {
195 {"\uff71", "\uff72", "\uff73", "\uff74", "\uff75", "\uff67", "\uff68", "\uff69", "\uff6a", "\uff6b"},
196 {"\uff76", "\uff77", "\uff78", "\uff79", "\uff7a"},
197 {"\uff7b", "\uff7c", "\uff7d", "\uff7e", "\uff7f"},
198 {"\uff80", "\uff81", "\uff82", "\uff83", "\uff84", "\uff6f"},
199 {"\uff85", "\uff86", "\uff87", "\uff88", "\uff89"},
200 {"\uff8a", "\uff8b", "\uff8c", "\uff8d", "\uff8e"},
201 {"\uff8f", "\uff90", "\uff91", "\uff92", "\uff93"},
202 {"\uff94", "\uff95", "\uff96", "\uff6c", "\uff6d", "\uff6e"},
203 {"\uff97", "\uff98", "\uff99", "\uff9a", "\uff9b"},
204 {"\uff9c", "\uff66", "\uff9d", "\uff70"},
205 {"\uff64", "\uff61", "?", "!", "\uff65", " "},
208 /** Replace table for half-width KATAKANA */
209 private static final HashMap<String,String> JP_HALF_KATAKANA_REPLACE_TABLE = new HashMap<String,String>() {{
210 put("\uff71", "\uff67"); put("\uff72", "\uff68"); put("\uff73", "\uff69"); put("\uff74", "\uff6a"); put("\uff75", "\uff6b");
211 put("\uff67", "\uff71"); put("\uff68", "\uff72"); put("\uff69", "\uff73\uff9e"); put("\uff6a", "\uff74"); put("\uff6b", "\uff75");
212 put("\uff76", "\uff76\uff9e"); put("\uff77", "\uff77\uff9e"); put("\uff78", "\uff78\uff9e"); put("\uff79", "\uff79\uff9e"); put("\uff7a", "\uff7a\uff9e");
213 put("\uff76\uff9e", "\uff76"); put("\uff77\uff9e", "\uff77"); put("\uff78\uff9e", "\uff78"); put("\uff79\uff9e", "\uff79"); put("\uff7a\uff9e", "\uff7a");
214 put("\uff7b", "\uff7b\uff9e"); put("\uff7c", "\uff7c\uff9e"); put("\uff7d", "\uff7d\uff9e"); put("\uff7e", "\uff7e\uff9e"); put("\uff7f", "\uff7f\uff9e");
215 put("\uff7b\uff9e", "\uff7b"); put("\uff7c\uff9e", "\uff7c"); put("\uff7d\uff9e", "\uff7d"); put("\uff7e\uff9e", "\uff7e"); put("\uff7f\uff9e", "\uff7f");
216 put("\uff80", "\uff80\uff9e"); put("\uff81", "\uff81\uff9e"); put("\uff82", "\uff6f"); put("\uff83", "\uff83\uff9e"); put("\uff84", "\uff84\uff9e");
217 put("\uff80\uff9e", "\uff80"); put("\uff81\uff9e", "\uff81"); put("\uff6f", "\uff82\uff9e"); put("\uff83\uff9e", "\uff83"); put("\uff84\uff9e", "\uff84");
218 put("\uff82\uff9e", "\uff82");
219 put("\uff8a", "\uff8a\uff9e"); put("\uff8b", "\uff8b\uff9e"); put("\uff8c", "\uff8c\uff9e"); put("\uff8d", "\uff8d\uff9e"); put("\uff8e", "\uff8e\uff9e");
220 put("\uff8a\uff9e", "\uff8a\uff9f");put("\uff8b\uff9e", "\uff8b\uff9f");put("\uff8c\uff9e", "\uff8c\uff9f");put("\uff8d\uff9e", "\uff8d\uff9f");put("\uff8e\uff9e", "\uff8e\uff9f");
221 put("\uff8a\uff9f", "\uff8a"); put("\uff8b\uff9f", "\uff8b"); put("\uff8c\uff9f", "\uff8c"); put("\uff8d\uff9f", "\uff8d"); put("\uff8e\uff9f", "\uff8e");
222 put("\uff94", "\uff6c"); put("\uff95", "\uff6d"); put("\uff96", "\uff6e");
223 put("\uff6c", "\uff94"); put("\uff6d", "\uff95"); put("\uff6e", "\uff96");
224 put("\uff9c", "\uff9c"); put("\uff73\uff9e", "\uff73");
227 /** Toggle cycle table for full-width alphabet */
228 private static final String[][] JP_FULL_ALPHABET_CYCLE_TABLE = {
229 {"\uff0e", "\uff20", "\uff0d", "\uff3f", "\uff0f", "\uff1a", "\uff5e", "\uff11"},
230 {"\uff41", "\uff42", "\uff43", "\uff21", "\uff22", "\uff23", "\uff12"},
231 {"\uff44", "\uff45", "\uff46", "\uff24", "\uff25", "\uff26", "\uff13"},
232 {"\uff47", "\uff48", "\uff49", "\uff27", "\uff28", "\uff29", "\uff14"},
233 {"\uff4a", "\uff4b", "\uff4c", "\uff2a", "\uff2b", "\uff2c", "\uff15"},
234 {"\uff4d", "\uff4e", "\uff4f", "\uff2d", "\uff2e", "\uff2f", "\uff16"},
235 {"\uff50", "\uff51", "\uff52", "\uff53", "\uff30", "\uff31", "\uff32", "\uff33", "\uff17"},
236 {"\uff54", "\uff55", "\uff56", "\uff34", "\uff35", "\uff36", "\uff18"},
237 {"\uff57", "\uff58", "\uff59", "\uff5a", "\uff37", "\uff38", "\uff39", "\uff3a", "\uff19"},
238 {"\uff0d", "\uff10"},
239 {"\uff0c", "\uff0e", "\uff1f", "\uff01", "\u30fb", "\u3000"}
242 /** Replace table for full-width alphabet */
243 private static final HashMap<String,String> JP_FULL_ALPHABET_REPLACE_TABLE = new HashMap<String,String>() {{
244 put("\uff21", "\uff41"); put("\uff22", "\uff42"); put("\uff23", "\uff43"); put("\uff24", "\uff44"); put("\uff25", "\uff45");
245 put("\uff41", "\uff21"); put("\uff42", "\uff22"); put("\uff43", "\uff23"); put("\uff44", "\uff24"); put("\uff45", "\uff25");
246 put("\uff26", "\uff46"); put("\uff27", "\uff47"); put("\uff28", "\uff48"); put("\uff29", "\uff49"); put("\uff2a", "\uff4a");
247 put("\uff46", "\uff26"); put("\uff47", "\uff27"); put("\uff48", "\uff28"); put("\uff49", "\uff29"); put("\uff4a", "\uff2a");
248 put("\uff2b", "\uff4b"); put("\uff2c", "\uff4c"); put("\uff2d", "\uff4d"); put("\uff2e", "\uff4e"); put("\uff2f", "\uff4f");
249 put("\uff4b", "\uff2b"); put("\uff4c", "\uff2c"); put("\uff4d", "\uff2d"); put("\uff4e", "\uff2e"); put("\uff4f", "\uff2f");
250 put("\uff30", "\uff50"); put("\uff31", "\uff51"); put("\uff32", "\uff52"); put("\uff33", "\uff53"); put("\uff34", "\uff54");
251 put("\uff50", "\uff30"); put("\uff51", "\uff31"); put("\uff52", "\uff32"); put("\uff53", "\uff33"); put("\uff54", "\uff34");
252 put("\uff35", "\uff55"); put("\uff36", "\uff56"); put("\uff37", "\uff57"); put("\uff38", "\uff58"); put("\uff39", "\uff59");
253 put("\uff55", "\uff35"); put("\uff56", "\uff36"); put("\uff57", "\uff37"); put("\uff58", "\uff38"); put("\uff59", "\uff39");
254 put("\uff3a", "\uff5a");
255 put("\uff5a", "\uff3a");
258 /** Toggle cycle table for half-width alphabet */
259 private static final String[][] JP_HALF_ALPHABET_CYCLE_TABLE = {
260 {".", "@", "-", "_", "/", ":", "~", "1"},
261 {"a", "b", "c", "A", "B", "C", "2"},
262 {"d", "e", "f", "D", "E", "F", "3"},
263 {"g", "h", "i", "G", "H", "I", "4"},
264 {"j", "k", "l", "J", "K", "L", "5"},
265 {"m", "n", "o", "M", "N", "O", "6"},
266 {"p", "q", "r", "s", "P", "Q", "R", "S", "7"},
267 {"t", "u", "v", "T", "U", "V", "8"},
268 {"w", "x", "y", "z", "W", "X", "Y", "Z", "9"},
270 {",", ".", "?", "!", ";", " "}
273 /** Replace table for half-width alphabet */
274 private static final HashMap<String,String> JP_HALF_ALPHABET_REPLACE_TABLE = new HashMap<String,String>() {{
275 put("A", "a"); put("B", "b"); put("C", "c"); put("D", "d"); put("E", "e");
276 put("a", "A"); put("b", "B"); put("c", "C"); put("d", "D"); put("e", "E");
277 put("F", "f"); put("G", "g"); put("H", "h"); put("I", "i"); put("J", "j");
278 put("f", "F"); put("g", "G"); put("h", "H"); put("i", "I"); put("j", "J");
279 put("K", "k"); put("L", "l"); put("M", "m"); put("N", "n"); put("O", "o");
280 put("k", "K"); put("l", "L"); put("m", "M"); put("n", "N"); put("o", "O");
281 put("P", "p"); put("Q", "q"); put("R", "r"); put("S", "s"); put("T", "t");
282 put("p", "P"); put("q", "Q"); put("r", "R"); put("s", "S"); put("t", "T");
283 put("U", "u"); put("V", "v"); put("W", "w"); put("X", "x"); put("Y", "y");
284 put("u", "U"); put("v", "V"); put("w", "W"); put("x", "X"); put("y", "Y");
289 /** Toggle cycle table for full-width Nikotouch */
290 private static final String[][] JP_FULL_NIKO_CYCLE_TABLE = {
291 {"\u3042"}, {"\u3044"}, {"\u3046"}, {"\u3048"}, {"\u304a"}, {"."}, {"-"}, {"@"}, {"_"}, {"1"},
292 {"\u304b"}, {"\u304d"}, {"\u304f"}, {"\u3051"}, {"\u3053"}, {" "}, {"a"}, {"b"}, {"c"}, {"2"},
293 {"\u3055"}, {"\u3057"}, {"\u3059"}, {"\u305b"}, {"\u305d"}, {"/"}, {"d"}, {"e"}, {"f"}, {"3"},
294 {"\u305f"}, {"\u3061"}, {"\u3064"}, {"\u3066"}, {"\u3068"}, {"\u3063"}, {"g"}, {"h"}, {"i"}, {"4"},
295 {"\u306a"}, {"\u306b"}, {"\u306c"}, {"\u306d"}, {"\u306e"}, {"("}, {"j"}, {"k"}, {"l"}, {"5"},
296 {"\u306f"}, {"\u3072"}, {"\u3075"}, {"\u3078"}, {"\u307b"}, {")"}, {"m"}, {"n"}, {"o"}, {"6"},
297 {"\u307e"}, {"\u307f"}, {"\u3080"}, {"\u3081"}, {"\u3082"}, {"p"}, {"q"}, {"r"}, {"s"}, {"7"},
298 {"\u3084"}, {"\u3086"}, {"\u3088"}, {"\u3083"}, {"\u3085"}, {"\u3087"}, {"t"}, {"u"}, {"v"}, {"8"},
299 {"\u3089"}, {"\u308a"}, {"\u308b"}, {"\u308c"}, {"\u308d"}, {"w"}, {"x"}, {"y"}, {"z"}, {"9"},
300 {"\u308f"}, {"\u3092"}, {"\u3093"}, {"\u3001"}, {"\u3002"}, {"\u30fc"}, {"\u30fb"}, {"\uff01"}, {"\uff1f"}, {"0"},
302 /** Toggle cycle table for full-width belltouch */
303 private static final String[][] JP_FULL_BELL_CYCLE_TABLE = {
304 {"\u3042"}, {"\u3044"}, {"\u3046"}, {"\u3048"}, {"\u304a"}, {"A"}, {"B"}, {"C"}, {"D"}, {"E"},
305 {"\u304b"}, {"\u304d"}, {"\u304f"}, {"\u3051"}, {"\u3053"}, {"F"}, {"G"}, {"H"}, {"I"}, {"J"},
306 {"\u3055"}, {"\u3057"}, {"\u3059"}, {"\u305b"}, {"\u305d"}, {"K"}, {"L"}, {"M"}, {"N"}, {"O"},
307 {"\u305f"}, {"\u3061"}, {"\u3064"}, {"\u3066"}, {"\u3068"}, {"P"}, {"Q"}, {"R"}, {"S"}, {"T"},
308 {"\u306a"}, {"\u306b"}, {"\u306c"}, {"\u306d"}, {"\u306e"}, {"U"}, {"V"}, {"W"}, {"X"}, {"Y"},
309 {"\u306f"}, {"\u3072"}, {"\u3075"}, {"\u3078"}, {"\u307b"}, {"Z"}, {" "}, {" "}, {" "}, {" "},
310 {"\u307e"}, {"\u307f"}, {"\u3080"}, {"\u3081"}, {"\u3082"}, {" "}, {" "}, {" "}, {" "}, {" "},
311 {"\u3084"}, {" "}, {"\u3086"}, {" "}, {"\u3088"}, {"\u30fc"}, {"\u30fb"}, {"\uff01"}, {"\uff1f"}, {" "},
312 {"\u3089"}, {"\u308a"}, {"\u308b"}, {"\u308c"}, {"\u308d"}, {"1"}, {"2"}, {"3"}, {"4"}, {"5"},
313 {"\u308f"}, {"\u3092"}, {"\u3093"}, {"\u3001"}, {"\u3002"}, {"6"}, {"7"}, {"8"}, {"9"}, {"0"},
316 /** Replace table for full-width Nikotouch */
317 private static final HashMap<String, String> JP_FULL_NIKO_REPLACE_TABLE = new HashMap<String, String>() {{
318 put("\u3042", "\u3041"); put("\u3044", "\u3043"); put("\u3046", "\u3045"); put("\u3048", "\u3047"); put("\u304a", "\u3049"); // A
319 put("\u3041", "\u3042"); put("\u3043", "\u3044"); put("\u3045", "\u30f4"); put("\u3047", "\u3048"); put("\u3049", "\u304a"); // a
320 put("\u304b", "\u304c"); put("\u304d", "\u304e"); put("\u304f", "\u3050"); put("\u3051", "\u3052"); put("\u3053", "\u3054"); // K
321 put("\u304c", "\u304b"); put("\u304e", "\u304d"); put("\u3050", "\u304f"); put("\u3052", "\u3051"); put("\u3054", "\u3053"); // k
322 put("\u3055", "\u3056"); put("\u3057", "\u3058"); put("\u3059", "\u305a"); put("\u305b", "\u305c"); put("\u305d", "\u305e"); // S
323 put("\u3056", "\u3055"); put("\u3058", "\u3057"); put("\u305a", "\u3059"); put("\u305c", "\u305b"); put("\u305e", "\u305d"); // s
324 put("\u305f", "\u3060"); put("\u3061", "\u3062"); put("\u3064", "\u3065"); put("\u3066", "\u3067"); put("\u3068", "\u3069"); // T
325 put("\u3060", "\u305f"); put("\u3062", "\u3061"); put("\u3065", "\u3063"); put("\u3067", "\u3066"); put("\u3069", "\u3068"); // t
326 put("\u3063", "\u3064"); put("\u30f4", "\u3046");
327 put("\u306f", "\u3070"); put("\u3072", "\u3073"); put("\u3075", "\u3076"); put("\u3078", "\u3079"); put("\u307b", "\u307c"); // H
328 put("\u3070", "\u3071"); put("\u3073", "\u3074"); put("\u3076", "\u3077"); put("\u3079", "\u307a"); put("\u307c", "\u307d"); // h
329 put("\u3071", "\u306f"); put("\u3074", "\u3072"); put("\u3077", "\u3075"); put("\u307a", "\u3078"); put("\u307d", "\u307b"); // h.
330 put("\u3084", "\u3083"); put("\u3086", "\u3085"); put("\u3088", "\u3087"); // Y
331 put("\u3083", "\u3084"); put("\u3085", "\u3086"); put("\u3087", "\u3088"); // y
332 put("\u308f", "\u308e");
333 put("\u308e", "\u308f");
334 put("\u309b", "\u309c");
335 put("\u309c", "\u309b");
337 put("a", "A"); put("b", "B"); put("c", "C"); put("d", "D"); put("e", "E"); put("f", "F"); put("g", "G"); put("h", "H"); put("i", "I"); put("j", "J");
338 put("k", "K"); put("l", "L"); put("m", "M"); put("n", "N"); put("o", "O"); put("p", "P"); put("q", "Q"); put("r", "R"); put("s", "S"); put("t", "T");
339 put("u", "U"); put("v", "V"); put("w", "W"); put("x", "X"); put("y", "Y"); put("z", "Z");
340 put("A", "a"); put("B", "b"); put("C", "c"); put("D", "d"); put("E", "e"); put("F", "f"); put("G", "g"); put("H", "h"); put("I", "i"); put("J", "j");
341 put("K", "k"); put("L", "l"); put("M", "m"); put("N", "n"); put("O", "o"); put("P", "p"); put("Q", "q"); put("R", "r"); put("S", "s"); put("T", "t");
342 put("U", "u"); put("V", "v"); put("W", "w"); put("X", "x"); put("Y", "y"); put("Z", "z");
344 put("1", "\uff11"); put("2", "\uff12"); put("3", "\uff13"); put("4", "\uff14"); put("5", "\uff15");
345 put("6", "\uff16"); put("7", "\uff17"); put("8", "\uff18"); put("9", "\uff19"); put("0", "\uff10");
346 put("\uff11", "1"); put("\uff12", "2"); put("\uff13", "3"); put("\uff14", "4"); put("\uff15", "5");
347 put("\uff16", "6"); put("\uff17", "7"); put("\uff18", "8"); put("\uff19", "9"); put("\uff10", "0");
349 put(".", "\uff0e"); put("-", "\u2015"); put("@", "\uff20"); put("_", "\uff3f");
350 put("\uff0e", "."); put("\u2015", "-"); put("\uff20", "@"); put("\uff3f", "_");
352 put("\uff01", "!"); put("\uff1f", "?");
353 put("!", "\uff01"); put("?", "\uff1f");
355 put("\u3000", " "); put(" ", "\u3000");
357 put("(", "["); put("[", "(");
358 put(")", "]"); put("]", ")");
363 /** Character table for full-width number */
364 private static final char[] INSTANT_CHAR_CODE_FULL_NUMBER =
365 "\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\uff10\uff03\uff0a".toCharArray();
367 /** Character table for half-width number */
368 private static final char[] INSTANT_CHAR_CODE_HALF_NUMBER =
369 "1234567890#*".toCharArray();
371 /** The constant for mFixedKeyMode. It means that input mode is not fixed. */
372 private static final int INVALID_KEYMODE = -1;
374 /** KeyIndex of "Moji" key on 12 keyboard (depends on the definition of keyboards) */
375 private static final int KEY_INDEX_CHANGE_MODE_12KEY = 15;
377 /** KeyIndex of "Moji" key on QWERTY keyboard (depends on the definition of keyboards) */
378 private static final int KEY_INDEX_CHANGE_MODE_QWERTY = 29;
380 /** Type of input mode */
381 private int mInputType = INPUT_TYPE_TOGGLE;
383 /** Previous input character code */
384 private int mPrevInputKeyCode = 0;
387 private int mFlickLimitX;
388 private int mFlickLimitY;
391 * Character table to input when mInputType becomes INPUT_TYPE_INSTANT.
392 * (Either INSTANT_CHAR_CODE_FULL_NUMBER or INSTANT_CHAR_CODE_HALF_NUMBER)
394 private char[] mCurrentInstantTable = null;
396 /** Input mode that is not able to be changed. If ENABLE_CHANGE_KEYMODE is set, input mode can change. */
397 private int[] mLimitedKeyMode = null;
399 /** Input mode that is given the first priority. If ENABLE_CHANGE_KEYMODE is set, input mode can change. */
400 private int mPreferenceKeyMode = INVALID_KEYMODE;
402 /** The last input type */
403 private int mLastInputType = 0;
405 /** Auto caps mode */
406 private boolean mEnableAutoCaps = true;
408 /** PopupResId of "Moji" key (this is used for canceling long-press) */
409 private int mPopupResId = 0;
411 /** Whether the InputType is null */
412 private boolean mIsInputTypeNull = false;
414 /** {@code SharedPreferences} for save the keyboard type */
415 private SharedPreferences.Editor mPrefEditor = null;
417 /** "Moji" key (this is used for canceling long-press) */
418 private Keyboard.Key mChangeModeKey = null;
420 private boolean mNikoFirst = false;
422 private Keyboard[][] mNikoKeyboard;
423 private Keyboard[][] mYBellKeyboard;
424 private Keyboard[][] mBellKeyboard;
426 /** option keyboard type */
427 private int mHookStockKeyType;
429 /** change keitai skip **/
430 private boolean mOnOffKeitaiMode = false;
431 /** change eisu change mode **/
432 private boolean mChange12keyQwertyMode = false;
433 private final int[] m12keyTable = {
434 KEYBOARD_12KEY, KEYBOARD_12KEY, KEYBOARD_QWERTY, KEYBOARD_QWERTY, KEYBOARD_12KEY, KEYBOARD_QWERTY, KEYBOARD_QWERTY, KEYBOARD_12KEY, KEYBOARD_12KEY
436 /** option bell type **/
437 private boolean mChangeYLineBellMode = false;
438 private boolean mChangeBellMode = false;
440 /** Default constructor */
441 public DefaultSoftKeyboardJAJP() {
442 mCurrentLanguage = LANG_JA;
443 mCurrentKeyboardType = KEYBOARD_12KEY;
444 mHookStockKeyType = KEYBOARD_12KEY;
445 mShiftOn = KEYBOARD_SHIFT_OFF;
446 mCurrentKeyMode = KEYMODE_JA_FULL_NIKO;
447 mCurrentSlide = NIKO_SLIDE_MODE_TOP;
450 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#createKeyboards */
451 @Override protected void createKeyboards(NicoWnn parent) {
453 /* Keyboard[# of Languages][portrait/landscape][# of keyboard type][shift off/on][max # of key-modes][noinput/input] */
454 mKeyboard = new Keyboard[3][2][4][2][9][2];
456 SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(parent);
457 mChange12keyQwertyMode = pref.getBoolean("change_12key_qwerty", false);
458 mChangeYLineBellMode = pref.getBoolean("change_y_bellmode", false);
459 mChangeBellMode = pref.getBoolean("change_bellmode", false);
461 if (mHardKeyboardHidden) {
462 /* Create the suitable keyboard object */
463 if (mDisplayMode == DefaultSoftKeyboard.PORTRAIT) {
464 //mCurrentKeyboardType = KEYBOARD_12KEY;
465 createKeyboardsPortrait(parent);
469 //mCurrentKeyboardType = KEYBOARD_QWERTY;
470 createKeyboardsLandscape(parent);
475 if (mCurrentKeyboardType == KEYBOARD_12KEY) {
476 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
477 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_12KEY));
479 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
480 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
483 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
484 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
489 * Commit the pre-edit string for committing operation that is not explicit
490 * (ex. when a candidate is selected)
492 private void commitText() {
494 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.COMMIT_COMPOSING_TEXT));
501 * @param keyMode The type of input mode
503 public void changeKeyMode(int keyMode) {
504 int targetMode = filterKeyMode(keyMode);
505 if (targetMode == INVALID_KEYMODE) {
512 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
513 new KeyEvent(KeyEvent.ACTION_UP,
514 KeyEvent.KEYCODE_SHIFT_LEFT)));
517 mShiftOn = KEYBOARD_SHIFT_OFF;
518 Keyboard kbd = getModeChangeKeyboard(targetMode);
519 mCurrentKeyMode = targetMode;
520 mPrevInputKeyCode = 0;
523 int mode = NicoWnnEvent.Mode.DIRECT;
525 switch (targetMode) {
526 case KEYMODE_JA_FULL_HIRAGANA:
527 mInputType = INPUT_TYPE_TOGGLE;
528 mode = NicoWnnEvent.Mode.DEFAULT;
531 case KEYMODE_JA_HALF_ALPHABET:
532 if (USE_ENGLISH_PREDICT) {
533 mInputType = INPUT_TYPE_TOGGLE;
534 mode = NicoWnnEvent.Mode.NO_LV1_CONV;
536 mInputType = INPUT_TYPE_TOGGLE;
537 mode = NicoWnnEvent.Mode.DIRECT;
541 case KEYMODE_JA_FULL_NUMBER:
542 mInputType = INPUT_TYPE_INSTANT;
543 mode = NicoWnnEvent.Mode.DIRECT;
544 mCurrentInstantTable = INSTANT_CHAR_CODE_FULL_NUMBER;
547 case KEYMODE_JA_HALF_NUMBER:
548 mInputType = INPUT_TYPE_INSTANT;
549 mode = NicoWnnEvent.Mode.DIRECT;
550 mCurrentInstantTable = INSTANT_CHAR_CODE_HALF_NUMBER;
553 case KEYMODE_JA_FULL_KATAKANA:
554 mInputType = INPUT_TYPE_TOGGLE;
555 mode = NicoWnnJAJP.ENGINE_MODE_FULL_KATAKANA;
558 case KEYMODE_JA_FULL_ALPHABET:
559 mInputType = INPUT_TYPE_TOGGLE;
560 mode = NicoWnnEvent.Mode.DIRECT;
563 case KEYMODE_JA_HALF_KATAKANA:
564 mInputType = INPUT_TYPE_TOGGLE;
565 mode = NicoWnnJAJP.ENGINE_MODE_HALF_KATAKANA;
568 case KEYMODE_JA_FULL_NIKO:
569 mInputType = INPUT_TYPE_TOGGLE;
570 mode = NicoWnnEvent.Mode.DEFAULT;
580 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, mode));
581 if (mChange12keyQwertyMode == true) {
582 changeKeyboardType(m12keyTable[targetMode]);
586 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#initView */
587 @Override public View initView(NicoWnn parent, int width, int height) {
588 View view = super.initView(parent, width, height);
589 SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(parent);
590 changeKeyboard(mKeyboard[mCurrentLanguage][mDisplayMode][mCurrentKeyboardType][mShiftOn][mCurrentKeyMode][0]);
594 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#changeKeyboard */
595 @Override protected boolean changeKeyboard(Keyboard keyboard) {
597 if (keyboard != null) {
598 if (mIsInputTypeNull) {
599 mChangeModeKey.popupResId = mPopupResId;
602 List<Keyboard.Key> keys = keyboard.getKeys();
603 int keyIndex = (KEY_NUMBER_12KEY < keys.size())
604 ? KEY_INDEX_CHANGE_MODE_QWERTY : KEY_INDEX_CHANGE_MODE_12KEY;
605 mChangeModeKey = keys.get(keyIndex);
607 if (mIsInputTypeNull) {
608 mPopupResId = mChangeModeKey.popupResId;
609 mChangeModeKey.popupResId = 0;
612 return super.changeKeyboard(keyboard);
615 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#changeKeyboardType */
616 @Override public void changeKeyboardType(int type) {
618 Keyboard kbd = getTypeChangeKeyboard(type);
620 mCurrentKeyboardType = type;
621 mPrefEditor.putBoolean("opt_enable_qwerty", type == KEYBOARD_QWERTY);
622 mPrefEditor.commit();
625 if (type == KEYBOARD_12KEY) {
626 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_12KEY));
628 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
631 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#setPreferences */
632 @Override public void setPreferences(SharedPreferences pref, EditorInfo editor) {
633 mPrefEditor = pref.edit();
634 boolean isQwerty = pref.getBoolean("opt_enable_qwerty", false);
635 if (isQwerty && (mCurrentKeyboardType != KEYBOARD_QWERTY)) {
636 changeKeyboardType(KEYBOARD_QWERTY);
639 super.setPreferences(pref, editor);
641 int inputType = editor.inputType;
642 if (mHardKeyboardHidden) {
643 if (inputType == EditorInfo.TYPE_NULL) {
644 if (!mIsInputTypeNull) {
645 mIsInputTypeNull = true;
646 mPopupResId = mChangeModeKey.popupResId;
647 mChangeModeKey.popupResId = 0;
652 if (mIsInputTypeNull) {
653 mIsInputTypeNull = false;
654 mChangeModeKey.popupResId = mPopupResId;
658 mEnableAutoCaps = pref.getBoolean("auto_caps", true);
659 mLimitedKeyMode = null;
660 mPreferenceKeyMode = INVALID_KEYMODE;
662 mDisableKeyInput = false;
665 mOnOffKeitaiMode = pref.getBoolean("change_keitaimode", false);
666 if (true == mOnOffKeitaiMode) {
667 // off keitai hiragana mode
668 mLimitedKeyMode = new int[] {KEYMODE_JA_FULL_NIKO, KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
670 switch (inputType & EditorInfo.TYPE_MASK_CLASS) {
672 case EditorInfo.TYPE_CLASS_NUMBER:
673 case EditorInfo.TYPE_CLASS_DATETIME:
674 mPreferenceKeyMode = KEYMODE_JA_HALF_NUMBER;
677 case EditorInfo.TYPE_CLASS_PHONE:
678 if (mHardKeyboardHidden) {
679 //mLimitedKeyMode = new int[] {KEYMODE_JA_FULL_NIKO};
680 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
682 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET};
683 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
687 case EditorInfo.TYPE_CLASS_TEXT:
688 switch (inputType & EditorInfo.TYPE_MASK_VARIATION) {
690 case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD:
691 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
694 case EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
695 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
697 case EditorInfo.TYPE_TEXT_VARIATION_URI:
698 //mPreferenceKeyMode = KEYMODE_JA_HALF_ALPHABET;
699 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
711 boolean restartkey = false;
712 boolean old12keyqwerty = mChange12keyQwertyMode;
713 boolean oldnicobell = mChangeBellMode;
715 mChange12keyQwertyMode = pref.getBoolean("change_12key_qwerty", false);
716 mChangeYLineBellMode = pref.getBoolean("change_y_bellmode", false);
717 mChangeBellMode = pref.getBoolean("change_bellmode", false);
718 if (old12keyqwerty != mChange12keyQwertyMode) {
720 if (false == mChange12keyQwertyMode) {
721 mCurrentKeyboardType = mHookStockKeyType; // change last keyboard type.
724 if (oldnicobell != mChangeBellMode) {
728 if (inputType != mLastInputType) {
729 changeNicoBellLayout();
730 setDefaultKeyboard();
731 mLastInputType = inputType;
733 else if (true == restartkey) {
734 changeNicoBellLayout();
735 setDefaultKeyboard();
739 setShiftByEditorInfo();
742 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#onUpdateState */
743 @Override public void onUpdateState(NicoWnn parent) {
744 super.onUpdateState(parent);
746 setShiftByEditorInfo();
747 if (true == mNoInput && true == mNikoFirst) {
753 * Change the keyboard to default
755 public void setDefaultKeyboard() {
756 Locale locale = Locale.getDefault();
757 int keymode = KEYMODE_JA_FULL_NIKO;
760 if (mPreferenceKeyMode != INVALID_KEYMODE) {
761 keymode = mPreferenceKeyMode;
762 } else if (mLimitedKeyMode != null) {
763 keymode = mLimitedKeyMode[0];
765 if (!locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
766 keymode = KEYMODE_JA_HALF_ALPHABET;
770 changeKeyMode(keymode);
775 * Change to the next input mode
777 public void nextKeyMode() {
778 /* Search the current mode in the toggle table */
779 boolean found = false;
781 for (index = 0; index < JP_MODE_CYCLE_TABLE.length; index++) {
782 if (JP_MODE_CYCLE_TABLE[index] == mCurrentKeyMode) {
789 /* If the current mode not exists, set the default mode */
790 setDefaultKeyboard();
792 /* If the current mode exists, set the next input mode */
793 int size = JP_MODE_CYCLE_TABLE.length;
794 int keyMode = INVALID_KEYMODE;
795 for (int i = 0; i < size; i++) {
796 index = (++index) % size;
798 keyMode = filterKeyMode(JP_MODE_CYCLE_TABLE[index]);
799 if (keyMode != INVALID_KEYMODE) {
804 if (keyMode != INVALID_KEYMODE) {
805 changeKeyMode(keyMode);
811 * Create the keyboard for portrait mode
813 * @param parent The context
815 private void createKeyboardsPortrait(NicoWnn parent) {
816 Keyboard[][] keyList;
817 /* qwerty shift_off (portrait) */
818 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF];
819 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp);
820 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet);
821 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols);
822 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana);
823 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet);
824 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols);
825 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana);
826 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone);
827 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
829 /* qwerty shift_on (portrait) */
830 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_ON];
831 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_shift);
832 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_shift);
833 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_shift);
834 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_shift);
835 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_shift);
836 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_shift);
837 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_shift);
838 keyList[KEYMODE_JA_HALF_PHONE][0] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE][0];
839 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
841 /* 12-keys shift_off (portrait) */
842 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
843 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_12keyjp);
844 keyList[KEYMODE_JA_FULL_HIRAGANA][1] = new Keyboard(parent, R.xml.keyboard_12keyjp_input);
845 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana);
846 keyList[KEYMODE_JA_FULL_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_input);
847 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana);
848 keyList[KEYMODE_JA_HALF_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_input);
849 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone);
851 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet);
852 keyList[KEYMODE_JA_FULL_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_input);
853 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_full_num);
854 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet);
855 keyList[KEYMODE_JA_HALF_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_input);
856 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_half_num);
858 /* 12-keys shift_on (portrait) */
859 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
860 keyList[KEYMODE_JA_FULL_HIRAGANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_HIRAGANA];
861 keyList[KEYMODE_JA_FULL_KATAKANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_KATAKANA];
862 keyList[KEYMODE_JA_HALF_KATAKANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_KATAKANA];
863 keyList[KEYMODE_JA_HALF_PHONE] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE];
865 keyList[KEYMODE_JA_FULL_ALPHABET] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_ALPHABET];
866 keyList[KEYMODE_JA_FULL_NUMBER] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_NUMBER];
867 keyList[KEYMODE_JA_HALF_ALPHABET] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_ALPHABET];;
868 keyList[KEYMODE_JA_HALF_NUMBER] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_NUMBER];
871 mNikoKeyboard = new Keyboard[11][2];
872 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_top);
873 mNikoKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_a);
874 mNikoKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_k);
875 mNikoKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_s);
876 mNikoKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_t);
877 mNikoKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_n);
878 mNikoKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_h);
879 mNikoKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_m);
880 mNikoKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_y);
881 mNikoKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_r);
882 mNikoKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_w);
884 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_top);
885 mNikoKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_a);
886 mNikoKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_k);
887 mNikoKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_s);
888 mNikoKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_t);
889 mNikoKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_n);
890 mNikoKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_h);
891 mNikoKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_m);
892 mNikoKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_y);
893 mNikoKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_r);
894 mNikoKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_w);
896 // belltouch slide(Y)
897 mYBellKeyboard = new Keyboard[11][2];
898 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0];
899 mYBellKeyboard[NIKO_SLIDE_MODE_A][0] = mNikoKeyboard[NIKO_SLIDE_MODE_A][0];
900 mYBellKeyboard[NIKO_SLIDE_MODE_K][0] = mNikoKeyboard[NIKO_SLIDE_MODE_K][0];
901 mYBellKeyboard[NIKO_SLIDE_MODE_S][0] = mNikoKeyboard[NIKO_SLIDE_MODE_S][0];
902 mYBellKeyboard[NIKO_SLIDE_MODE_T][0] = mNikoKeyboard[NIKO_SLIDE_MODE_T][0];
903 mYBellKeyboard[NIKO_SLIDE_MODE_N][0] = mNikoKeyboard[NIKO_SLIDE_MODE_N][0];
904 mYBellKeyboard[NIKO_SLIDE_MODE_H][0] = mNikoKeyboard[NIKO_SLIDE_MODE_H][0];
905 mYBellKeyboard[NIKO_SLIDE_MODE_M][0] = mNikoKeyboard[NIKO_SLIDE_MODE_M][0];
906 mYBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_y);
907 mYBellKeyboard[NIKO_SLIDE_MODE_R][0] = mNikoKeyboard[NIKO_SLIDE_MODE_R][0];
908 mYBellKeyboard[NIKO_SLIDE_MODE_W][0] = mNikoKeyboard[NIKO_SLIDE_MODE_W][0];
910 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1];
911 mYBellKeyboard[NIKO_SLIDE_MODE_A][1] = mNikoKeyboard[NIKO_SLIDE_MODE_A][1];
912 mYBellKeyboard[NIKO_SLIDE_MODE_K][1] = mNikoKeyboard[NIKO_SLIDE_MODE_K][1];
913 mYBellKeyboard[NIKO_SLIDE_MODE_S][1] = mNikoKeyboard[NIKO_SLIDE_MODE_S][1];
914 mYBellKeyboard[NIKO_SLIDE_MODE_T][1] = mNikoKeyboard[NIKO_SLIDE_MODE_T][1];
915 mYBellKeyboard[NIKO_SLIDE_MODE_N][1] = mNikoKeyboard[NIKO_SLIDE_MODE_N][1];
916 mYBellKeyboard[NIKO_SLIDE_MODE_H][1] = mNikoKeyboard[NIKO_SLIDE_MODE_H][1];
917 mYBellKeyboard[NIKO_SLIDE_MODE_M][1] = mNikoKeyboard[NIKO_SLIDE_MODE_M][1];
918 mYBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_input_y);
919 mYBellKeyboard[NIKO_SLIDE_MODE_R][1] = mNikoKeyboard[NIKO_SLIDE_MODE_R][1];
920 mYBellKeyboard[NIKO_SLIDE_MODE_W][1] = mNikoKeyboard[NIKO_SLIDE_MODE_W][1];
923 mBellKeyboard = new Keyboard[11][2];
924 mBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_top);
925 mBellKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_a);
926 mBellKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_k);
927 mBellKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_s);
928 mBellKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_t);
929 mBellKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_n);
930 mBellKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_h);
931 mBellKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_m);
932 mBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_y);
933 mBellKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_r);
934 mBellKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_w);
936 mBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_top);
937 mBellKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_a);
938 mBellKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_k);
939 mBellKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_s);
940 mBellKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_t);
941 mBellKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_n);
942 mBellKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_h);
943 mBellKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_m);
944 mBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_y);
945 mBellKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_r);
946 mBellKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_w);
948 changeNicoBellLayout();
952 * Create the keyboard for landscape mode
954 * @param parent The context
956 private void createKeyboardsLandscape(NicoWnn parent) {
957 Keyboard[][] keyList;
958 /* qwerty shift_off (landscape) */
959 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF];
960 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_land);
961 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_land);
962 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_land);
963 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_land);
964 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_land);
965 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_land);
966 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_land);
967 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone_land);
968 if (false == mChangeBellMode) {
969 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_niko_land);
972 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_bell_land);
974 /* qwerty shift_on (landscape) */
975 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_ON];
976 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_shift_land);
977 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_shift_land);
978 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_shift_land);
979 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_shift_land);
980 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_shift_land);
981 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_shift_land);
982 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_shift_land);
983 keyList[KEYMODE_JA_HALF_PHONE][0] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE][0];
984 if (false == mChangeBellMode) {
985 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_niko_shift_land);
988 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_bell_shift_land);
990 /* 12-keys shift_off (landscape) */
991 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
992 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_12keyjp_land);
993 keyList[KEYMODE_JA_FULL_HIRAGANA][1] = new Keyboard(parent, R.xml.keyboard_12keyjp_input_land);
994 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_land);
995 keyList[KEYMODE_JA_FULL_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_input_land);
996 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_full_num_land);
997 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_land);
998 keyList[KEYMODE_JA_FULL_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_input_land);
999 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_land);
1000 keyList[KEYMODE_JA_HALF_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_input_land);
1001 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_half_num_land);
1002 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_land);
1003 keyList[KEYMODE_JA_HALF_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_input_land);
1004 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone_land);
1006 /* 12-keys shift_on (landscape) */
1007 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1008 keyList[KEYMODE_JA_FULL_HIRAGANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_HIRAGANA];
1009 keyList[KEYMODE_JA_FULL_ALPHABET] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_ALPHABET];
1010 keyList[KEYMODE_JA_FULL_NUMBER] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_NUMBER];
1011 keyList[KEYMODE_JA_FULL_KATAKANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_KATAKANA];
1012 keyList[KEYMODE_JA_HALF_ALPHABET] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_ALPHABET];;
1013 keyList[KEYMODE_JA_HALF_NUMBER] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_NUMBER];
1014 keyList[KEYMODE_JA_HALF_KATAKANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_KATAKANA];
1015 keyList[KEYMODE_JA_HALF_PHONE] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE];
1018 mNikoKeyboard = new Keyboard[11][2];
1019 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_top_land);
1020 mNikoKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_a_land);
1021 mNikoKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_k_land);
1022 mNikoKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_s_land);
1023 mNikoKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_t_land);
1024 mNikoKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_n_land);
1025 mNikoKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_h_land);
1026 mNikoKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_m_land);
1027 mNikoKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_y_land);
1028 mNikoKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_r_land);
1029 mNikoKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_w_land);
1031 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_top_land);
1032 mNikoKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_a_land);
1033 mNikoKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_k_land);
1034 mNikoKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_s_land);
1035 mNikoKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_t_land);
1036 mNikoKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_n_land);
1037 mNikoKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_h_land);
1038 mNikoKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_m_land);
1039 mNikoKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_y_land);
1040 mNikoKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_r_land);
1041 mNikoKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_w_land);
1043 // belltouch slide(Y)
1044 mYBellKeyboard = new Keyboard[11][2];
1045 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0];
1046 mYBellKeyboard[NIKO_SLIDE_MODE_A][0] = mNikoKeyboard[NIKO_SLIDE_MODE_A][0];
1047 mYBellKeyboard[NIKO_SLIDE_MODE_K][0] = mNikoKeyboard[NIKO_SLIDE_MODE_K][0];
1048 mYBellKeyboard[NIKO_SLIDE_MODE_S][0] = mNikoKeyboard[NIKO_SLIDE_MODE_S][0];
1049 mYBellKeyboard[NIKO_SLIDE_MODE_T][0] = mNikoKeyboard[NIKO_SLIDE_MODE_T][0];
1050 mYBellKeyboard[NIKO_SLIDE_MODE_N][0] = mNikoKeyboard[NIKO_SLIDE_MODE_N][0];
1051 mYBellKeyboard[NIKO_SLIDE_MODE_H][0] = mNikoKeyboard[NIKO_SLIDE_MODE_H][0];
1052 mYBellKeyboard[NIKO_SLIDE_MODE_M][0] = mNikoKeyboard[NIKO_SLIDE_MODE_M][0];
1053 mYBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_y_land);
1054 mYBellKeyboard[NIKO_SLIDE_MODE_R][0] = mNikoKeyboard[NIKO_SLIDE_MODE_R][0];
1055 mYBellKeyboard[NIKO_SLIDE_MODE_W][0] = mNikoKeyboard[NIKO_SLIDE_MODE_W][0];
1057 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1];
1058 mYBellKeyboard[NIKO_SLIDE_MODE_A][1] = mNikoKeyboard[NIKO_SLIDE_MODE_A][1];
1059 mYBellKeyboard[NIKO_SLIDE_MODE_K][1] = mNikoKeyboard[NIKO_SLIDE_MODE_K][1];
1060 mYBellKeyboard[NIKO_SLIDE_MODE_S][1] = mNikoKeyboard[NIKO_SLIDE_MODE_S][1];
1061 mYBellKeyboard[NIKO_SLIDE_MODE_T][1] = mNikoKeyboard[NIKO_SLIDE_MODE_T][1];
1062 mYBellKeyboard[NIKO_SLIDE_MODE_N][1] = mNikoKeyboard[NIKO_SLIDE_MODE_N][1];
1063 mYBellKeyboard[NIKO_SLIDE_MODE_H][1] = mNikoKeyboard[NIKO_SLIDE_MODE_H][1];
1064 mYBellKeyboard[NIKO_SLIDE_MODE_M][1] = mNikoKeyboard[NIKO_SLIDE_MODE_M][1];
1065 mYBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_input_y_land);
1066 mYBellKeyboard[NIKO_SLIDE_MODE_R][1] = mNikoKeyboard[NIKO_SLIDE_MODE_R][1];
1067 mYBellKeyboard[NIKO_SLIDE_MODE_W][1] = mNikoKeyboard[NIKO_SLIDE_MODE_W][1];
1070 mBellKeyboard = new Keyboard[11][2];
1071 mBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_top_land);
1072 mBellKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_a_land);
1073 mBellKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_k_land);
1074 mBellKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_s_land);
1075 mBellKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_t_land);
1076 mBellKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_n_land);
1077 mBellKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_h_land);
1078 mBellKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_m_land);
1079 mBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_y_land);
1080 mBellKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_r_land);
1081 mBellKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_w_land);
1083 mBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_top_land);
1084 mBellKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_a_land);
1085 mBellKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_k_land);
1086 mBellKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_s_land);
1087 mBellKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_t_land);
1088 mBellKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_n_land);
1089 mBellKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_h_land);
1090 mBellKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_m_land);
1091 mBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_y_land);
1092 mBellKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_r_land);
1093 mBellKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_w_land);
1095 changeNicoBellLayout();
1099 * Convert the key code to the index of table
1101 * @param index The key code
1102 * @return The index of the toggle table for input
1104 private int getTableIndex(int keyCode) {
1106 (keyCode == KEYCODE_JP12_1) ? 0 :
1107 (keyCode == KEYCODE_JP12_2) ? 1 :
1108 (keyCode == KEYCODE_JP12_3) ? 2 :
1109 (keyCode == KEYCODE_JP12_4) ? 3 :
1110 (keyCode == KEYCODE_JP12_5) ? 4 :
1111 (keyCode == KEYCODE_JP12_6) ? 5 :
1112 (keyCode == KEYCODE_JP12_7) ? 6 :
1113 (keyCode == KEYCODE_JP12_8) ? 7 :
1114 (keyCode == KEYCODE_JP12_9) ? 8 :
1115 (keyCode == KEYCODE_JP12_0) ? 9 :
1116 (keyCode == KEYCODE_JP12_SHARP) ? 10 :
1117 (keyCode == KEYCODE_JP12_ASTER) ? 11 :
1124 * Get the toggle table for input that is appropriate in current mode.
1126 * @return The toggle table for input
1128 private String[][] getCycleTable() {
1129 String[][] cycleTable = null;
1130 switch (mCurrentKeyMode) {
1131 case KEYMODE_JA_FULL_HIRAGANA:
1132 cycleTable = JP_FULL_HIRAGANA_CYCLE_TABLE;
1135 case KEYMODE_JA_FULL_KATAKANA:
1136 cycleTable = JP_FULL_KATAKANA_CYCLE_TABLE;
1139 case KEYMODE_JA_FULL_ALPHABET:
1140 cycleTable = JP_FULL_ALPHABET_CYCLE_TABLE;
1143 case KEYMODE_JA_FULL_NUMBER:
1144 case KEYMODE_JA_HALF_NUMBER:
1145 /* Because these modes belong to direct input group, No toggle table exists */
1148 case KEYMODE_JA_HALF_ALPHABET:
1149 cycleTable = JP_HALF_ALPHABET_CYCLE_TABLE;
1152 case KEYMODE_JA_HALF_KATAKANA:
1153 cycleTable = JP_HALF_KATAKANA_CYCLE_TABLE;
1156 case KEYMODE_JA_FULL_NIKO:
1157 if (false == mChangeBellMode) {
1158 cycleTable = JP_FULL_NIKO_CYCLE_TABLE;
1161 cycleTable = JP_FULL_BELL_CYCLE_TABLE;
1172 * Get the replace table that is appropriate in current mode.
1174 * @return The replace table
1176 private HashMap getReplaceTable() {
1177 HashMap hashTable = null;
1178 switch (mCurrentKeyMode) {
1179 case KEYMODE_JA_FULL_HIRAGANA:
1180 hashTable = JP_FULL_HIRAGANA_REPLACE_TABLE;
1182 case KEYMODE_JA_FULL_KATAKANA:
1183 hashTable = JP_FULL_KATAKANA_REPLACE_TABLE;
1186 case KEYMODE_JA_FULL_ALPHABET:
1187 hashTable = JP_FULL_ALPHABET_REPLACE_TABLE;
1190 case KEYMODE_JA_FULL_NUMBER:
1191 case KEYMODE_JA_HALF_NUMBER:
1192 /* Because these modes belong to direct input group, No replacing table exists */
1195 case KEYMODE_JA_HALF_ALPHABET:
1196 hashTable = JP_HALF_ALPHABET_REPLACE_TABLE;
1199 case KEYMODE_JA_HALF_KATAKANA:
1200 hashTable = JP_HALF_KATAKANA_REPLACE_TABLE;
1203 case KEYMODE_JA_FULL_NIKO:
1204 hashTable = JP_FULL_NIKO_REPLACE_TABLE;
1214 * Set the status icon that is appropriate in current mode
1216 private void setStatusIcon() {
1219 switch (mCurrentKeyMode) {
1220 case KEYMODE_JA_FULL_HIRAGANA:
1221 icon = R.drawable.immodeic_hiragana;
1223 case KEYMODE_JA_FULL_KATAKANA:
1224 icon = R.drawable.immodeic_full_kana;
1226 case KEYMODE_JA_FULL_ALPHABET:
1227 icon = R.drawable.immodeic_full_alphabet;
1229 case KEYMODE_JA_FULL_NUMBER:
1230 icon = R.drawable.immodeic_full_number;
1232 case KEYMODE_JA_HALF_KATAKANA:
1233 icon = R.drawable.immodeic_half_kana;
1235 case KEYMODE_JA_HALF_ALPHABET:
1236 icon = R.drawable.immodeic_half_alphabet;
1238 case KEYMODE_JA_HALF_NUMBER:
1239 case KEYMODE_JA_HALF_PHONE:
1240 icon = R.drawable.immodeic_half_number;
1242 case KEYMODE_JA_FULL_NIKO:
1243 icon = R.drawable.immodeic_niko;
1250 mWnn.showStatusIcon(icon);
1254 * Get the shift key state from the editor.
1256 * @param editor The editor information
1257 * @return The state id of the shift key (0:off, 1:on)
1259 protected int getShiftKeyState(EditorInfo editor) {
1260 InputConnection connection = mWnn.getCurrentInputConnection();
1261 if (connection != null) {
1262 int caps = connection.getCursorCapsMode(editor.inputType);
1263 return (caps == 0) ? 0 : 1;
1270 * Set the shift key state from {@link EditorInfo}.
1272 private void setShiftByEditorInfo() {
1273 if (mEnableAutoCaps && (mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET)) {
1274 int shift = getShiftKeyState(mWnn.getCurrentInputEditorInfo());
1277 changeKeyboard(getShiftChangeKeyboard(shift));
1281 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#setHardKeyboardHidden */
1282 @Override public void setHardKeyboardHidden(boolean hidden) {
1285 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
1286 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
1289 if (mHardKeyboardHidden != hidden) {
1290 if ((mLimitedKeyMode != null)
1291 || ((mCurrentKeyMode != KEYMODE_JA_FULL_NIKO) && (mCurrentKeyMode != KEYMODE_JA_FULL_HIRAGANA) && (mCurrentKeyMode != KEYMODE_JA_HALF_ALPHABET))) {
1293 mLastInputType = EditorInfo.TYPE_NULL;
1294 if (mWnn.isInputViewShown()) {
1295 setDefaultKeyboard();
1300 super.setHardKeyboardHidden(hidden);
1304 * Change the key-mode to the allowed one which is restricted
1305 * by the text input field or the type of the keyboard.
1306 * @param keyMode The key-mode
1307 * @return the key-mode allowed
1309 private int filterKeyMode(int keyMode) {
1310 int targetMode = keyMode;
1311 int[] limits = mLimitedKeyMode;
1313 if (!mHardKeyboardHidden) { /* for hardware keyboard */
1314 if ((targetMode != KEYMODE_JA_FULL_NIKO) && (targetMode != KEYMODE_JA_FULL_HIRAGANA) && (targetMode != KEYMODE_JA_HALF_ALPHABET)) {
1315 Locale locale = Locale.getDefault();
1316 int keymode = KEYMODE_JA_HALF_ALPHABET;
1317 if (locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
1318 switch (targetMode) {
1319 case KEYMODE_JA_FULL_NIKO:
1320 case KEYMODE_JA_FULL_HIRAGANA:
1321 case KEYMODE_JA_FULL_KATAKANA:
1322 case KEYMODE_JA_HALF_KATAKANA:
1323 keymode = KEYMODE_JA_FULL_NIKO;
1330 targetMode = keymode;
1334 /* restrict by the type of the text field */
1335 if (limits != null) {
1336 boolean hasAccepted = false;
1337 boolean hasRequiredChange = true;
1338 int size = limits.length;
1339 int nowMode = mCurrentKeyMode;
1341 for (int i = 0; i < size; i++) {
1342 if (targetMode == limits[i]) {
1346 if (nowMode == limits[i]) {
1347 hasRequiredChange = false;
1352 if (hasRequiredChange) {
1353 targetMode = mLimitedKeyMode[0];
1355 targetMode = INVALID_KEYMODE;
1365 /*****************************************
1368 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#onKey */
1369 @Override public void onKey(int primaryCode, int[] keyCodes) {
1371 if (mDisableKeyInput) {
1375 if (mCurrentKeyMode == KEYMODE_JA_FULL_NIKO) {
1376 if (true == onKeyNiko(primaryCode, keyCodes)) {
1377 /* update shift key's state */
1378 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1379 setShiftByEditorInfo();
1384 if (true == mIsEnableFlick) {
1385 onkeyFlick(primaryCode, keyCodes);
1389 switch (primaryCode) {
1390 case KEYCODE_JP12_TOGGLE_MODE:
1391 case KEYCODE_QWERTY_TOGGLE_MODE:
1392 if (!mIsInputTypeNull) {
1397 case DefaultSoftKeyboard.KEYCODE_QWERTY_BACKSPACE:
1398 case KEYCODE_JP12_BACKSPACE:
1399 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1400 new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)));
1403 case DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT:
1407 case DefaultSoftKeyboard.KEYCODE_QWERTY_ALT:
1411 case KEYCODE_QWERTY_ENTER:
1412 case KEYCODE_JP12_ENTER:
1413 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1414 new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)));
1417 case KEYCODE_JP12_REVERSE:
1419 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_REVERSE_CHAR, mCurrentCycleTable));
1423 case KEYCODE_QWERTY_KBD:
1424 changeKeyboardType(KEYBOARD_12KEY);
1425 mHookStockKeyType = KEYBOARD_12KEY;
1428 case KEYCODE_JP12_KBD:
1429 changeKeyboardType(KEYBOARD_QWERTY);
1430 mHookStockKeyType = KEYBOARD_QWERTY;
1433 case KEYCODE_JP12_EMOJI:
1434 case KEYCODE_QWERTY_EMOJI:
1436 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_SYMBOL));
1439 case KEYCODE_JP12_1:
1440 case KEYCODE_JP12_2:
1441 case KEYCODE_JP12_3:
1442 case KEYCODE_JP12_4:
1443 case KEYCODE_JP12_5:
1444 case KEYCODE_JP12_6:
1445 case KEYCODE_JP12_7:
1446 case KEYCODE_JP12_8:
1447 case KEYCODE_JP12_9:
1448 case KEYCODE_JP12_0:
1449 case KEYCODE_JP12_SHARP:
1450 /* Processing to input by ten key */
1451 if (mInputType == INPUT_TYPE_INSTANT) {
1452 /* Send a input character directly if instant input type is selected */
1454 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR,
1455 mCurrentInstantTable[getTableIndex(primaryCode)]));
1457 if ((mPrevInputKeyCode != primaryCode)) {
1458 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOUCH_OTHER_KEY));
1459 if ((mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET)
1460 && (primaryCode == KEYCODE_JP12_SHARP)) {
1461 /* Commit text by symbol character (',' '.') when alphabet input mode is selected */
1466 /* Convert the key code to the table index and send the toggle event with the table index */
1467 String[][] cycleTable = getCycleTable();
1468 if (cycleTable == null) {
1469 Log.e("NicoWnn", "not founds cycle table");
1471 int index = getTableIndex(primaryCode);
1472 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[index]));
1473 mCurrentCycleTable = cycleTable[index];
1475 mPrevInputKeyCode = primaryCode;
1479 case KEYCODE_JP12_ASTER:
1480 if (mInputType == INPUT_TYPE_INSTANT) {
1482 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR,
1483 mCurrentInstantTable[getTableIndex(primaryCode)]));
1486 /* Processing to toggle Dakuten, Handakuten, and capital */
1487 HashMap replaceTable = getReplaceTable();
1488 if (replaceTable == null) {
1489 Log.e("NicoWnn", "not founds replace table");
1491 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.REPLACE_CHAR, replaceTable));
1492 mPrevInputKeyCode = primaryCode;
1498 case KEYCODE_SWITCH_FULL_HIRAGANA:
1499 /* Change mode to Full width hiragana */
1500 changeKeyMode(KEYMODE_JA_FULL_HIRAGANA);
1503 case KEYCODE_SWITCH_FULL_KATAKANA:
1504 /* Change mode to Full width katakana */
1505 changeKeyMode(KEYMODE_JA_FULL_KATAKANA);
1508 case KEYCODE_SWITCH_FULL_ALPHABET:
1509 /* Change mode to Full width alphabet */
1510 changeKeyMode(KEYMODE_JA_FULL_ALPHABET);
1513 case KEYCODE_SWITCH_FULL_NUMBER:
1514 /* Change mode to Full width numeric */
1515 changeKeyMode(KEYMODE_JA_FULL_NUMBER);
1518 case KEYCODE_SWITCH_HALF_KATAKANA:
1519 /* Change mode to Half width katakana */
1520 changeKeyMode(KEYMODE_JA_HALF_KATAKANA);
1523 case KEYCODE_SWITCH_HALF_ALPHABET:
1524 /* Change mode to Half width alphabet */
1525 changeKeyMode(KEYMODE_JA_HALF_ALPHABET);
1528 case KEYCODE_SWITCH_HALF_NUMBER:
1529 /* Change mode to Half width numeric */
1530 changeKeyMode(KEYMODE_JA_HALF_NUMBER);
1533 case KEYCODE_SWITCH_FULL_NIKO:
1534 /* Change mode to Full width nikotouch */
1535 changeKeyMode(KEYMODE_JA_FULL_NIKO);
1538 case KEYCODE_SELECT_CASE:
1539 int shifted = (mShiftOn == 0) ? 1 : 0;
1540 Keyboard newKeyboard = getShiftChangeKeyboard(shifted);
1541 if (newKeyboard != null) {
1543 changeKeyboard(newKeyboard);
1547 case KEYCODE_JP12_SPACE:
1548 if ((mCurrentKeyMode == KEYMODE_JA_FULL_HIRAGANA) && !mNoInput) {
1549 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CONVERT));
1551 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, ' '));
1555 case KEYCODE_EISU_KANA:
1556 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_EISU_KANA));
1559 case KEYCODE_JP12_CLOSE:
1560 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_KEY,
1561 new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)));
1564 case KEYCODE_JP12_LEFT:
1565 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1566 new KeyEvent(KeyEvent.ACTION_DOWN,
1567 KeyEvent.KEYCODE_DPAD_LEFT)));
1570 case KEYCODE_JP12_RIGHT:
1571 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1572 new KeyEvent(KeyEvent.ACTION_DOWN,
1573 KeyEvent.KEYCODE_DPAD_RIGHT)));
1579 if (primaryCode >= 0) {
1580 if (mKeyboardView.isShifted()) {
1581 primaryCode = Character.toUpperCase(primaryCode);
1583 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, (char)primaryCode));
1588 /* update shift key's state */
1589 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1590 setShiftByEditorInfo();
1595 /*****************************************
1598 private boolean onKeyNiko(int primaryCode, int[] keyCodes) {
1599 Keyboard newKeyboard = null;
1600 boolean retcode = false;
1601 switch (primaryCode) {
1602 case DefaultSoftKeyboard.KEYCODE_QWERTY_BACKSPACE:
1603 case KEYCODE_JP12_BACKSPACE:
1604 if (mNikoFirst == true) {
1605 resetNikoKeyboard();
1608 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)));
1612 case KEYCODE_QWERTY_ENTER:
1613 case KEYCODE_JP12_ENTER:
1614 if (mNikoFirst == false) {
1615 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)));
1620 case KEYCODE_JP12_REVERSE:
1621 if (mNikoFirst == true) {
1622 resetNikoKeyboard();
1628 case KEYCODE_QWERTY_KBD:
1629 case KEYCODE_JP12_KBD:
1630 resetNikoKeyboard();
1633 case KEYCODE_JP12_EMOJI:
1634 case KEYCODE_QWERTY_EMOJI:
1635 if (mNikoFirst == false) {
1637 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_SYMBOL));
1642 case KEYCODE_JP12_SHARP:
1646 case KEYCODE_JP12_1:
1647 case KEYCODE_JP12_2:
1648 case KEYCODE_JP12_3:
1649 case KEYCODE_JP12_4:
1650 case KEYCODE_JP12_5:
1651 case KEYCODE_JP12_6:
1652 case KEYCODE_JP12_7:
1653 case KEYCODE_JP12_8:
1654 case KEYCODE_JP12_9:
1655 case KEYCODE_JP12_0:
1656 if (mNikoFirst == false) {
1657 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOUCH_OTHER_KEY));
1659 int index = getTableIndex(primaryCode);
1660 Keyboard[][] keyList = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1661 if (false == mChangeBellMode) {
1662 if (false == mChangeYLineBellMode) {
1663 keyList[KEYMODE_JA_FULL_NIKO] = mNikoKeyboard[index+1];
1666 keyList[KEYMODE_JA_FULL_NIKO] = mYBellKeyboard[index+1];
1670 keyList[KEYMODE_JA_FULL_NIKO] = mBellKeyboard[index+1];
1672 newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_ON);
1673 if (newKeyboard != null) {
1674 mShiftOn = KEYBOARD_SHIFT_ON;
1675 changeKeyboard(newKeyboard);
1677 mPrevInputKeyCode = primaryCode;
1681 int col = getTableIndex(mPrevInputKeyCode);
1682 int row = getTableIndex(primaryCode);
1683 String[][] cycleTable = getCycleTable();
1684 if (cycleTable == null) {
1685 Log.e("NicoWnn", "not founds cycle table");
1688 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[col * 10 + row]));
1690 newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_OFF);
1691 if (newKeyboard != null) {
1692 mShiftOn = KEYBOARD_SHIFT_OFF;
1693 changeKeyboard(newKeyboard);
1700 case KEYCODE_JP12_ASTER:
1701 if (mNikoFirst == false && !mNoInput) {
1702 /* Processing to toggle Dakuten, Handakuten, and capital */
1703 HashMap replaceTable = getReplaceTable();
1704 if (replaceTable == null) {
1705 Log.e("NicoWnn", "not founds replace table");
1707 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.REPLACE_CHAR, replaceTable));
1708 mPrevInputKeyCode = primaryCode;
1714 case KEYCODE_JP12_SPACE:
1715 if (mNikoFirst == false) {
1716 if ((mCurrentKeyMode == KEYMODE_JA_FULL_HIRAGANA) && !mNoInput) {
1717 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CONVERT));
1719 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, ' '));
1725 case KEYCODE_EISU_KANA:
1726 if (mNikoFirst == false) {
1727 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_EISU_KANA));
1732 case KEYCODE_JP12_CLOSE:
1733 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)));
1737 case KEYCODE_JP12_LEFT:
1738 if (mNikoFirst == false) {
1739 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_LEFT)));
1743 case KEYCODE_JP12_RIGHT:
1744 if (mNikoFirst == false) {
1745 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT)));
1753 * reset nikotouch keyboard
1755 @Override public void resetNikoKeyboard() {
1756 Keyboard newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_OFF);
1757 if (newKeyboard != null) {
1758 mShiftOn = KEYBOARD_SHIFT_OFF;
1759 changeKeyboard(newKeyboard);
1762 } // resetNikoKeyboard
1763 private void setLastNikoChar(int keycode) {
1764 int col = getTableIndex(keycode);
1765 String[][] cycleTable = getCycleTable();
1766 if (cycleTable == null) {
1767 Log.e("NicoWnn", "not founds cycle table");
1770 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[col * 10]));
1772 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOUCH_OTHER_KEY));
1773 } // setLastNikoChar
1775 private void changeNicoBellLayout() {
1776 Keyboard[][] keyList, keyListOn;
1777 keyList = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
1778 keyListOn = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1779 if (false == mChangeBellMode) {
1780 keyList[KEYMODE_JA_FULL_NIKO] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP];
1781 if (false == mChangeYLineBellMode) {
1782 keyListOn[KEYMODE_JA_FULL_NIKO] = mNikoKeyboard[NIKO_SLIDE_MODE_A];
1785 keyListOn[KEYMODE_JA_FULL_NIKO] = mYBellKeyboard[NIKO_SLIDE_MODE_A];
1789 keyList[KEYMODE_JA_FULL_NIKO] = mBellKeyboard[NIKO_SLIDE_MODE_TOP];
1790 keyListOn[KEYMODE_JA_FULL_NIKO] = mBellKeyboard[NIKO_SLIDE_MODE_A];
1795 /*************************************************
1798 private void onkeyFlick(int primaryCode, int[] keyCodes) {
1799 switch (primaryCode) {
1800 case KEYCODE_JP12_TOGGLE_MODE:
1801 case KEYCODE_QWERTY_TOGGLE_MODE:
1802 if (!mIsInputTypeNull) {
1806 case KEYCODE_SWITCH_FULL_HIRAGANA:
1807 /* Change mode to Full width hiragana */
1808 changeKeyMode(KEYMODE_JA_FULL_HIRAGANA);
1811 case KEYCODE_SWITCH_FULL_KATAKANA:
1812 /* Change mode to Full width katakana */
1813 changeKeyMode(KEYMODE_JA_FULL_KATAKANA);
1816 case KEYCODE_SWITCH_FULL_ALPHABET:
1817 /* Change mode to Full width alphabet */
1818 changeKeyMode(KEYMODE_JA_FULL_ALPHABET);
1821 case KEYCODE_SWITCH_FULL_NUMBER:
1822 /* Change mode to Full width numeric */
1823 changeKeyMode(KEYMODE_JA_FULL_NUMBER);
1826 case KEYCODE_SWITCH_HALF_KATAKANA:
1827 /* Change mode to Half width katakana */
1828 changeKeyMode(KEYMODE_JA_HALF_KATAKANA);
1831 case KEYCODE_SWITCH_HALF_ALPHABET:
1832 /* Change mode to Half width alphabet */
1833 changeKeyMode(KEYMODE_JA_HALF_ALPHABET);
1836 case KEYCODE_SWITCH_HALF_NUMBER:
1837 /* Change mode to Half width numeric */
1838 changeKeyMode(KEYMODE_JA_HALF_NUMBER);
1841 case KEYCODE_SWITCH_FULL_NIKO:
1842 /* Change mode to Full width nikotouch */
1843 changeKeyMode(KEYMODE_JA_FULL_NIKO);
1845 case KEYCODE_SELECT_CASE:
1846 int shifted = (mShiftOn == 0) ? 1 : 0;
1847 Keyboard newKeyboard = getShiftChangeKeyboard(shifted);
1848 if (newKeyboard != null) {
1850 changeKeyboard(newKeyboard);
1856 /* update shift key's state */
1857 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1858 setShiftByEditorInfo();
1863 @Override public void onPress(int primaryCode) {
1864 super.onPress(primaryCode);
1865 mStockFlickCode = primaryCode;
1869 @Override public void onRelease(int primaryCode) {
1870 super.onRelease(primaryCode);
1872 if (false == mIsEnableFlick) {
1875 if (mCurrentKeyMode == KEYMODE_JA_FULL_NIKO) {
1879 if (true == mIsHookFlick) {
1880 onKey(mStockFlickCode, null);
1884 float getx = mReleaseX - mPressX;
1885 float gety = mReleaseY - mPressY;
1888 if (limx < 0.0f) limx *= -1.0f;
1889 if (limy < 0.0f) limy *= -1.0f;
1891 if (limx < mFlickLimitX) {
1894 if (limy < mFlickLimitY) {
1900 if (getx < mFlickLimitX) {
1907 else if (limy > limx) {
1909 if (gety < mFlickLimitY) {
1919 switch (mStockFlickCode) {
1920 case KEYCODE_JP12_1:
1921 case KEYCODE_JP12_2:
1922 case KEYCODE_JP12_3:
1923 case KEYCODE_JP12_4:
1924 case KEYCODE_JP12_5:
1925 case KEYCODE_JP12_6:
1926 case KEYCODE_JP12_7:
1927 case KEYCODE_JP12_8:
1928 case KEYCODE_JP12_9:
1929 case KEYCODE_JP12_0:
1930 int col = getTableIndex(mStockFlickCode);
1931 String[][] cycleTable = getCycleTable();
1932 if (cycleTable == null) {
1933 Log.e("NicoWnn", "not founds cycle table");
1936 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[col * 10 + offset]));
1938 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOUCH_OTHER_KEY));
1941 onKey(mStockFlickCode, null);
1944 /* update shift key's state */
1945 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1946 setShiftByEditorInfo();