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 /* Create the suitable keyboard object */
462 if (mDisplayMode == DefaultSoftKeyboard.PORTRAIT) {
463 //mCurrentKeyboardType = KEYBOARD_12KEY;
464 createKeyboardsPortrait(parent);
468 //mCurrentKeyboardType = KEYBOARD_QWERTY;
469 createKeyboardsLandscape(parent);
474 if (mCurrentKeyboardType == KEYBOARD_12KEY) {
475 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
476 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_12KEY));
478 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
479 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
484 * Commit the pre-edit string for committing operation that is not explicit
485 * (ex. when a candidate is selected)
487 private void commitText() {
489 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.COMMIT_COMPOSING_TEXT));
496 * @param keyMode The type of input mode
498 public void changeKeyMode(int keyMode) {
499 int targetMode = filterKeyMode(keyMode);
500 if (targetMode == INVALID_KEYMODE) {
507 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
508 new KeyEvent(KeyEvent.ACTION_UP,
509 KeyEvent.KEYCODE_SHIFT_LEFT)));
512 mShiftOn = KEYBOARD_SHIFT_OFF;
513 Keyboard kbd = getModeChangeKeyboard(targetMode);
514 mCurrentKeyMode = targetMode;
515 mPrevInputKeyCode = 0;
518 int mode = NicoWnnEvent.Mode.DIRECT;
520 switch (targetMode) {
521 case KEYMODE_JA_FULL_HIRAGANA:
522 mInputType = INPUT_TYPE_TOGGLE;
523 mode = NicoWnnEvent.Mode.DEFAULT;
526 case KEYMODE_JA_HALF_ALPHABET:
527 if (USE_ENGLISH_PREDICT) {
528 mInputType = INPUT_TYPE_TOGGLE;
529 mode = NicoWnnEvent.Mode.NO_LV1_CONV;
531 mInputType = INPUT_TYPE_TOGGLE;
532 mode = NicoWnnEvent.Mode.DIRECT;
536 case KEYMODE_JA_FULL_NUMBER:
537 mInputType = INPUT_TYPE_INSTANT;
538 mode = NicoWnnEvent.Mode.DIRECT;
539 mCurrentInstantTable = INSTANT_CHAR_CODE_FULL_NUMBER;
542 case KEYMODE_JA_HALF_NUMBER:
543 mInputType = INPUT_TYPE_INSTANT;
544 mode = NicoWnnEvent.Mode.DIRECT;
545 mCurrentInstantTable = INSTANT_CHAR_CODE_HALF_NUMBER;
548 case KEYMODE_JA_FULL_KATAKANA:
549 mInputType = INPUT_TYPE_TOGGLE;
550 mode = NicoWnnJAJP.ENGINE_MODE_FULL_KATAKANA;
553 case KEYMODE_JA_FULL_ALPHABET:
554 mInputType = INPUT_TYPE_TOGGLE;
555 mode = NicoWnnEvent.Mode.DIRECT;
558 case KEYMODE_JA_HALF_KATAKANA:
559 mInputType = INPUT_TYPE_TOGGLE;
560 mode = NicoWnnJAJP.ENGINE_MODE_HALF_KATAKANA;
563 case KEYMODE_JA_FULL_NIKO:
564 mInputType = INPUT_TYPE_TOGGLE;
565 mode = NicoWnnEvent.Mode.DEFAULT;
575 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, mode));
576 if (mChange12keyQwertyMode == true) {
577 changeKeyboardType(m12keyTable[targetMode]);
581 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#initView */
582 @Override public View initView(NicoWnn parent, int width, int height) {
583 View view = super.initView(parent, width, height);
584 SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(parent);
585 changeKeyboard(mKeyboard[mCurrentLanguage][mDisplayMode][mCurrentKeyboardType][mShiftOn][mCurrentKeyMode][0]);
589 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#changeKeyboard */
590 @Override protected boolean changeKeyboard(Keyboard keyboard) {
592 if (keyboard != null) {
593 if (mIsInputTypeNull) {
594 mChangeModeKey.popupResId = mPopupResId;
597 List<Keyboard.Key> keys = keyboard.getKeys();
598 int keyIndex = (KEY_NUMBER_12KEY < keys.size())
599 ? KEY_INDEX_CHANGE_MODE_QWERTY : KEY_INDEX_CHANGE_MODE_12KEY;
600 mChangeModeKey = keys.get(keyIndex);
602 if (mIsInputTypeNull) {
603 mPopupResId = mChangeModeKey.popupResId;
604 mChangeModeKey.popupResId = 0;
607 return super.changeKeyboard(keyboard);
610 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#changeKeyboardType */
611 @Override public void changeKeyboardType(int type) {
613 Keyboard kbd = getTypeChangeKeyboard(type);
615 mCurrentKeyboardType = type;
616 mPrefEditor.putBoolean("opt_enable_qwerty", type == KEYBOARD_QWERTY);
617 mPrefEditor.commit();
620 if (type == KEYBOARD_12KEY) {
621 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_12KEY));
623 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
626 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#setPreferences */
627 @Override public void setPreferences(SharedPreferences pref, EditorInfo editor) {
628 mPrefEditor = pref.edit();
629 boolean isQwerty = pref.getBoolean("opt_enable_qwerty", false);
630 if (isQwerty && (mCurrentKeyboardType != KEYBOARD_QWERTY)) {
631 changeKeyboardType(KEYBOARD_QWERTY);
634 super.setPreferences(pref, editor);
636 int inputType = editor.inputType;
637 if (mHardKeyboardHidden) {
638 if (inputType == EditorInfo.TYPE_NULL) {
639 if (!mIsInputTypeNull) {
640 mIsInputTypeNull = true;
641 mPopupResId = mChangeModeKey.popupResId;
642 mChangeModeKey.popupResId = 0;
647 if (mIsInputTypeNull) {
648 mIsInputTypeNull = false;
649 mChangeModeKey.popupResId = mPopupResId;
653 mEnableAutoCaps = pref.getBoolean("auto_caps", true);
654 mLimitedKeyMode = null;
655 mPreferenceKeyMode = INVALID_KEYMODE;
657 mDisableKeyInput = false;
660 mOnOffKeitaiMode = pref.getBoolean("change_keitaimode", false);
661 if (true == mOnOffKeitaiMode) {
662 // off keitai hiragana mode
663 mLimitedKeyMode = new int[] {KEYMODE_JA_FULL_NIKO, KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
665 switch (inputType & EditorInfo.TYPE_MASK_CLASS) {
667 case EditorInfo.TYPE_CLASS_NUMBER:
668 case EditorInfo.TYPE_CLASS_DATETIME:
669 mPreferenceKeyMode = KEYMODE_JA_HALF_NUMBER;
672 case EditorInfo.TYPE_CLASS_PHONE:
673 if (mHardKeyboardHidden) {
674 //mLimitedKeyMode = new int[] {KEYMODE_JA_FULL_NIKO};
675 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
677 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET};
678 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
682 case EditorInfo.TYPE_CLASS_TEXT:
683 switch (inputType & EditorInfo.TYPE_MASK_VARIATION) {
685 case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD:
686 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
689 case EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
690 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
692 case EditorInfo.TYPE_TEXT_VARIATION_URI:
693 //mPreferenceKeyMode = KEYMODE_JA_HALF_ALPHABET;
694 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
706 boolean restartkey = false;
707 boolean old12keyqwerty = mChange12keyQwertyMode;
708 boolean oldnicobell = mChangeBellMode;
710 mChange12keyQwertyMode = pref.getBoolean("change_12key_qwerty", false);
711 mChangeYLineBellMode = pref.getBoolean("change_y_bellmode", false);
712 mChangeBellMode = pref.getBoolean("change_bellmode", false);
713 if (old12keyqwerty != mChange12keyQwertyMode) {
715 if (false == mChange12keyQwertyMode) {
716 mCurrentKeyboardType = mHookStockKeyType; // change last keyboard type.
719 if (oldnicobell != mChangeBellMode) {
723 if (inputType != mLastInputType) {
724 changeNicoBellLayout();
725 setDefaultKeyboard();
726 mLastInputType = inputType;
728 else if (true == restartkey) {
729 changeNicoBellLayout();
730 setDefaultKeyboard();
734 setShiftByEditorInfo();
737 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#onUpdateState */
738 @Override public void onUpdateState(NicoWnn parent) {
739 super.onUpdateState(parent);
741 setShiftByEditorInfo();
742 if (true == mNoInput && true == mNikoFirst) {
748 * Change the keyboard to default
750 public void setDefaultKeyboard() {
751 Locale locale = Locale.getDefault();
752 int keymode = KEYMODE_JA_FULL_NIKO;
755 if (mPreferenceKeyMode != INVALID_KEYMODE) {
756 keymode = mPreferenceKeyMode;
757 } else if (mLimitedKeyMode != null) {
758 keymode = mLimitedKeyMode[0];
760 if (!locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
761 keymode = KEYMODE_JA_HALF_ALPHABET;
765 changeKeyMode(keymode);
770 * Change to the next input mode
772 public void nextKeyMode() {
773 /* Search the current mode in the toggle table */
774 boolean found = false;
776 for (index = 0; index < JP_MODE_CYCLE_TABLE.length; index++) {
777 if (JP_MODE_CYCLE_TABLE[index] == mCurrentKeyMode) {
784 /* If the current mode not exists, set the default mode */
785 setDefaultKeyboard();
787 /* If the current mode exists, set the next input mode */
788 int size = JP_MODE_CYCLE_TABLE.length;
789 int keyMode = INVALID_KEYMODE;
790 for (int i = 0; i < size; i++) {
791 index = (++index) % size;
793 keyMode = filterKeyMode(JP_MODE_CYCLE_TABLE[index]);
794 if (keyMode != INVALID_KEYMODE) {
799 if (keyMode != INVALID_KEYMODE) {
800 changeKeyMode(keyMode);
806 * Create the keyboard for portrait mode
808 * @param parent The context
810 private void createKeyboardsPortrait(NicoWnn parent) {
811 Keyboard[][] keyList;
812 /* qwerty shift_off (portrait) */
813 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF];
814 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp);
815 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet);
816 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols);
817 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana);
818 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet);
819 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols);
820 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana);
821 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone);
822 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
824 /* qwerty shift_on (portrait) */
825 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_ON];
826 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_shift);
827 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_shift);
828 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_shift);
829 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_shift);
830 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_shift);
831 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_shift);
832 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_shift);
833 keyList[KEYMODE_JA_HALF_PHONE][0] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE][0];
834 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
836 /* 12-keys shift_off (portrait) */
837 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
838 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_12keyjp);
839 keyList[KEYMODE_JA_FULL_HIRAGANA][1] = new Keyboard(parent, R.xml.keyboard_12keyjp_input);
840 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana);
841 keyList[KEYMODE_JA_FULL_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_input);
842 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana);
843 keyList[KEYMODE_JA_HALF_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_input);
844 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone);
846 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet);
847 keyList[KEYMODE_JA_FULL_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_input);
848 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_full_num);
849 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet);
850 keyList[KEYMODE_JA_HALF_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_input);
851 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_half_num);
853 /* 12-keys shift_on (portrait) */
854 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
855 keyList[KEYMODE_JA_FULL_HIRAGANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_HIRAGANA];
856 keyList[KEYMODE_JA_FULL_KATAKANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_KATAKANA];
857 keyList[KEYMODE_JA_HALF_KATAKANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_KATAKANA];
858 keyList[KEYMODE_JA_HALF_PHONE] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE];
860 keyList[KEYMODE_JA_FULL_ALPHABET] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_ALPHABET];
861 keyList[KEYMODE_JA_FULL_NUMBER] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_NUMBER];
862 keyList[KEYMODE_JA_HALF_ALPHABET] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_ALPHABET];;
863 keyList[KEYMODE_JA_HALF_NUMBER] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_NUMBER];
866 mNikoKeyboard = new Keyboard[11][2];
867 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_top);
868 mNikoKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_a);
869 mNikoKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_k);
870 mNikoKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_s);
871 mNikoKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_t);
872 mNikoKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_n);
873 mNikoKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_h);
874 mNikoKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_m);
875 mNikoKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_y);
876 mNikoKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_r);
877 mNikoKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_w);
879 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_top);
880 mNikoKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_a);
881 mNikoKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_k);
882 mNikoKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_s);
883 mNikoKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_t);
884 mNikoKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_n);
885 mNikoKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_h);
886 mNikoKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_m);
887 mNikoKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_y);
888 mNikoKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_r);
889 mNikoKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_w);
891 // belltouch slide(Y)
892 mYBellKeyboard = new Keyboard[11][2];
893 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0];
894 mYBellKeyboard[NIKO_SLIDE_MODE_A][0] = mNikoKeyboard[NIKO_SLIDE_MODE_A][0];
895 mYBellKeyboard[NIKO_SLIDE_MODE_K][0] = mNikoKeyboard[NIKO_SLIDE_MODE_K][0];
896 mYBellKeyboard[NIKO_SLIDE_MODE_S][0] = mNikoKeyboard[NIKO_SLIDE_MODE_S][0];
897 mYBellKeyboard[NIKO_SLIDE_MODE_T][0] = mNikoKeyboard[NIKO_SLIDE_MODE_T][0];
898 mYBellKeyboard[NIKO_SLIDE_MODE_N][0] = mNikoKeyboard[NIKO_SLIDE_MODE_N][0];
899 mYBellKeyboard[NIKO_SLIDE_MODE_H][0] = mNikoKeyboard[NIKO_SLIDE_MODE_H][0];
900 mYBellKeyboard[NIKO_SLIDE_MODE_M][0] = mNikoKeyboard[NIKO_SLIDE_MODE_M][0];
901 mYBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_y);
902 mYBellKeyboard[NIKO_SLIDE_MODE_R][0] = mNikoKeyboard[NIKO_SLIDE_MODE_R][0];
903 mYBellKeyboard[NIKO_SLIDE_MODE_W][0] = mNikoKeyboard[NIKO_SLIDE_MODE_W][0];
905 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1];
906 mYBellKeyboard[NIKO_SLIDE_MODE_A][1] = mNikoKeyboard[NIKO_SLIDE_MODE_A][1];
907 mYBellKeyboard[NIKO_SLIDE_MODE_K][1] = mNikoKeyboard[NIKO_SLIDE_MODE_K][1];
908 mYBellKeyboard[NIKO_SLIDE_MODE_S][1] = mNikoKeyboard[NIKO_SLIDE_MODE_S][1];
909 mYBellKeyboard[NIKO_SLIDE_MODE_T][1] = mNikoKeyboard[NIKO_SLIDE_MODE_T][1];
910 mYBellKeyboard[NIKO_SLIDE_MODE_N][1] = mNikoKeyboard[NIKO_SLIDE_MODE_N][1];
911 mYBellKeyboard[NIKO_SLIDE_MODE_H][1] = mNikoKeyboard[NIKO_SLIDE_MODE_H][1];
912 mYBellKeyboard[NIKO_SLIDE_MODE_M][1] = mNikoKeyboard[NIKO_SLIDE_MODE_M][1];
913 mYBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_input_y);
914 mYBellKeyboard[NIKO_SLIDE_MODE_R][1] = mNikoKeyboard[NIKO_SLIDE_MODE_R][1];
915 mYBellKeyboard[NIKO_SLIDE_MODE_W][1] = mNikoKeyboard[NIKO_SLIDE_MODE_W][1];
918 mBellKeyboard = new Keyboard[11][2];
919 mBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_top);
920 mBellKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_a);
921 mBellKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_k);
922 mBellKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_s);
923 mBellKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_t);
924 mBellKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_n);
925 mBellKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_h);
926 mBellKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_m);
927 mBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_y);
928 mBellKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_r);
929 mBellKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_w);
931 mBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_top);
932 mBellKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_a);
933 mBellKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_k);
934 mBellKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_s);
935 mBellKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_t);
936 mBellKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_n);
937 mBellKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_h);
938 mBellKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_m);
939 mBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_y);
940 mBellKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_r);
941 mBellKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_w);
943 changeNicoBellLayout();
947 * Create the keyboard for landscape mode
949 * @param parent The context
951 private void createKeyboardsLandscape(NicoWnn parent) {
952 Keyboard[][] keyList;
953 /* qwerty shift_off (landscape) */
954 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF];
955 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_land);
956 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_land);
957 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_land);
958 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_land);
959 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_land);
960 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_land);
961 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_land);
962 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone_land);
963 if (false == mChangeBellMode) {
964 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_niko_land);
967 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_bell_land);
969 /* qwerty shift_on (landscape) */
970 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_ON];
971 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_shift_land);
972 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_shift_land);
973 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_shift_land);
974 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_shift_land);
975 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_shift_land);
976 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_shift_land);
977 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_shift_land);
978 keyList[KEYMODE_JA_HALF_PHONE][0] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE][0];
979 if (false == mChangeBellMode) {
980 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_niko_shift_land);
983 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_bell_shift_land);
985 /* 12-keys shift_off (landscape) */
986 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
987 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_12keyjp_land);
988 keyList[KEYMODE_JA_FULL_HIRAGANA][1] = new Keyboard(parent, R.xml.keyboard_12keyjp_input_land);
989 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_land);
990 keyList[KEYMODE_JA_FULL_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_input_land);
991 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_full_num_land);
992 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_land);
993 keyList[KEYMODE_JA_FULL_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_input_land);
994 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_land);
995 keyList[KEYMODE_JA_HALF_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_input_land);
996 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_half_num_land);
997 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_land);
998 keyList[KEYMODE_JA_HALF_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_input_land);
999 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone_land);
1001 /* 12-keys shift_on (landscape) */
1002 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1003 keyList[KEYMODE_JA_FULL_HIRAGANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_HIRAGANA];
1004 keyList[KEYMODE_JA_FULL_ALPHABET] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_ALPHABET];
1005 keyList[KEYMODE_JA_FULL_NUMBER] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_NUMBER];
1006 keyList[KEYMODE_JA_FULL_KATAKANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_KATAKANA];
1007 keyList[KEYMODE_JA_HALF_ALPHABET] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_ALPHABET];;
1008 keyList[KEYMODE_JA_HALF_NUMBER] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_NUMBER];
1009 keyList[KEYMODE_JA_HALF_KATAKANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_KATAKANA];
1010 keyList[KEYMODE_JA_HALF_PHONE] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE];
1013 mNikoKeyboard = new Keyboard[11][2];
1014 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_top_land);
1015 mNikoKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_a_land);
1016 mNikoKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_k_land);
1017 mNikoKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_s_land);
1018 mNikoKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_t_land);
1019 mNikoKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_n_land);
1020 mNikoKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_h_land);
1021 mNikoKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_m_land);
1022 mNikoKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_y_land);
1023 mNikoKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_r_land);
1024 mNikoKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_w_land);
1026 mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_top_land);
1027 mNikoKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_a_land);
1028 mNikoKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_k_land);
1029 mNikoKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_s_land);
1030 mNikoKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_t_land);
1031 mNikoKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_n_land);
1032 mNikoKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_h_land);
1033 mNikoKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_m_land);
1034 mNikoKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_y_land);
1035 mNikoKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_r_land);
1036 mNikoKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_w_land);
1038 // belltouch slide(Y)
1039 mYBellKeyboard = new Keyboard[11][2];
1040 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][0];
1041 mYBellKeyboard[NIKO_SLIDE_MODE_A][0] = mNikoKeyboard[NIKO_SLIDE_MODE_A][0];
1042 mYBellKeyboard[NIKO_SLIDE_MODE_K][0] = mNikoKeyboard[NIKO_SLIDE_MODE_K][0];
1043 mYBellKeyboard[NIKO_SLIDE_MODE_S][0] = mNikoKeyboard[NIKO_SLIDE_MODE_S][0];
1044 mYBellKeyboard[NIKO_SLIDE_MODE_T][0] = mNikoKeyboard[NIKO_SLIDE_MODE_T][0];
1045 mYBellKeyboard[NIKO_SLIDE_MODE_N][0] = mNikoKeyboard[NIKO_SLIDE_MODE_N][0];
1046 mYBellKeyboard[NIKO_SLIDE_MODE_H][0] = mNikoKeyboard[NIKO_SLIDE_MODE_H][0];
1047 mYBellKeyboard[NIKO_SLIDE_MODE_M][0] = mNikoKeyboard[NIKO_SLIDE_MODE_M][0];
1048 mYBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_y_land);
1049 mYBellKeyboard[NIKO_SLIDE_MODE_R][0] = mNikoKeyboard[NIKO_SLIDE_MODE_R][0];
1050 mYBellKeyboard[NIKO_SLIDE_MODE_W][0] = mNikoKeyboard[NIKO_SLIDE_MODE_W][0];
1052 mYBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = mNikoKeyboard[NIKO_SLIDE_MODE_TOP][1];
1053 mYBellKeyboard[NIKO_SLIDE_MODE_A][1] = mNikoKeyboard[NIKO_SLIDE_MODE_A][1];
1054 mYBellKeyboard[NIKO_SLIDE_MODE_K][1] = mNikoKeyboard[NIKO_SLIDE_MODE_K][1];
1055 mYBellKeyboard[NIKO_SLIDE_MODE_S][1] = mNikoKeyboard[NIKO_SLIDE_MODE_S][1];
1056 mYBellKeyboard[NIKO_SLIDE_MODE_T][1] = mNikoKeyboard[NIKO_SLIDE_MODE_T][1];
1057 mYBellKeyboard[NIKO_SLIDE_MODE_N][1] = mNikoKeyboard[NIKO_SLIDE_MODE_N][1];
1058 mYBellKeyboard[NIKO_SLIDE_MODE_H][1] = mNikoKeyboard[NIKO_SLIDE_MODE_H][1];
1059 mYBellKeyboard[NIKO_SLIDE_MODE_M][1] = mNikoKeyboard[NIKO_SLIDE_MODE_M][1];
1060 mYBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_ybell_input_y_land);
1061 mYBellKeyboard[NIKO_SLIDE_MODE_R][1] = mNikoKeyboard[NIKO_SLIDE_MODE_R][1];
1062 mYBellKeyboard[NIKO_SLIDE_MODE_W][1] = mNikoKeyboard[NIKO_SLIDE_MODE_W][1];
1065 mBellKeyboard = new Keyboard[11][2];
1066 mBellKeyboard[NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_top_land);
1067 mBellKeyboard[NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_a_land);
1068 mBellKeyboard[NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_k_land);
1069 mBellKeyboard[NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_s_land);
1070 mBellKeyboard[NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_t_land);
1071 mBellKeyboard[NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_n_land);
1072 mBellKeyboard[NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_h_land);
1073 mBellKeyboard[NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_m_land);
1074 mBellKeyboard[NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_y_land);
1075 mBellKeyboard[NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_r_land);
1076 mBellKeyboard[NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_w_land);
1078 mBellKeyboard[NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_top_land);
1079 mBellKeyboard[NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_a_land);
1080 mBellKeyboard[NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_k_land);
1081 mBellKeyboard[NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_s_land);
1082 mBellKeyboard[NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_t_land);
1083 mBellKeyboard[NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_n_land);
1084 mBellKeyboard[NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_h_land);
1085 mBellKeyboard[NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_m_land);
1086 mBellKeyboard[NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_y_land);
1087 mBellKeyboard[NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_r_land);
1088 mBellKeyboard[NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_w_land);
1090 changeNicoBellLayout();
1094 * Convert the key code to the index of table
1096 * @param index The key code
1097 * @return The index of the toggle table for input
1099 private int getTableIndex(int keyCode) {
1101 (keyCode == KEYCODE_JP12_1) ? 0 :
1102 (keyCode == KEYCODE_JP12_2) ? 1 :
1103 (keyCode == KEYCODE_JP12_3) ? 2 :
1104 (keyCode == KEYCODE_JP12_4) ? 3 :
1105 (keyCode == KEYCODE_JP12_5) ? 4 :
1106 (keyCode == KEYCODE_JP12_6) ? 5 :
1107 (keyCode == KEYCODE_JP12_7) ? 6 :
1108 (keyCode == KEYCODE_JP12_8) ? 7 :
1109 (keyCode == KEYCODE_JP12_9) ? 8 :
1110 (keyCode == KEYCODE_JP12_0) ? 9 :
1111 (keyCode == KEYCODE_JP12_SHARP) ? 10 :
1112 (keyCode == KEYCODE_JP12_ASTER) ? 11 :
1119 * Get the toggle table for input that is appropriate in current mode.
1121 * @return The toggle table for input
1123 private String[][] getCycleTable() {
1124 String[][] cycleTable = null;
1125 switch (mCurrentKeyMode) {
1126 case KEYMODE_JA_FULL_HIRAGANA:
1127 cycleTable = JP_FULL_HIRAGANA_CYCLE_TABLE;
1130 case KEYMODE_JA_FULL_KATAKANA:
1131 cycleTable = JP_FULL_KATAKANA_CYCLE_TABLE;
1134 case KEYMODE_JA_FULL_ALPHABET:
1135 cycleTable = JP_FULL_ALPHABET_CYCLE_TABLE;
1138 case KEYMODE_JA_FULL_NUMBER:
1139 case KEYMODE_JA_HALF_NUMBER:
1140 /* Because these modes belong to direct input group, No toggle table exists */
1143 case KEYMODE_JA_HALF_ALPHABET:
1144 cycleTable = JP_HALF_ALPHABET_CYCLE_TABLE;
1147 case KEYMODE_JA_HALF_KATAKANA:
1148 cycleTable = JP_HALF_KATAKANA_CYCLE_TABLE;
1151 case KEYMODE_JA_FULL_NIKO:
1152 if (false == mChangeBellMode) {
1153 cycleTable = JP_FULL_NIKO_CYCLE_TABLE;
1156 cycleTable = JP_FULL_BELL_CYCLE_TABLE;
1167 * Get the replace table that is appropriate in current mode.
1169 * @return The replace table
1171 private HashMap getReplaceTable() {
1172 HashMap hashTable = null;
1173 switch (mCurrentKeyMode) {
1174 case KEYMODE_JA_FULL_HIRAGANA:
1175 hashTable = JP_FULL_HIRAGANA_REPLACE_TABLE;
1177 case KEYMODE_JA_FULL_KATAKANA:
1178 hashTable = JP_FULL_KATAKANA_REPLACE_TABLE;
1181 case KEYMODE_JA_FULL_ALPHABET:
1182 hashTable = JP_FULL_ALPHABET_REPLACE_TABLE;
1185 case KEYMODE_JA_FULL_NUMBER:
1186 case KEYMODE_JA_HALF_NUMBER:
1187 /* Because these modes belong to direct input group, No replacing table exists */
1190 case KEYMODE_JA_HALF_ALPHABET:
1191 hashTable = JP_HALF_ALPHABET_REPLACE_TABLE;
1194 case KEYMODE_JA_HALF_KATAKANA:
1195 hashTable = JP_HALF_KATAKANA_REPLACE_TABLE;
1198 case KEYMODE_JA_FULL_NIKO:
1199 hashTable = JP_FULL_NIKO_REPLACE_TABLE;
1209 * Set the status icon that is appropriate in current mode
1211 private void setStatusIcon() {
1214 switch (mCurrentKeyMode) {
1215 case KEYMODE_JA_FULL_HIRAGANA:
1216 icon = R.drawable.immodeic_hiragana;
1218 case KEYMODE_JA_FULL_KATAKANA:
1219 icon = R.drawable.immodeic_full_kana;
1221 case KEYMODE_JA_FULL_ALPHABET:
1222 icon = R.drawable.immodeic_full_alphabet;
1224 case KEYMODE_JA_FULL_NUMBER:
1225 icon = R.drawable.immodeic_full_number;
1227 case KEYMODE_JA_HALF_KATAKANA:
1228 icon = R.drawable.immodeic_half_kana;
1230 case KEYMODE_JA_HALF_ALPHABET:
1231 icon = R.drawable.immodeic_half_alphabet;
1233 case KEYMODE_JA_HALF_NUMBER:
1234 case KEYMODE_JA_HALF_PHONE:
1235 icon = R.drawable.immodeic_half_number;
1237 case KEYMODE_JA_FULL_NIKO:
1238 icon = R.drawable.immodeic_niko;
1245 mWnn.showStatusIcon(icon);
1249 * Get the shift key state from the editor.
1251 * @param editor The editor information
1252 * @return The state id of the shift key (0:off, 1:on)
1254 protected int getShiftKeyState(EditorInfo editor) {
1255 InputConnection connection = mWnn.getCurrentInputConnection();
1256 if (connection != null) {
1257 int caps = connection.getCursorCapsMode(editor.inputType);
1258 return (caps == 0) ? 0 : 1;
1265 * Set the shift key state from {@link EditorInfo}.
1267 private void setShiftByEditorInfo() {
1268 if (mEnableAutoCaps && (mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET)) {
1269 int shift = getShiftKeyState(mWnn.getCurrentInputEditorInfo());
1272 changeKeyboard(getShiftChangeKeyboard(shift));
1276 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#setHardKeyboardHidden */
1277 @Override public void setHardKeyboardHidden(boolean hidden) {
1280 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE,
1281 NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY));
1284 if (mHardKeyboardHidden != hidden) {
1285 if ((mLimitedKeyMode != null)
1286 || ((mCurrentKeyMode != KEYMODE_JA_FULL_NIKO) && (mCurrentKeyMode != KEYMODE_JA_FULL_HIRAGANA) && (mCurrentKeyMode != KEYMODE_JA_HALF_ALPHABET))) {
1288 mLastInputType = EditorInfo.TYPE_NULL;
1289 if (mWnn.isInputViewShown()) {
1290 setDefaultKeyboard();
1295 super.setHardKeyboardHidden(hidden);
1299 * Change the key-mode to the allowed one which is restricted
1300 * by the text input field or the type of the keyboard.
1301 * @param keyMode The key-mode
1302 * @return the key-mode allowed
1304 private int filterKeyMode(int keyMode) {
1305 int targetMode = keyMode;
1306 int[] limits = mLimitedKeyMode;
1308 if (!mHardKeyboardHidden) { /* for hardware keyboard */
1309 if ((targetMode != KEYMODE_JA_FULL_NIKO) && (targetMode != KEYMODE_JA_FULL_HIRAGANA) && (targetMode != KEYMODE_JA_HALF_ALPHABET)) {
1310 Locale locale = Locale.getDefault();
1311 int keymode = KEYMODE_JA_HALF_ALPHABET;
1312 if (locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
1313 switch (targetMode) {
1314 case KEYMODE_JA_FULL_NIKO:
1315 case KEYMODE_JA_FULL_HIRAGANA:
1316 case KEYMODE_JA_FULL_KATAKANA:
1317 case KEYMODE_JA_HALF_KATAKANA:
1318 // hiromitsu-s!!! 2009-09-23 12:47:08
1319 //keymode = KEYMODE_JA_FULL_NIKO;
1326 targetMode = keymode;
1330 /* restrict by the type of the text field */
1331 if (limits != null) {
1332 boolean hasAccepted = false;
1333 boolean hasRequiredChange = true;
1334 int size = limits.length;
1335 int nowMode = mCurrentKeyMode;
1337 for (int i = 0; i < size; i++) {
1338 if (targetMode == limits[i]) {
1342 if (nowMode == limits[i]) {
1343 hasRequiredChange = false;
1348 if (hasRequiredChange) {
1349 targetMode = mLimitedKeyMode[0];
1351 targetMode = INVALID_KEYMODE;
1361 /*****************************************
1364 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#onKey */
1365 @Override public void onKey(int primaryCode, int[] keyCodes) {
1367 if (mDisableKeyInput) {
1371 if (mCurrentKeyMode == KEYMODE_JA_FULL_NIKO) {
1372 if (true == onKeyNiko(primaryCode, keyCodes)) {
1373 /* update shift key's state */
1374 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1375 setShiftByEditorInfo();
1380 if (true == mIsEnableFlick) {
1381 onkeyFlick(primaryCode, keyCodes);
1385 switch (primaryCode) {
1386 case KEYCODE_JP12_TOGGLE_MODE:
1387 case KEYCODE_QWERTY_TOGGLE_MODE:
1388 if (!mIsInputTypeNull) {
1393 case DefaultSoftKeyboard.KEYCODE_QWERTY_BACKSPACE:
1394 case KEYCODE_JP12_BACKSPACE:
1395 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1396 new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)));
1399 case DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT:
1403 case DefaultSoftKeyboard.KEYCODE_QWERTY_ALT:
1407 case KEYCODE_QWERTY_ENTER:
1408 case KEYCODE_JP12_ENTER:
1409 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1410 new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)));
1413 case KEYCODE_JP12_REVERSE:
1415 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_REVERSE_CHAR, mCurrentCycleTable));
1419 case KEYCODE_QWERTY_KBD:
1420 changeKeyboardType(KEYBOARD_12KEY);
1421 mHookStockKeyType = KEYBOARD_12KEY;
1424 case KEYCODE_JP12_KBD:
1425 changeKeyboardType(KEYBOARD_QWERTY);
1426 mHookStockKeyType = KEYBOARD_QWERTY;
1429 case KEYCODE_JP12_EMOJI:
1430 case KEYCODE_QWERTY_EMOJI:
1432 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_SYMBOL));
1435 case KEYCODE_JP12_1:
1436 case KEYCODE_JP12_2:
1437 case KEYCODE_JP12_3:
1438 case KEYCODE_JP12_4:
1439 case KEYCODE_JP12_5:
1440 case KEYCODE_JP12_6:
1441 case KEYCODE_JP12_7:
1442 case KEYCODE_JP12_8:
1443 case KEYCODE_JP12_9:
1444 case KEYCODE_JP12_0:
1445 case KEYCODE_JP12_SHARP:
1446 /* Processing to input by ten key */
1447 if (mInputType == INPUT_TYPE_INSTANT) {
1448 /* Send a input character directly if instant input type is selected */
1450 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR,
1451 mCurrentInstantTable[getTableIndex(primaryCode)]));
1453 if ((mPrevInputKeyCode != primaryCode)) {
1454 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOUCH_OTHER_KEY));
1455 if ((mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET)
1456 && (primaryCode == KEYCODE_JP12_SHARP)) {
1457 /* Commit text by symbol character (',' '.') when alphabet input mode is selected */
1462 /* Convert the key code to the table index and send the toggle event with the table index */
1463 String[][] cycleTable = getCycleTable();
1464 if (cycleTable == null) {
1465 Log.e("NicoWnn", "not founds cycle table");
1467 int index = getTableIndex(primaryCode);
1468 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[index]));
1469 mCurrentCycleTable = cycleTable[index];
1471 mPrevInputKeyCode = primaryCode;
1475 case KEYCODE_JP12_ASTER:
1476 if (mInputType == INPUT_TYPE_INSTANT) {
1478 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR,
1479 mCurrentInstantTable[getTableIndex(primaryCode)]));
1482 /* Processing to toggle Dakuten, Handakuten, and capital */
1483 HashMap replaceTable = getReplaceTable();
1484 if (replaceTable == null) {
1485 Log.e("NicoWnn", "not founds replace table");
1487 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.REPLACE_CHAR, replaceTable));
1488 mPrevInputKeyCode = primaryCode;
1494 case KEYCODE_SWITCH_FULL_HIRAGANA:
1495 /* Change mode to Full width hiragana */
1496 changeKeyMode(KEYMODE_JA_FULL_HIRAGANA);
1499 case KEYCODE_SWITCH_FULL_KATAKANA:
1500 /* Change mode to Full width katakana */
1501 changeKeyMode(KEYMODE_JA_FULL_KATAKANA);
1504 case KEYCODE_SWITCH_FULL_ALPHABET:
1505 /* Change mode to Full width alphabet */
1506 changeKeyMode(KEYMODE_JA_FULL_ALPHABET);
1509 case KEYCODE_SWITCH_FULL_NUMBER:
1510 /* Change mode to Full width numeric */
1511 changeKeyMode(KEYMODE_JA_FULL_NUMBER);
1514 case KEYCODE_SWITCH_HALF_KATAKANA:
1515 /* Change mode to Half width katakana */
1516 changeKeyMode(KEYMODE_JA_HALF_KATAKANA);
1519 case KEYCODE_SWITCH_HALF_ALPHABET:
1520 /* Change mode to Half width alphabet */
1521 changeKeyMode(KEYMODE_JA_HALF_ALPHABET);
1524 case KEYCODE_SWITCH_HALF_NUMBER:
1525 /* Change mode to Half width numeric */
1526 changeKeyMode(KEYMODE_JA_HALF_NUMBER);
1529 case KEYCODE_SWITCH_FULL_NIKO:
1530 /* Change mode to Full width nikotouch */
1531 changeKeyMode(KEYMODE_JA_FULL_NIKO);
1534 case KEYCODE_SELECT_CASE:
1535 int shifted = (mShiftOn == 0) ? 1 : 0;
1536 Keyboard newKeyboard = getShiftChangeKeyboard(shifted);
1537 if (newKeyboard != null) {
1539 changeKeyboard(newKeyboard);
1543 case KEYCODE_JP12_SPACE:
1544 if ((mCurrentKeyMode == KEYMODE_JA_FULL_HIRAGANA) && !mNoInput) {
1545 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CONVERT));
1547 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, ' '));
1551 case KEYCODE_EISU_KANA:
1552 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_EISU_KANA));
1555 case KEYCODE_JP12_CLOSE:
1556 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_KEY,
1557 new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)));
1560 case KEYCODE_JP12_LEFT:
1561 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1562 new KeyEvent(KeyEvent.ACTION_DOWN,
1563 KeyEvent.KEYCODE_DPAD_LEFT)));
1566 case KEYCODE_JP12_RIGHT:
1567 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY,
1568 new KeyEvent(KeyEvent.ACTION_DOWN,
1569 KeyEvent.KEYCODE_DPAD_RIGHT)));
1575 if (primaryCode >= 0) {
1576 if (mKeyboardView.isShifted()) {
1577 primaryCode = Character.toUpperCase(primaryCode);
1579 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, (char)primaryCode));
1584 /* update shift key's state */
1585 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1586 setShiftByEditorInfo();
1591 /*****************************************
1594 private boolean onKeyNiko(int primaryCode, int[] keyCodes) {
1595 Keyboard newKeyboard = null;
1596 boolean retcode = false;
1597 switch (primaryCode) {
1598 case DefaultSoftKeyboard.KEYCODE_QWERTY_BACKSPACE:
1599 case KEYCODE_JP12_BACKSPACE:
1600 if (mNikoFirst == true) {
1601 resetNikoKeyboard();
1604 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)));
1608 case KEYCODE_QWERTY_ENTER:
1609 case KEYCODE_JP12_ENTER:
1610 if (mNikoFirst == false) {
1611 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)));
1616 case KEYCODE_JP12_REVERSE:
1617 if (mNikoFirst == true) {
1618 resetNikoKeyboard();
1624 case KEYCODE_QWERTY_KBD:
1625 case KEYCODE_JP12_KBD:
1626 resetNikoKeyboard();
1629 case KEYCODE_JP12_EMOJI:
1630 case KEYCODE_QWERTY_EMOJI:
1631 if (mNikoFirst == false) {
1633 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_SYMBOL));
1638 case KEYCODE_JP12_SHARP:
1639 if (mNikoFirst == false) {
1641 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_DOCOMOSYMBOL));
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();