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