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.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 Malayalam keyboard.
     28  */
     29 public final class Malayalam extends LayoutBase {
     30     private static final String LAYOUT_NAME = "malayalam";
     31 
     32     public Malayalam(final Locale locale) {
     33         super(new MalayalamCustomizer(locale), Symbols.class, SymbolsShifted.class);
     34     }
     35 
     36     @Override
     37     public String getName() { return LAYOUT_NAME; }
     38 
     39     private static class MalayalamCustomizer extends LayoutCustomizer {
     40         MalayalamCustomizer(final Locale locale) { super(locale); }
     41 
     42         @Override
     43         public ExpectedKey getAlphabetKey() { return MALAYALAM_ALPHABET_KEY; }
     44 
     45         @Override
     46         public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; }
     47 
     48         @Override
     49         public ExpectedKey[] getOtherCurrencyKeys() {
     50             return SymbolsShifted.CURRENCIES_OTHER_GENERIC;
     51         }
     52 
     53         @Override
     54         public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) {
     55             return EMPTY_KEYS;
     56         }
     57 
     58         @Override
     59         public ExpectedKey[] getRightShiftKeys(final boolean isPhone) {
     60             return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS;
     61         }
     62 
     63         // U+0D05: "" MALAYALAM LETTER A
     64         private static final ExpectedKey MALAYALAM_ALPHABET_KEY = key(
     65                 "\u0D05", Constants.CODE_SWITCH_ALPHA_SYMBOL);
     66 
     67         // U+20B9: "" INDIAN RUPEE SIGN
     68         private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9",
     69                 Symbols.CURRENCY_GENERIC_MORE_KEYS);
     70     }
     71 
     72     @Override
     73     ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
     74 
     75     @Override
     76     ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) {
     77         return null;
     78     }
     79 
     80     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
     81             .setKeysOfRow(1,
     82                     // U+0D4D: "" MALAYALAM SIGN VIRAMA
     83                     // U+0D05: "" MALAYALAM LETTER A
     84                     key("\u0D4D", joinMoreKeys("\u0D05", "1")),
     85                     // U+0D3E: "" MALAYALAM VOWEL SIGN AA
     86                     // U+0D06: "" MALAYALAM LETTER AA
     87                     key("\u0D3E", joinMoreKeys("\u0D06", "2")),
     88                     // U+0D3F: "" MALAYALAM VOWEL SIGN I
     89                     // U+0D07: "" MALAYALAM LETTER I
     90                     key("\u0D3F", joinMoreKeys("\u0D07", "3")),
     91                     // U+0D40: "" MALAYALAM VOWEL SIGN II
     92                     // U+0D08: "" MALAYALAM LETTER II
     93                     key("\u0D40", joinMoreKeys("\u0D08", "4")),
     94                     // U+0D41: "" MALAYALAM VOWEL SIGN U
     95                     // U+0D09: "" MALAYALAM LETTER U
     96                     key("\u0D41", joinMoreKeys("\u0D09", "5")),
     97                     // U+0D42: "" MALAYALAM VOWEL SIGN UU
     98                     // U+0D0A: "" MALAYALAM LETTER UU
     99                     key("\u0D42", joinMoreKeys("\u0D0A", "6")),
    100                     // U+0D43: "" MALAYALAM VOWEL SIGN VOCALIC R
    101                     // U+0D0B: "" MALAYALAM LETTER VOCALIC R
    102                     key("\u0D43", joinMoreKeys("\u0D0B", "7")),
    103                     // U+0D46: "" MALAYALAM VOWEL SIGN E
    104                     // U+0D0E: "" MALAYALAM LETTER E
    105                     // U+0D10: "" MALAYALAM LETTER AI
    106                     // U+0D48: "" MALAYALAM VOWEL SIGN AI
    107                     key("\u0D46", joinMoreKeys("\u0D0E", "\u0D10", "\u0D48", "8")),
    108                     // U+0D47: "" MALAYALAM VOWEL SIGN EE
    109                     // U+0D0F: "" MALAYALAM LETTER EE
    110                     key("\u0D47", joinMoreKeys("\u0D0F", "9")),
    111                     // U+0D4A: "" MALAYALAM VOWEL SIGN O
    112                     // U+0D12: "" MALAYALAM LETTER O
    113                     key("\u0D4A", joinMoreKeys("\u0D12", "0")),
    114                     // U+0D4B: "" MALAYALAM VOWEL SIGN OO
    115                     // U+0D13: "" MALAYALAM LETTER OO
    116                     // U+0D14: "" MALAYALAM LETTER AU
    117                     // U+0D57: "" MALAYALAM AU LENGTH MARK
    118                     key("\u0D4B", joinMoreKeys("\u0D13", "\u0D14", "\u0D57")))
    119             .setKeysOfRow(2,
    120                     // U+0D15: "" MALAYALAM LETTER KA
    121                     // U+0D16: "" MALAYALAM LETTER KHA
    122                     key("\u0D15", moreKey("\u0D16")),
    123                     // U+0D17: "" MALAYALAM LETTER GA
    124                     // U+0D18: "" MALAYALAM LETTER GHA
    125                     key("\u0D17", moreKey("\u0D18")),
    126                     // U+0D19: "" MALAYALAM LETTER NGA
    127                     // U+0D1E: "" MALAYALAM LETTER NYA
    128                     key("\u0D19", moreKey("\u0D1E")),
    129                     // U+0D1A: "" MALAYALAM LETTER CA
    130                     // U+0D1B: "" MALAYALAM LETTER CHA
    131                     key("\u0D1A", moreKey("\u0D1B")),
    132                     // U+0D1C: "" MALAYALAM LETTER JA
    133                     // U+0D1D: "" MALAYALAM LETTER JHA
    134                     key("\u0D1C", moreKey("\u0D1D")),
    135                     // U+0D1F: "" MALAYALAM LETTER TTA
    136                     // U+0D20: "" MALAYALAM LETTER TTHA
    137                     key("\u0D1F", moreKey("\u0D20")),
    138                     // U+0D21: "" MALAYALAM LETTER DDA
    139                     // U+0D22: "" MALAYALAM LETTER DDHA
    140                     key("\u0D21", moreKey("\u0D22")),
    141                     // U+0D23: "" MALAYALAM LETTER NNA
    142                     // U+0D7A: "" MALAYALAM LETTER CHILLU NN
    143                     key("\u0D23", moreKey("\u0D7A")),
    144                     // U+0D24: "" MALAYALAM LETTER TA
    145                     // U+0D25: "" MALAYALAM LETTER THA
    146                     key("\u0D24", moreKey("\u0D25")),
    147                     // U+0D26: "" MALAYALAM LETTER DA
    148                     // U+0D27: "" MALAYALAM LETTER DHA
    149                     key("\u0D26", moreKey("\u0D27")),
    150                     // U+0D28: "" MALAYALAM LETTER NA
    151                     // U+0D7B: "" MALAYALAM LETTER CHILLU N
    152                     key("\u0D28", moreKey("\u0D7B")))
    153             .setKeysOfRow(3,
    154                     // U+0D2A: "" MALAYALAM LETTER PA
    155                     // U+0D2B: "" MALAYALAM LETTER PHA
    156                     key("\u0D2A", moreKey("\u0D2B")),
    157                     // U+0D2C: "" MALAYALAM LETTER BA
    158                     // U+0D2D: "" MALAYALAM LETTER BHA
    159                     key("\u0D2C", moreKey("\u0D2D")),
    160                     // U+0D2E: "" MALAYALAM LETTER MA
    161                     // U+0D02: "" MALAYALAM SIGN ANUSVARA
    162                     key("\u0D2E", moreKey("\u0D02")),
    163                     // U+0D2F: "" MALAYALAM LETTER YA
    164                     // U+0D4D/U+0D2F: "" MALAYALAM SIGN VIRAMA/MALAYALAM LETTER YA
    165                     key("\u0D2F", moreKey("\u0D4D\u0D2F")),
    166                     // U+0D30: "" MALAYALAM LETTER RA
    167                     // U+0D4D/U+0D30: "" MALAYALAM SIGN VIRAMA/MALAYALAM LETTER RA
    168                     // U+0D7C: "" MALAYALAM LETTER CHILLU RR
    169                     // U+0D31: "" MALAYALAM LETTER RRA
    170                     key("\u0D30", joinMoreKeys("\u0D4D\u0D30", "\u0D7C", "\u0D31")),
    171                     // U+0D32: "" MALAYALAM LETTER LA
    172                     // U+0D7D: "" MALAYALAM LETTER CHILLU L
    173                     key("\u0D32", moreKey("\u0D7D")),
    174                     // U+0D35: "" MALAYALAM LETTER VA
    175                     // U+0D4D/U+0D35: "" MALAYALAM SIGN VIRAMA/MALAYALAM LETTER VA
    176                     key("\u0D35", moreKey("\u0D4D\u0D35")),
    177                     // U+0D36: "" MALAYALAM LETTER SHA
    178                     // U+0D37: "" MALAYALAM LETTER SSA
    179                     // U+0D38: "" MALAYALAM LETTER SA
    180                     key("\u0D36", joinMoreKeys("\u0D37", "\u0D38")),
    181                     // U+0D39: "" MALAYALAM LETTER HA
    182                     // U+0D03: "" MALAYALAM SIGN VISARGA
    183                     key("\u0D39", moreKey("\u0D03")),
    184                     // U+0D33: "" MALAYALAM LETTER LLA
    185                     // U+0D7E: "" MALAYALAM LETTER CHILLU LL
    186                     // U+0D34: "" MALAYALAM LETTER LLLA
    187                     key("\u0D33", joinMoreKeys("\u0D7E", "\u0D34")))
    188             .build();
    189 }
    190