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