1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 package com.android.inputmethod.keyboard.layout; 18 19 import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*; 20 21 import com.android.inputmethod.keyboard.KeyboardId; 22 import com.android.inputmethod.keyboard.layout.customizer.LayoutCustomizer; 23 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; 24 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; 25 26 /** 27 * The Hindi keyboard. 28 */ 29 public final class Hindi extends LayoutBase { 30 private static final String LAYOUT_NAME = "hindi"; 31 32 public Hindi(final LayoutCustomizer customizer) { 33 super(customizer, HindiSymbols.class, SymbolsShifted.class); 34 } 35 36 @Override 37 public String getName() { return LAYOUT_NAME; } 38 39 @Override 40 ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } 41 42 @Override 43 ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { 44 if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { 45 return getCommonAlphabetLayout(isPhone); 46 } 47 return ALPHABET_SHIFTED_COMMON; 48 } 49 50 private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() 51 .setKeysOfRow(1, 52 // U+094C: "" DEVANAGARI VOWEL SIGN AU 53 // U+094C/U+0902: "" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA 54 // U+0967: "" DEVANAGARI DIGIT ONE 55 key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys( 56 moreKey(VOWEL_SIGN_AU + "\u0902", "\u094C\u0902"), 57 "\u0967", "1")), 58 // U+0948: "" DEVANAGARI VOWEL SIGN AI 59 // U+0948/U+0902: "" DEVANAGARI VOWEL SIGN AI/DEVANAGARI SIGN ANUSVARA 60 // U+0968: "" DEVANAGARI DIGIT TWO 61 key(VOWEL_SIGN_AI, "\u0948", joinMoreKeys( 62 moreKey(VOWEL_SIGN_AI + "\u0902", "\u0948\u0902"), 63 "\u0968", "2")), 64 // U+093E: "" DEVANAGARI VOWEL SIGN AA 65 // U+093E/U+0902: "" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN ANUSVARA 66 // U+093E/U+0901: "" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN CANDRABINDU 67 // U+0969: "" DEVANAGARI DIGIT THREE 68 key(VOWEL_SIGN_AA, "\u093E", joinMoreKeys( 69 moreKey(VOWEL_SIGN_AA + "\u0902", "\u093E\u0902"), 70 moreKey(VOWEL_SIGN_AA + "\u0901", "\u093E\u0901"), 71 "\u0969", "3")), 72 // U+0940: "" DEVANAGARI VOWEL SIGN II 73 // U+0940/U+0902: "" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA 74 // U+096A: "" DEVANAGARI DIGIT FOUR 75 key(VOWEL_SIGN_II, "\u0940", joinMoreKeys( 76 moreKey(VOWEL_SIGN_II + "\u0902", "\u0940\u0902"), 77 "\u096A", "4")), 78 // U+0942: "" DEVANAGARI VOWEL SIGN UU 79 // U+0942/U+0902: "" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN ANUSVARA 80 // U+0942/U+0901: "" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN CANDRABINDU 81 // U+096B: "" DEVANAGARI DIGIT FIVE 82 key(VOWEL_SIGN_UU, "\u0942", joinMoreKeys( 83 moreKey(VOWEL_SIGN_UU + "\u0902", "\u0942\u0902"), 84 moreKey(VOWEL_SIGN_UU + "\u0901", "\u0942\u0901"), 85 "\u096B", "5")), 86 // U+092C: "" DEVANAGARI LETTER BA 87 // U+092C/U+0952: "" DEVANAGARI LETTER BA/DEVANAGARI STRESS SIGN ANUDATTA 88 // U+096C: "" DEVANAGARI DIGIT SIX 89 key("\u092C", joinMoreKeys("\u092C\u0952", "\u096C", "6")), 90 // U+0939: "" DEVANAGARI LETTER HA 91 // U+096D: "" DEVANAGARI DIGIT SEVEN 92 key("\u0939", joinMoreKeys("\u096D", "7")), 93 // U+0917: "" DEVANAGARI LETTER GA 94 // U+091C/U+094D/U+091E: 95 // "" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA 96 // U+0917/U+093C: "" DEVANAGARI LETTER GA/DEVANAGARI SIGN NUKTA 97 // U+0917/U+0952: "" DEVANAGARI LETTER GA/DEVANAGARI STRESS SIGN ANUDATTA 98 // U+096E: "" DEVANAGARI DIGIT EIGHT 99 key("\u0917", joinMoreKeys("\u091C\u094D\u091E", "\u0917\u093C", "\u0917\u0952", 100 "\u096E", "8")), 101 // U+0926: "" DEVANAGARI LETTER DA 102 // U+096F: "" DEVANAGARI DIGIT NINE 103 key("\u0926", joinMoreKeys("\u096F", "9")), 104 // U+091C: "" DEVANAGARI LETTER JA 105 // U+091C/U+0952: "" DEVANAGARI LETTER JA/DEVANAGARI STRESS SIGN ANUDATTA 106 // U+091C/U+094D/U+091E: 107 // "" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA 108 // U+091C/U+093C: "" DEVANAGARI LETTER JA/DEVANAGARI SIGN NUKTA 109 // U+0966: "" DEVANAGARI DIGIT ZERO 110 key("\u091C", joinMoreKeys("\u091C\u0952", "\u091C\u094D\u091E", "\u091C\u093C", 111 "\u0966", "0")), 112 // U+0921: "" DEVANAGARI LETTER DDA 113 // U+0921/U+0952: "" DEVANAGARI LETTER DDA/DEVANAGARI STRESS SIGN ANUDATTA 114 // U+0921/U+093C: "" DEVANAGARI LETTER DDA/DEVANAGARI SIGN NUKTA 115 key("\u0921", joinMoreKeys("\u0921\u0952", "\u0921\u093C"))) 116 .setKeysOfRow(2, 117 // U+094B: "" DEVANAGARI VOWEL SIGN O 118 // U+094B/U+0902: "" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA 119 // U+0949: "" DEVANAGARI VOWEL SIGN CANDRA O 120 // U+094A: "" DEVANAGARI VOWEL SIGN SHORT O 121 key(VOWEL_SIGN_O, "\u094B", joinMoreKeys( 122 moreKey(VOWEL_SIGN_O + "\u0902", "\u094B\u0902"), 123 moreKey(VOWEL_SIGN_CANDRA_O, "\u0949"), 124 moreKey(VOWEL_SIGN_SHORT_O, "\u094A"))), 125 // U+0947: "" DEVANAGARI VOWEL SIGN E 126 // U+0947/U+0902: "" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA 127 key(VOWEL_SIGN_E, "\u0947", 128 moreKey(VOWEL_SIGN_E + "\u0902", "\u0947\u0902")), 129 // U+094D: "" DEVANAGARI SIGN VIRAMA 130 key(SIGN_VIRAMA, "\u094D"), 131 // U+093F: "" DEVANAGARI VOWEL SIGN I 132 // U+093F/U+0902: "" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA 133 key(VOWEL_SIGN_I, "\u093F", 134 moreKey("\u093F" + SIGN_ANUSVARA, "\u093F\u0902")), 135 // U+0941: "" DEVANAGARI VOWEL SIGN U 136 // U+0941/U+0902: "" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN ANUSVARA 137 // U+0941/U+0901: "" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN CANDRABINDU 138 key(VOWEL_SIGN_U, "\u0941", joinMoreKeys( 139 moreKey(VOWEL_SIGN_U + "\u0902", "\u0941\u0902"), 140 moreKey(VOWEL_SIGN_U + "\u0901", "\u0941\u0901"))), 141 // U+092A: "" DEVANAGARI LETTER PA 142 "\u092A", 143 // U+0930: "" DEVANAGARI LETTER RA 144 // U+090B: "" DEVANAGARI LETTER VOCALIC R 145 // U+0930/U+093C: "" DEVANAGARI LETTER RA/DEVANAGARI SIGN NUKTA 146 // U+0960: "" DEVANAGARI LETTER VOCALIC RR 147 key("\u0930", joinMoreKeys("\u090B", "\u0930\u093C", "\u0960")), 148 // U+0915: "" DEVANAGARI LETTER KA 149 // U+0915/U+093C: "" DEVANAGARI LETTER KA/DEVANAGARI SIGN NUKTA 150 key("\u0915", moreKey("\u0915\u093C")), 151 // U+0924: "" DEVANAGARI LETTER TA 152 // U+0924/U+094D/U+0930: 153 // "" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA 154 key("\u0924", moreKey("\u0924\u094D\u0930")), 155 // U+091A: "" DEVANAGARI LETTER CA 156 // U+091F: "" DEVANAGARI LETTER TTA 157 "\u091A","\u091F") 158 .setKeysOfRow(3, 159 // U+0949: "" DEVANAGARI VOWEL SIGN CANDRA O 160 key(VOWEL_SIGN_CANDRA_O, "\u0949"), 161 // U+0902: "" DEVANAGARI SIGN ANUSVARA 162 key(SIGN_ANUSVARA, "\u0902"), 163 // U+092E: "" DEVANAGARI LETTER MA 164 // U+0950: "" DEVANAGARI OM 165 key("\u092E", moreKey("\u0950")), 166 // U+0928: "" DEVANAGARI LETTER NA 167 // U+091E: "" DEVANAGARI LETTER NYA 168 // U+0919: "" DEVANAGARI LETTER NGA 169 // U+0928/U+093C: "" DEVANAGARI LETTER NA/DEVANAGARI SIGN NUKTA 170 key("\u0928", joinMoreKeys("\u091E", "\u0919", "\u0928\u093C")), 171 // U+0935: "" DEVANAGARI LETTER VA 172 "\u0935", 173 // U+0932: "" DEVANAGARI LETTER LA 174 // U+090C: "" DEVANAGARI LETTER VOCALIC L 175 // U+0961: "" DEVANAGARI LETTER VOCALIC LL 176 key("\u0932", joinMoreKeys("\u090C", "\u0961")), 177 // U+0938: "" DEVANAGARI LETTER SA 178 "\u0938", 179 // U+092F: "" DEVANAGARI LETTER YA 180 // U+095F: "" DEVANAGARI LETTER YYA 181 key("\u092F", moreKey("\u095F")), 182 // U+093C: "" DEVANAGARI SIGN NUKTA 183 // U+097D: "" DEVANAGARI LETTER GLOTTAL STOP 184 // U+0970: "" DEVANAGARI ABBREVIATION SIGN 185 // U+093D: "" DEVANAGARI SIGN AVAGRAHA 186 key(SIGN_NUKTA, "\u093C", joinMoreKeys( 187 moreKey(LETTER_GLOTTAL_STOP, "\u097D"), 188 moreKey(ABBREVIATION_SIGN, "\u0970"), 189 moreKey(SIGN_AVAGRAHA, "\u093D")))) 190 .build(); 191 192 private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() 193 .setKeysOfRow(1, 194 // U+0914: "" DEVANAGARI LETTER AU 195 // U+0912/U+0902: "" DEVANAGARI LETTER SHORT O//DEVANAGARI SIGN ANUSVARA 196 key("\u0914", moreKey("\u0912\u0902")), 197 // U+0910: "" DEVANAGARI LETTER AI 198 // U+0910/U+0902: "" DEVANAGARI LETTER AI/DEVANAGARI SIGN ANUSVARA 199 key("\u0910", moreKey("\u0910\u0902")), 200 // U+0906: "" DEVANAGARI LETTER AA 201 // U+0906/U+0902: "" DEVANAGARI LETTER AA/DEVANAGARI SIGN ANUSVARA 202 // U+0906/U+0901: "" DEVANAGARI LETTER AA/DEVANAGARI SIGN CANDRABINDU 203 key("\u0906", joinMoreKeys("\u0906\u0902", "\u0906\u0901")), 204 // U+0908: "" DEVANAGARI LETTER II 205 // U+0908/U+0902: "" DEVANAGARI LETTER II/DEVANAGARI SIGN ANUSVARA 206 key("\u0908", moreKey("\u0908\u0902")), 207 // U+090A: "" DEVANAGARI LETTER UU 208 // U+090A/U+0902: "" DEVANAGARI LETTER UU/DEVANAGARI SIGN ANUSVARA 209 // U+090A/U+0901: "" DEVANAGARI LETTER UU/DEVANAGARI SIGN CANDRABINDU 210 key("\u090A", joinMoreKeys("\u090A\u0902", "\u090A\u0901")), 211 // U+092D: "" DEVANAGARI LETTER BHA 212 // U+0903: "" DEVANAGARI SIGN VISARGA 213 // U+0918: "" DEVANAGARI LETTER GHA 214 "\u092D", key(SIGN_VISARGA, "\u0903"), "\u0918", 215 // U+0927: "" DEVANAGARI LETTER DHA 216 // U+0915/U+094D/U+0937: 217 // "" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA 218 // U+0936/U+094D/U+0930: 219 // "" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA 220 key("\u0927", joinMoreKeys("\u0915\u094D\u0937", "\u0936\u094D\u0930")), 221 // U+091D: "" DEVANAGARI LETTER JHA 222 // U+0922: "" DEVANAGARI LETTER DDHA 223 "\u091D", "\u0922") 224 .setKeysOfRow(2, 225 // U+0913: "" DEVANAGARI LETTER O 226 // U+0913/U+0902: "" DEVANAGARI LETTER O/DEVANAGARI SIGN ANUSVARA 227 // U+0911: "" DEVANAGARI LETTER CANDRA O 228 // U+0912: "" DEVANAGARI LETTER SHORT O 229 key("\u0913", joinMoreKeys("\u0913\u0902", "\u0911", "\u0912")), 230 // U+090F: "" DEVANAGARI LETTER E 231 // U+090F/U+0902: "" DEVANAGARI LETTER E/DEVANAGARI SIGN ANUSVARA 232 // U+090F/U+0901: "" DEVANAGARI LETTER E/DEVANAGARI SIGN CANDRABINDU 233 // U+090D: "" DEVANAGARI LETTER CANDRA E 234 // U+090E: "" DEVANAGARI LETTER SHORT E 235 key("\u090F", joinMoreKeys("\u090F\u0902", "\u090F\u0901", "\u090D", "\u090E")), 236 // U+0905: "" DEVANAGARI LETTER A 237 // U+0905/U+0902: "" DEVANAGARI LETTER A/DEVANAGARI SIGN ANUSVARA 238 // U+0905/U+0901: "" DEVANAGARI LETTER A/DEVANAGARI SIGN CANDRABINDU 239 key("\u0905", joinMoreKeys("\u0905\u0902", "\u0905\u0901")), 240 // U+0907: "" DEVANAGARI LETTER I 241 // U+0907/U+0902: "" DEVANAGARI LETTER I/DEVANAGARI SIGN ANUSVARA 242 // U+0907/U+0901: "" DEVANAGARI LETTER I/DEVANAGARI SIGN CANDRABINDU 243 key("\u0907", joinMoreKeys("\u0907\u0902", "\u0907\u0901")), 244 // U+0909: "" DEVANAGARI LETTER U 245 // U+0909/U+0902: "" DEVANAGARI LETTER U/DEVANAGARI SIGN ANUSVARA 246 // U+0909/U+0901: "" DEVANAGARI LETTER U/DEVANAGARI SIGN CANDRABINDU 247 key("\u0909", joinMoreKeys("\u0909\u0902", "\u0909\u0901")), 248 // U+092B: "" DEVANAGARI LETTER PHA 249 // U+092B/U+093C: "" DEVANAGARI LETTER PHA/DEVANAGARI SIGN NUKTA 250 key("\u092B", moreKey("\u092B\u093C")), 251 // U+0931: "" DEVANAGARI LETTER RRA 252 // U+094D/U+0930: "" DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA 253 // U+0930/U+094D: "" DEVANAGARI LETTER RA/DEVANAGARI SIGN VIRAMA 254 key("\u0931", joinMoreKeys("\u094D\u0930", "\u0930\u094D")), 255 // U+0916: "" DEVANAGARI LETTER KHA 256 // U+0916/U+093C: "" DEVANAGARI LETTER KHA/DEVANAGARI SIGN NUKTA 257 key("\u0916", moreKey("\u0916\u093C")), 258 // U+0925: "" DEVANAGARI LETTER THA 259 // U+091B: "" DEVANAGARI LETTER CHA 260 // U+0920: "" DEVANAGARI LETTER TTHA 261 "\u0925", "\u091B", "\u0920") 262 .setKeysOfRow(3, 263 // U+0911: "" DEVANAGARI LETTER CANDRA O 264 "\u0911", 265 // U+0901: "" DEVANAGARI SIGN CANDRABINDU 266 // U+0945: "" DEVANAGARI VOWEL SIGN CANDRA E 267 key(SIGN_CANDRABINDU, "\u0901", moreKey(VOWEL_SIGN_CANDRA_E, "\u0945")), 268 // U+0923: "" DEVANAGARI LETTER NNA 269 // U+0929: "" DEVANAGARI LETTER NNNA 270 "\u0923", "\u0929", 271 // U+0933: "" DEVANAGARI LETTER LLA 272 // U+0934: "" DEVANAGARI LETTER LLLA 273 key("\u0933", moreKey("\u0934")), 274 // U+0936: "" DEVANAGARI LETTER SHA 275 // U+0937: "" DEVANAGARI LETTER SSA 276 "\u0936", "\u0937", 277 // U+0943: "" DEVANAGARI VOWEL SIGN VOCALIC R 278 // U+0944: "" DEVANAGARI VOWEL SIGN VOCALIC RR 279 key(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey(VOWEL_SIGN_VOCALIC_RR, "\u0944")), 280 // U+091E: "" DEVANAGARI LETTER NYA 281 "\u091E") 282 .build(); 283 284 static class HindiSymbols extends Symbols { 285 public HindiSymbols(final LayoutCustomizer customizer) { 286 super(customizer); 287 } 288 289 @Override 290 public ExpectedKey[][] getLayout(final boolean isPhone) { 291 return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) 292 // U+0967: "" DEVANAGARI DIGIT ONE 293 // U+00B9: "" SUPERSCRIPT ONE 294 // U+00BD: "" VULGAR FRACTION ONE HALF 295 // U+2153: "" VULGAR FRACTION ONE THIRD 296 // U+00BC: "" VULGAR FRACTION ONE QUARTER 297 // U+215B: "" VULGAR FRACTION ONE EIGHTH 298 .replaceKeyOfLabel("1", key("\u0967", 299 joinMoreKeys("1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B"))) 300 // U+0968: "" DEVANAGARI DIGIT TWO 301 // U+00B2: "" SUPERSCRIPT TWO 302 // U+2154: "" VULGAR FRACTION TWO THIRDS 303 .replaceKeyOfLabel("2", key("\u0968", joinMoreKeys("2", "\u00B2", "\u2154"))) 304 // U+0969: "" DEVANAGARI DIGIT THREE 305 // U+00B3: "" SUPERSCRIPT THREE 306 // U+00BE: "" VULGAR FRACTION THREE QUARTERS 307 // U+215C: "" VULGAR FRACTION THREE EIGHTHS 308 .replaceKeyOfLabel("3", key("\u0969", 309 joinMoreKeys("3", "\u00B3", "\u00BE","\u215C"))) 310 // U+096A: "" DEVANAGARI DIGIT FOUR 311 // U+2074: "" SUPERSCRIPT FOUR 312 .replaceKeyOfLabel("4", key("\u096A", joinMoreKeys("4", "\u2074"))) 313 // U+096B: "" DEVANAGARI DIGIT FIVE 314 // U+215D: "" VULGAR FRACTION FIVE EIGHTHS 315 .replaceKeyOfLabel("5", key("\u096B", joinMoreKeys("5", "\u215D"))) 316 // U+096C: "" DEVANAGARI DIGIT SIX 317 .replaceKeyOfLabel("6", key("\u096C", moreKey("6"))) 318 // U+096D: "" DEVANAGARI DIGIT SEVEN 319 // U+215E: "" VULGAR FRACTION SEVEN EIGHTHS 320 .replaceKeyOfLabel("7", key("\u096D", joinMoreKeys("7", "\u215E"))) 321 // U+096E: "" DEVANAGARI DIGIT EIGHT 322 .replaceKeyOfLabel("8", key("\u096E", moreKey("8"))) 323 // U+096F: "" DEVANAGARI DIGIT NINE 324 .replaceKeyOfLabel("9", key("\u096F", moreKey("9"))) 325 // U+0966: "" DEVANAGARI DIGIT ZERO 326 // U+207F: "" SUPERSCRIPT LATIN SMALL LETTER N 327 // U+2205: "" EMPTY SET 328 .replaceKeyOfLabel("0", key("\u0966", joinMoreKeys("0", "\u207F", "\u2205"))) 329 .build(); 330 } 331 } 332 } 333