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 Armenian Phonetic alphabet keyboard.
     28  */
     29 public final class ArmenianPhonetic extends LayoutBase {
     30     private static final String LAYOUT_NAME = "armenian_phonetic";
     31 
     32     public ArmenianPhonetic(final Locale locale) {
     33         super(new ArmenianPhoneticCustomizer(locale), ArmenianSymbols.class,
     34                 ArmenianSymbolsShifted.class);
     35     }
     36 
     37     @Override
     38     public String getName() { return LAYOUT_NAME; }
     39 
     40     private static class ArmenianPhoneticCustomizer extends LayoutCustomizer {
     41         ArmenianPhoneticCustomizer(final Locale locale) { super(locale); }
     42 
     43         @Override
     44         public int getNumberOfRows() { return 5; }
     45 
     46         @Override
     47         public ExpectedKey getAlphabetKey() { return ARMENIAN_ALPHABET_KEY; }
     48 
     49         @Override
     50         public ExpectedKey[] getRightShiftKeys(final boolean isPhone) {
     51             if (isPhone) {
     52                 return EMPTY_KEYS;
     53             }
     54             // U+055C: "" ARMENIAN EXCLAMATION MARK
     55             // U+00A1: "" INVERTED EXCLAMATION MARK
     56             // U+055E: "" ARMENIAN QUESTION MARK
     57             // U+00BF: "" INVERTED QUESTION MARK
     58             return joinKeys(key("!", joinMoreKeys("\u055C", "\u00A1")),
     59                     key("?", joinMoreKeys("\u055E", "\u00BF")),
     60                     SHIFT_KEY);
     61         }
     62 
     63         @Override
     64         public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
     65             // U+055D: "" ARMENIAN COMMA
     66             return isPhone ? joinKeys(key("\u055D", SETTINGS_KEY))
     67                     : joinKeys(key("\u055D", SETTINGS_KEY));
     68         }
     69 
     70         @Override
     71         public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
     72             // U+0589: "" ARMENIAN FULL STOP
     73             final ExpectedKey fullStopKey = key("\u0589", getPunctuationMoreKeys(isPhone));
     74             return joinKeys(fullStopKey);
     75         }
     76 
     77         @Override
     78         public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) {
     79             return ARMENIAN_PUNCTUATION_MORE_KEYS;
     80         }
     81 
     82         // U+0531: "" ARMENIAN CAPITAL LETTER AYB
     83         // U+0532: "" ARMENIAN CAPITAL LETTER BEN
     84         // U+0533: "" ARMENIAN CAPITAL LETTER GIM
     85         private static final ExpectedKey ARMENIAN_ALPHABET_KEY = key(
     86                 "\u0531\u0532\u0533", Constants.CODE_SWITCH_ALPHA_SYMBOL);
     87 
     88         // U+055E: "" ARMENIAN QUESTION MARK
     89         // U+055C: "" ARMENIAN EXCLAMATION MARK
     90         // U+055A: "" ARMENIAN APOSTROPHE
     91         // U+0559: "" ARMENIAN MODIFIER LETTER LEFT HALF RING
     92         // U+055D: "" ARMENIAN COMMA
     93         // U+055B: "" ARMENIAN EMPHASIS MARK
     94         // U+058A: "" ARMENIAN HYPHEN
     95         // U+00BB: "" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
     96         // U+00AB: "" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
     97         // U+055F: "" ARMENIAN ABBREVIATION MARK
     98         private static final ExpectedKey[] ARMENIAN_PUNCTUATION_MORE_KEYS = joinMoreKeys(
     99                 ",", "\u055E", "\u055C", ".", "\u055A", "\u0559", "?", "!",
    100                 "\u055D", "\u055B", "\u058A", "\u00BB", "\u00AB", "\u055F", ";", ":");
    101     }
    102 
    103     @Override
    104     ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) {
    105         final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON);
    106         if (isPhone) {
    107             // U+056D: "" ARMENIAN SMALL LETTER XEH
    108             // U+0577: "" ARMENIAN SMALL LETTER SHA
    109             builder.addKeysOnTheRightOfRow(3, "\u056D")
    110                     .addKeysOnTheRightOfRow(4, "\u0577");
    111         } else {
    112             // U+056D: "" ARMENIAN SMALL LETTER XEH
    113             // U+0577: "" ARMENIAN SMALL LETTER SHA
    114             builder.addKeysOnTheRightOfRow(2, "\u056D")
    115                     .addKeysOnTheRightOfRow(3, "\u0577");
    116         }
    117         return builder.build();
    118     }
    119 
    120     private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
    121             .setKeysOfRow(1,
    122                     // U+0567: "" ARMENIAN SMALL LETTER EH
    123                     key("\u0567", moreKey("1")),
    124                     // U+0569: "" ARMENIAN SMALL LETTER TO
    125                     key("\u0569", moreKey("2")),
    126                     // U+0583: "" ARMENIAN SMALL LETTER PIWR
    127                     key("\u0583", moreKey("3")),
    128                     // U+0571: "" ARMENIAN SMALL LETTER JA
    129                     key("\u0571", moreKey("4")),
    130                     // U+057B: "" ARMENIAN SMALL LETTER JHEH
    131                     key("\u057B", moreKey("5")),
    132                     // U+0580: "" ARMENIAN SMALL LETTER REH
    133                     key("\u0580", moreKey("6")),
    134                     // U+0579: "" ARMENIAN SMALL LETTER CHA
    135                     key("\u0579", moreKey("7")),
    136                     // U+0573: "" ARMENIAN SMALL LETTER CHEH
    137                     key("\u0573", moreKey("8")),
    138                     // U+056A: "" ARMENIAN SMALL LETTER ZHE
    139                     key("\u056A", moreKey("9")),
    140                     // U+056E: "" ARMENIAN SMALL LETTER CA
    141                     key("\u056E", moreKey("0")))
    142             .setKeysOfRow(2,
    143                     // U+0584: "" ARMENIAN SMALL LETTER KEH
    144                     // U+0578: "" ARMENIAN SMALL LETTER VO
    145                     "\u0584", "\u0578",
    146                     // U+0565: "" ARMENIAN SMALL LETTER ECH
    147                     // U+0587: "" ARMENIAN SMALL LIGATURE ECH YIWN
    148                     key("\u0565", moreKey("\u0587")),
    149                     // U+057C: "" ARMENIAN SMALL LETTER RA
    150                     // U+057F: "" ARMENIAN SMALL LETTER TIWN
    151                     // U+0568: "" ARMENIAN SMALL LETTER ET
    152                     // U+0582: "" ARMENIAN SMALL LETTER YIWN
    153                     // U+056B: "" ARMENIAN SMALL LETTER INI
    154                     // U+0585: "" ARMENIAN SMALL LETTER OH
    155                     // U+057A: "" ARMENIAN SMALL LETTER PEH
    156                     "\u057C", "\u057F", "\u0568", "\u0582", "\u056B", "\u0585", "\u057A")
    157             .setKeysOfRow(3,
    158                     // U+0561: "" ARMENIAN SMALL LETTER AYB
    159                     // U+057D: "" ARMENIAN SMALL LETTER SEH
    160                     // U+0564: "" ARMENIAN SMALL LETTER DA
    161                     // U+0586: "" ARMENIAN SMALL LETTER FEH
    162                     // U+0563: "" ARMENIAN SMALL LETTER GIM
    163                     // U+0570: "" ARMENIAN SMALL LETTER HO
    164                     // U+0575: "" ARMENIAN SMALL LETTER YI
    165                     // U+056F: "" ARMENIAN SMALL LETTER KEN
    166                     // U+056C: "" ARMENIAN SMALL LETTER LIWN
    167                     "\u0561", "\u057D", "\u0564", "\u0586", "\u0563", "\u0570", "\u0575", "\u056F",
    168                     "\u056C")
    169             .setKeysOfRow(4,
    170                     // U+0566: "" ARMENIAN SMALL LETTER ZA
    171                     // U+0572: "" ARMENIAN SMALL LETTER GHAD
    172                     // U+0581: "" ARMENIAN SMALL LETTER CO
    173                     // U+057E: "" ARMENIAN SMALL LETTER VEW
    174                     // U+0562: "" ARMENIAN SMALL LETTER BEN
    175                     // U+0576: "" ARMENIAN SMALL LETTER NOW
    176                     // U+0574: "" ARMENIAN SMALL LETTER MEN
    177                     "\u0566", "\u0572", "\u0581", "\u057E", "\u0562", "\u0576", "\u0574")
    178             .build();
    179 
    180     private static final class ArmenianSymbols extends Symbols {
    181         public ArmenianSymbols(final LayoutCustomizer customizer) { super(customizer); }
    182 
    183         @Override
    184         public ExpectedKey[][] getLayout(final boolean isPhone) {
    185             final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(
    186                     super.getLayout(isPhone));
    187             // U+055D: "" ARMENIAN COMMA
    188             builder.replaceKeyOfLabel(",", "\u055D");
    189             // U+055C: "" ARMENIAN EXCLAMATION MARK
    190             // U+00A1: "" INVERTED EXCLAMATION MARK
    191             // U+055E: "" ARMENIAN QUESTION MARK
    192             // U+00BF: "" INVERTED QUESTION MARK
    193             builder.setMoreKeysOf("!", "\u055C", "\u00A1")
    194                     .setMoreKeysOf("?", "\u055E", "\u00BF");
    195             return builder.build();
    196         }
    197     }
    198 
    199     private static final class ArmenianSymbolsShifted extends SymbolsShifted {
    200         public ArmenianSymbolsShifted(final LayoutCustomizer customizer) { super(customizer); }
    201 
    202         @Override
    203         public ExpectedKey[][] getLayout(final boolean isPhone) {
    204             final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(
    205                     super.getLayout(isPhone));
    206             // U+055D: "" ARMENIAN COMMA
    207             builder.replaceKeyOfLabel(",", "\u055D");
    208             return builder.build();
    209         }
    210     }
    211 }
    212