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 com.android.inputmethod.keyboard.KeyboardId; 20 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; 21 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; 22 import com.android.inputmethod.latin.Constants; 23 24 import java.util.Locale; 25 26 /** 27 * The Khmer alphabet keyboard. 28 */ 29 public final class Khmer extends LayoutBase { 30 private static final String LAYOUT_NAME = "khmer"; 31 32 public Khmer(final LayoutCustomizer customizer) { 33 super(customizer, Symbols.class, SymbolsShifted.class); 34 } 35 36 @Override 37 public String getName() { return LAYOUT_NAME; } 38 39 public static class KhmerCustomizer extends LayoutCustomizer { 40 public KhmerCustomizer(final Locale locale) { super(locale); } 41 42 @Override 43 public int getNumberOfRows() { return 5; } 44 45 @Override 46 public ExpectedKey getAlphabetKey() { return KHMER_ALPHABET_KEY; } 47 48 @Override 49 public ExpectedKey getCurrencyKey() { return CURRENCY_DOLLAR_WITH_RIEL; } 50 51 @Override 52 public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { return EMPTY_KEYS; } 53 54 // U+1780: "" KHMER LETTER KA 55 // U+1781: "" KHMER LETTER KHA 56 // U+1782: "" KHMER LETTER KO 57 private static final ExpectedKey KHMER_ALPHABET_KEY = key( 58 "\u1780\u1781\u1782", Constants.CODE_SWITCH_ALPHA_SYMBOL); 59 60 // U+17DB: "" KHMER CURRENCY SYMBOL RIEL 61 private static final ExpectedKey CURRENCY_DOLLAR_WITH_RIEL = key(Symbols.DOLLAR_SIGN, 62 moreKey("\u17DB"), Symbols.CENT_SIGN, Symbols.POUND_SIGN, Symbols.EURO_SIGN, 63 Symbols.YEN_SIGN, Symbols.PESO_SIGN); 64 } 65 66 @Override 67 ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { 68 if (isPhone) { 69 return ALPHABET_COMMON; 70 } 71 final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); 72 builder.addKeysOnTheRightOfRow(4, (Object[])EXCLAMATION_AND_QUESTION_MARKS); 73 return builder.build(); 74 } 75 76 @Override 77 public ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, 78 final int elementId) { 79 if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { 80 return getCommonAlphabetLayout(isPhone); 81 } 82 return ALPHABET_SHIFTED_COMMON; 83 } 84 85 private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() 86 .setKeysOfRow(1, 87 // U+17E1: "" KHMER DIGIT ONE 88 // U+17F1: "" KHMER SYMBOL LEK ATTAK MUOY 89 key("\u17E1", joinMoreKeys("1", "\u17F1")), 90 // U+17E2: "" KHMER DIGIT TWO 91 // U+17F2: "" KHMER SYMBOL LEK ATTAK PII 92 key("\u17E2", joinMoreKeys("2", "\u17F2")), 93 // U+17E3: "" KHMER DIGIT THREE 94 // U+17F3: "" KHMER SYMBOL LEK ATTAK BEI 95 key("\u17E3", joinMoreKeys("3", "\u17F3")), 96 // U+17E4: "" KHMER DIGIT FOUR 97 // U+17F4: "" KHMER SYMBOL LEK ATTAK BUON 98 key("\u17E4", joinMoreKeys("4", "\u17F4")), 99 // U+17E5: "" KHMER DIGIT FIVE 100 // U+17F5: "" KHMER SYMBOL LEK ATTAK PRAM 101 key("\u17E5", joinMoreKeys("5", "\u17F5")), 102 // U+17E6: "" KHMER DIGIT SIX 103 // U+17F6: "" KHMER SYMBOL LEK ATTAK PRAM-MUOY 104 key("\u17E6", joinMoreKeys("6", "\u17F6")), 105 // U+17E7: "" KHMER DIGIT SEVEN 106 // U+17F7: "" KHMER SYMBOL LEK ATTAK PRAM-PII 107 key("\u17E7", joinMoreKeys("7", "\u17F7")), 108 // U+17E8: "" KHMER DIGIT EIGHT 109 // U+17F8: "" KHMER SYMBOL LEK ATTAK PRAM-BEI 110 key("\u17E8", joinMoreKeys("8", "\u17F8")), 111 // U+17E9: "" KHMER DIGIT NINE 112 // U+17F9: "" KHMER SYMBOL LEK ATTAK PRAM-BUON 113 key("\u17E9", joinMoreKeys("9", "\u17F9")), 114 // U+17E0: "" KHMER DIGIT ZERO 115 // U+17F0: "" KHMER SYMBOL LEK ATTAK SON 116 key("\u17E0", joinMoreKeys("0", "\u17F0")), 117 // U+17A5: "" KHMER INDEPENDENT VOWEL QI 118 // U+17A6: "" KHMER INDEPENDENT VOWEL QII 119 key("\u17A5", moreKey("\u17A6")), 120 // U+17B2: "" KHMER INDEPENDENT VOWEL QOO TYPE TWO 121 // U+17B1: "" KHMER INDEPENDENT VOWEL QOO TYPE ONE 122 key("\u17B2", moreKey("\u17B1"))) 123 .setKeysOfRow(2, 124 // U+1786: "" KHMER LETTER CHA 125 // U+17B9: "" KHMER VOWEL SIGN Y 126 // U+17C1: "" KHMER VOWEL SIGN E 127 // U+179A: "" KHMER LETTER RO 128 // U+178F: "" KHMER LETTER TA 129 // U+1799: "" KHMER LETTER YO 130 // U+17BB: "" KHMER VOWEL SIGN U 131 // U+17B7: "" KHMER VOWEL SIGN I 132 // U+17C4: "" KHMER VOWEL SIGN OO 133 // U+1795: "" KHMER LETTER PHA 134 // U+17C0: "" KHMER VOWEL SIGN IE 135 "\u1786", "\u17B9", "\u17C1", "\u179A", "\u178F", "\u1799", "\u17BB", "\u17B7", 136 "\u17C4", "\u1795", "\u17C0", 137 // U+17AA: "" KHMER INDEPENDENT VOWEL QUUV 138 // U+17A7: "" KHMER INDEPENDENT VOWEL QU 139 // U+17B1: "" KHMER INDEPENDENT VOWEL QOO TYPE ONE 140 // U+17B3: "" KHMER INDEPENDENT VOWEL QAU 141 // U+17A9: "" KHMER INDEPENDENT VOWEL QUU 142 // U+17A8: "" KHMER INDEPENDENT VOWEL QUK 143 key("\u17AA", joinMoreKeys("\u17A7", "\u17B1", "\u17B3", "\u17A9", "\u17A8"))) 144 .setKeysOfRow(3, 145 // U+17B6: "" KHMER VOWEL SIGN AA 146 // U+179F: "" KHMER LETTER SA 147 // U+178A: "" KHMER LETTER DA 148 // U+1790: "" KHMER LETTER THA 149 // U+1784: "" KHMER LETTER NGO 150 // U+17A0: "" KHMER LETTER HA 151 // U+17D2: "" KHMER SIGN COENG 152 // U+1780: "" KHMER LETTER KA 153 // U+179B: "" KHMER LETTER LO 154 // U+17BE: "" KHMER VOWEL SIGN OE 155 // U+17CB: "" KHMER SIGN BANTOC 156 "\u17B6", "\u179F", "\u178A", "\u1790", "\u1784", "\u17A0", "\u17D2", "\u1780", 157 "\u179B", "\u17BE", "\u17CB", 158 // U+17AE: "" KHMER INDEPENDENT VOWEL LYY 159 // U+17AD: "" KHMER INDEPENDENT VOWEL LY 160 // U+17B0: "" KHMER INDEPENDENT VOWEL QAI 161 key("\u17AE", joinMoreKeys("\u17AD", "\u17B0"))) 162 .setKeysOfRow(4, 163 // U+178B: "" KHMER LETTER TTHA 164 // U+1781: "" KHMER LETTER KHA 165 // U+1785: "" KHMER LETTER CA 166 // U+179C: "" KHMER LETTER VO 167 // U+1794: "" KHMER LETTER BA 168 // U+1793: "" KHMER LETTER NO 169 // U+1798: "" KHMER LETTER MO 170 // U+17BB/U+17C6: "" KHMER VOWEL SIGN U/KHMER SIGN NIKAHIT 171 // U+17D4: "" KHMER SIGN KHAN 172 // U+17CA: "" KHMER SIGN TRIISAP 173 "\u178B", "\u1781", "\u1785", "\u179C", "\u1794", "\u1793", "\u1798", 174 "\u17BB\u17C6", "\u17D4", "\u17CA") 175 .build(); 176 177 private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() 178 .setKeysOfRow(1, 179 key("!", ZWJ_KEY), 180 // U+17D7: "" KHMER SIGN LEK TOO 181 key("\u17D7", ZWNJ_KEY), 182 // U+17D1: "" KHMER SIGN VIRIAM 183 key("\"", moreKey("\u17D1")), 184 // U+17DB: "" KHMER CURRENCY SYMBOL RIEL 185 key("\u17DB", joinMoreKeys(Symbols.DOLLAR_SIGN, Symbols.EURO_SIGN)), 186 // U+17D6: "" KHMER SIGN CAMNUC PII KUUH 187 key("%", moreKey("\u17D6")), 188 // U+17CD: "" KHMER SIGN TOANDAKHIAT 189 // U+17D9: "" KHMER SIGN PHNAEK MUAN 190 key("\u17CD", moreKey("\u17D9")), 191 // U+17D0: "" KHMER SIGN SAMYOK SANNYA 192 // U+17DA: "" KHMER SIGN KOOMUUT 193 key("\u17D0", moreKey("\u17DA")), 194 // U+17CF: "" KHMER SIGN AHSDA 195 key("\u17CF", moreKey("*")), 196 // U+00AB: "" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 197 key("(", joinMoreKeys("{", "\u00AB")), 198 // U+00BB: "" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 199 key(")", joinMoreKeys("}", "\u00BB")), 200 // U+17CC: "" KHMER SIGN ROBAT 201 // U+00D7: "" MULTIPLICATION SIGN 202 key("\u17CC", moreKey("\u00D7")), 203 // U+17CE: "" KHMER SIGN KAKABAT 204 "\u17CE") 205 .setKeysOfRow(2, 206 // U+1788: "" KHMER LETTER CHO 207 // U+17DC: "" KHMER SIGN AVAKRAHASANYA 208 key("\u1788", moreKey("\u17DC")), 209 // U+17BA: "" KHMER VOWEL SIGN YY 210 // U+17DD: "" KHMER SIGN ATTHACAN 211 key("\u17BA", moreKey("\u17DD")), 212 // U+17C2: "" KHMER VOWEL SIGN AE 213 "\u17C2", 214 // U+17AC: "" KHMER INDEPENDENT VOWEL RYY 215 // U+17AB: "" KHMER INDEPENDENT VOWEL RY 216 key("\u17AC", moreKey("\u17AB")), 217 // U+1791: "" KHMER LETTER TO 218 // U+17BD: "" KHMER VOWEL SIGN UA 219 // U+17BC: "" KHMER VOWEL SIGN UU 220 // U+17B8: "" KHMER VOWEL SIGN II 221 // U+17C5: "" KHMER VOWEL SIGN AU 222 // U+1797: "" KHMER LETTER PHO 223 // U+17BF: "" KHMER VOWEL SIGN YA 224 // U+17B0: "" KHMER INDEPENDENT VOWEL QAI 225 "\u1791", "\u17BD", "\u17BC", "\u17B8", "\u17C5", "\u1797", "\u17BF", "\u17B0") 226 .setKeysOfRow(3, 227 // U+17B6/U+17C6: "" KHMER VOWEL SIGN AA/KHMER SIGN NIKAHIT 228 // U+17C3: "" KHMER VOWEL SIGN AI 229 // U+178C: "" KHMER LETTER DO 230 // U+1792: "" KHMER LETTER THO 231 // U+17A2: "" KHMER LETTER QAE 232 "\u17B6\u17C6", "\u17C3", "\u178C", "\u1792", "\u17A2", 233 // U+17C7: "" KHMER SIGN REAHMUK 234 // U+17C8: "" KHMER SIGN YUUKALEAPINTU 235 key("\u17C7", moreKey("\u17C8")), 236 // U+1789: "" KHMER LETTER NYO 237 "\u1789", 238 // U+1782: "" KHMER LETTER KO 239 // U+179D: "" KHMER LETTER SHA 240 key("\u1782", moreKey("\u179D")), 241 // U+17A1: "" KHMER LETTER LA 242 // U+17C4/U+17C7: "" KHMER VOWEL SIGN OO/KHMER SIGN REAHMUK 243 // U+17C9: "" KHMER SIGN MUUSIKATOAN 244 // U+17AF: "" KHMER INDEPENDENT VOWEL QE 245 "\u17A1", "\u17C4\u17C7", "\u17C9", "\u17AF") 246 .setKeysOfRow(4, 247 // U+178D: "" KHMER LETTER TTHO 248 // U+1783: "" KHMER LETTER KHO 249 // U+1787: "" KHMER LETTER CO 250 // U+17C1/U+17C7: "" KHMER VOWEL SIGN E/KHMER SIGN REAHMUK 251 "\u178D", "\u1783", "\u1787", "\u17C1\u17C7", 252 // U+1796: "" KHMER LETTER PO 253 // U+179E: "" KHMER LETTER SSO 254 key("\u1796", moreKey("\u179E")), 255 // U+178E: "" KHMER LETTER NNO 256 // U+17C6: "" KHMER SIGN NIKAHIT 257 // U+17BB/U+17C7: "" KHMER VOWEL SIGN U/KHMER SIGN REAHMUK 258 // U+17D5: "" KHMER SIGN BARIYOOSAN 259 "\u178E", "\u17C6", "\u17BB\u17C7", "\u17D5", "?") 260 .build(); 261 } 262