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 static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*;
     20 
     21 import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer;
     22 import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols;
     23 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
     24 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
     25 
     26 import java.util.Locale;
     27 
     28 /**
     29  * The Hindi Compact keyboard.
     30  */
     31 public final class HindiCompact extends LayoutBase {
     32     private static final String LAYOUT_NAME = "hindi_compact";
     33 
     34     public HindiCompact(final LayoutCustomizer customizer) {
     35         super(customizer, HindiSymbols.class, SymbolsShifted.class);
     36     }
     37 
     38     @Override
     39     public String getName() { return LAYOUT_NAME; }
     40 
     41     public static class HindiCompactCustomizer extends HindiCustomizer {
     42         public HindiCompactCustomizer(final Locale locale) { super(locale); }
     43 
     44         @Override
     45         public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) {
     46             return EMPTY_KEYS;
     47         }
     48 
     49         @Override
     50         public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
     51             // U+0964: "" DEVANAGARI DANDA
     52             final ExpectedKey periodKey = key("\u0964", getPunctuationMoreKeys(isPhone));
     53             return joinKeys(periodKey);
     54         }
     55 
     56         @Override
     57         public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) {
     58             return isPhone ? HINDI_PHONE_PUNCTUATION_MORE_KEYS : HINDI_TABLET_PUNCTUATION_MORE_KEYS;
     59         }
     60 
     61         // Punctuation more keys for phone form factor.
     62         private static final ExpectedKey[] HINDI_PHONE_PUNCTUATION_MORE_KEYS = joinKeys(
     63                 ",", ".", "?", "!", "#", ")", "(", "/", ";",
     64                 "'", "@", ":", "-", "\"", "+", "%", "&");
     65         // Punctuation more keys for tablet form factor.
     66         private static final ExpectedKey[] HINDI_TABLET_PUNCTUATION_MORE_KEYS = joinKeys(
     67                 ",", ".", "'", "#", ")", "(", "/", ";",
     68                 "@", ":", "-", "\"", "+", "%", "&");
     69     }
     70 
     71     @Override
     72     ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
     73 
     74     @Override
     75     ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) {
     76         return null;
     77     }
     78 
     79     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
     80             .setKeysOfRow(1,
     81                     // U+0914: "" DEVANAGARI LETTER AU
     82                     // U+094C: "" DEVANAGARI VOWEL SIGN AU
     83                     // U+0967: "" DEVANAGARI DIGIT ONE
     84                     key("\u0914", joinMoreKeys(moreKey(VOWEL_SIGN_AU, "\u094C"), "\u0967", "1")),
     85                     // U+0910: "" DEVANAGARI LETTER AI
     86                     // U+0948: "" DEVANAGARI VOWEL SIGN AI
     87                     // U+0968: "" DEVANAGARI DIGIT TWO
     88                     key("\u0910", joinMoreKeys(moreKey(VOWEL_SIGN_AI, "\u0948"), "\u0968", "2")),
     89                     // U+0906: "" DEVANAGARI LETTER AA
     90                     // U+093E: "" DEVANAGARI VOWEL SIGN AA
     91                     // U+0969: "" DEVANAGARI DIGIT THREE
     92                     key("\u0906", joinMoreKeys(moreKey(VOWEL_SIGN_AA, "\u093E"), "\u0969", "3")),
     93                     // U+0908: "" DEVANAGARI LETTER II
     94                     // U+0940: "" DEVANAGARI VOWEL SIGN II
     95                     // U+096A: "" DEVANAGARI DIGIT FOUR
     96                     key("\u0908", joinMoreKeys(moreKey(VOWEL_SIGN_II, "\u0940"), "\u096A", "4")),
     97                     // U+090A: "" DEVANAGARI LETTER UU
     98                     // U+0942: "" DEVANAGARI VOWEL SIGN UU
     99                     // U+096B: "" DEVANAGARI DIGIT FIVE
    100                     key("\u090A", joinMoreKeys(moreKey(VOWEL_SIGN_UU, "\u0942"), "\u096B", "5")),
    101                     // U+092C: "" DEVANAGARI LETTER BA
    102                     // U+092D: "" DEVANAGARI LETTER BHA
    103                     // U+096C: "" DEVANAGARI DIGIT SIX
    104                     key("\u092C", joinMoreKeys("\u092D", "\u096C", "6")),
    105                     // U+0939: "" DEVANAGARI LETTER HA
    106                     // U+096D: "" DEVANAGARI DIGIT SEVEN
    107                     key("\u0939", joinMoreKeys("\u096D", "7")),
    108                     // U+0917: "" DEVANAGARI LETTER GA
    109                     // U+0918: "" DEVANAGARI LETTER GHA
    110                     // U+096E: "" DEVANAGARI DIGIT EIGHT
    111                     key("\u0917", joinMoreKeys("\u0918", "\u096E", "8")),
    112                     // U+0926: "" DEVANAGARI LETTER DA
    113                     // U+0927: "" DEVANAGARI LETTER DHA
    114                     // U+096F: "" DEVANAGARI DIGIT NINE
    115                     key("\u0926", joinMoreKeys("\u0927", "\u096F", "9")),
    116                     // U+091C: "" DEVANAGARI LETTER JA
    117                     // U+091D: "" DEVANAGARI LETTER JHA
    118                     // U+091C/U+094D/U+091E:
    119                     //     "" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA
    120                     // U+0966: "" DEVANAGARI DIGIT ZERO
    121                     key("\u091C", joinMoreKeys("\u091D", "\u091C\u094D\u091E", "\u0966", "0")),
    122                     // U+0921: "" DEVANAGARI LETTER DDA
    123                     // U+0922: "" DEVANAGARI LETTER DDHA
    124                     key("\u0921", moreKey("\u0922")))
    125             .setKeysOfRow(2,
    126                     // U+0913: "" DEVANAGARI LETTER O
    127                     // U+094B: "" DEVANAGARI VOWEL SIGN O
    128                     key("\u0913", moreKey(VOWEL_SIGN_O, "\u094B")),
    129                     // U+090F: "" DEVANAGARI LETTER E
    130                     // U+0947: "" DEVANAGARI VOWEL SIGN E
    131                     key("\u090F", moreKey(VOWEL_SIGN_E, "\u0947")),
    132                     // U+0905: "" DEVANAGARI LETTER A
    133                     // U+094D: "" DEVANAGARI SIGN VIRAMA
    134                     key("\u0905", moreKey(SIGN_VIRAMA, "\u094D")),
    135                     // U+0907: "" DEVANAGARI LETTER I
    136                     // U+093F: "" DEVANAGARI VOWEL SIGN I
    137                     key("\u0907", moreKey(VOWEL_SIGN_I, "\u093F")),
    138                     // U+0909: "" DEVANAGARI LETTER U
    139                     // U+0941: "" DEVANAGARI VOWEL SIGN U
    140                     key("\u0909", moreKey(VOWEL_SIGN_U, "\u0941")),
    141                     // U+092A: "" DEVANAGARI LETTER PA
    142                     // U+092B: "" DEVANAGARI LETTER PHA
    143                     key("\u092A", moreKey("\u092B")),
    144                     // U+0930: "" DEVANAGARI LETTER RA
    145                     // U+090B: "" DEVANAGARI LETTER VOCALIC R
    146                     // U+0943: "" DEVANAGARI VOWEL SIGN VOCALIC R
    147                     key("\u0930", joinMoreKeys("\u090B", moreKey(VOWEL_SIGN_VOCALIC_R, "\u0943"))),
    148                     // U+0915: "" DEVANAGARI LETTER KA
    149                     // U+0916: "" DEVANAGARI LETTER KHA
    150                     key("\u0915", moreKey("\u0916")),
    151                     // U+0924: "" DEVANAGARI LETTER TA
    152                     // U+0925: "" DEVANAGARI LETTER THA
    153                     // U+0924/U+094D/U+0930:
    154                     //     "" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
    155                     key("\u0924", joinMoreKeys("\u0925", "\u0924\u094D\u0930")),
    156                     // U+091A: "" DEVANAGARI LETTER CA
    157                     // U+091B: "" DEVANAGARI LETTER CHA
    158                     key("\u091A", moreKey("\u091B")),
    159                     // U+091F: "" DEVANAGARI LETTER TTA
    160                     // U+0920: "" DEVANAGARI LETTER TTHA
    161                     key("\u091F", moreKey("\u0920")))
    162             .setKeysOfRow(3,
    163                     // U+0911: "" DEVANAGARI LETTER CANDRA O
    164                     // U+0949: "" DEVANAGARI VOWEL SIGN CANDRA O
    165                     key("\u0911", moreKey(VOWEL_SIGN_CANDRA_O, "\u0949")),
    166                     // U+094D: "" DEVANAGARI SIGN VIRAMA
    167                     // U+0945: "" DEVANAGARI VOWEL SIGN CANDRA E
    168                     // U+090D: "" DEVANAGARI LETTER CANDRA E
    169                     key(SIGN_VIRAMA, "\u094D", joinMoreKeys(
    170                             moreKey(VOWEL_SIGN_CANDRA_E, "\u0945"), "\u090D")),
    171                     // U+0902: "" DEVANAGARI SIGN ANUSVARA
    172                     // U+0903: "" DEVANAGARI SIGN VISARGA
    173                     // U+0901: "" DEVANAGARI SIGN CANDRABINDU
    174                     // U+093C: "" DEVANAGARI SIGN NUKTA
    175                     key(SIGN_ANUSVARA, "\u0902", joinMoreKeys(
    176                             moreKey(SIGN_VISARGA, "\u0903"),
    177                             moreKey(SIGN_CANDRABINDU, "\u0901"),
    178                             moreKey(SIGN_NUKTA, "\u093C"))),
    179                     // U+092E: "" DEVANAGARI LETTER MA
    180                     // U+0950: "" DEVANAGARI OM
    181                     key("\u092E", moreKey("\u0950")),
    182                     // U+0928: "" DEVANAGARI LETTER NA
    183                     // U+0923: "" DEVANAGARI LETTER NNA
    184                     // U+091E: "" DEVANAGARI LETTER NYA
    185                     // U+0919: "" DEVANAGARI LETTER NGA
    186                     key("\u0928", joinMoreKeys("\u0923", "\u091E", "\u0919")),
    187                     // U+0935: "" DEVANAGARI LETTER VA
    188                     // U+0932: "" DEVANAGARI LETTER LA
    189                     "\u0935", "\u0932",
    190                     // U+0938: "" DEVANAGARI LETTER SA
    191                     // U+0936: "" DEVANAGARI LETTER SHA
    192                     // U+0937: "" DEVANAGARI LETTER SSA
    193                     // U+0936/U+094D/U+0930:
    194                     //     "" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
    195                     key("\u0938", joinMoreKeys("\u0936", "\u0937", "\u0936\u094D\u0930")),
    196                     // U+092F: "" DEVANAGARI LETTER YA
    197                     // U+0915/U+094D/U+0937:
    198                     //     "" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA
    199                     "\u092F", "\u0915\u094D\u0937")
    200             .build();
    201 }
    202