Home | History | Annotate | Download | only in layout
      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 Khmer alphabet keyboard.
     29  */
     30 public final class Khmer extends LayoutBase {
     31     private static final String LAYOUT_NAME = "khmer";
     32 
     33     public Khmer(final Locale locale) {
     34         super(new KhmerCustomizer(locale), Symbols.class, SymbolsShifted.class);
     35     }
     36 
     37     @Override
     38     public String getName() { return LAYOUT_NAME; }
     39 
     40     private static class KhmerCustomizer extends LayoutCustomizer {
     41         KhmerCustomizer(final Locale locale) { super(locale); }
     42 
     43         @Override
     44         public int getNumberOfRows() { return 5; }
     45 
     46         @Override
     47         public ExpectedKey getAlphabetKey() { return KHMER_ALPHABET_KEY; }
     48 
     49         @Override
     50         public ExpectedKey getCurrencyKey() { return CURRENCY_DOLLAR_WITH_RIEL; }
     51 
     52         @Override
     53         public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { return EMPTY_KEYS; }
     54 
     55         // U+1780: "" KHMER LETTER KA
     56         // U+1781: "" KHMER LETTER KHA
     57         // U+1782: "" KHMER LETTER KO
     58         private static final ExpectedKey KHMER_ALPHABET_KEY = key(
     59                 "\u1780\u1781\u1782", Constants.CODE_SWITCH_ALPHA_SYMBOL);
     60 
     61         // U+17DB: "" KHMER CURRENCY SYMBOL RIEL
     62         private static final ExpectedKey CURRENCY_DOLLAR_WITH_RIEL = key(Symbols.DOLLAR_SIGN,
     63                 moreKey("\u17DB"), Symbols.CENT_SIGN, Symbols.POUND_SIGN, Symbols.EURO_SIGN,
     64                 Symbols.YEN_SIGN, Symbols.PESO_SIGN);
     65     }
     66 
     67     @Override
     68     ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) {
     69         if (isPhone) {
     70             return ALPHABET_COMMON;
     71         }
     72         final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON);
     73         builder.addKeysOnTheRightOfRow(4, (Object[])EXCLAMATION_AND_QUESTION_MARKS);
     74         return builder.build();
     75     }
     76 
     77     @Override
     78     public ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone,
     79             final int elementId) {
     80         if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
     81             return getCommonAlphabetLayout(isPhone);
     82         }
     83         return ALPHABET_SHIFTED_COMMON;
     84     }
     85 
     86     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
     87             .setKeysOfRow(1,
     88                     // U+17E1: "" KHMER DIGIT ONE
     89                     // U+17F1: "" KHMER SYMBOL LEK ATTAK MUOY
     90                     key("\u17E1", joinMoreKeys("1", "\u17F1")),
     91                     // U+17E2: "" KHMER DIGIT TWO
     92                     // U+17F2: "" KHMER SYMBOL LEK ATTAK PII
     93                     key("\u17E2", joinMoreKeys("2", "\u17F2")),
     94                     // U+17E3: "" KHMER DIGIT THREE
     95                     // U+17F3: "" KHMER SYMBOL LEK ATTAK BEI
     96                     key("\u17E3", joinMoreKeys("3", "\u17F3")),
     97                     // U+17E4: "" KHMER DIGIT FOUR
     98                     // U+17F4: "" KHMER SYMBOL LEK ATTAK BUON
     99                     key("\u17E4", joinMoreKeys("4", "\u17F4")),
    100                     // U+17E5: "" KHMER DIGIT FIVE
    101                     // U+17F5: "" KHMER SYMBOL LEK ATTAK PRAM
    102                     key("\u17E5", joinMoreKeys("5", "\u17F5")),
    103                     // U+17E6: "" KHMER DIGIT SIX
    104                     // U+17F6: "" KHMER SYMBOL LEK ATTAK PRAM-MUOY
    105                     key("\u17E6", joinMoreKeys("6", "\u17F6")),
    106                     // U+17E7: "" KHMER DIGIT SEVEN
    107                     // U+17F7: "" KHMER SYMBOL LEK ATTAK PRAM-PII
    108                     key("\u17E7", joinMoreKeys("7", "\u17F7")),
    109                     // U+17E8: "" KHMER DIGIT EIGHT
    110                     // U+17F8: "" KHMER SYMBOL LEK ATTAK PRAM-BEI
    111                     key("\u17E8", joinMoreKeys("8", "\u17F8")),
    112                     // U+17E9: "" KHMER DIGIT NINE
    113                     // U+17F9: "" KHMER SYMBOL LEK ATTAK PRAM-BUON
    114                     key("\u17E9", joinMoreKeys("9", "\u17F9")),
    115                     // U+17E0: "" KHMER DIGIT ZERO
    116                     // U+17F0: "" KHMER SYMBOL LEK ATTAK SON
    117                     key("\u17E0", joinMoreKeys("0", "\u17F0")),
    118                     // U+17A5: "" KHMER INDEPENDENT VOWEL QI
    119                     // U+17A6: "" KHMER INDEPENDENT VOWEL QII
    120                     key("\u17A5", moreKey("\u17A6")),
    121                     // U+17B2: "" KHMER INDEPENDENT VOWEL QOO TYPE TWO
    122                     // U+17B1: "" KHMER INDEPENDENT VOWEL QOO TYPE ONE
    123                     key("\u17B2", moreKey("\u17B1")))
    124             .setKeysOfRow(2,
    125                     // U+1786: "" KHMER LETTER CHA
    126                     // U+17B9: "" KHMER VOWEL SIGN Y
    127                     // U+17C1: "" KHMER VOWEL SIGN E
    128                     // U+179A: "" KHMER LETTER RO
    129                     // U+178F: "" KHMER LETTER TA
    130                     // U+1799: "" KHMER LETTER YO
    131                     // U+17BB: "" KHMER VOWEL SIGN U
    132                     // U+17B7: "" KHMER VOWEL SIGN I
    133                     // U+17C4: "" KHMER VOWEL SIGN OO
    134                     // U+1795: "" KHMER LETTER PHA
    135                     // U+17C0: "" KHMER VOWEL SIGN IE
    136                     "\u1786", "\u17B9", "\u17C1", "\u179A", "\u178F", "\u1799", "\u17BB", "\u17B7",
    137                     "\u17C4", "\u1795", "\u17C0",
    138                     // U+17AA: "" KHMER INDEPENDENT VOWEL QUUV
    139                     // U+17A7: "" KHMER INDEPENDENT VOWEL QU
    140                     // U+17B1: "" KHMER INDEPENDENT VOWEL QOO TYPE ONE
    141                     // U+17B3: "" KHMER INDEPENDENT VOWEL QAU
    142                     // U+17A9: "" KHMER INDEPENDENT VOWEL QUU
    143                     // U+17A8: "" KHMER INDEPENDENT VOWEL QUK
    144                     key("\u17AA", joinMoreKeys("\u17A7", "\u17B1", "\u17B3", "\u17A9", "\u17A8")))
    145             .setKeysOfRow(3,
    146                     // U+17B6: "" KHMER VOWEL SIGN AA
    147                     // U+179F: "" KHMER LETTER SA
    148                     // U+178A: "" KHMER LETTER DA
    149                     // U+1790: "" KHMER LETTER THA
    150                     // U+1784: "" KHMER LETTER NGO
    151                     // U+17A0: "" KHMER LETTER HA
    152                     // U+17D2: "" KHMER SIGN COENG
    153                     // U+1780: "" KHMER LETTER KA
    154                     // U+179B: "" KHMER LETTER LO
    155                     // U+17BE: "" KHMER VOWEL SIGN OE
    156                     // U+17CB: "" KHMER SIGN BANTOC
    157                     "\u17B6", "\u179F", "\u178A", "\u1790", "\u1784", "\u17A0", "\u17D2", "\u1780",
    158                     "\u179B", "\u17BE", "\u17CB",
    159                     // U+17AE: "" KHMER INDEPENDENT VOWEL LYY
    160                     // U+17AD: "" KHMER INDEPENDENT VOWEL LY
    161                     // U+17B0: "" KHMER INDEPENDENT VOWEL QAI
    162                     key("\u17AE", joinMoreKeys("\u17AD", "\u17B0")))
    163             .setKeysOfRow(4,
    164                     // U+178B: "" KHMER LETTER TTHA
    165                     // U+1781: "" KHMER LETTER KHA
    166                     // U+1785: "" KHMER LETTER CA
    167                     // U+179C: "" KHMER LETTER VO
    168                     // U+1794: "" KHMER LETTER BA
    169                     // U+1793: "" KHMER LETTER NO
    170                     // U+1798: "" KHMER LETTER MO
    171                     // U+17BB/U+17C6: "" KHMER VOWEL SIGN U/KHMER SIGN NIKAHIT
    172                     // U+17D4: "" KHMER SIGN KHAN
    173                     // U+17CA: "" KHMER SIGN TRIISAP
    174                     "\u178B", "\u1781", "\u1785", "\u179C", "\u1794", "\u1793", "\u1798",
    175                     "\u17BB\u17C6", "\u17D4", "\u17CA")
    176             .build();
    177 
    178     private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder()
    179             .setKeysOfRow(1,
    180                     key("!", ZWJ_KEY),
    181                     // U+17D7: "" KHMER SIGN LEK TOO
    182                     key("\u17D7", ZWNJ_KEY),
    183                     // U+17D1: "" KHMER SIGN VIRIAM
    184                     key("\"", moreKey("\u17D1")),
    185                     // U+17DB: "" KHMER CURRENCY SYMBOL RIEL
    186                     key("\u17DB", joinMoreKeys(Symbols.DOLLAR_SIGN, Symbols.EURO_SIGN)),
    187                     // U+17D6: "" KHMER SIGN CAMNUC PII KUUH
    188                     key("%", moreKey("\u17D6")),
    189                     // U+17CD: "" KHMER SIGN TOANDAKHIAT
    190                     // U+17D9: "" KHMER SIGN PHNAEK MUAN
    191                     key("\u17CD", moreKey("\u17D9")),
    192                     // U+17D0: "" KHMER SIGN SAMYOK SANNYA
    193                     // U+17DA: "" KHMER SIGN KOOMUUT
    194                     key("\u17D0", moreKey("\u17DA")),
    195                     // U+17CF: "" KHMER SIGN AHSDA
    196                     key("\u17CF", moreKey("*")),
    197                     // U+00AB: "" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
    198                     key("(", joinMoreKeys("{", "\u00AB")),
    199                     // U+00BB: "" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
    200                     key(")", joinMoreKeys("}", "\u00BB")),
    201                     // U+17CC: "" KHMER SIGN ROBAT
    202                     // U+00D7: "" MULTIPLICATION SIGN
    203                     key("\u17CC", moreKey("\u00D7")),
    204                     // U+17CE: "" KHMER SIGN KAKABAT
    205                     "\u17CE")
    206             .setKeysOfRow(2,
    207                     // U+1788: "" KHMER LETTER CHO
    208                     // U+17DC: "" KHMER SIGN AVAKRAHASANYA
    209                     key("\u1788", moreKey("\u17DC")),
    210                     // U+17BA: "" KHMER VOWEL SIGN YY
    211                     // U+17DD: "" KHMER SIGN ATTHACAN
    212                     key("\u17BA", moreKey("\u17DD")),
    213                     // U+17C2: "" KHMER VOWEL SIGN AE
    214                     "\u17C2",
    215                     // U+17AC: "" KHMER INDEPENDENT VOWEL RYY
    216                     // U+17AB: "" KHMER INDEPENDENT VOWEL RY
    217                     key("\u17AC", moreKey("\u17AB")),
    218                     // U+1791: "" KHMER LETTER TO
    219                     // U+17BD: "" KHMER VOWEL SIGN UA
    220                     // U+17BC: "" KHMER VOWEL SIGN UU
    221                     // U+17B8: "" KHMER VOWEL SIGN II
    222                     // U+17C5: "" KHMER VOWEL SIGN AU
    223                     // U+1797: "" KHMER LETTER PHO
    224                     // U+17BF: "" KHMER VOWEL SIGN YA
    225                     // U+17B0: "" KHMER INDEPENDENT VOWEL QAI
    226                     "\u1791", "\u17BD", "\u17BC", "\u17B8", "\u17C5", "\u1797", "\u17BF", "\u17B0")
    227             .setKeysOfRow(3,
    228                     // U+17B6/U+17C6: "" KHMER VOWEL SIGN AA/KHMER SIGN NIKAHIT
    229                     // U+17C3: "" KHMER VOWEL SIGN AI
    230                     // U+178C: "" KHMER LETTER DO
    231                     // U+1792: "" KHMER LETTER THO
    232                     // U+17A2: "" KHMER LETTER QAE
    233                     "\u17B6\u17C6", "\u17C3", "\u178C", "\u1792", "\u17A2",
    234                     // U+17C7: "" KHMER SIGN REAHMUK
    235                     // U+17C8: "" KHMER SIGN YUUKALEAPINTU
    236                     key("\u17C7", moreKey("\u17C8")),
    237                     // U+1789: "" KHMER LETTER NYO
    238                     "\u1789",
    239                     // U+1782: "" KHMER LETTER KO
    240                     // U+179D: "" KHMER LETTER SHA
    241                     key("\u1782", moreKey("\u179D")),
    242                     // U+17A1: "" KHMER LETTER LA
    243                     // U+17C4/U+17C7: "" KHMER VOWEL SIGN OO/KHMER SIGN REAHMUK
    244                     // U+17C9: "" KHMER SIGN MUUSIKATOAN
    245                     // U+17AF: "" KHMER INDEPENDENT VOWEL QE
    246                     "\u17A1", "\u17C4\u17C7", "\u17C9", "\u17AF")
    247             .setKeysOfRow(4,
    248                     // U+178D: "" KHMER LETTER TTHO
    249                     // U+1783: "" KHMER LETTER KHO
    250                     // U+1787: "" KHMER LETTER CO
    251                     // U+17C1/U+17C7: "" KHMER VOWEL SIGN E/KHMER SIGN REAHMUK
    252                     "\u178D", "\u1783", "\u1787", "\u17C1\u17C7",
    253                     // U+1796: "" KHMER LETTER PO
    254                     // U+179E: "" KHMER LETTER SSO
    255                     key("\u1796", moreKey("\u179E")),
    256                     // U+178E: "" KHMER LETTER NNO
    257                     // U+17C6: "" KHMER SIGN NIKAHIT
    258                     // U+17BB/U+17C7: "" KHMER VOWEL SIGN U/KHMER SIGN REAHMUK
    259                     // U+17D5: "" KHMER SIGN BARIYOOSAN
    260                     "\u178E", "\u17C6", "\u17BB\u17C7", "\u17D5", "?")
    261             .build();
    262 }
    263