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 Kannada keyboard.
     28  */
     29 public final class Kannada extends LayoutBase {
     30     private static final String LAYOUT_NAME = "kannada";
     31 
     32     public Kannada(final Locale locale) {
     33         super(new KannadaCustomizer(locale), Symbols.class, SymbolsShifted.class);
     34     }
     35 
     36     @Override
     37     public String getName() { return LAYOUT_NAME; }
     38 
     39     private static class KannadaCustomizer extends LayoutCustomizer {
     40         KannadaCustomizer(final Locale locale) { super(locale); }
     41 
     42         @Override
     43         public ExpectedKey getAlphabetKey() { return KANNADA_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         @Override
     64         public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
     65             return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
     66         }
     67 
     68         // U+0C85: "" KANNADA LETTER A
     69         // U+0C86: "" KANNADA LETTER AA
     70         // U+0C87: "" KANNADA LETTER I
     71         private static final ExpectedKey KANNADA_ALPHABET_KEY = key(
     72                 "\u0C85\u0C86\u0C87", Constants.CODE_SWITCH_ALPHA_SYMBOL);
     73 
     74         // U+20B9: "" INDIAN RUPEE SIGN
     75         private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9",
     76                 Symbols.CURRENCY_GENERIC_MORE_KEYS);
     77     }
     78 
     79     @Override
     80     ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
     81 
     82     @Override
     83     ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) {
     84         return null;
     85     }
     86 
     87     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
     88             .setKeysOfRow(1,
     89                     // U+0CCC: "" KANNADA VOWEL SIGN AU
     90                     // U+0C94: "" KANNADA LETTER AU
     91                     // U+0CE7: "" KANNADA DIGIT ONE
     92                     key("\u0CCC", joinMoreKeys("\u0C94", "\u0CE7", "1")),
     93                     // U+0CC8: "" KANNADA VOWEL SIGN AI
     94                     // U+0C90: "" KANNADA LETTER AI
     95                     // U+0CE8: "" KANNADA DIGIT TWO
     96                     key("\u0CC8", joinMoreKeys("\u0C90", "\u0CE8", "2")),
     97                     // U+0CBE: "" KANNADA VOWEL SIGN AA
     98                     // U+0C86: "" KANNADA LETTER AA
     99                     // U+0CE9: "" KANNADA DIGIT THREE
    100                     key("\u0CBE", joinMoreKeys("\u0C86", "\u0CE9", "3")),
    101                     // U+0CC0: "" KANNADA VOWEL SIGN II
    102                     // U+0C88: "" KANNADA LETTER II
    103                     // U+0CEA: "" KANNADA DIGIT FOUR
    104                     key("\u0CC0", joinMoreKeys("\u0C88", "\u0CEA", "4")),
    105                     // U+0CC2: "" KANNADA VOWEL SIGN UU
    106                     // U+0C8A: "" KANNADA LETTER UU
    107                     // U+0CEB: "" KANNADA DIGIT FIVE
    108                     key("\u0CC2", joinMoreKeys("\u0C8A", "\u0CEB", "5")),
    109                     // U+0CAC: "" KANNADA LETTER BA
    110                     // U+0CAD: "" KANNADA LETTER BHA
    111                     // U+0CEC: "" KANNADA DIGIT SIX
    112                     key("\u0CAC", joinMoreKeys("\u0CAD", "\u0CEC", "6")),
    113                     // U+0CB9: "" KANNADA LETTER HA
    114                     // U+0C99: "" KANNADA LETTER NGA
    115                     // U+0CED: "" KANNADA DIGIT SEVEN
    116                     key("\u0CB9", joinMoreKeys("\u0C99", "\u0CED", "7")),
    117                     // U+0C97: "" KANNADA LETTER GA
    118                     // U+0C98: "" KANNADA LETTER GHA
    119                     // U+0CEE: "" KANNADA DIGIT EIGHT
    120                     key("\u0C97", joinMoreKeys("\u0C98", "\u0CEE", "8")),
    121                     // U+0CA6: "" KANNADA LETTER DA
    122                     // U+0CA7: "" KANNADA LETTER DHA
    123                     // U+0CEF: "" KANNADA DIGIT NINE
    124                     key("\u0CA6", joinMoreKeys("\u0CA7", "\u0CEF", "9")),
    125                     // U+0C9C: "" KANNADA LETTER JA
    126                     // U+0C9D: "" KANNADA LETTER JHA
    127                     // U+0CE6: "" KANNADA DIGIT ZERO
    128                     key("\u0C9C", joinMoreKeys("\u0C9D", "\u0CE6", "0")),
    129                     // U+0CA1: "" KANNADA LETTER DDA
    130                     // U+0CA2: "" KANNADA LETTER DDHA
    131                     key("\u0CA1", moreKey("\u0CA2")))
    132             .setKeysOfRow(2,
    133                     // U+0CCB: "" KANNADA VOWEL SIGN OO
    134                     // U+0C93: "" KANNADA LETTER OO
    135                     key("\u0CCB", moreKey("\u0C93")),
    136                     // U+0CC7: "" KANNADA VOWEL SIGN EE
    137                     // U+0C8F: "" KANNADA LETTER EE
    138                     key("\u0CC7", moreKey("\u0C8F")),
    139                     // U+0CCD: "" KANNADA SIGN VIRAMA
    140                     // U+0C85: "" KANNADA LETTER A
    141                     key("\u0CCD", moreKey("\u0C85")),
    142                     // U+0CBF: "" KANNADA VOWEL SIGN I
    143                     // U+0C87: "" KANNADA LETTER I
    144                     key("\u0CBF", moreKey("\u0C87")),
    145                     // U+0CC1: "" KANNADA VOWEL SIGN U
    146                     // U+0C89: "" KANNADA LETTER U
    147                     key("\u0CC1", moreKey("\u0C89")),
    148                     // U+0CAA: "" KANNADA LETTER PA
    149                     // U+0CAB: "" KANNADA LETTER PHA
    150                     key("\u0CAA", moreKey("\u0CAB")),
    151                     // U+0CB0: "" KANNADA LETTER RA
    152                     // U+0CB1: "" KANNADA LETTER RRA
    153                     // U+0CC3: "" KANNADA VOWEL SIGN VOCALIC R
    154                     key("\u0CB0", joinMoreKeys("\u0CB1", "\u0CC3")),
    155                     // U+0C95: "" KANNADA LETTER KA
    156                     // U+0C96: "" KANNADA LETTER KHA
    157                     key("\u0C95", moreKey("\u0C96")),
    158                     // U+0CA4: "" KANNADA LETTER TA
    159                     // U+0CA5: "" KANNADA LETTER THA
    160                     key("\u0CA4", moreKey("\u0CA5")),
    161                     // U+0C9A: "" KANNADA LETTER CA
    162                     // U+0C9B: "" KANNADA LETTER CHA
    163                     key("\u0C9A", moreKey("\u0C9B")),
    164                     // U+0C9F: "" KANNADA LETTER TTA
    165                     // U+0CA0: "" KANNADA LETTER TTHA
    166                     key("\u0C9F", moreKey("\u0CA0")))
    167             .setKeysOfRow(3,
    168                     // U+0CC6: "" KANNADA VOWEL SIGN E
    169                     // U+0C92: "" KANNADA LETTER O
    170                     key("\u0CC6", moreKey("\u0C92")),
    171                     // U+0C82: "" KANNADA SIGN ANUSVARA
    172                     // U+0C8E: "" KANNADA LETTER E
    173                     key("\u0C82", moreKey("\u0C8E")),
    174                     // U+0CAE: "" KANNADA LETTER MA
    175                     "\u0CAE",
    176                     // U+0CA8: "" KANNADA LETTER NA
    177                     // U+0CA3: "" KANNADA LETTER NNA
    178                     key("\u0CA8", moreKey("\u0CA3")),
    179                     // U+0CB5: "" KANNADA LETTER VA
    180                     "\u0CB5",
    181                     // U+0CB2: "" KANNADA LETTER LA
    182                     // U+0CB3: "" KANNADA LETTER LLA
    183                     key("\u0CB2", moreKey("\u0CB3")),
    184                     // U+0CB8: "" KANNADA LETTER SA
    185                     // U+0CB6: "" KANNADA LETTER SHA
    186                     key("\u0CB8", moreKey("\u0CB6")),
    187                     // U+0C8B: "" KANNADA LETTER VOCALIC R
    188                     // U+0CCD/U+0CB0: "" KANNADA SIGN VIRAMA/KANNADA LETTER RA
    189                     key("\u0C8B", moreKey("\u0CCD\u0CB0")),
    190                     // U+0CB7: "" KANNADA LETTER SSA
    191                     // U+0C95/U+0CCD/U+0CB7:
    192                     //     "" KANNADA LETTER RA/KANNADA SIGN VIRAMA/KANNADA LETTER SSA
    193                     key("\u0CB7", moreKey("\u0C95\u0CCD\u0CB7")),
    194                     // U+0CAF: "" KANNADA LETTER YA
    195                     // U+0C9C/U+0CCD/U+0C9E:
    196                     //     "" KANNADA LETTER JA/KANNADA SIGN VIRAMA/KANNADA LETTER NYA
    197                     key("\u0CAF", moreKey("\u0C9C\u0CCD\u0C9E")))
    198             .build();
    199 }
    200