• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.expected.ExpectedKey;
20 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
21 import com.android.inputmethod.latin.Constants;
22 
23 import java.util.Locale;
24 
25 /**
26  * The Armenian Phonetic alphabet keyboard.
27  */
28 public final class ArmenianPhonetic extends LayoutBase {
29     private static final String LAYOUT_NAME = "armenian_phonetic";
30 
ArmenianPhonetic(final LayoutCustomizer customizer)31     public ArmenianPhonetic(final LayoutCustomizer customizer) {
32         super(customizer, ArmenianSymbols.class, ArmenianSymbolsShifted.class);
33     }
34 
35     @Override
getName()36     public String getName() { return LAYOUT_NAME; }
37 
38     public static class ArmenianPhoneticCustomizer extends LayoutCustomizer {
ArmenianPhoneticCustomizer(final Locale locale)39         public ArmenianPhoneticCustomizer(final Locale locale) { super(locale); }
40 
41         @Override
getNumberOfRows()42         public int getNumberOfRows() { return 5; }
43 
44         @Override
getAlphabetKey()45         public ExpectedKey getAlphabetKey() { return ARMENIAN_ALPHABET_KEY; }
46 
47         @Override
getRightShiftKeys(final boolean isPhone)48         public ExpectedKey[] getRightShiftKeys(final boolean isPhone) {
49             if (isPhone) {
50                 return EMPTY_KEYS;
51             }
52             // U+055C: "՜" ARMENIAN EXCLAMATION MARK
53             // U+00A1: "¡" INVERTED EXCLAMATION MARK
54             // U+055E: "՞" ARMENIAN QUESTION MARK
55             // U+00BF: "¿" INVERTED QUESTION MARK
56             return joinKeys(key("!", joinMoreKeys("\u055C", "\u00A1")),
57                     key("?", joinMoreKeys("\u055E", "\u00BF")),
58                     SHIFT_KEY);
59         }
60 
61         @Override
getKeysLeftToSpacebar(final boolean isPhone)62         public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
63             // U+055D: "՝" ARMENIAN COMMA
64             return isPhone ? joinKeys(key("\u055D", SETTINGS_KEY))
65                     : joinKeys(key("\u055D", SETTINGS_KEY));
66         }
67 
68         @Override
getKeysRightToSpacebar(final boolean isPhone)69         public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
70             // U+0589: "։" ARMENIAN FULL STOP
71             final ExpectedKey fullStopKey = key("\u0589", getPunctuationMoreKeys(isPhone));
72             return joinKeys(fullStopKey);
73         }
74 
75         @Override
getPunctuationMoreKeys(final boolean isPhone)76         public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) {
77             return ARMENIAN_PUNCTUATION_MORE_KEYS;
78         }
79 
80         // U+0531: "Ա" ARMENIAN CAPITAL LETTER AYB
81         // U+0532: "Բ" ARMENIAN CAPITAL LETTER BEN
82         // U+0533: "Գ" ARMENIAN CAPITAL LETTER GIM
83         private static final ExpectedKey ARMENIAN_ALPHABET_KEY = key(
84                 "\u0531\u0532\u0533", Constants.CODE_SWITCH_ALPHA_SYMBOL);
85 
86         // U+055E: "՞" ARMENIAN QUESTION MARK
87         // U+055C: "՜" ARMENIAN EXCLAMATION MARK
88         // U+055A: "՚" ARMENIAN APOSTROPHE
89         // U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING
90         // U+055D: "՝" ARMENIAN COMMA
91         // U+055B: "՛" ARMENIAN EMPHASIS MARK
92         // U+058A: "֊" ARMENIAN HYPHEN
93         // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
94         // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
95         // U+055F: "՟" ARMENIAN ABBREVIATION MARK
96         private static final ExpectedKey[] ARMENIAN_PUNCTUATION_MORE_KEYS = joinMoreKeys(
97                 ",", "\u055E", "\u055C", ".", "\u055A", "\u0559", "?", "!",
98                 "\u055D", "\u055B", "\u058A", "\u00BB", "\u00AB", "\u055F", ";", ":");
99     }
100 
101     @Override
getCommonAlphabetLayout(final boolean isPhone)102     ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) {
103         final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON);
104         if (isPhone) {
105             // U+056D: "խ" ARMENIAN SMALL LETTER XEH
106             // U+0577: "շ" ARMENIAN SMALL LETTER SHA
107             builder.addKeysOnTheRightOfRow(3, "\u056D")
108                     .addKeysOnTheRightOfRow(4, "\u0577");
109         } else {
110             // U+056D: "խ" ARMENIAN SMALL LETTER XEH
111             // U+0577: "շ" ARMENIAN SMALL LETTER SHA
112             builder.addKeysOnTheRightOfRow(2, "\u056D")
113                     .addKeysOnTheRightOfRow(3, "\u0577");
114         }
115         return builder.build();
116     }
117 
118     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
119             .setKeysOfRow(1,
120                     // U+0567: "է" ARMENIAN SMALL LETTER EH
121                     key("\u0567", moreKey("1")),
122                     // U+0569: "թ" ARMENIAN SMALL LETTER TO
123                     key("\u0569", moreKey("2")),
124                     // U+0583: "փ" ARMENIAN SMALL LETTER PIWR
125                     key("\u0583", moreKey("3")),
126                     // U+0571: "ձ" ARMENIAN SMALL LETTER JA
127                     key("\u0571", moreKey("4")),
128                     // U+057B: "ջ" ARMENIAN SMALL LETTER JHEH
129                     key("\u057B", moreKey("5")),
130                     // U+0580: "ր" ARMENIAN SMALL LETTER REH
131                     key("\u0580", moreKey("6")),
132                     // U+0579: "չ" ARMENIAN SMALL LETTER CHA
133                     key("\u0579", moreKey("7")),
134                     // U+0573: "ճ" ARMENIAN SMALL LETTER CHEH
135                     key("\u0573", moreKey("8")),
136                     // U+056A: "ժ" ARMENIAN SMALL LETTER ZHE
137                     key("\u056A", moreKey("9")),
138                     // U+056E: "ծ" ARMENIAN SMALL LETTER CA
139                     key("\u056E", moreKey("0")))
140             .setKeysOfRow(2,
141                     // U+0584: "ք" ARMENIAN SMALL LETTER KEH
142                     // U+0578: "ո" ARMENIAN SMALL LETTER VO
143                     "\u0584", "\u0578",
144                     // U+0565: "ե" ARMENIAN SMALL LETTER ECH
145                     // U+0587: "և" ARMENIAN SMALL LIGATURE ECH YIWN
146                     key("\u0565", moreKey("\u0587")),
147                     // U+057C: "ռ" ARMENIAN SMALL LETTER RA
148                     // U+057F: "տ" ARMENIAN SMALL LETTER TIWN
149                     // U+0568: "ը" ARMENIAN SMALL LETTER ET
150                     // U+0582: "ւ" ARMENIAN SMALL LETTER YIWN
151                     // U+056B: "ի" ARMENIAN SMALL LETTER INI
152                     // U+0585: "օ" ARMENIAN SMALL LETTER OH
153                     // U+057A: "պ" ARMENIAN SMALL LETTER PEH
154                     "\u057C", "\u057F", "\u0568", "\u0582", "\u056B", "\u0585", "\u057A")
155             .setKeysOfRow(3,
156                     // U+0561: "ա" ARMENIAN SMALL LETTER AYB
157                     // U+057D: "ս" ARMENIAN SMALL LETTER SEH
158                     // U+0564: "դ" ARMENIAN SMALL LETTER DA
159                     // U+0586: "ֆ" ARMENIAN SMALL LETTER FEH
160                     // U+0563: "գ" ARMENIAN SMALL LETTER GIM
161                     // U+0570: "հ" ARMENIAN SMALL LETTER HO
162                     // U+0575: "յ" ARMENIAN SMALL LETTER YI
163                     // U+056F: "կ" ARMENIAN SMALL LETTER KEN
164                     // U+056C: "լ" ARMENIAN SMALL LETTER LIWN
165                     "\u0561", "\u057D", "\u0564", "\u0586", "\u0563", "\u0570", "\u0575", "\u056F",
166                     "\u056C")
167             .setKeysOfRow(4,
168                     // U+0566: "զ" ARMENIAN SMALL LETTER ZA
169                     // U+0572: "ղ" ARMENIAN SMALL LETTER GHAD
170                     // U+0581: "ց" ARMENIAN SMALL LETTER CO
171                     // U+057E: "վ" ARMENIAN SMALL LETTER VEW
172                     // U+0562: "բ" ARMENIAN SMALL LETTER BEN
173                     // U+0576: "ն" ARMENIAN SMALL LETTER NOW
174                     // U+0574: "մ" ARMENIAN SMALL LETTER MEN
175                     "\u0566", "\u0572", "\u0581", "\u057E", "\u0562", "\u0576", "\u0574")
176             .build();
177 
178     private static final class ArmenianSymbols extends Symbols {
ArmenianSymbols(final LayoutCustomizer customizer)179         public ArmenianSymbols(final LayoutCustomizer customizer) { super(customizer); }
180 
181         @Override
getLayout(final boolean isPhone)182         public ExpectedKey[][] getLayout(final boolean isPhone) {
183             final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(
184                     super.getLayout(isPhone));
185             // U+055D: "՝" ARMENIAN COMMA
186             builder.replaceKeyOfLabel(",", "\u055D");
187             // U+055C: "՜" ARMENIAN EXCLAMATION MARK
188             // U+00A1: "¡" INVERTED EXCLAMATION MARK
189             // U+055E: "՞" ARMENIAN QUESTION MARK
190             // U+00BF: "¿" INVERTED QUESTION MARK
191             builder.setMoreKeysOf("!", "\u055C", "\u00A1")
192                     .setMoreKeysOf("?", "\u055E", "\u00BF");
193             return builder.build();
194         }
195     }
196 
197     private static final class ArmenianSymbolsShifted extends SymbolsShifted {
ArmenianSymbolsShifted(final LayoutCustomizer customizer)198         public ArmenianSymbolsShifted(final LayoutCustomizer customizer) { super(customizer); }
199 
200         @Override
getLayout(final boolean isPhone)201         public ExpectedKey[][] getLayout(final boolean isPhone) {
202             final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(
203                     super.getLayout(isPhone));
204             // U+055D: "՝" ARMENIAN COMMA
205             builder.replaceKeyOfLabel(",", "\u055D");
206             return builder.build();
207         }
208     }
209 }
210