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.Symbols.RtlSymbols; 20 import com.android.inputmethod.keyboard.layout.SymbolsShifted.RtlSymbolsShifted; 21 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; 22 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; 23 import com.android.inputmethod.latin.Constants; 24 25 import java.util.Locale; 26 27 public final class Hebrew extends LayoutBase { 28 private static final String LAYOUT_NAME = "hebrew"; 29 30 public Hebrew(final LayoutCustomizer customizer) { 31 super(customizer, HebrewSymbols.class, RtlSymbolsShifted.class); 32 } 33 34 @Override 35 public String getName() { return LAYOUT_NAME; } 36 37 public static class HebrewCustomizer extends LayoutCustomizer { 38 public HebrewCustomizer(final Locale locale) { 39 super(locale); 40 } 41 42 @Override 43 public ExpectedKey getAlphabetKey() { return HEBREW_ALPHABET_KEY; } 44 45 @Override 46 public ExpectedKey getCurrencyKey() { return CURRENCY_NEW_SHEQEL; } 47 48 @Override 49 public ExpectedKey[] getOtherCurrencyKeys() { 50 return SymbolsShifted.CURRENCIES_OTHER_GENERIC; 51 } 52 53 @Override 54 public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_LR9; } 55 56 @Override 57 public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_LR9; } 58 59 @Override 60 public ExpectedKey[] getDoubleAngleQuoteKeys() { 61 return RtlSymbols.DOUBLE_ANGLE_QUOTES_LR_RTL; 62 } 63 64 @Override 65 public ExpectedKey[] getSingleAngleQuoteKeys() { 66 return RtlSymbols.SINGLE_ANGLE_QUOTES_LR_RTL; 67 } 68 69 @Override 70 public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { 71 return EMPTY_KEYS; 72 } 73 74 @Override 75 public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { 76 return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; 77 } 78 79 @Override 80 public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { 81 return isPhone ? RTL_PHONE_PUNCTUATION_MORE_KEYS 82 : RTL_TABLET_PUNCTUATION_MORE_KEYS; 83 } 84 85 // U+05D0: "" HEBREW LETTER ALEF 86 // U+05D1: "" HEBREW LETTER BET 87 // U+05D2: "" HEBREW LETTER GIMEL 88 private static final ExpectedKey HEBREW_ALPHABET_KEY = key( 89 "\u05D0\u05D1\u05D2", Constants.CODE_SWITCH_ALPHA_SYMBOL); 90 // U+20AA: "" NEW SHEQEL SIGN 91 private static final ExpectedKey CURRENCY_NEW_SHEQEL = key("\u20AA", 92 Symbols.CURRENCY_GENERIC_MORE_KEYS); 93 private static final ExpectedKey[] RTL_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( 94 ",", "?", "!", "#", key(")", "("), key("(", ")"), "/", ";", 95 "'", "@", ":", "-", "\"", "+", "%", "&"); 96 // Punctuation more keys for tablet form factor. 97 private static final ExpectedKey[] RTL_TABLET_PUNCTUATION_MORE_KEYS = joinKeys( 98 ",", "'", "#", key(")", "("), key("(", ")"), "/", ";", 99 "@", ":", "-", "\"", "+", "%", "&"); 100 } 101 102 @Override 103 ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } 104 105 @Override 106 ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { 107 return null; 108 } 109 110 private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() 111 .setKeysOfRow(1, 112 key("'", joinMoreKeys("1", "\"")), 113 key("-", joinMoreKeys("2", "_")), 114 // U+05E7: "" HEBREW LETTER QOF 115 key("\u05E7", moreKey("3")), 116 // U+05E8: "" HEBREW LETTER RESH 117 key("\u05E8", moreKey("4")), 118 // U+05D0: "" HEBREW LETTER ALEF 119 key("\u05D0", moreKey("5")), 120 // U+05D8: "" HEBREW LETTER TET 121 key("\u05D8", moreKey("6")), 122 // U+05D5: "" HEBREW LETTER VAV 123 key("\u05D5", moreKey("7")), 124 // U+05DF: "" HEBREW LETTER FINAL NUN 125 key("\u05DF", moreKey("8")), 126 // U+05DD: "" HEBREW LETTER FINAL MEM 127 key("\u05DD", moreKey("9")), 128 // U+05E4: "" HEBREW LETTER PE 129 key("\u05E4", moreKey("0"))) 130 .setKeysOfRow(2, 131 // U+05E9: "" HEBREW LETTER SHIN 132 // U+05D3: "" HEBREW LETTER DALET 133 "\u05E9", "\u05D3", 134 // U+05D2: "" HEBREW LETTER GIMEL 135 // U+05D2 U+05F3: "" HEBREW LETTER GIMEL + HEBREW PUNCTUATION GERESH 136 key("\u05D2", moreKey("\u05D2\u05F3")), 137 // U+05DB: "" HEBREW LETTER KAF 138 // U+05E2: "" HEBREW LETTER AYIN 139 "\u05DB", "\u05E2", 140 // U+05D9: "" HEBREW LETTER YOD 141 // U+05F2 U+05B7: "" HEBREW LIGATURE YIDDISH DOUBLE YOD + HEBREW POINT PATAH 142 key("\u05D9", moreKey("\u05F2\u05B7")), 143 // U+05D7: "" HEBREW LETTER HET 144 // U+05D7 U+05F3: "" HEBREW LETTER HET + HEBREW PUNCTUATION GERESH 145 key("\u05D7", moreKey("\u05D7\u05F3")), 146 // U+05DC: "" HEBREW LETTER LAMED 147 // U+05DA: "" HEBREW LETTER FINAL KAF 148 // U+05E3: "" HEBREW LETTER FINAL PE 149 "\u05DC", "\u05DA", "\u05E3") 150 .setKeysOfRow(3, 151 // U+05D6: "" HEBREW LETTER ZAYIN 152 // U+05D6 U+05F3: "" HEBREW LETTER ZAYIN + HEBREW PUNCTUATION GERESH 153 key("\u05D6", moreKey("\u05D6\u05F3")), 154 // U+05E1: "" HEBREW LETTER SAMEKH 155 // U+05D1: "" HEBREW LETTER BET 156 // U+05D4: "" HEBREW LETTER HE 157 // U+05E0: "" HEBREW LETTER NUN 158 // U+05DE: "" HEBREW LETTER MEM 159 "\u05E1", "\u05D1", "\u05D4", "\u05E0", "\u05DE", 160 // U+05E6: "" HEBREW LETTER TSADI 161 // U+05E6 U+05F3: "" HEBREW LETTER TSADI + HEBREW PUNCTUATION GERESH 162 key("\u05E6", moreKey("\u05E6\u05F3")), 163 // U+05EA: "" HEBREW LETTER TAV 164 // U+05EA U+05F3: "" HEBREW LETTER TAV + HEBREW PUNCTUATION GERESH 165 key("\u05EA", moreKey("\u05EA\u05F3")), 166 // U+05E5: "" HEBREW LETTER FINAL TSADI 167 // U+05E5 U+05F3: "" HEBREW LETTER FINAL TSADI + HEBREW PUNCTUATION GERESH 168 key("\u05E5", moreKey("\u05E5\u05F3"))) 169 .build(); 170 171 private static class HebrewSymbols extends RtlSymbols { 172 public HebrewSymbols(final LayoutCustomizer customizer) { 173 super(customizer); 174 } 175 176 @Override 177 public ExpectedKey[][] getLayout(final boolean isPhone) { 178 return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) 179 // U+00B1: "" PLUS-MINUS SIGN 180 // U+FB29: "" HEBREW LETTER ALTERNATIVE PLUS SIGN 181 .setMoreKeysOf("+", "\u00B1", "\uFB29") 182 // U+2605: "" BLACK STAR 183 .setMoreKeysOf("*", "\u2605") 184 .build(); 185 } 186 } 187 } 188