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