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 
NepaliRomanized(final Locale locale)35     public NepaliRomanized(final Locale locale) {
36         super(new NepaliCustomizer(locale), HindiSymbols.class, SymbolsShifted.class);
37     }
38 
39     @Override
getName()40     public String getName() { return LAYOUT_NAME; }
41 
42     @Override
getCommonAlphabetLayout(final boolean isPhone)43     ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; }
44 
45     @Override
getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId)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