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.layout.Hindi.HindiSymbols;
22 import com.android.inputmethod.keyboard.layout.customizer.DevanagariCustomizer;
23 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
24 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
25 
26 import java.util.Locale;
27 
28 /**
29  * The Marathi keyboard.
30  */
31 public final class Marathi extends LayoutBase {
32     private static final String LAYOUT_NAME = "marathi";
33 
Marathi(final Locale locale)34     public Marathi(final Locale locale) {
35         super(new MarathiCustomizer(locale), HindiSymbols.class, SymbolsShifted.class);
36     }
37 
38     @Override
getName()39     public String getName() { return LAYOUT_NAME; }
40 
41     private static class MarathiCustomizer extends DevanagariCustomizer {
MarathiCustomizer(final Locale locale)42         MarathiCustomizer(final Locale locale) { super(locale); }
43 
44         @Override
getCurrencyKey()45         public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; }
46 
47         @Override
getOtherCurrencyKeys()48         public ExpectedKey[] getOtherCurrencyKeys() {
49             return SymbolsShifted.CURRENCIES_OTHER_GENERIC;
50         }
51 
52         @Override
getLeftShiftKeys(final boolean isPhone)53         public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) {
54             return EMPTY_KEYS;
55         }
56 
57         @Override
getRightShiftKeys(final boolean isPhone)58         public ExpectedKey[] getRightShiftKeys(final boolean isPhone) {
59             return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS;
60         }
61 
62         // U+20B9: "₹" INDIAN RUPEE SIGN
63         private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9",
64                 Symbols.CURRENCY_GENERIC_MORE_KEYS);
65     }
66 
67     @Override
getCommonAlphabetLayout(boolean isPhone)68     ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
69 
70     @Override
getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId)71     ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) {
72         return null;
73     }
74 
75     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
76             .setKeysOfRow(1,
77                     // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
78                     // U+0914: "औ" DEVANAGARI LETTER AU
79                     // U+0967: "१" DEVANAGARI DIGIT ONE
80                     key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys("\u0914", "\u0967", "1")),
81                     // U+0948: "ै" DEVANAGARI VOWEL SIGN AI
82                     // U+0910: "ऐ" DEVANAGARI LETTER AI
83                     // U+0968: "२" DEVANAGARI DIGIT TWO
84                     key(VOWEL_SIGN_AI, "\u0948", joinMoreKeys("\u0910", "\u0968", "2")),
85                     // U+093E: "ा" DEVANAGARI VOWEL SIGN AA
86                     // U+0906: "आ" DEVANAGARI LETTER AA
87                     // U+0969: "३" DEVANAGARI DIGIT THREE
88                     key(VOWEL_SIGN_AA, "\u093E", joinMoreKeys("\u0906", "\u0969", "3")),
89                     // U+0940: "ी" DEVANAGARI VOWEL SIGN II
90                     // U+0908: "ई" DEVANAGARI LETTER II
91                     // U+096A: "४" DEVANAGARI DIGIT FOUR
92                     key(VOWEL_SIGN_II, "\u0940", joinMoreKeys("\u0908", "\u096A", "4")),
93                     // U+0942: "ू" DEVANAGARI VOWEL SIGN UU
94                     // U+090A: "ऊ" DEVANAGARI LETTER UU
95                     // U+096B: "५" DEVANAGARI DIGIT FIVE
96                     key(VOWEL_SIGN_UU, "\u0942", joinMoreKeys("\u090A", "\u096B", "5")),
97                     // U+092C: "ब" DEVANAGARI LETTER BA
98                     // U+092D: "भ" DEVANAGARI LETTER BHA
99                     // U+096C: "६" DEVANAGARI DIGIT SIX
100                     key("\u092C", joinMoreKeys("\u092D", "\u096C", "6")),
101                     // U+0939: "ह" DEVANAGARI LETTER HA
102                     // U+096D: "७" DEVANAGARI DIGIT SEVEN
103                     key("\u0939", joinMoreKeys("\u096D", "7")),
104                     // U+0917: "ग" DEVANAGARI LETTER GA
105                     // U+0918: "घ" DEVANAGARI LETTER GHA
106                     // U+096E: "८" DEVANAGARI DIGIT EIGHT
107                     key("\u0917", joinMoreKeys("\u0918", "\u096E", "8")),
108                     // U+0926: "द" DEVANAGARI LETTER DA
109                     // U+0927: "ध" DEVANAGARI LETTER DHA
110                     // U+096F: "९" DEVANAGARI DIGIT NINE
111                     key("\u0926", joinMoreKeys("\u0927", "\u096F", "9")),
112                     // U+091C: "ज" DEVANAGARI LETTER JA
113                     // U+091D: "झ" DEVANAGARI LETTER JHA
114                     // U+091C/U+094D/U+091E:
115                     //     "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA
116                     // U+0966: "०" DEVANAGARI DIGIT ZERO
117                     key("\u091C", joinMoreKeys("\u091D", "\u091C\u094D\u091E", "\u0966", "0")),
118                     // U+0921: "ड" DEVANAGARI LETTER DDA
119                     // U+0922: "ढ" DEVANAGARI LETTER DDHA
120                     key("\u0921", moreKey("\u0922")))
121             .setKeysOfRow(2,
122                     // U+094B: "ो" DEVANAGARI VOWEL SIGN O
123                     // U+0913: "ओ" DEVANAGARI LETTER O
124                     key(VOWEL_SIGN_O, "\u094B", moreKey("\u0913")),
125                     // U+0947: "े" DEVANAGARI VOWEL SIGN E
126                     // U+090F: "ए" DEVANAGARI LETTER SHORT E
127                     key(VOWEL_SIGN_E, "\u0947", moreKey("\u090F")),
128                     // U+094D: "्" DEVANAGARI SIGN VIRAMA
129                     // U+0905: "अ" DEVANAGARI LETTER A
130                     key(SIGN_VIRAMA, "\u094D", moreKey("\u0905")),
131                     // U+093F: "ि" DEVANAGARI VOWEL SIGN I
132                     // U+0907: "इ" DEVANAGARI LETTER I
133                     key(VOWEL_SIGN_I, "\u093F", moreKey("\u0907")),
134                     // U+0941: "ु" DEVANAGARI VOWEL SIGN U
135                     // U+0909: "उ" DEVANAGARI LETTER U
136                     key(VOWEL_SIGN_U, "\u0941", moreKey("\u0909")),
137                     // U+092A: "प" DEVANAGARI LETTER PA
138                     // U+092B: "फ" DEVANAGARI LETTER PHA
139                     key("\u092A", moreKey("\u092B")),
140                     // U+0930: "र" DEVANAGARI LETTER RA
141                     // U+0931: "ऱ" DEVANAGARI LETTER RRA
142                     // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
143                     // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
144                     key("\u0930", joinMoreKeys(
145                             "\u0931", "\u090B", moreKey(VOWEL_SIGN_VOCALIC_R, "\u0943"))),
146                     // U+0915: "क" DEVANAGARI LETTER KA
147                     // U+0916: "ख" DEVANAGARI LETTER KHA
148                     key("\u0915", moreKey("\u0916")),
149                     // U+0924: "त" DEVANAGARI LETTER TA
150                     // U+0925: "थ" DEVANAGARI LETTER THA
151                     // U+0924/U+094D/U+0930:
152                     //     "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
153                     key("\u0924", joinMoreKeys("\u0925", "\u0924\u094D\u0930")),
154                     // U+091A: "च" DEVANAGARI LETTER CA
155                     // U+091B: "छ" DEVANAGARI LETTER CHA
156                     key("\u091A", moreKey("\u091B")),
157                     // U+091F: "ट" DEVANAGARI LETTER TTA
158                     // U+0920: "ठ" DEVANAGARI LETTER TTHA
159                     key("\u091F", moreKey("\u0920")))
160             .setKeysOfRow(3,
161                     // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
162                     // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O
163                     key(VOWEL_SIGN_CANDRA_O, "\u0949", moreKey("\u0911")),
164                     // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E
165                     // U+090D: "ऍ" DEVANAGARI LETTER CANDRA E
166                     key(VOWEL_SIGN_CANDRA_E, "\u0945", moreKey("\u090D")),
167                     // U+0902: "ं" DEVANAGARI SIGN ANUSVARA
168                     // U+0903: "ः‍" DEVANAGARI SIGN VISARGA
169                     // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
170                     key(SIGN_ANUSVARA, "\u0902", joinMoreKeys(
171                             moreKey(SIGN_VISARGA, "\u0903"), moreKey(SIGN_CANDRABINDU, "\u0901"))),
172                     // U+092E: "म" DEVANAGARI LETTER MA
173                     "\u092E",
174                     // U+0928: "न" DEVANAGARI LETTER NA
175                     // U+0923: "ण" DEVANAGARI LETTER NNA
176                     // U+091E: "ञ" DEVANAGARI LETTER NYA
177                     // U+0919: "ङ" DEVANAGARI LETTER NGA
178                     key("\u0928", joinMoreKeys("\u0923", "\u091E", "\u0919")),
179                     // U+0935: "व" DEVANAGARI LETTER VA
180                     "\u0935",
181                     // U+0932: "ल" DEVANAGARI LETTER LA
182                     // U+0933: "ळ" DEVANAGARI LETTER LLA
183                     key("\u0932", moreKey("\u0933")),
184                     // U+0938: "स" DEVANAGARI LETTER SA
185                     // U+0936: "श" DEVANAGARI LETTER SHA
186                     // U+0937: "ष" DEVANAGARI LETTER SSA
187                     // U+0936/U+094D/U+0930:
188                     //     "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
189                     key("\u0938", joinMoreKeys("\u0936", "\u0937", "\u0936\u094D\u0930")),
190                     // U+092F: "य" DEVANAGARI LETTER YA
191                     "\u092F",
192                     // U+0915/U+094D/U+0937:
193                     //     "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA
194                     "\u0915\u094D\u0937")
195             .build();
196 }
197