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 NepaliTraditional(final Locale locale)35 public NepaliTraditional(final Locale locale) { 36 super(new NepaliTraditionalCustomizer(locale), HindiSymbols.class, SymbolsShifted.class); 37 } 38 39 @Override getName()40 public String getName() { return LAYOUT_NAME; } 41 42 private static class NepaliTraditionalCustomizer extends NepaliCustomizer { NepaliTraditionalCustomizer(final Locale locale)43 NepaliTraditionalCustomizer(final Locale locale) { super(locale); } 44 45 @Override getRightShiftKeys(final boolean isPhone)46 public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { 47 return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; 48 } 49 } 50 51 @Override getCommonAlphabetLayout(final boolean isPhone)52 ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } 53 54 @Override getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId)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