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 com.android.inputmethod.keyboard.layout.customizer.LayoutCustomizer;
20 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
21 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
22 import com.android.inputmethod.latin.common.Constants;
23 
24 import java.util.Locale;
25 
26 /**
27  * The Telugu keyboard.
28  */
29 public final class Telugu extends LayoutBase {
30     private static final String LAYOUT_NAME = "telugu";
31 
Telugu(final Locale locale)32     public Telugu(final Locale locale) {
33         super(new TeluguCustomizer(locale), Symbols.class, SymbolsShifted.class);
34     }
35 
36     @Override
getName()37     public String getName() { return LAYOUT_NAME; }
38 
39     private static class TeluguCustomizer extends LayoutCustomizer {
TeluguCustomizer(final Locale locale)40         TeluguCustomizer(final Locale locale) { super(locale); }
41 
42         @Override
getAlphabetKey()43         public ExpectedKey getAlphabetKey() { return TELUGU_ALPHABET_KEY; }
44 
45         @Override
getCurrencyKey()46         public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; }
47 
48         @Override
getOtherCurrencyKeys()49         public ExpectedKey[] getOtherCurrencyKeys() {
50             return SymbolsShifted.CURRENCIES_OTHER_GENERIC;
51         }
52 
53         @Override
getLeftShiftKeys(final boolean isPhone)54         public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) {
55             return EMPTY_KEYS;
56         }
57 
58         @Override
getRightShiftKeys(final boolean isPhone)59         public ExpectedKey[] getRightShiftKeys(final boolean isPhone) {
60             return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS;
61         }
62 
63         @Override
getSpaceKeys(final boolean isPhone)64         public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
65             return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
66         }
67 
68         // U+0C05: "అ" TELUGU LETTER A
69         // U+0C06: "ఆ" TELUGU LETTER AA
70         // U+0C07: "ఇ" TELUGU LETTER I
71         private static final ExpectedKey TELUGU_ALPHABET_KEY = key(
72                 "\u0C05\u0C06\u0C07", Constants.CODE_SWITCH_ALPHA_SYMBOL);
73 
74         // U+20B9: "₹" INDIAN RUPEE SIGN
75         private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9",
76                 Symbols.CURRENCY_GENERIC_MORE_KEYS);
77     }
78 
79     @Override
getCommonAlphabetLayout(boolean isPhone)80     ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
81 
82     @Override
getCommonAlphabetShiftLayout(boolean isPhone, final int elementId)83     ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) {
84         return null;
85     }
86 
87     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
88             .setKeysOfRow(1,
89                     // U+0C4C: "ౌ" TELUGU VOWEL SIGN AU
90                     // U+0C14: "ఔ" TELUGU LETTER AU
91                     key("\u0C4C", joinMoreKeys("\u0C14", "1")),
92                     // U+0C48: "ై" TELUGU VOWEL SIGN AI
93                     // U+0C10: "ఐ" TELUGU LETTER AI
94                     key("\u0C48", joinMoreKeys("\u0C10", "2")),
95                     // U+0C3E: "ా" TELUGU VOWEL SIGN AA
96                     // U+0C06: "ఆ" TELUGU LETTER AA
97                     key("\u0C3E", joinMoreKeys("\u0C06", "3")),
98                     // U+0C40: "ీ" TELUGU VOWEL SIGN II
99                     // U+0C08: "ఈ" TELUGU LETTER II
100                     key("\u0C40", joinMoreKeys("\u0C08", "4")),
101                     // U+0C42: "ూ" TELUGU VOWEL SIGN UU
102                     // U+0C0A: "ఊ" TELUGU LETTER UU
103                     key("\u0C42", joinMoreKeys("\u0C0A", "5")),
104                     // U+0C2C: "బ" TELUGU LETTER BA
105                     // U+0C2D: "భ" TELUGU LETTER BHA
106                     key("\u0C2C", joinMoreKeys("\u0C2D", "6")),
107                     // U+0C39: "హ" TELUGU LETTER HA
108                     // U+0C03: "ః" TELUGU SIGN VISARGA
109                     key("\u0C39", joinMoreKeys("\u0C03", "7")),
110                     // U+0C17: "గ" TELUGU LETTER GA
111                     // U+0C18: "ఘ" TELUGU LETTER GHA
112                     key("\u0C17", joinMoreKeys("\u0C18", "8")),
113                     // U+0C26: "ద" TELUGU LETTER DA
114                     // U+0C27: "ధ" TELUGU LETTER DHA
115                     key("\u0C26", joinMoreKeys("\u0C27", "9")),
116                     // U+0C1C: "జ" TELUGU LETTER JA
117                     // U+0C1D: "ఝ" TELUGU LETTER JHA
118                     key("\u0C1C", joinMoreKeys("\u0C1D", "0")),
119                     // U+0C21: "డ" TELUGU LETTER DDA
120                     // U+0C22: "ఢ" TELUGU LETTER DDHA
121                     key("\u0C21", moreKey("\u0C22")))
122             .setKeysOfRow(2,
123                     // U+0C4B: "ో" TELUGU VOWEL SIGN OO
124                     // U+0C13: "ఓ" TELUGU LETTER OO
125                     key("\u0C4B", moreKey("\u0C13")),
126                     // U+0C47: "ే" TELUGU VOWEL SIGN EE
127                     // U+0C0F: "ఏ" TELUGU LETTER EE
128                     key("\u0C47", moreKey("\u0C0F")),
129                     // U+0C4D: "్" TELUGU SIGN VIRAMA
130                     // U+0C05: "అ" TELUGU LETTER A
131                     key("\u0C4D", moreKey("\u0C05")),
132                     // U+0C3F: "ి" TELUGU VOWEL SIGN I
133                     // U+0C07: "ఇ" TELUGU LETTER I
134                     key("\u0C3F", moreKey("\u0C07")),
135                     // U+0C41: "ు" TELUGU VOWEL SIGN U
136                     // U+0C09: "ఉ" TELUGU LETTER U
137                     key("\u0C41", moreKey("\u0C09")),
138                     // U+0C2A: "ప" TELUGU LETTER PA
139                     // U+0C2B: "ఫ" TELUGU LETTER PHA
140                     key("\u0C2A", moreKey("\u0C2B")),
141                     // U+0C30: "ర" TELUGU LETTER RA
142                     // U+0C31: "ఱ" TELUGU LETTER RRA
143                     // U+0C4D/U+0C30: "్ర" TELUGU SIGN VIRAMA/TELUGU LETTER RA
144                     key("\u0C30", joinMoreKeys("\u0C31", "\u0C4D\u0C30")),
145                     // U+0C15: "క" TELUGU LETTER KA
146                     // U+0C16: "ఖ" TELUGU LETTER KHA
147                     key("\u0C15", moreKey("\u0C16")),
148                     // U+0C24: "త" TELUGU LETTER TA
149                     // U+0C25: "థ" TELUGU LETTER THA
150                     key("\u0C24", moreKey("\u0C25")),
151                     // U+0C1A: "చ" TELUGU LETTER CA
152                     // U+0C1B: "ఛ" TELUGU LETTER CHA
153                     key("\u0C1A", moreKey("\u0C1B")),
154                     // U+0C1F: "ట" TELUGU LETTER TTA
155                     // U+0C20: "ఠ" TELUGU LETTER TTHA
156                     key("\u0C1F", moreKey("\u0C20")))
157             .setKeysOfRow(3,
158                     // U+0C4A: "ొ" TELUGU VOWEL SIGN O
159                     // U+0C12: "ఒ" TELUGU LETTER O
160                     key("\u0C4A", moreKey("\u0C12")),
161                     // U+0C46: "ె" TELUGU VOWEL SIGN E
162                     // U+0C0E: "ఎ" TELUGU LETTER E
163                     key("\u0C46", moreKey("\u0C0E")),
164                     // U+0C2E: "మ" TELUGU LETTER MA
165                     // U+0C02: "ం" TELUGU SIGN ANUSVARA
166                     // U+0C01: "ఁ" TELUGU SIGN CANDRABINDU
167                     key("\u0C2E", joinMoreKeys("\u0C02", "\u0C01")),
168                     // U+0C28: "న" TELUGU LETTER NA
169                     // U+0C23: "ణ" TELUGU LETTER NNA
170                     // U+0C19: "ఙ" TELUGU LETTER NGA
171                     // U+0C1E: "ఞ" TELUGU LETTER NYA
172                     key("\u0C28", joinMoreKeys("\u0C23", "\u0C19", "\u0C1E")),
173                     // U+0C35: "వ" TELUGU LETTER VA
174                     "\u0C35",
175                     // U+0C32: "ల" TELUGU LETTER LA
176                     // U+0C33: "ళ" TELUGU LETTER LLA
177                     key("\u0C32", moreKey("\u0C33")),
178                     // U+0C38: "స" TELUGU LETTER SA
179                     // U+0C36: "శ" TELUGU LETTER SHA
180                     key("\u0C38", moreKey("\u0C36")),
181                     // U+0C0B: "ఋ" TELUGU LETTER VOCALIC R
182                     // U+0C43: "ృ" TELUGU VOWEL SIGN VOCALIC R
183                     key("\u0C0B", moreKey("\u0C43")),
184                     // U+0C37: "ష" TELUGU LETTER SSA
185                     // U+0C15/U+0C4D/U+0C37:
186                     //     "క్ష" TELUGU LETTER KA/TELUGU SIGN VIRAMA/TELUGU LETTER SSA
187                     key("\u0C37", moreKey("\u0C15\u0C4D\u0C37")),
188                     // U+0C2F: "య" TELUGU LETTER YA
189                     // U+0C1C/U+0C4D/U+0C1E:
190                     //     "జ్ఞ" TELUGU LETTER JA/TELUGU SIGN VIRAMA/TELUGU LETTER NYA
191                     key("\u0C2F", moreKey("\u0C1C\u0C4D\u0C1E")))
192             .build();
193 }
194