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.KeyboardId; 20 import com.android.inputmethod.keyboard.layout.customizer.LayoutCustomizer; 21 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; 22 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; 23 import com.android.inputmethod.latin.common.Constants; 24 25 import java.util.Locale; 26 27 /** 28 * The Sinhala keyboard. 29 */ 30 public final class Sinhala extends LayoutBase { 31 private static final String LAYOUT_NAME = "sinhala"; 32 33 public Sinhala(final Locale locale) { 34 super(new SinhalaCustomizer(locale), Symbols.class, SymbolsShifted.class); 35 } 36 37 @Override 38 public String getName() { return LAYOUT_NAME; } 39 40 private static class SinhalaCustomizer extends LayoutCustomizer { 41 SinhalaCustomizer(final Locale locale) { super(locale); } 42 43 @Override 44 public ExpectedKey getAlphabetKey() { return SINHALA_ALPHABET_KEY; } 45 46 @Override 47 public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } 48 49 @Override 50 public ExpectedKey[] getOtherCurrencyKeys() { 51 return SymbolsShifted.CURRENCIES_OTHER_GENERIC; 52 } 53 54 @Override 55 public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { 56 return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; 57 } 58 59 // U+0D85: "" SINHALA LETTER AYANNA 60 // U+0D86: "" SINHALA LETTER AAYANNA 61 private static final ExpectedKey SINHALA_ALPHABET_KEY = key( 62 "\u0D85,\u0D86", Constants.CODE_SWITCH_ALPHA_SYMBOL); 63 64 // U+0DBB/U+0DD4: "" SINHALA LETTER RAYANNA/SINHALA VOWEL SIGN KETTI PAA-PILLA 65 private static final ExpectedKey CURRENCY_RUPEE = key("\u0DBB\u0DD4", 66 Symbols.CURRENCY_GENERIC_MORE_KEYS); 67 } 68 69 @Override 70 ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } 71 72 @Override 73 ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { 74 if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { 75 return ALPHABET_COMMON; 76 } 77 return ALPHABET_SHIFTED_COMMON; 78 } 79 80 private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() 81 .setKeysOfRow(1, 82 // U+0DD4: "" SINHALA VOWEL SIGN KETTI PAA-PILLA 83 key("\u0DD4", moreKey("1")), 84 // U+0D85: "" SINHALA LETTER AYANNA 85 key("\u0D85", moreKey("2")), 86 // U+0DD0: "" SINHALA VOWEL SIGN KETTI AEDA-PILLA 87 key("\u0DD0", moreKey("3")), 88 // U+0DBB: "" SINHALA LETTER RAYANNA 89 key("\u0DBB", moreKey("4")), 90 // U+0D91: "" SINHALA LETTER EYANNA 91 key("\u0D91", moreKey("5")), 92 // U+0DC4: "" SINHALA LETTER HAYANNA 93 key("\u0DC4", moreKey("6")), 94 // U+0DB8: "" SINHALA LETTER MAYANNA 95 key("\u0DB8", moreKey("7")), 96 // U+0DC3: "" SINHALA LETTER DANTAJA SAYANNA 97 key("\u0DC3", moreKey("8")), 98 // U+0DAF: "" SINHALA LETTER ALPAPRAANA DAYANNA 99 // U+0DB3: "" SINHALA LETTER SANYAKA DAYANNA 100 key("\u0DAF", joinMoreKeys("9", "\u0DB3")), 101 // U+0DA0: "" SINHALA LETTER ALPAPRAANA CAYANNA 102 key("\u0DA0", moreKey("0")), 103 // U+0DA4: "" SINHALA LETTER TAALUJA NAASIKYAYA 104 // U+0DF4: "" SINHALA PUNCTUATION KUNDDALIYA 105 key("\u0DA4", moreKey("\u0DF4"))) 106 .setKeysOfRow(2, 107 // U+0DCA: "" SINHALA SIGN AL-LAKUNA 108 // U+0DD2: "" SINHALA VOWEL SIGN KETTI IS-PILLA 109 // U+0DCF: "" SINHALA VOWEL SIGN AELA-PILLA 110 // U+0DD9: "" SINHALA VOWEL SIGN KOMBUVA 111 // U+0DA7: "" SINHALA LETTER ALPAPRAANA TTAYANNA 112 // U+0DBA: "" SINHALA LETTER YAYANNA 113 // U+0DC0: "" SINHALA LETTER VAYANNA 114 // U+0DB1: "" SINHALA LETTER DANTAJA NAYANNA 115 // U+0D9A: "" SINHALA LETTER ALPAPRAANA KAYANNA 116 // U+0DAD: "" SINHALA LETTER ALPAPRAANA TAYANNA 117 // U+0D8F: "" SINHALA LETTER ILUYANNA 118 "\u0DCA", "\u0DD2", "\u0DCF", "\u0DD9", "\u0DA7", "\u0DBA", "\u0DC0", "\u0DB1", 119 "\u0D9A", "\u0DAD", "\u0D8F") 120 .setKeysOfRow(3, 121 // U+0D82: "" SINHALA SIGN ANUSVARAYA 122 // U+0D83: "" SINHALA SIGN VISARGAYA 123 key("\u0D82", moreKey("\u0D83")), 124 // U+0DA2: "" SINHALA LETTER ALPAPRAANA JAYANNA 125 // U+0DA6: "" SINHALA LETTER SANYAKA JAYANNA 126 key("\u0DA2", moreKey("\u0DA6")), 127 // U+0DA9: "" SINHALA LETTER ALPAPRAANA DDAYANNA 128 // U+0DAC: "" SINHALA LETTER SANYAKA DDAYANNA 129 key("\u0DA9", moreKey("\u0DAC")), 130 // U+0D89: "" SINHALA LETTER IYANNA 131 // U+0DB6: "" SINHALA LETTER ALPAPRAANA BAYANNA 132 // U+0DB4: "" SINHALA LETTER ALPAPRAANA PAYANNA 133 // U+0DBD: "" SINHALA LETTER DANTAJA LAYANNA 134 "\u0D89", "\u0DB6", "\u0DB4", "\u0DBD", 135 // U+0D9C: "" SINHALA LETTER ALPAPRAANA GAYANNA 136 // U+0D9F: "" SINHALA LETTER SANYAKA GAYANNA 137 key("\u0D9C", moreKey("\u0D9F")), 138 // U+0DF3: "" SINHALA VOWEL SIGN DIGA GAYANUKITTA 139 "\u0DF3") 140 .build(); 141 142 private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() 143 .setKeysOfRow(1, 144 // U+0DD6: "" SINHALA VOWEL SIGN DIGA PAA-PILLA 145 // U+0D8B: "" SINHALA LETTER UYANNA 146 // U+0DD1: "" SINHALA VOWEL SIGN DIGA AEDA-PILLA 147 // U+0D8D: "" SINHALA LETTER IRUYANNA 148 // U+0D94: "" SINHALA LETTER OYANNA 149 // U+0DC1: "" SINHALA LETTER TAALUJA SAYANNA 150 // U+0DB9: "" SINHALA LETTER AMBA BAYANNA 151 // U+0DC2: "" SINHALA LETTER MUURDHAJA SAYANNA 152 // U+0DB0: "" SINHALA LETTER MAHAAPRAANA DAYANNA 153 // U+0DA1: "" SINHALA LETTER MAHAAPRAANA CAYANNA 154 "\u0DD6", "\u0D8B", "\u0DD1", "\u0D8D", "\u0D94", "\u0DC1", "\u0DB9", "\u0DC2", 155 "\u0DB0", "\u0DA1", 156 // U+0DA5: "" SINHALA LETTER TAALUJA SANYOOGA NAAKSIKYAYA 157 // U+0DF4: "" SINHALA PUNCTUATION KUNDDALIYA 158 key("\u0DA5", moreKey("\u0DF4"))) 159 .setKeysOfRow(2, 160 // U+0DDF: "" SINHALA VOWEL SIGN GAYANUKITTA 161 // U+0DD3: "" SINHALA VOWEL SIGN DIGA IS-PILLA 162 // U+0DD8: "" SINHALA VOWEL SIGN GAETTA-PILLA 163 // U+0DC6: "" SINHALA LETTER FAYANNA 164 // U+0DA8: "" SINHALA LETTER MAHAAPRAANA TTAYANNA 165 // U+0DCA/U+200D/U+0DBA: 166 // "" SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER/SINHALA LETTER YAYANNA 167 // U+0DC5/U+0DD4: 168 // "" SINHALA LETTER MUURDHAJA LAYANNA/SINHALA VOWEL SIGN KETTI PAA-PILLA 169 // U+0DAB: "" SINHALA LETTER MUURDHAJA NAYANNA 170 // U+0D9B: "" SINHALA LETTER MAHAAPRAANA KAYANNA 171 // U+0DAE: "" SINHALA LETTER MAHAAPRAANA TAYANNA 172 // U+0DCA/U+200D/U+0DBB: 173 // "" SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER/SINHALA LETTER RAYANNA 174 "\u0DDF", "\u0DD3", "\u0DD8", "\u0DC6", "\u0DA8", "\u0DCA\u200D\u0DBA", 175 "\u0DC5\u0DD4", "\u0DAB", "\u0D9B", "\u0DAE", "\u0DCA\u200D\u0DBB") 176 .setKeysOfRow(3, 177 // U+0D9E: "" SINHALA LETTER KANTAJA NAASIKYAYA 178 // U+0DA3: "" SINHALA LETTER MAHAAPRAANA JAYANNA 179 // U+0DAA: "" SINHALA LETTER MAHAAPRAANA DDAYANNA 180 // U+0D8A: "" SINHALA LETTER IIYANNA 181 // U+0DB7: "" SINHALA LETTER MAHAAPRAANA BAYANNA 182 // U+0DB5: "" SINHALA LETTER MAHAAPRAANA PAYANNA 183 // U+0DC5: "" SINHALA LETTER MUURDHAJA LAYANNA 184 // U+0D9D: "" SINHALA LETTER MAHAAPRAANA GAYANNA 185 // U+0DBB/U+0DCA/U+200D: 186 // "" SINHALA LETTER RAYANNA/SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER 187 "\u0d9E", "\u0DA3", "\u0DAA", "\u0D8A", "\u0DB7", "\u0DB5", "\u0DC5", "\u0D9D", 188 "\u0DBB\u0DCA\u200D") 189 .build(); 190 } 191