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 /** Toggle cycle table for full-width Nikotouch */
317 private static final String[][] JP_FULL_NIKO_CYCLE_TABLE_BIG = {
318 {"\u3042"}, {"\u3044"}, {"\u3046"}, {"\u3048"}, {"\u304a"}, {"."}, {"-"}, {"@"}, {"_"}, {"1"},
319 {"\u304b"}, {"\u304d"}, {"\u304f"}, {"\u3051"}, {"\u3053"}, {" "}, {"A"}, {"B"}, {"C"}, {"2"},
320 {"\u3055"}, {"\u3057"}, {"\u3059"}, {"\u305b"}, {"\u305d"}, {"/"}, {"D"}, {"E"}, {"F"}, {"3"},
321 {"\u305f"}, {"\u3061"}, {"\u3064"}, {"\u3066"}, {"\u3068"}, {"\u3063"}, {"G"}, {"H"}, {"I"}, {"4"},
322 {"\u306a"}, {"\u306b"}, {"\u306c"}, {"\u306d"}, {"\u306e"}, {"("}, {"J"}, {"K"}, {"L"}, {"5"},
323 {"\u306f"}, {"\u3072"}, {"\u3075"}, {"\u3078"}, {"\u307b"}, {")"}, {"M"}, {"N"}, {"O"}, {"6"},
324 {"\u307e"}, {"\u307f"}, {"\u3080"}, {"\u3081"}, {"\u3082"}, {"P"}, {"Q"}, {"R"}, {"S"}, {"7"},
325 {"\u3084"}, {"\u3086"}, {"\u3088"}, {"\u3083"}, {"\u3085"}, {"\u3087"}, {"T"}, {"U"}, {"V"}, {"8"},
326 {"\u3089"}, {"\u308a"}, {"\u308b"}, {"\u308c"}, {"\u308d"}, {"W"}, {"X"}, {"Y"}, {"Z"}, {"9"},
327 {"\u308f"}, {"\u3092"}, {"\u3093"}, {"\u3001"}, {"\u3002"}, {"\u30fc"}, {"\u30fb"}, {"\uff01"}, {"\uff1f"}, {"0"},
329 /** Toggle cycle table for full-width belltouch */
330 private static final String[][] JP_FULL_BELL_CYCLE_TABLE_BIG = {
331 {"\u3042"}, {"\u3044"}, {"\u3046"}, {"\u3048"}, {"\u304a"}, {"A"}, {"B"}, {"C"}, {"D"}, {"E"},
332 {"\u304b"}, {"\u304d"}, {"\u304f"}, {"\u3051"}, {"\u3053"}, {"F"}, {"G"}, {"H"}, {"I"}, {"J"},
333 {"\u3055"}, {"\u3057"}, {"\u3059"}, {"\u305b"}, {"\u305d"}, {"K"}, {"L"}, {"M"}, {"N"}, {"O"},
334 {"\u305f"}, {"\u3061"}, {"\u3064"}, {"\u3066"}, {"\u3068"}, {"P"}, {"Q"}, {"R"}, {"S"}, {"T"},
335 {"\u306a"}, {"\u306b"}, {"\u306c"}, {"\u306d"}, {"\u306e"}, {"U"}, {"V"}, {"W"}, {"X"}, {"Y"},
336 {"\u306f"}, {"\u3072"}, {"\u3075"}, {"\u3078"}, {"\u307b"}, {"Z"}, {" "}, {" "}, {" "}, {" "},
337 {"\u307e"}, {"\u307f"}, {"\u3080"}, {"\u3081"}, {"\u3082"}, {" "}, {" "}, {" "}, {" "}, {" "},
338 {"\u3084"}, {" "}, {"\u3086"}, {" "}, {"\u3088"}, {"\u30fc"}, {"\u30fb"}, {"\uff01"}, {"\uff1f"}, {" "},
339 {"\u3089"}, {"\u308a"}, {"\u308b"}, {"\u308c"}, {"\u308d"}, {"1"}, {"2"}, {"3"}, {"4"}, {"5"},
340 {"\u308f"}, {"\u3092"}, {"\u3093"}, {"\u3001"}, {"\u3002"}, {"6"}, {"7"}, {"8"}, {"9"}, {"0"},
343 /** Replace table for full-width Nikotouch */
344 private static final HashMap<String, String> JP_FULL_NIKO_REPLACE_TABLE = new HashMap<String, String>() {{
345 put("\u3042", "\u3041"); put("\u3044", "\u3043"); put("\u3046", "\u3045"); put("\u3048", "\u3047"); put("\u304a", "\u3049"); // A
346 put("\u3041", "\u3042"); put("\u3043", "\u3044"); put("\u3045", "\u30f4"); put("\u3047", "\u3048"); put("\u3049", "\u304a"); // a
347 put("\u304b", "\u304c"); put("\u304d", "\u304e"); put("\u304f", "\u3050"); put("\u3051", "\u3052"); put("\u3053", "\u3054"); // K
348 put("\u304c", "\u304b"); put("\u304e", "\u304d"); put("\u3050", "\u304f"); put("\u3052", "\u3051"); put("\u3054", "\u3053"); // k
349 put("\u3055", "\u3056"); put("\u3057", "\u3058"); put("\u3059", "\u305a"); put("\u305b", "\u305c"); put("\u305d", "\u305e"); // S
350 put("\u3056", "\u3055"); put("\u3058", "\u3057"); put("\u305a", "\u3059"); put("\u305c", "\u305b"); put("\u305e", "\u305d"); // s
351 put("\u305f", "\u3060"); put("\u3061", "\u3062"); put("\u3064", "\u3065"); put("\u3066", "\u3067"); put("\u3068", "\u3069"); // T
352 put("\u3060", "\u305f"); put("\u3062", "\u3061"); put("\u3065", "\u3063"); put("\u3067", "\u3066"); put("\u3069", "\u3068"); // t
353 put("\u3063", "\u3064"); put("\u30f4", "\u3046");
354 put("\u306f", "\u3070"); put("\u3072", "\u3073"); put("\u3075", "\u3076"); put("\u3078", "\u3079"); put("\u307b", "\u307c"); // H
355 put("\u3070", "\u3071"); put("\u3073", "\u3074"); put("\u3076", "\u3077"); put("\u3079", "\u307a"); put("\u307c", "\u307d"); // h
356 put("\u3071", "\u306f"); put("\u3074", "\u3072"); put("\u3077", "\u3075"); put("\u307a", "\u3078"); put("\u307d", "\u307b"); // h.
357 put("\u3084", "\u3083"); put("\u3086", "\u3085"); put("\u3088", "\u3087"); // Y
358 put("\u3083", "\u3084"); put("\u3085", "\u3086"); put("\u3087", "\u3088"); // y
359 put("\u308f", "\u308e");
360 put("\u308e", "\u308f");
361 put("\u309b", "\u309c");
362 put("\u309c", "\u309b");
364 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");
365 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");
366 put("u", "U"); put("v", "V"); put("w", "W"); put("x", "X"); put("y", "Y"); put("z", "Z");
367 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");
368 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");
369 put("U", "u"); put("V", "v"); put("W", "w"); put("X", "x"); put("Y", "y"); put("Z", "z");
371 put("1", "\uff11"); put("2", "\uff12"); put("3", "\uff13"); put("4", "\uff14"); put("5", "\uff15");
372 put("6", "\uff16"); put("7", "\uff17"); put("8", "\uff18"); put("9", "\uff19"); put("0", "\uff10");
373 put("\uff11", "1"); put("\uff12", "2"); put("\uff13", "3"); put("\uff14", "4"); put("\uff15", "5");
374 put("\uff16", "6"); put("\uff17", "7"); put("\uff18", "8"); put("\uff19", "9"); put("\uff10", "0");
376 put(".", "\uff0e"); put("-", "\u2015"); put("@", "\uff20"); put("_", "\uff3f");
377 put("\uff0e", "."); put("\u2015", "-"); put("\uff20", "@"); put("\uff3f", "_");
379 put("\uff01", "!"); put("\uff1f", "?");
380 put("!", "\uff01"); put("?", "\uff1f");
382 put("\u3000", " "); put(" ", "\u3000");
384 put("(", "["); put("[", "\u300c"); put("\u300c", "\u300e"); put("\u300e", "\u3010"); put("\u3010", "(");
385 put(")", "]"); put("]", "\u300d"); put("\u300d", "\u300f"); put("\u300f", "\u3011"); put("\u3011", ")");
390 /** Character table for full-width number */
391 private static final char[] INSTANT_CHAR_CODE_FULL_NUMBER =
392 "\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\uff10\uff03\uff0a".toCharArray();
394 /** Character table for half-width number */
395 private static final char[] INSTANT_CHAR_CODE_HALF_NUMBER =
396 "1234567890#*".toCharArray();
398 /** The constant for mFixedKeyMode. It means that input mode is not fixed. */
399 private static final int INVALID_KEYMODE = -1;
401 /** KeyIndex of "Moji" key on 12 keyboard (depends on the definition of keyboards) */
402 private static final int KEY_INDEX_CHANGE_MODE_12KEY = 15;
404 /** KeyIndex of "Moji" key on QWERTY keyboard (depends on the definition of keyboards) */
405 private static final int KEY_INDEX_CHANGE_MODE_QWERTY = 29;
407 /** Type of input mode */
408 private int mInputType = INPUT_TYPE_TOGGLE;
410 /** Previous input character code */
411 private int mPrevInputKeyCode = 0;
413 /** flick nicoinput **/
414 private static final int NICOFLICK_NONE = 0;
415 private static final int NICOFLICK_1STROKE = 1;
416 private static final int NICOFLICK_NICOSTROKE = 2;
418 private int mFlickNicoInput = 0;
419 private boolean mNicoFlick = false;
420 private static final HashMap<String, Integer> flickModeTable = new HashMap<String, Integer>() {{
421 put("none_flick", 0);
422 put("normal_stroke", 1);
423 put("nico_stroke", 2);
427 private int mFlickLimitX;
428 private int mFlickLimitY;
431 private static final NicoWnnEvent mEventTouchOtherKey = new NicoWnnEvent(NicoWnnEvent.TOUCH_OTHER_KEY);
432 private static final NicoWnnEvent mEventCommitText = new NicoWnnEvent(NicoWnnEvent.COMMIT_COMPOSING_TEXT);
433 private static final NicoWnnEvent mEventConvert = new NicoWnnEvent(NicoWnnEvent.CONVERT);
435 private static final NicoWnnEvent mEventChangeMode12Key = new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_12KEY);
436 private static final NicoWnnEvent mEventChangeModeQwerty = new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_OPT_TYPE_QWERTY);
437 private static final NicoWnnEvent mEventChangeModeSymbol = new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_SYMBOL);
438 private static final NicoWnnEvent mEventChangeModeDocomo = new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_DOCOMOSYMBOL);
439 private static final NicoWnnEvent mEventChangeModeEisuKana = new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, NicoWnnJAJP.ENGINE_MODE_EISU_KANA);
441 private static final NicoWnnEvent mEventInputShiftLeft = new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
443 private static final NicoWnnEvent mEventInputKeyDel = new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
444 private static final NicoWnnEvent mEventInputEnter = new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
445 private static final NicoWnnEvent mEventInputBack = new NicoWnnEvent(NicoWnnEvent.INPUT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
446 private static final NicoWnnEvent mEventInputDpadLeft = new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_LEFT));
447 private static final NicoWnnEvent mEventInputDpadRight = new NicoWnnEvent(NicoWnnEvent.INPUT_SOFT_KEY, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT));
451 * Character table to input when mInputType becomes INPUT_TYPE_INSTANT.
452 * (Either INSTANT_CHAR_CODE_FULL_NUMBER or INSTANT_CHAR_CODE_HALF_NUMBER)
454 private char[] mCurrentInstantTable = null;
456 /** Input mode that is not able to be changed. If ENABLE_CHANGE_KEYMODE is set, input mode can change. */
457 private int[] mLimitedKeyMode = null;
459 /** Input mode that is given the first priority. If ENABLE_CHANGE_KEYMODE is set, input mode can change. */
460 private int mPreferenceKeyMode = INVALID_KEYMODE;
462 /** The last input type */
463 private int mLastInputType = 0;
465 /** Auto caps mode */
466 private boolean mEnableAutoCaps = true;
468 /** PopupResId of "Moji" key (this is used for canceling long-press) */
469 private int mPopupResId = 0;
471 /** Whether the InputType is null */
472 private boolean mIsInputTypeNull = false;
474 /** {@code SharedPreferences} for save the keyboard type */
475 private SharedPreferences.Editor mPrefEditor = null;
477 /** "Moji" key (this is used for canceling long-press) */
478 private Keyboard.Key mChangeModeKey = null;
480 private boolean mNikoFirst = false;
482 private static final int KEYBOARD_NICO = 0;
483 private static final int KEYBOARD_BELL = 1;
484 private static final int KEYBOARD_MAX = 2;
485 private int mNicoBellKeyboardMode = 0;
487 private Keyboard[][][] mNicoBellKeyboard;
489 //private Keyboard[][] mNicoKeyboard;
490 //private Keyboard[][] mBellKeyboard;
492 private boolean mGetNoFlipScreen = false;
493 private boolean mNoFlipScreen = false;
495 /** option keyboard type */
496 private int mHookStockKeyType;
498 /** change keitai skip **/
499 private boolean mOnOffKeitaiMode = false;
500 /** change eisu change mode **/
501 private boolean mChange12keyQwertyMode = false;
502 private final int[] m12keyTable = {
503 KEYBOARD_12KEY, KEYBOARD_12KEY, KEYBOARD_QWERTY, KEYBOARD_QWERTY, KEYBOARD_12KEY, KEYBOARD_QWERTY, KEYBOARD_QWERTY, KEYBOARD_12KEY, KEYBOARD_12KEY
505 /** option bell type **/
506 private boolean mChangeBellMode = false;
507 private boolean mChangeAlphaBigMode = false;
509 /** Default constructor */
510 public DefaultSoftKeyboardJAJP() {
511 mCurrentLanguage = LANG_JA;
512 mCurrentKeyboardType = KEYBOARD_12KEY;
513 mHookStockKeyType = KEYBOARD_12KEY;
514 mShiftOn = KEYBOARD_SHIFT_OFF;
515 mCurrentKeyMode = KEYMODE_JA_FULL_NIKO;
516 mCurrentSlide = NIKO_SLIDE_MODE_TOP;
519 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#createKeyboards */
520 @Override protected void createKeyboards(NicoWnn parent) {
522 /* Keyboard[# of Languages][portrait/landscape][# of keyboard type][shift off/on][max # of key-modes][noinput/input] */
523 mKeyboard = new Keyboard[3][2][4][2][9][2];
525 SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(parent);
526 mChange12keyQwertyMode = pref.getBoolean("change_12key_qwerty", false);
527 mChangeBellMode = pref.getBoolean("change_bellmode", false);
528 mChangeAlphaBigMode = pref.getBoolean("change_alphamode", false);
529 mGetNoFlipScreen = pref.getBoolean("no_flip_screen", false);
530 mFlickNicoInput = flickModeTable.get(pref.getString("nicoflick_mode", "none_flick"));
531 //if ((true == mGetNoFlipScreen) && (NICOFLICK_NONE != mFlickNicoInput)) {
532 if (true == mGetNoFlipScreen) {
533 mNoFlipScreen = true;
536 mNoFlipScreen = false;
538 if (false == mChangeBellMode) {
539 mNicoBellKeyboardMode = KEYBOARD_NICO;
542 mNicoBellKeyboardMode = KEYBOARD_BELL;
545 /* Create the suitable keyboard object */
546 if (mDisplayMode == DefaultSoftKeyboard.PORTRAIT) {
547 //mCurrentKeyboardType = KEYBOARD_12KEY;
548 createKeyboardsPortrait(parent);
552 //mCurrentKeyboardType = KEYBOARD_QWERTY;
553 createKeyboardsLandscape(parent);
558 if (mCurrentKeyboardType == KEYBOARD_12KEY) {
559 mWnn.onEvent(mEventChangeMode12Key);
561 mWnn.onEvent(mEventChangeModeQwerty);
566 * Commit the pre-edit string for committing operation that is not explicit
567 * (ex. when a candidate is selected)
569 private void commitText() {
571 mWnn.onEvent(mEventCommitText);
578 * @param keyMode The type of input mode
580 public void changeKeyMode(int keyMode) {
581 int targetMode = filterKeyMode(keyMode);
582 if (targetMode == INVALID_KEYMODE) {
589 mWnn.onEvent(mEventInputShiftLeft);
592 mShiftOn = KEYBOARD_SHIFT_OFF;
593 Keyboard kbd = getModeChangeKeyboard(targetMode);
594 mCurrentKeyMode = targetMode;
595 mPrevInputKeyCode = 0;
598 int mode = NicoWnnEvent.Mode.DIRECT;
600 switch (targetMode) {
601 case KEYMODE_JA_FULL_HIRAGANA:
602 mInputType = INPUT_TYPE_TOGGLE;
603 mode = NicoWnnEvent.Mode.DEFAULT;
606 case KEYMODE_JA_HALF_ALPHABET:
607 if (USE_ENGLISH_PREDICT) {
608 mInputType = INPUT_TYPE_TOGGLE;
609 mode = NicoWnnEvent.Mode.NO_LV1_CONV;
611 mInputType = INPUT_TYPE_TOGGLE;
612 mode = NicoWnnEvent.Mode.DIRECT;
616 case KEYMODE_JA_FULL_NUMBER:
617 mInputType = INPUT_TYPE_INSTANT;
618 mode = NicoWnnEvent.Mode.DIRECT;
619 mCurrentInstantTable = INSTANT_CHAR_CODE_FULL_NUMBER;
622 case KEYMODE_JA_HALF_NUMBER:
623 mInputType = INPUT_TYPE_INSTANT;
624 mode = NicoWnnEvent.Mode.DIRECT;
625 mCurrentInstantTable = INSTANT_CHAR_CODE_HALF_NUMBER;
628 case KEYMODE_JA_FULL_KATAKANA:
629 mInputType = INPUT_TYPE_TOGGLE;
630 mode = NicoWnnJAJP.ENGINE_MODE_FULL_KATAKANA;
633 case KEYMODE_JA_FULL_ALPHABET:
634 mInputType = INPUT_TYPE_TOGGLE;
635 mode = NicoWnnEvent.Mode.DIRECT;
638 case KEYMODE_JA_HALF_KATAKANA:
639 mInputType = INPUT_TYPE_TOGGLE;
640 mode = NicoWnnJAJP.ENGINE_MODE_HALF_KATAKANA;
643 case KEYMODE_JA_FULL_NIKO:
644 mInputType = INPUT_TYPE_TOGGLE;
645 mode = NicoWnnEvent.Mode.DEFAULT;
656 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.CHANGE_MODE, mode));
657 if (mChange12keyQwertyMode == true) {
658 changeKeyboardType(m12keyTable[targetMode]);
662 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#initView */
663 @Override public View initView(NicoWnn parent, int width, int height) {
664 View view = super.initView(parent, width, height);
665 SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(parent);
667 changeKeyboard(mKeyboard[mCurrentLanguage][mDisplayMode][mCurrentKeyboardType][mShiftOn][mCurrentKeyMode][0]);
671 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#changeKeyboard */
672 @Override protected boolean changeKeyboard(Keyboard keyboard) {
674 if (keyboard != null) {
675 if (mIsInputTypeNull) {
676 mChangeModeKey.popupResId = mPopupResId;
679 List<Keyboard.Key> keys = keyboard.getKeys();
680 int keyIndex = (KEY_NUMBER_12KEY < keys.size())
681 ? KEY_INDEX_CHANGE_MODE_QWERTY : KEY_INDEX_CHANGE_MODE_12KEY;
682 mChangeModeKey = keys.get(keyIndex);
684 if (mIsInputTypeNull) {
685 mPopupResId = mChangeModeKey.popupResId;
686 mChangeModeKey.popupResId = 0;
689 return super.changeKeyboard(keyboard);
692 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#changeKeyboardType */
693 @Override public void changeKeyboardType(int type) {
695 Keyboard kbd = getTypeChangeKeyboard(type);
697 mCurrentKeyboardType = type;
698 mPrefEditor.putBoolean("opt_enable_qwerty", type == KEYBOARD_QWERTY);
699 mPrefEditor.commit();
702 if (type == KEYBOARD_12KEY) {
703 mWnn.onEvent(mEventChangeMode12Key);
705 mWnn.onEvent(mEventChangeModeQwerty);
708 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#setPreferences */
709 @Override public void setPreferences(SharedPreferences pref, EditorInfo editor) {
710 mPrefEditor = pref.edit();
711 boolean isQwerty = pref.getBoolean("opt_enable_qwerty", false);
712 if (isQwerty && (mCurrentKeyboardType != KEYBOARD_QWERTY)) {
713 changeKeyboardType(KEYBOARD_QWERTY);
716 super.setPreferences(pref, editor);
718 int inputType = editor.inputType;
719 if (mHardKeyboardHidden) {
720 if (inputType == EditorInfo.TYPE_NULL) {
721 if (!mIsInputTypeNull) {
722 mIsInputTypeNull = true;
723 mPopupResId = mChangeModeKey.popupResId;
724 mChangeModeKey.popupResId = 0;
729 if (mIsInputTypeNull) {
730 mIsInputTypeNull = false;
731 mChangeModeKey.popupResId = mPopupResId;
735 mEnableAutoCaps = pref.getBoolean("auto_caps", true);
736 mLimitedKeyMode = null;
737 mPreferenceKeyMode = INVALID_KEYMODE;
739 mDisableKeyInput = false;
742 mOnOffKeitaiMode = pref.getBoolean("change_keitaimode", false);
743 if (true == mOnOffKeitaiMode) {
744 // off keitai hiragana mode
745 mLimitedKeyMode = new int[] {KEYMODE_JA_FULL_NIKO, KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
747 switch (inputType & EditorInfo.TYPE_MASK_CLASS) {
749 case EditorInfo.TYPE_CLASS_NUMBER:
750 case EditorInfo.TYPE_CLASS_DATETIME:
751 mPreferenceKeyMode = KEYMODE_JA_HALF_NUMBER;
754 case EditorInfo.TYPE_CLASS_PHONE:
755 if (mHardKeyboardHidden) {
756 //mLimitedKeyMode = new int[] {KEYMODE_JA_FULL_NIKO};
757 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
759 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET};
760 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
764 case EditorInfo.TYPE_CLASS_TEXT:
765 switch (inputType & EditorInfo.TYPE_MASK_VARIATION) {
767 case EditorInfo.TYPE_TEXT_VARIATION_PASSWORD:
768 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
771 case EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
772 //mLimitedKeyMode = new int[] {KEYMODE_JA_HALF_ALPHABET, KEYMODE_JA_HALF_NUMBER};
774 case EditorInfo.TYPE_TEXT_VARIATION_URI:
775 //mPreferenceKeyMode = KEYMODE_JA_HALF_ALPHABET;
776 mPreferenceKeyMode = KEYMODE_JA_FULL_NIKO;
788 boolean restartkey = false;
789 boolean old12keyqwerty = mChange12keyQwertyMode;
790 boolean oldnicobell = mChangeBellMode;
792 mChange12keyQwertyMode = pref.getBoolean("change_12key_qwerty", false);
793 mChangeBellMode = pref.getBoolean("change_bellmode", false);
794 mChangeAlphaBigMode = pref.getBoolean("change_alphamode", false);
795 mGetNoFlipScreen = pref.getBoolean("no_flip_screen", false);
796 mFlickNicoInput = flickModeTable.get(pref.getString("nicoflick_mode", "none_flick"));
797 //if ((true == mGetNoFlipScreen) && (NICOFLICK_NONE != mFlickNicoInput)) {
798 if (true == mGetNoFlipScreen) {
799 mNoFlipScreen = true;
802 mNoFlipScreen = false;
805 if (old12keyqwerty != mChange12keyQwertyMode) {
807 if (false == mChange12keyQwertyMode) {
808 mCurrentKeyboardType = mHookStockKeyType; // change last keyboard type.
811 if (oldnicobell != mChangeBellMode) {
814 if (false == mChangeBellMode) {
815 mNicoBellKeyboardMode = KEYBOARD_NICO;
818 mNicoBellKeyboardMode = KEYBOARD_BELL;
821 if (inputType != mLastInputType) {
822 changeNicoBellLayout();
823 setDefaultKeyboard();
824 mLastInputType = inputType;
826 else if (true == restartkey) {
827 changeNicoBellLayout();
828 setDefaultKeyboard();
832 setShiftByEditorInfo();
835 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#onUpdateState */
836 @Override public void onUpdateState(NicoWnn parent) {
837 super.onUpdateState(parent);
839 setShiftByEditorInfo();
840 if (true == mNoInput && true == mNikoFirst) {
846 * Change the keyboard to default
848 public void setDefaultKeyboard() {
849 Locale locale = Locale.getDefault();
850 int keymode = KEYMODE_JA_FULL_NIKO;
853 if (mPreferenceKeyMode != INVALID_KEYMODE) {
854 keymode = mPreferenceKeyMode;
855 } else if (mLimitedKeyMode != null) {
856 keymode = mLimitedKeyMode[0];
858 if (!locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
859 keymode = KEYMODE_JA_HALF_ALPHABET;
863 changeKeyMode(keymode);
868 * Change to the next input mode
870 public void nextKeyMode() {
871 /* Search the current mode in the toggle table */
872 boolean found = false;
874 for (index = 0; index < JP_MODE_CYCLE_TABLE.length; index++) {
875 if (JP_MODE_CYCLE_TABLE[index] == mCurrentKeyMode) {
882 /* If the current mode not exists, set the default mode */
883 setDefaultKeyboard();
885 /* If the current mode exists, set the next input mode */
886 int size = JP_MODE_CYCLE_TABLE.length;
887 int keyMode = INVALID_KEYMODE;
888 for (int i = 0; i < size; i++) {
889 index = (++index) % size;
891 keyMode = filterKeyMode(JP_MODE_CYCLE_TABLE[index]);
892 if (keyMode != INVALID_KEYMODE) {
897 if (keyMode != INVALID_KEYMODE) {
898 changeKeyMode(keyMode);
904 * Create the keyboard for portrait mode
906 * @param parent The context
908 private void createKeyboardsPortrait(NicoWnn parent) {
909 Keyboard[][] keyList;
910 /* qwerty shift_off (portrait) */
911 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF];
912 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp);
913 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet);
914 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols);
915 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana);
916 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet);
917 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols);
918 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana);
919 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone);
920 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
922 /* qwerty shift_on (portrait) */
923 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_ON];
924 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_shift);
925 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_shift);
926 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_shift);
927 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_shift);
928 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_shift);
929 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_shift);
930 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_shift);
931 keyList[KEYMODE_JA_HALF_PHONE][0] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE][0];
932 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
934 /* 12-keys shift_off (portrait) */
935 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
936 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_12keyjp);
937 keyList[KEYMODE_JA_FULL_HIRAGANA][1] = new Keyboard(parent, R.xml.keyboard_12keyjp_input);
938 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana);
939 keyList[KEYMODE_JA_FULL_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_input);
940 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana);
941 keyList[KEYMODE_JA_HALF_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_input);
942 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone);
944 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet);
945 keyList[KEYMODE_JA_FULL_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_input);
946 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_full_num);
947 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet);
948 keyList[KEYMODE_JA_HALF_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_input);
949 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_half_num);
951 /* 12-keys shift_on (portrait) */
952 keyList = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
953 keyList[KEYMODE_JA_FULL_HIRAGANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_HIRAGANA];
954 keyList[KEYMODE_JA_FULL_KATAKANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_KATAKANA];
955 keyList[KEYMODE_JA_HALF_KATAKANA] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_KATAKANA];
956 keyList[KEYMODE_JA_HALF_PHONE] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE];
958 keyList[KEYMODE_JA_FULL_ALPHABET] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_ALPHABET];
959 keyList[KEYMODE_JA_FULL_NUMBER] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_NUMBER];
960 keyList[KEYMODE_JA_HALF_ALPHABET] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_ALPHABET];;
961 keyList[KEYMODE_JA_HALF_NUMBER] = mKeyboard[LANG_JA][PORTRAIT][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_NUMBER];
963 mNicoBellKeyboard = new Keyboard[KEYBOARD_MAX][11][2];
965 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_top);
966 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_a);
967 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_k);
968 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_s);
969 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_t);
970 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_n);
971 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_h);
972 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_m);
973 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_y);
974 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_r);
975 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_w);
977 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_top);
978 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_a);
979 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_k);
980 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_s);
981 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_t);
982 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_n);
983 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_h);
984 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_m);
985 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_y);
986 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_r);
987 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_w);
990 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_top);
991 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_a);
992 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_k);
993 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_s);
994 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_t);
995 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_n);
996 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_h);
997 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_m);
998 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_y);
999 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_r);
1000 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_w);
1002 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_top);
1003 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_a);
1004 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_k);
1005 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_s);
1006 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_t);
1007 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_n);
1008 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_h);
1009 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_m);
1010 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_y);
1011 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_r);
1012 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_w);
1014 changeNicoBellLayout();
1018 * Create the keyboard for landscape mode
1020 * @param parent The context
1022 private void createKeyboardsLandscape(NicoWnn parent) {
1023 Keyboard[][] keyList;
1024 /* qwerty shift_off (landscape) */
1025 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF];
1026 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_land);
1027 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_land);
1028 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_land);
1029 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_land);
1030 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_land);
1031 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_land);
1032 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_land);
1033 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone_land);
1035 if (false == mChangeBellMode) {
1036 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_niko_land);
1039 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_bell_land);
1042 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
1044 /* qwerty shift_on (landscape) */
1045 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_ON];
1046 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_shift_land);
1047 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_alphabet_shift_land);
1048 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_symbols_shift_land);
1049 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_full_katakana_shift_land);
1050 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_alphabet_shift_land);
1051 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_symbols_shift_land);
1052 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_half_katakana_shift_land);
1053 keyList[KEYMODE_JA_HALF_PHONE][0] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_QWERTY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE][0];
1055 if (false == mChangeBellMode) {
1056 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_niko_shift_land);
1059 keyList[KEYMODE_JA_FULL_NIKO][0] = new Keyboard(parent, R.xml.keyboard_qwerty_jp_bell_shift_land);
1062 keyList[KEYMODE_JA_FULL_NIKO][0] = keyList[KEYMODE_JA_FULL_HIRAGANA][0];
1064 /* 12-keys shift_off (landscape) */
1065 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
1066 keyList[KEYMODE_JA_FULL_HIRAGANA][0] = new Keyboard(parent, R.xml.keyboard_12keyjp_land);
1067 keyList[KEYMODE_JA_FULL_HIRAGANA][1] = new Keyboard(parent, R.xml.keyboard_12keyjp_input_land);
1068 keyList[KEYMODE_JA_FULL_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_land);
1069 keyList[KEYMODE_JA_FULL_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_full_alphabet_input_land);
1070 keyList[KEYMODE_JA_FULL_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_full_num_land);
1071 keyList[KEYMODE_JA_FULL_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_land);
1072 keyList[KEYMODE_JA_FULL_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_full_katakana_input_land);
1073 keyList[KEYMODE_JA_HALF_ALPHABET][0] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_land);
1074 keyList[KEYMODE_JA_HALF_ALPHABET][1] = new Keyboard(parent, R.xml.keyboard_12key_half_alphabet_input_land);
1075 keyList[KEYMODE_JA_HALF_NUMBER][0] = new Keyboard(parent, R.xml.keyboard_12key_half_num_land);
1076 keyList[KEYMODE_JA_HALF_KATAKANA][0] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_land);
1077 keyList[KEYMODE_JA_HALF_KATAKANA][1] = new Keyboard(parent, R.xml.keyboard_12key_half_katakana_input_land);
1078 keyList[KEYMODE_JA_HALF_PHONE][0] = new Keyboard(parent, R.xml.keyboard_12key_phone_land);
1080 /* 12-keys shift_on (landscape) */
1081 keyList = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1082 keyList[KEYMODE_JA_FULL_HIRAGANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_HIRAGANA];
1083 keyList[KEYMODE_JA_FULL_ALPHABET] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_ALPHABET];
1084 keyList[KEYMODE_JA_FULL_NUMBER] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_NUMBER];
1085 keyList[KEYMODE_JA_FULL_KATAKANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_FULL_KATAKANA];
1086 keyList[KEYMODE_JA_HALF_ALPHABET] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_ALPHABET];;
1087 keyList[KEYMODE_JA_HALF_NUMBER] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_NUMBER];
1088 keyList[KEYMODE_JA_HALF_KATAKANA] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_KATAKANA];
1089 keyList[KEYMODE_JA_HALF_PHONE] = mKeyboard[LANG_JA][LANDSCAPE][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF][KEYMODE_JA_HALF_PHONE];
1091 mNicoBellKeyboard = new Keyboard[KEYBOARD_MAX][11][2];
1093 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_top_land);
1094 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_a_land);
1095 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_k_land);
1096 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_s_land);
1097 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_t_land);
1098 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_n_land);
1099 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_h_land);
1100 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_m_land);
1101 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_y_land);
1102 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_r_land);
1103 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_w_land);
1105 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_top_land);
1106 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_a_land);
1107 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_k_land);
1108 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_s_land);
1109 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_t_land);
1110 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_n_land);
1111 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_h_land);
1112 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_m_land);
1113 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_y_land);
1114 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_r_land);
1115 mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_niko_input_w_land);
1118 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_TOP][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_top_land);
1119 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_A][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_a_land);
1120 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_K][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_k_land);
1121 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_S][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_s_land);
1122 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_T][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_t_land);
1123 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_N][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_n_land);
1124 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_H][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_h_land);
1125 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_M][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_m_land);
1126 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_Y][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_y_land);
1127 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_R][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_r_land);
1128 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_W][0] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_w_land);
1130 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_TOP][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_top_land);
1131 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_A][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_a_land);
1132 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_K][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_k_land);
1133 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_S][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_s_land);
1134 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_T][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_t_land);
1135 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_N][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_n_land);
1136 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_H][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_h_land);
1137 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_M][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_m_land);
1138 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_Y][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_y_land);
1139 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_R][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_r_land);
1140 mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_W][1] = new Keyboard(parent, R.xml.keyboard_12key_full_bell_input_w_land);
1142 changeNicoBellLayout();
1146 * Convert the key code to the index of table
1148 * @param index The key code
1149 * @return The index of the toggle table for input
1151 private int getTableIndex(int keyCode) {
1153 (keyCode == KEYCODE_JP12_1) ? 0 :
1154 (keyCode == KEYCODE_JP12_2) ? 1 :
1155 (keyCode == KEYCODE_JP12_3) ? 2 :
1156 (keyCode == KEYCODE_JP12_4) ? 3 :
1157 (keyCode == KEYCODE_JP12_5) ? 4 :
1158 (keyCode == KEYCODE_JP12_6) ? 5 :
1159 (keyCode == KEYCODE_JP12_7) ? 6 :
1160 (keyCode == KEYCODE_JP12_8) ? 7 :
1161 (keyCode == KEYCODE_JP12_9) ? 8 :
1162 (keyCode == KEYCODE_JP12_0) ? 9 :
1163 (keyCode == KEYCODE_JP12_SHARP) ? 10 :
1164 (keyCode == KEYCODE_JP12_ASTER) ? 11 :
1171 * Get the toggle table for input that is appropriate in current mode.
1173 * @return The toggle table for input
1175 private String[][] getCycleTable() {
1176 String[][] cycleTable = null;
1177 switch (mCurrentKeyMode) {
1178 case KEYMODE_JA_FULL_HIRAGANA:
1179 cycleTable = JP_FULL_HIRAGANA_CYCLE_TABLE;
1182 case KEYMODE_JA_FULL_KATAKANA:
1183 cycleTable = JP_FULL_KATAKANA_CYCLE_TABLE;
1186 case KEYMODE_JA_FULL_ALPHABET:
1187 cycleTable = JP_FULL_ALPHABET_CYCLE_TABLE;
1190 case KEYMODE_JA_FULL_NUMBER:
1191 case KEYMODE_JA_HALF_NUMBER:
1192 /* Because these modes belong to direct input group, No toggle table exists */
1195 case KEYMODE_JA_HALF_ALPHABET:
1196 cycleTable = JP_HALF_ALPHABET_CYCLE_TABLE;
1199 case KEYMODE_JA_HALF_KATAKANA:
1200 cycleTable = JP_HALF_KATAKANA_CYCLE_TABLE;
1203 case KEYMODE_JA_FULL_NIKO:
1204 if (false == mChangeBellMode) {
1205 if (false == mChangeAlphaBigMode) {
1206 cycleTable = JP_FULL_NIKO_CYCLE_TABLE;
1209 cycleTable = JP_FULL_NIKO_CYCLE_TABLE_BIG;
1213 if (false == mChangeAlphaBigMode) {
1214 cycleTable = JP_FULL_BELL_CYCLE_TABLE;
1217 cycleTable = JP_FULL_BELL_CYCLE_TABLE_BIG;
1229 * Get the replace table that is appropriate in current mode.
1231 * @return The replace table
1233 private HashMap getReplaceTable() {
1234 HashMap hashTable = null;
1235 switch (mCurrentKeyMode) {
1236 case KEYMODE_JA_FULL_HIRAGANA:
1237 hashTable = JP_FULL_HIRAGANA_REPLACE_TABLE;
1239 case KEYMODE_JA_FULL_KATAKANA:
1240 hashTable = JP_FULL_KATAKANA_REPLACE_TABLE;
1243 case KEYMODE_JA_FULL_ALPHABET:
1244 hashTable = JP_FULL_ALPHABET_REPLACE_TABLE;
1247 case KEYMODE_JA_FULL_NUMBER:
1248 case KEYMODE_JA_HALF_NUMBER:
1249 /* Because these modes belong to direct input group, No replacing table exists */
1252 case KEYMODE_JA_HALF_ALPHABET:
1253 hashTable = JP_HALF_ALPHABET_REPLACE_TABLE;
1256 case KEYMODE_JA_HALF_KATAKANA:
1257 hashTable = JP_HALF_KATAKANA_REPLACE_TABLE;
1260 case KEYMODE_JA_FULL_NIKO:
1261 hashTable = JP_FULL_NIKO_REPLACE_TABLE;
1271 * Set the status icon that is appropriate in current mode
1273 private void setStatusIcon() {
1276 switch (mCurrentKeyMode) {
1277 case KEYMODE_JA_FULL_HIRAGANA:
1278 icon = R.drawable.immodeic_hiragana;
1280 case KEYMODE_JA_FULL_KATAKANA:
1281 icon = R.drawable.immodeic_full_kana;
1283 case KEYMODE_JA_FULL_ALPHABET:
1284 icon = R.drawable.immodeic_full_alphabet;
1286 case KEYMODE_JA_FULL_NUMBER:
1287 icon = R.drawable.immodeic_full_number;
1289 case KEYMODE_JA_HALF_KATAKANA:
1290 icon = R.drawable.immodeic_half_kana;
1292 case KEYMODE_JA_HALF_ALPHABET:
1293 icon = R.drawable.immodeic_half_alphabet;
1295 case KEYMODE_JA_HALF_NUMBER:
1296 case KEYMODE_JA_HALF_PHONE:
1297 icon = R.drawable.immodeic_half_number;
1299 case KEYMODE_JA_FULL_NIKO:
1300 icon = R.drawable.immodeic_niko;
1307 mWnn.showStatusIcon(icon);
1311 * Get the shift key state from the editor.
1313 * @param editor The editor information
1314 * @return The state id of the shift key (0:off, 1:on)
1316 protected int getShiftKeyState(EditorInfo editor) {
1317 InputConnection connection = mWnn.getCurrentInputConnection();
1318 if (connection != null) {
1319 int caps = connection.getCursorCapsMode(editor.inputType);
1320 return (caps == 0) ? 0 : 1;
1327 * Set the shift key state from {@link EditorInfo}.
1329 private void setShiftByEditorInfo() {
1330 if (mEnableAutoCaps && (mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET)) {
1331 int shift = getShiftKeyState(mWnn.getCurrentInputEditorInfo());
1334 changeKeyboard(getShiftChangeKeyboard(shift));
1338 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#setHardKeyboardHidden */
1339 @Override public void setHardKeyboardHidden(boolean hidden) {
1342 mWnn.onEvent(mEventChangeModeQwerty);
1345 if (mHardKeyboardHidden != hidden) {
1346 if ((mLimitedKeyMode != null)
1347 || ((mCurrentKeyMode != KEYMODE_JA_FULL_NIKO) && (mCurrentKeyMode != KEYMODE_JA_FULL_HIRAGANA) && (mCurrentKeyMode != KEYMODE_JA_HALF_ALPHABET))) {
1349 mLastInputType = EditorInfo.TYPE_NULL;
1350 if (mWnn.isInputViewShown()) {
1351 setDefaultKeyboard();
1356 super.setHardKeyboardHidden(hidden);
1360 * Change the key-mode to the allowed one which is restricted
1361 * by the text input field or the type of the keyboard.
1362 * @param keyMode The key-mode
1363 * @return the key-mode allowed
1365 private int filterKeyMode(int keyMode) {
1366 int targetMode = keyMode;
1367 int[] limits = mLimitedKeyMode;
1369 if (!mHardKeyboardHidden) { /* for hardware keyboard */
1370 if ((targetMode != KEYMODE_JA_FULL_NIKO) && (targetMode != KEYMODE_JA_FULL_HIRAGANA) && (targetMode != KEYMODE_JA_HALF_ALPHABET)) {
1371 Locale locale = Locale.getDefault();
1372 int keymode = KEYMODE_JA_HALF_ALPHABET;
1373 if (locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
1374 switch (targetMode) {
1375 case KEYMODE_JA_FULL_NIKO:
1376 case KEYMODE_JA_FULL_HIRAGANA:
1377 case KEYMODE_JA_FULL_KATAKANA:
1378 case KEYMODE_JA_HALF_KATAKANA:
1379 // hiromitsu-s!!! 2009-09-23 12:47:08
1380 //keymode = KEYMODE_JA_FULL_NIKO;
1387 targetMode = keymode;
1391 /* restrict by the type of the text field */
1392 if (limits != null) {
1393 boolean hasAccepted = false;
1394 boolean hasRequiredChange = true;
1395 int size = limits.length;
1396 int nowMode = mCurrentKeyMode;
1398 for (int i = 0; i < size; i++) {
1399 if (targetMode == limits[i]) {
1403 if (nowMode == limits[i]) {
1404 hasRequiredChange = false;
1409 if (hasRequiredChange) {
1410 targetMode = mLimitedKeyMode[0];
1412 targetMode = INVALID_KEYMODE;
1422 /*****************************************
1425 /** @see com.hiroshica.android.input.nicownn2.DefaultSoftKeyboard#onKey */
1426 @Override public void onKey(int primaryCode, int[] keyCodes) {
1428 if (mDisableKeyInput) {
1432 if (mCurrentKeyMode == KEYMODE_JA_FULL_NIKO) {
1433 if (true == onKeyNico(primaryCode, keyCodes)) {
1434 /* update shift key's state */
1435 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1436 setShiftByEditorInfo();
1441 if (true == mIsEnableFlick) {
1442 onkeyFlick(primaryCode, keyCodes);
1446 switch (primaryCode) {
1447 case KEYCODE_JP12_TOGGLE_MODE:
1448 case KEYCODE_QWERTY_TOGGLE_MODE:
1449 if (!mIsInputTypeNull) {
1454 case DefaultSoftKeyboard.KEYCODE_QWERTY_BACKSPACE:
1455 case KEYCODE_JP12_BACKSPACE:
1456 mWnn.onEvent(mEventInputKeyDel);
1459 case DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT:
1463 case DefaultSoftKeyboard.KEYCODE_QWERTY_ALT:
1467 case KEYCODE_QWERTY_ENTER:
1468 case KEYCODE_JP12_ENTER:
1469 mWnn.onEvent(mEventInputEnter);
1472 case KEYCODE_JP12_REVERSE:
1474 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_REVERSE_CHAR, mCurrentCycleTable));
1478 case KEYCODE_QWERTY_KBD:
1479 changeKeyboardType(KEYBOARD_12KEY);
1480 mHookStockKeyType = KEYBOARD_12KEY;
1483 case KEYCODE_JP12_KBD:
1484 changeKeyboardType(KEYBOARD_QWERTY);
1485 mHookStockKeyType = KEYBOARD_QWERTY;
1488 case KEYCODE_JP12_EMOJI:
1489 case KEYCODE_QWERTY_EMOJI:
1491 mWnn.onEvent(mEventChangeModeSymbol);
1494 case KEYCODE_JP12_1:
1495 case KEYCODE_JP12_2:
1496 case KEYCODE_JP12_3:
1497 case KEYCODE_JP12_4:
1498 case KEYCODE_JP12_5:
1499 case KEYCODE_JP12_6:
1500 case KEYCODE_JP12_7:
1501 case KEYCODE_JP12_8:
1502 case KEYCODE_JP12_9:
1503 case KEYCODE_JP12_0:
1504 case KEYCODE_JP12_SHARP:
1505 /* Processing to input by ten key */
1506 if (mInputType == INPUT_TYPE_INSTANT) {
1507 /* Send a input character directly if instant input type is selected */
1509 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, mCurrentInstantTable[getTableIndex(primaryCode)]));
1511 if ((mPrevInputKeyCode != primaryCode)) {
1512 mWnn.onEvent(mEventTouchOtherKey);
1513 if ((mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET)
1514 && (primaryCode == KEYCODE_JP12_SHARP)) {
1515 /* Commit text by symbol character (',' '.') when alphabet input mode is selected */
1520 /* Convert the key code to the table index and send the toggle event with the table index */
1521 String[][] cycleTable = getCycleTable();
1522 if (cycleTable == null) {
1523 Log.e("NicoWnn", "not founds cycle table");
1525 int index = getTableIndex(primaryCode);
1526 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[index]));
1527 mCurrentCycleTable = cycleTable[index];
1529 mPrevInputKeyCode = primaryCode;
1533 case KEYCODE_JP12_ASTER:
1534 if (mInputType == INPUT_TYPE_INSTANT) {
1536 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, mCurrentInstantTable[getTableIndex(primaryCode)]));
1539 /* Processing to toggle Dakuten, Handakuten, and capital */
1540 HashMap replaceTable = getReplaceTable();
1541 if (replaceTable == null) {
1542 Log.e("NicoWnn", "not founds replace table");
1544 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.REPLACE_CHAR, replaceTable));
1545 mPrevInputKeyCode = primaryCode;
1551 case KEYCODE_SWITCH_FULL_HIRAGANA:
1552 /* Change mode to Full width hiragana */
1553 changeKeyMode(KEYMODE_JA_FULL_HIRAGANA);
1556 case KEYCODE_SWITCH_FULL_KATAKANA:
1557 /* Change mode to Full width katakana */
1558 changeKeyMode(KEYMODE_JA_FULL_KATAKANA);
1561 case KEYCODE_SWITCH_FULL_ALPHABET:
1562 /* Change mode to Full width alphabet */
1563 changeKeyMode(KEYMODE_JA_FULL_ALPHABET);
1566 case KEYCODE_SWITCH_FULL_NUMBER:
1567 /* Change mode to Full width numeric */
1568 changeKeyMode(KEYMODE_JA_FULL_NUMBER);
1571 case KEYCODE_SWITCH_HALF_KATAKANA:
1572 /* Change mode to Half width katakana */
1573 changeKeyMode(KEYMODE_JA_HALF_KATAKANA);
1576 case KEYCODE_SWITCH_HALF_ALPHABET:
1577 /* Change mode to Half width alphabet */
1578 changeKeyMode(KEYMODE_JA_HALF_ALPHABET);
1581 case KEYCODE_SWITCH_HALF_NUMBER:
1582 /* Change mode to Half width numeric */
1583 changeKeyMode(KEYMODE_JA_HALF_NUMBER);
1586 case KEYCODE_SWITCH_FULL_NIKO:
1587 /* Change mode to Full width nikotouch */
1588 changeKeyMode(KEYMODE_JA_FULL_NIKO);
1591 case KEYCODE_SELECT_CASE:
1592 int shifted = (mShiftOn == 0) ? 1 : 0;
1593 Keyboard newKeyboard = getShiftChangeKeyboard(shifted);
1594 if (newKeyboard != null) {
1596 changeKeyboard(newKeyboard);
1600 case KEYCODE_JP12_SPACE:
1601 if ((mCurrentKeyMode == KEYMODE_JA_FULL_HIRAGANA) && !mNoInput) {
1602 mWnn.onEvent(mEventConvert);
1604 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, ' '));
1608 case KEYCODE_EISU_KANA:
1609 mWnn.onEvent(mEventChangeModeEisuKana);
1612 case KEYCODE_JP12_CLOSE:
1613 mWnn.onEvent(mEventInputBack);
1616 case KEYCODE_JP12_LEFT:
1617 mWnn.onEvent(mEventInputDpadLeft);
1620 case KEYCODE_JP12_RIGHT:
1621 mWnn.onEvent(mEventInputDpadRight);
1627 if (primaryCode >= 0) {
1628 if (mKeyboardView.isShifted()) {
1629 primaryCode = Character.toUpperCase(primaryCode);
1631 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, (char)primaryCode));
1636 /* update shift key's state */
1637 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1638 setShiftByEditorInfo();
1643 /*****************************************
1646 private boolean onKeyNico(int primaryCode, int[] keyCodes) {
1647 Keyboard newKeyboard = null;
1648 boolean retcode = false;
1650 //Log.v("key", "onkey event!!\n");
1652 switch (primaryCode) {
1653 case DefaultSoftKeyboard.KEYCODE_QWERTY_BACKSPACE:
1654 case KEYCODE_JP12_BACKSPACE:
1655 if (mNikoFirst == true) {
1656 resetNikoKeyboard();
1659 mWnn.onEvent(mEventInputKeyDel);
1663 case KEYCODE_QWERTY_ENTER:
1664 case KEYCODE_JP12_ENTER:
1665 if (mNikoFirst == false) {
1666 mWnn.onEvent(mEventInputEnter);
1671 case KEYCODE_JP12_REVERSE:
1672 if (mNikoFirst == true) {
1673 resetNikoKeyboard();
1679 case KEYCODE_QWERTY_KBD:
1680 case KEYCODE_JP12_KBD:
1681 resetNikoKeyboard();
1684 case KEYCODE_JP12_EMOJI:
1685 case KEYCODE_QWERTY_EMOJI:
1686 if (mNikoFirst == false) {
1688 mWnn.onEvent(mEventChangeModeSymbol);
1693 case KEYCODE_JP12_SHARP:
1694 if (mNikoFirst == false) {
1696 mWnn.onEvent(mEventChangeModeDocomo);
1701 case KEYCODE_JP12_1:
1702 case KEYCODE_JP12_2:
1703 case KEYCODE_JP12_3:
1704 case KEYCODE_JP12_4:
1705 case KEYCODE_JP12_5:
1706 case KEYCODE_JP12_6:
1707 case KEYCODE_JP12_7:
1708 case KEYCODE_JP12_8:
1709 case KEYCODE_JP12_9:
1710 case KEYCODE_JP12_0:
1711 if ((NICOFLICK_1STROKE == mFlickNicoInput) && (false == mNikoFirst)) {
1715 if ((NICOFLICK_NICOSTROKE == mFlickNicoInput) && (true == mNicoFlick) && (mPrevInputKeyCode == primaryCode)) {
1721 if (mNikoFirst == false) {
1722 mWnn.onEvent(mEventTouchOtherKey);
1724 int index = getTableIndex(primaryCode);
1725 Keyboard[][] keyList = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1727 keyList[KEYMODE_JA_FULL_NIKO] = mNicoBellKeyboard[mNicoBellKeyboardMode][index+1];
1728 if (false == mNoFlipScreen) {
1729 newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_ON);
1730 if (newKeyboard != null) {
1731 mShiftOn = KEYBOARD_SHIFT_ON;
1732 changeKeyboard(newKeyboard);
1735 mPrevInputKeyCode = primaryCode;
1739 int col = getTableIndex(mPrevInputKeyCode);
1740 int row = getTableIndex(primaryCode);
1741 String[][] cycleTable = getCycleTable();
1742 if (cycleTable == null) {
1743 Log.e("NicoWnn", "not founds cycle table");
1746 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[col * 10 + row]));
1748 if (false == mNoFlipScreen) {
1749 newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_OFF);
1750 if (newKeyboard != null) {
1751 mShiftOn = KEYBOARD_SHIFT_OFF;
1752 changeKeyboard(newKeyboard);
1761 case KEYCODE_JP12_ASTER:
1762 if (mNikoFirst == true) {
1763 resetNikoKeyboard();
1765 if (mNikoFirst == false && !mNoInput) {
1766 /* Processing to toggle Dakuten, Handakuten, and capital */
1767 HashMap replaceTable = getReplaceTable();
1768 if (replaceTable == null) {
1769 Log.e("NicoWnn", "not founds replace table");
1771 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.REPLACE_CHAR, replaceTable));
1772 mPrevInputKeyCode = primaryCode;
1778 case KEYCODE_JP12_SPACE:
1779 if (mNikoFirst == false) {
1780 if ((mCurrentKeyMode == KEYMODE_JA_FULL_HIRAGANA) && !mNoInput) {
1781 mWnn.onEvent(mEventConvert);
1783 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.INPUT_CHAR, ' '));
1789 case KEYCODE_EISU_KANA:
1790 if (mNikoFirst == false) {
1791 mWnn.onEvent(mEventChangeModeEisuKana);
1796 case KEYCODE_JP12_CLOSE:
1797 mWnn.onEvent(mEventInputBack);
1801 case KEYCODE_JP12_LEFT:
1802 if (mNikoFirst == false) {
1803 mWnn.onEvent(mEventInputDpadLeft);
1807 case KEYCODE_JP12_RIGHT:
1808 if (mNikoFirst == false) {
1809 mWnn.onEvent(mEventInputDpadRight);
1817 * reset nikotouch keyboard
1819 @Override public void resetNikoKeyboard() {
1820 Keyboard newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_OFF);
1821 if (newKeyboard != null) {
1822 mShiftOn = KEYBOARD_SHIFT_OFF;
1823 changeKeyboard(newKeyboard);
1827 } // resetNikoKeyboard
1828 private void setLastNikoChar(int keycode) {
1829 int col = getTableIndex(keycode);
1830 String[][] cycleTable = getCycleTable();
1831 if (cycleTable == null) {
1832 Log.e("NicoWnn", "not founds cycle table");
1835 mWnn.onEvent(new NicoWnnEvent(NicoWnnEvent.TOGGLE_CHAR, cycleTable[col * 10]));
1837 mWnn.onEvent(mEventTouchOtherKey);
1838 } // setLastNikoChar
1840 private void changeNicoBellLayout() {
1841 Keyboard[][] keyList, keyListOn;
1842 keyList = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_OFF];
1843 keyListOn = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1844 if (false == mChangeBellMode) {
1845 keyList[KEYMODE_JA_FULL_NIKO] = mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_TOP];
1846 keyListOn[KEYMODE_JA_FULL_NIKO] = mNicoBellKeyboard[KEYBOARD_NICO][NIKO_SLIDE_MODE_A];
1849 keyList[KEYMODE_JA_FULL_NIKO] = mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_TOP];
1850 keyListOn[KEYMODE_JA_FULL_NIKO] = mNicoBellKeyboard[KEYBOARD_BELL][NIKO_SLIDE_MODE_A];
1855 /*************************************************
1858 private void onkeyFlick(int primaryCode, int[] keyCodes) {
1859 switch (primaryCode) {
1860 case KEYCODE_JP12_TOGGLE_MODE:
1861 case KEYCODE_QWERTY_TOGGLE_MODE:
1862 if (!mIsInputTypeNull) {
1866 case KEYCODE_SWITCH_FULL_HIRAGANA:
1867 /* Change mode to Full width hiragana */
1868 changeKeyMode(KEYMODE_JA_FULL_HIRAGANA);
1871 case KEYCODE_SWITCH_FULL_KATAKANA:
1872 /* Change mode to Full width katakana */
1873 changeKeyMode(KEYMODE_JA_FULL_KATAKANA);
1876 case KEYCODE_SWITCH_FULL_ALPHABET:
1877 /* Change mode to Full width alphabet */
1878 changeKeyMode(KEYMODE_JA_FULL_ALPHABET);
1881 case KEYCODE_SWITCH_FULL_NUMBER:
1882 /* Change mode to Full width numeric */
1883 changeKeyMode(KEYMODE_JA_FULL_NUMBER);
1886 case KEYCODE_SWITCH_HALF_KATAKANA:
1887 /* Change mode to Half width katakana */
1888 changeKeyMode(KEYMODE_JA_HALF_KATAKANA);
1891 case KEYCODE_SWITCH_HALF_ALPHABET:
1892 /* Change mode to Half width alphabet */
1893 changeKeyMode(KEYMODE_JA_HALF_ALPHABET);
1896 case KEYCODE_SWITCH_HALF_NUMBER:
1897 /* Change mode to Half width numeric */
1898 changeKeyMode(KEYMODE_JA_HALF_NUMBER);
1901 case KEYCODE_SWITCH_FULL_NIKO:
1902 /* Change mode to Full width nikotouch */
1903 changeKeyMode(KEYMODE_JA_FULL_NIKO);
1905 case KEYCODE_SELECT_CASE:
1906 int shifted = (mShiftOn == 0) ? 1 : 0;
1907 Keyboard newKeyboard = getShiftChangeKeyboard(shifted);
1908 if (newKeyboard != null) {
1910 changeKeyboard(newKeyboard);
1916 /* update shift key's state */
1917 if (!mCapsLock && (primaryCode != DefaultSoftKeyboard.KEYCODE_QWERTY_SHIFT)) {
1918 setShiftByEditorInfo();
1923 @Override public void onPress(int primaryCode) {
1924 super.onPress(primaryCode);
1925 Keyboard newKeyboard = null;
1927 mStockFlickCode = primaryCode;
1928 if (mCurrentKeyMode == KEYMODE_JA_FULL_NIKO) {
1929 if (NICOFLICK_NONE == mFlickNicoInput) {
1932 switch (primaryCode) {
1933 case KEYCODE_JP12_1:
1934 case KEYCODE_JP12_2:
1935 case KEYCODE_JP12_3:
1936 case KEYCODE_JP12_4:
1937 case KEYCODE_JP12_5:
1938 case KEYCODE_JP12_6:
1939 case KEYCODE_JP12_7:
1940 case KEYCODE_JP12_8:
1941 case KEYCODE_JP12_9:
1942 case KEYCODE_JP12_0:
1943 if ((false == mNikoFirst) && (false == mNicoFlick)) {
1944 mWnn.onEvent(mEventTouchOtherKey);
1946 int index = getTableIndex(primaryCode);
1947 Keyboard[][] keyList = mKeyboard[LANG_JA][mDisplayMode][KEYBOARD_12KEY][KEYBOARD_SHIFT_ON];
1948 keyList[KEYMODE_JA_FULL_NIKO] = mNicoBellKeyboard[mNicoBellKeyboardMode][index+1];
1949 if (false == mNoFlipScreen) {
1950 newKeyboard = getShiftChangeKeyboard(KEYBOARD_SHIFT_ON);
1951 if (newKeyboard != null) {
1952 mShiftOn = KEYBOARD_SHIFT_ON;
1953 changeKeyboard(newKeyboard);
1956 mPrevInputKeyCode = primaryCode;
1966 @Override public void onRelease(int primaryCode) {
1967 super.onRelease(primaryCode);