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