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.Hindi.HindiCustomizer; 23 import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols; 24 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; 25 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; 26 27 import java.util.Locale; 28 29 /** 30 * The nepali_romanized layout 31 */ 32 public final class NepaliRomanized extends LayoutBase { 33 private static final String LAYOUT_NAME = "nepali_romanized"; 34 35 public NepaliRomanized(final LayoutCustomizer customizer) { 36 super(customizer, HindiSymbols.class, SymbolsShifted.class); 37 } 38 39 @Override 40 public String getName() { return LAYOUT_NAME; } 41 42 public static class NepaliRomanizedCustomizer extends HindiCustomizer { 43 public NepaliRomanizedCustomizer(final Locale locale) { super(locale); } 44 45 @Override 46 public ExpectedKey getCurrencyKey() { return CURRENCY_NEPALI; } 47 48 @Override 49 public ExpectedKey[] getSpaceKeys(final boolean isPhone) { 50 return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY)); 51 } 52 53 // U+0930/U+0941/U+002E "." NEPALESE RUPEE SIGN 54 private static final ExpectedKey CURRENCY_NEPALI = key("\u0930\u0941\u002E", 55 Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, 56 Symbols.YEN_SIGN, Symbols.PESO_SIGN); 57 } 58 59 @Override 60 ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } 61 62 @Override 63 ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { 64 if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { 65 return getCommonAlphabetLayout(isPhone); 66 } 67 return ALPHABET_SHIFTED_COMMON; 68 } 69 70 private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() 71 .setKeysOfRow(1, 72 // U+091F: "" DEVANAGARI LETTER TTA 73 // U+0967: "" DEVANAGARI DIGIT ONE 74 // U+093C: "" DEVANAGARI SIGN NUKTA 75 key("\u091F", joinMoreKeys("\u0967", "1", key(SIGN_NUKTA, "\u093C"))), 76 // U+094C: "" DEVANAGARI VOWEL SIGN AU 77 // U+0968: "" DEVANAGARI DIGIT TWO 78 key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys("\u0968", "2")), 79 // U+0947: "" DEVANAGARI VOWEL SIGN E 80 // U+0969: "" DEVANAGARI DIGIT THREE 81 key(VOWEL_SIGN_E, "\u0947", joinMoreKeys("\u0969", "3")), 82 // U+0930: "" DEVANAGARI LETTER RA 83 // U+096A: "" DEVANAGARI DIGIT FOUR 84 key("\u0930", joinMoreKeys("\u096A", "4")), 85 // U+0924: "" DEVANAGARI LETTER TA 86 // U+096B: "" DEVANAGARI DIGIT FIVE 87 key("\u0924", joinMoreKeys("\u096B", "5")), 88 // U+092F: "" DEVANAGARI LETTER YA 89 // U+096C: "" DEVANAGARI DIGIT SIX 90 key("\u092F", joinMoreKeys("\u096C", "6")), 91 // U+0941: "" DEVANAGARI VOWEL SIGN U 92 // U+096D: "" DEVANAGARI DIGIT SEVEN 93 key(VOWEL_SIGN_U, "\u0941", joinMoreKeys("\u096D", "7")), 94 // U+093F: "" DEVANAGARI VOWEL SIGN I 95 // U+096E: "" DEVANAGARI DIGIT EIGHT 96 key(VOWEL_SIGN_I, "\u093F", joinMoreKeys("\u096E", "8")), 97 // U+094B: "" DEVANAGARI VOWEL SIGN O 98 // U+096F: "" DEVANAGARI DIGIT NINE 99 key(VOWEL_SIGN_O, "\u094B", joinMoreKeys("\u096F", "9")), 100 // U+092A: "" DEVANAGARI LETTER PA 101 // U+0966: "" DEVANAGARI DIGIT ZERO 102 key("\u092A", joinMoreKeys("\u0966", "0")), 103 // U+0907: "" DEVANAGARI LETTER I 104 "\u0907") 105 .setKeysOfRow(2, 106 // U+093E: "" DEVANAGARI VOWEL SIGN AA 107 key(VOWEL_SIGN_AA, "\u093E"), 108 // U+0938: "" DEVANAGARI LETTER SA 109 // U+0926: "" DEVANAGARI LETTER DA 110 // U+0909: "" DEVANAGARI LETTER U 111 // U+0917: "" DEVANAGARI LETTER GA 112 // U+0939: "" DEVANAGARI LETTER HA 113 // U+091C: "" DEVANAGARI LETTER JA 114 // U+0915: "" DEVANAGARI LETTER KA 115 // U+0932: "" DEVANAGARI LETTER LA 116 // U+090F: "" DEVANAGARI LETTER E 117 // U+0950: "" DEVANAGARI OM 118 "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915", "\u0932", 119 "\u090F", "\u0950") 120 .setKeysOfRow(3, 121 // U+0937: "" DEVANAGARI LETTER SSA 122 // U+0921: "" DEVANAGARI LETTER DDA 123 // U+091A: "" DEVANAGARI LETTER CA 124 // U+0935: "" DEVANAGARI LETTER VA 125 // U+092C: "" DEVANAGARI LETTER BHA 126 // U+0928: "" DEVANAGARI LETTER NA 127 // U+092E: "" DEVANAGARI LETTER MA 128 "\u0937", "\u0921", "\u091A", "\u0935", "\u092C", "\u0928", "\u092E", 129 // U+0964: "" DEVANAGARI DANDA 130 // U+093D: "" DEVANAGARI SIGN AVAGRAHA 131 key("\u0964", moreKey("\u093D")), 132 // U+094D: "" DEVANAGARI SIGN VIRAMA 133 key(SIGN_VIRAMA, "\u094D")) 134 .build(); 135 136 private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() 137 .setKeysOfRow(1, 138 // U+0920: "" DEVANAGARI LETTER TTHA 139 // U+0914: "" DEVANAGARI LETTER AU 140 "\u0920", "\u0914", 141 // U+0948: "" DEVANAGARI VOWEL SIGN AI 142 key(VOWEL_SIGN_AI, "\u0948"), 143 // U+0943: "" DEVANAGARI VOWEL SIGN VOCALIC R 144 key(VOWEL_SIGN_VOCALIC_R, "\u0943"), 145 // U+0925: "" DEVANAGARI LETTER THA 146 // U+091E: "" DEVANAGARI LETTER NYA 147 "\u0925", "\u091E", 148 // U+0942: "" DEVANAGARI VOWEL SIGN UU 149 key(VOWEL_SIGN_UU, "\u0942"), 150 // U+0940: "" DEVANAGARI VOWEL SIGN II 151 key(VOWEL_SIGN_II, "\u0940"), 152 // U+0913: "" DEVANAGARI LETTER O 153 // U+092B: "" DEVANAGARI LETTER PHA 154 // U+0908: "" DEVANAGARI LETTER II 155 "\u0913", "\u092B", "\u0908") 156 .setKeysOfRow(2, 157 // U+0906: "" DEVANAGARI LETTER AA 158 // U+0936: "" DEVANAGARI LETTER SHA 159 // U+0927: "" DEVANAGARI LETTER DHA 160 // U+090A: "" DEVANAGARI LETTER UU 161 // U+0918: "" DEVANAGARI LETTER GHA 162 // U+0905: "" DEVANAGARI LETTER A 163 // U+091D: "" DEVANAGARI LETTER JHA 164 // U+0916: "" DEVANAGARI LETTER KHA 165 // U+0965: "" DEVANAGARI DOUBLE DANDA 166 // U+0910: "" DEVANAGARI LETTER AI 167 // U+0903: "" DEVANAGARI SIGN VISARGA 168 "\u0906", "\u0936", "\u0927", "\u090A", "\u0918", "\u0905", "\u091D", "\u0916", 169 "\u0965", "\u0910", key(SIGN_VISARGA, "\u0903")) 170 .setKeysOfRow(3, 171 // U+090B: "" DEVANAGARI LETTER VOCALIC R 172 // U+0922: "" DEVANAGARI LETTER DDHA 173 // U+091B: "" DEVANAGARI LETTER CHA 174 "\u090B", "\u0922", "\u091B", 175 // U+0901: "" DEVANAGARI SIGN CANDRABINDU 176 key(SIGN_CANDRABINDU, "\u0901"), 177 // U+092D: "" DEVANAGARI LETTER BHA 178 // U+0923: "" DEVANAGARI LETTER NNA 179 "\u092D", "\u0923", 180 // U+0902: "" DEVANAGARI SIGN ANUSVARA 181 key(SIGN_ANUSVARA, "\u0902"), 182 // U+0919: "" DEVANAGARI LETTER NGA 183 "\u0919", 184 // U+094D: "" DEVANAGARI SIGN VIRAMA 185 key(SIGN_VIRAMA, "\u094D")) 186 .build(); 187 } 188