Add QWERTY expected keyboard layouts
Bug: 13017434 Change-Id: Ia8a65b692521f0050f003e20712a5873a0b236b4main
parent
ad04ed5460
commit
238e9898cd
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.keyboard.layout;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.LayoutBase;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The generic upper case alphabet keyboard layout.
|
||||||
|
*/
|
||||||
|
public final class AlphabetShifted extends LayoutBase {
|
||||||
|
public static ExpectedKey[][] getAlphabet(final ExpectedKey[][] lowerCaseKeyboard,
|
||||||
|
final Locale locale) {
|
||||||
|
final ExpectedKey[][] upperCaseKeyboard = ExpectedKeyboardBuilder.toUpperCase(
|
||||||
|
lowerCaseKeyboard, locale);
|
||||||
|
return new ExpectedKeyboardBuilder(upperCaseKeyboard)
|
||||||
|
.replaceKeyOfAll(SHIFT_KEY, SHIFTED_SHIFT_KEY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Icon id.
|
||||||
|
private static final int ICON_SHIFTED_SHIFT = KeyboardIconsSet.getIconId("shift_key_shifted");
|
||||||
|
|
||||||
|
// Functional key.
|
||||||
|
private static final ExpectedKey SHIFTED_SHIFT_KEY = key(
|
||||||
|
ICON_SHIFTED_SHIFT, Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY);
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.keyboard.layout;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.LayoutBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The QWERTY alphabet keyboard.
|
||||||
|
*/
|
||||||
|
public final class Qwerty extends LayoutBase {
|
||||||
|
public static ExpectedKey[][] getAlphabet(final boolean isPhone) {
|
||||||
|
return toCommonAlphabet(ALPHABET_COMMON, isPhone);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 3)
|
||||||
|
.setLabelsOfRow(1, "q", "w", "e", "r", "t", "y", "u", "i", "o", "p")
|
||||||
|
.setMoreKeysOf("q", "1")
|
||||||
|
.setMoreKeysOf("w", "2")
|
||||||
|
.setMoreKeysOf("e", "3")
|
||||||
|
.setMoreKeysOf("r", "4")
|
||||||
|
.setMoreKeysOf("t", "5")
|
||||||
|
.setMoreKeysOf("y", "6")
|
||||||
|
.setMoreKeysOf("u", "7")
|
||||||
|
.setMoreKeysOf("i", "8")
|
||||||
|
.setMoreKeysOf("o", "9")
|
||||||
|
.setMoreKeysOf("p", "0")
|
||||||
|
.setLabelsOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l")
|
||||||
|
.setLabelsOfRow(3, "z", "x", "c", "v", "b", "n", "m")
|
||||||
|
.build();
|
||||||
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.keyboard.layout;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.LayoutBase;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The symbols keyboard layout.
|
||||||
|
*/
|
||||||
|
public final class Symbols extends LayoutBase {
|
||||||
|
public static ExpectedKey[][] getSymbols(final boolean isPhone) {
|
||||||
|
return isPhone ? toPhoneSymbol(SYMBOLS_COMMON) : toTabletSymbols(SYMBOLS_COMMON);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functional keys.
|
||||||
|
public static final ExpectedKey ALPHABET_KEY = key("ABC", Constants.CODE_SWITCH_ALPHA_SYMBOL);
|
||||||
|
public static final ExpectedKey SYMBOLS_SHIFT_KEY = key("= \\ <", Constants.CODE_SHIFT);
|
||||||
|
public static final ExpectedKey TABLET_SYMBOLS_SHIFT_KEY = key("~ [ <", Constants.CODE_SHIFT);
|
||||||
|
|
||||||
|
// Common symbols keyboard layout.
|
||||||
|
public static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 5)
|
||||||
|
.setLabelsOfRow(1, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
|
||||||
|
// U+00B9: "¹" SUPERSCRIPT ONE
|
||||||
|
// U+00BD: "½" VULGAR FRACTION ONE HALF
|
||||||
|
// U+2153: "⅓" VULGAR FRACTION ONE THIRD
|
||||||
|
// U+00BC: "¼" VULGAR FRACTION ONE QUARTER
|
||||||
|
// U+215B: "⅛" VULGAR FRACTION ONE EIGHTH
|
||||||
|
.setMoreKeysOf("1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B")
|
||||||
|
// U+00B2: "²" SUPERSCRIPT TWO
|
||||||
|
// U+2154: "⅔" VULGAR FRACTION TWO THIRDS
|
||||||
|
.setMoreKeysOf("2", "\u00B2", "\u2154")
|
||||||
|
// U+00B3: "³" SUPERSCRIPT THREE
|
||||||
|
// U+00BE: "¾" VULGAR FRACTION THREE QUARTERS
|
||||||
|
// U+215C: "⅜" VULGAR FRACTION THREE EIGHTHS
|
||||||
|
.setMoreKeysOf("3", "\u00B3", "\u00BE", "\u215C")
|
||||||
|
// U+2074: "⁴" SUPERSCRIPT FOUR
|
||||||
|
.setMoreKeysOf("4", "\u2074")
|
||||||
|
// U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS
|
||||||
|
.setMoreKeysOf("5", "\u215D")
|
||||||
|
// U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS
|
||||||
|
.setMoreKeysOf("7", "\u215E")
|
||||||
|
// U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N
|
||||||
|
// U+2205: "∅" EMPTY SET
|
||||||
|
.setMoreKeysOf("0", "\u207F", "\u2205")
|
||||||
|
.setLabelsOfRow(2, "@", "#", "$", "%", "&", "-", "+", "(", ")")
|
||||||
|
// U+00A2: "¢" CENT SIGN
|
||||||
|
// U+00A3: "£" POUND SIGN
|
||||||
|
// U+20AC: "€" EURO SIGN
|
||||||
|
// U+00A5: "¥" YEN SIGN
|
||||||
|
// U+20B1: "₱" PESO SIGN
|
||||||
|
.setMoreKeysOf("$", "\u00A2", "\u00A3", "\u20AC", "\u00A5", "\u20B1")
|
||||||
|
// U+2030: "‰" PER MILLE SIGN
|
||||||
|
.setMoreKeysOf("%", "\u2030")
|
||||||
|
// U+2013: "–" EN DASH
|
||||||
|
// U+2014: "—" EM DASH
|
||||||
|
// U+00B7: "·" MIDDLE DOT
|
||||||
|
.setMoreKeysOf("-", "_", "\u2013", "\u2014", "\u00B7")
|
||||||
|
// U+00B1: "±" PLUS-MINUS SIGN
|
||||||
|
.setMoreKeysOf("+", "\u00B1")
|
||||||
|
.setMoreKeysOf("(", "<", "{", "[")
|
||||||
|
.setMoreKeysOf(")", ">", "}", "]")
|
||||||
|
.setLabelsOfRow(3, "*", "\"", "'", ":", ";", "!", "?")
|
||||||
|
// U+2020: "†" DAGGER
|
||||||
|
// U+2021: "‡" DOUBLE DAGGER
|
||||||
|
// U+2605: "★" BLACK STAR
|
||||||
|
.setMoreKeysOf("*", "\u2020", "\u2021", "\u2605")
|
||||||
|
// U+201E: "„" DOUBLE LOW-9 QUOTATION MARK
|
||||||
|
// U+201C: "“" LEFT DOUBLE QUOTATION MARK
|
||||||
|
// U+201D: "”" RIGHT DOUBLE QUOTATION MARK
|
||||||
|
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("\"", "\u201E", "\u201C", "\u201D", "\u00AB", "\u00BB")
|
||||||
|
// U+201A: "‚" SINGLE LOW-9 QUOTATION MARK
|
||||||
|
// U+2018: "‘" LEFT SINGLE QUOTATION MARK
|
||||||
|
// U+2019: "’" RIGHT SINGLE QUOTATION MARK
|
||||||
|
// U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||||
|
// U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("'", "\u201A", "\u2018", "\u2019", "\u2039", "\u203A")
|
||||||
|
// U+00A1: "¡" INVERTED EXCLAMATION MARK
|
||||||
|
.setMoreKeysOf("!", "\u00A1")
|
||||||
|
// U+00BF: "¿" INVERTED QUESTION MARK
|
||||||
|
.setMoreKeysOf("?", "\u00BF")
|
||||||
|
.setLabelsOfRow(4, "_", "/", " ", ",", ".")
|
||||||
|
// U+2026: "…" HORIZONTAL ELLIPSIS
|
||||||
|
.setMoreKeysOf(".", "\u2026")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private static ExpectedKey[][] toPhoneSymbol(final ExpectedKey[][] common) {
|
||||||
|
return new ExpectedKeyboardBuilder(common)
|
||||||
|
.addKeysOnTheLeftOfRow(3, Symbols.SYMBOLS_SHIFT_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(3, DELETE_KEY)
|
||||||
|
.addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ExpectedKey[][] toTabletSymbols(final ExpectedKey[][] common) {
|
||||||
|
return new ExpectedKeyboardBuilder(common)
|
||||||
|
.addKeysOnTheLeftOfRow(3,
|
||||||
|
key("\\"), key("="))
|
||||||
|
.addKeysOnTheRightOfRow(1, DELETE_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(2, ENTER_KEY)
|
||||||
|
.addKeysOnTheLeftOfRow(3, Symbols.TABLET_SYMBOLS_SHIFT_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(3, Symbols.TABLET_SYMBOLS_SHIFT_KEY)
|
||||||
|
.addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(4, EMOJI_KEY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add currency symbols for Euro.
|
||||||
|
public static ExpectedKeyboardBuilder euro(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+20AC: "€" EURO SIGN
|
||||||
|
// U+00A2: "¢" CENT SIGN
|
||||||
|
// U+00A3: "£" POUND SIGN
|
||||||
|
// U+00A5: "¥" YEN SIGN
|
||||||
|
// U+20B1: "₱" PESO SIGN
|
||||||
|
.replaceKeyOfLabel("$", key("\u20AC",
|
||||||
|
moreKey("\u00A2"), moreKey("\u00A3"), moreKey("$"),
|
||||||
|
moreKey("\u00A5"), moreKey("\u20B1")));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add single quotes "more keys".
|
||||||
|
// "9LLR" means "9-low/Left quotation marks, Left/Right-pointing angle quotation marks".
|
||||||
|
public static ExpectedKeyboardBuilder singleQuotes9LLR(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+2019: "’" RIGHT SINGLE QUOTATION MARK
|
||||||
|
// U+201A: "‚" SINGLE LOW-9 QUOTATION MARK
|
||||||
|
// U+2018: "‘" LEFT SINGLE QUOTATION MARK
|
||||||
|
// U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||||
|
// U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("'", "\u2019", "\u201A", "\u2018", "\u2039", "\u203A");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add single quotes "more keys".
|
||||||
|
// "9LLR" means "9-low/Left quotation marks, Right/Left-pointing angle quotation marks".
|
||||||
|
public static ExpectedKeyboardBuilder singleQuotes9LRL(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+2019: "’" RIGHT SINGLE QUOTATION MARK
|
||||||
|
// U+201A: "‚" SINGLE LOW-9 QUOTATION MARK
|
||||||
|
// U+2018: "‘" LEFT SINGLE QUOTATION MARK
|
||||||
|
// U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||||
|
// U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("'", "\u2019", "\u201A", "\u2018", "\u203A", "\u2039");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add double quotes "more keys".
|
||||||
|
// "9LLR" means "9-low/Left quotation marks, Left/Right-pointing angle quotation marks".
|
||||||
|
public static ExpectedKeyboardBuilder doubleQuotes9LLR(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+201D: "”" RIGHT DOUBLE QUOTATION MARK
|
||||||
|
// U+201E: "„" DOUBLE LOW-9 QUOTATION MARK
|
||||||
|
// U+201C: "“" LEFT DOUBLE QUOTATION MARK
|
||||||
|
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("\"", "\u201D", "\u201E", "\u201C", "\u00AB", "\u00BB");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add double quotes "more keys".
|
||||||
|
// "9LLR" means "9-low/Left quotation marks, Right/Left-pointing angle quotation marks".
|
||||||
|
public static ExpectedKeyboardBuilder doubleQuotes9LRL(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+201D: "”" RIGHT DOUBLE QUOTATION MARK
|
||||||
|
// U+201E: "„" DOUBLE LOW-9 QUOTATION MARK
|
||||||
|
// U+201C: "“" LEFT DOUBLE QUOTATION MARK
|
||||||
|
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("\"", "\u201D", "\u201E", "\u201C", "\u00BB", "\u00AB");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.keyboard.layout;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
|
||||||
|
import com.android.inputmethod.keyboard.layout.expected.LayoutBase;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The symbols shifted keyboard layout.
|
||||||
|
*/
|
||||||
|
public final class SymbolsShifted extends LayoutBase {
|
||||||
|
public static ExpectedKey[][] getSymbolsShifted(final boolean isPhone) {
|
||||||
|
return isPhone ? toPhoneSymbolsShifted(SYMBOLS_SHIFTED_COMMON)
|
||||||
|
: toTabletSymbolsShifted(SYMBOLS_SHIFTED_COMMON);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functional key.
|
||||||
|
public static final ExpectedKey BACK_TO_SYMBOLS_KEY = key("?123", Constants.CODE_SHIFT);
|
||||||
|
|
||||||
|
// Common symbols shifted keyboard layout.
|
||||||
|
public static final ExpectedKey[][] SYMBOLS_SHIFTED_COMMON =
|
||||||
|
new ExpectedKeyboardBuilder(10, 9, 7, 5)
|
||||||
|
// U+0060: "`" GRAVE ACCENT
|
||||||
|
// U+2022: "•" BULLET
|
||||||
|
// U+221A: "√" SQUARE ROOT
|
||||||
|
// U+03C0: "π" GREEK SMALL LETTER PI
|
||||||
|
// U+00F7: "÷" DIVISION SIGN
|
||||||
|
// U+00D7: "×" MULTIPLICATION SIGN
|
||||||
|
// U+00B6: "¶" PILCROW SIGN
|
||||||
|
// U+2206: "∆" INCREMENT
|
||||||
|
.setLabelsOfRow(1,
|
||||||
|
"~", "\u0060", "|", "\u2022", "\u221A",
|
||||||
|
"\u03C0", "\u00F7", "\u00D7", "\u00B6", "\u2206")
|
||||||
|
// U+2022: "•" BULLET
|
||||||
|
// U+266A: "♪" EIGHTH NOTE
|
||||||
|
// U+2665: "♥" BLACK HEART SUIT
|
||||||
|
// U+2660: "♠" BLACK SPADE SUIT
|
||||||
|
// U+2666: "♦" BLACK DIAMOND SUIT
|
||||||
|
// U+2663: "♣" BLACK CLUB SUIT
|
||||||
|
.setMoreKeysOf("\u2022", "\u266A", "\u2665", "\u2660", "\u2666", "\u2663")
|
||||||
|
// U+03C0: "π" GREEK SMALL LETTER PI
|
||||||
|
// U+03A0: "Π" GREEK CAPITAL LETTER PI
|
||||||
|
.setMoreKeysOf("\u03C0", "\u03A0")
|
||||||
|
// U+00B6: "¶" PILCROW SIGN
|
||||||
|
// U+00A7: "§" SECTION SIGN
|
||||||
|
.setMoreKeysOf("\u00B6", "\u00A7")
|
||||||
|
// U+00A3: "£" POUND SIGN
|
||||||
|
// U+00A2: "¢" CENT SIGN
|
||||||
|
// U+20AC: "€" EURO SIGN
|
||||||
|
// U+00A5: "¥" YEN SIGN
|
||||||
|
// U+00B0: "°" DEGREE SIGN
|
||||||
|
.setLabelsOfRow(2,
|
||||||
|
"\u00A3", "\u00A2", "\u20AC", "\u00A5", "^",
|
||||||
|
"\u00B0", "=", "{", "}")
|
||||||
|
// U+2191: "↑" UPWARDS ARROW
|
||||||
|
// U+2193: "↓" DOWNWARDS ARROW
|
||||||
|
// U+2190: "←" LEFTWARDS ARROW
|
||||||
|
// U+2192: "→" RIGHTWARDS ARROW
|
||||||
|
.setMoreKeysOf("^", "\u2191", "\u2193", "\u2190", "\u2192")
|
||||||
|
// U+00B0: "°" DEGREE SIGN
|
||||||
|
// U+2032: "′" PRIME
|
||||||
|
// U+2033: "″" DOUBLE PRIME
|
||||||
|
.setMoreKeysOf("\u00B0", "\u2032", "\u2033")
|
||||||
|
// U+2260: "≠" NOT EQUAL TO
|
||||||
|
// U+2248: "≈" ALMOST EQUAL TO
|
||||||
|
// U+221E: "∞" INFINITY
|
||||||
|
.setMoreKeysOf("=", "\u2260", "\u2248", "\u221E")
|
||||||
|
// U+00A9: "©" COPYRIGHT SIGN
|
||||||
|
// U+00AE: "®" REGISTERED SIGN
|
||||||
|
// U+2122: "™" TRADE MARK SIGN
|
||||||
|
// U+2105: "℅" CARE OF
|
||||||
|
.setLabelsOfRow(3,
|
||||||
|
"\\", "\u00A9", "\u00AE", "\u2122", "\u2105",
|
||||||
|
"[", "]")
|
||||||
|
.setLabelsOfRow(4,
|
||||||
|
"<", ">", " ", ",", ".")
|
||||||
|
// U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||||
|
// U+2264: "≤" LESS-THAN OR EQUAL TO
|
||||||
|
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf("<", "\u2039", "\u2264", "\u00AB")
|
||||||
|
// U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||||
|
// U+2265: "≥" GREATER-THAN EQUAL TO
|
||||||
|
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||||
|
.setMoreKeysOf(">", "\u203A", "\u2265", "\u00BB")
|
||||||
|
// U+2026: "…" HORIZONTAL ELLIPSIS
|
||||||
|
.setMoreKeysOf(".", "\u2026")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private static ExpectedKey[][] toPhoneSymbolsShifted(final ExpectedKey[][] common) {
|
||||||
|
return new ExpectedKeyboardBuilder(common)
|
||||||
|
.addKeysOnTheLeftOfRow(3, BACK_TO_SYMBOLS_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(3, DELETE_KEY)
|
||||||
|
.addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ExpectedKey[][] toTabletSymbolsShifted(final ExpectedKey[][] common) {
|
||||||
|
return new ExpectedKeyboardBuilder(common)
|
||||||
|
// U+00BF: "¿" INVERTED QUESTION MARK
|
||||||
|
// U+00A1: "¡" INVERTED EXCLAMATION MARK
|
||||||
|
.addKeysOnTheRightOfRow(3,
|
||||||
|
key("\u00A1"), key("\u00BF"))
|
||||||
|
.addKeysOnTheRightOfRow(1, DELETE_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(2, ENTER_KEY)
|
||||||
|
.addKeysOnTheLeftOfRow(3, BACK_TO_SYMBOLS_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(3, BACK_TO_SYMBOLS_KEY)
|
||||||
|
.addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(4, EMOJI_KEY)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add currency symbols for Euro.
|
||||||
|
public static ExpectedKeyboardBuilder euro(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+00A5: "¥" YEN SIGN
|
||||||
|
// U+00A2: "¢" CENT SIGN
|
||||||
|
.replaceKeyOfLabel("\u00A5", key("\u00A2"))
|
||||||
|
// U+20AC: "€" EURO SIGN
|
||||||
|
// U+00A2: "¢" CENT SIGN
|
||||||
|
.replaceKeyOfLabel("\u20AC", key("$", moreKey("\u00A2")))
|
||||||
|
// U+00A2: "¢" CENT SIGN
|
||||||
|
// U+00A5: "¥" YEN SIGN
|
||||||
|
.replaceKeyOfLabel("\u00A2", key("\u00A5"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.keyboard.layout.expected;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class to create an expected keyboard for unit test.
|
||||||
|
*/
|
||||||
|
public class LayoutBase {
|
||||||
|
// Those helper methods have a lower case name to be readable when defining expected keyboard
|
||||||
|
// layouts.
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object that has the label.
|
||||||
|
public static ExpectedKey key(final String label, final ExpectedKey ... moreKeys) {
|
||||||
|
return ExpectedKey.newInstance(label, moreKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object that has the label and the output text.
|
||||||
|
public static ExpectedKey key(final String label, final String outputText,
|
||||||
|
final ExpectedKey ... moreKeys) {
|
||||||
|
return ExpectedKey.newInstance(label, outputText, moreKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object that has the label and the output code.
|
||||||
|
public static ExpectedKey key(final String label, final int code,
|
||||||
|
final ExpectedKey ... moreKeys) {
|
||||||
|
return ExpectedKey.newInstance(label, code, moreKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object that has the icon and the output code.
|
||||||
|
public static ExpectedKey key(final int iconId, final int code,
|
||||||
|
final ExpectedKey ... moreKeys) {
|
||||||
|
return ExpectedKey.newInstance(iconId, code, moreKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object that has new "more keys".
|
||||||
|
public static ExpectedKey key(final ExpectedKey key, final ExpectedKey ... moreKeys) {
|
||||||
|
return ExpectedKey.newInstance(key.getVisual(), key.getOutput(), moreKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object for "more key" that has the label.
|
||||||
|
public static ExpectedKey moreKey(final String label) {
|
||||||
|
return ExpectedKey.newInstance(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object for "more key" that has the label and the
|
||||||
|
// output text.
|
||||||
|
public static ExpectedKey moreKey(final String label, final String outputText) {
|
||||||
|
return ExpectedKey.newInstance(label, outputText);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create {@link ExpectedKey} object for "more key" that has the label and the
|
||||||
|
// output code.
|
||||||
|
public static ExpectedKey moreKey(final String label, final int code) {
|
||||||
|
return ExpectedKey.newInstance(label, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Icon ids.
|
||||||
|
private static final int ICON_SHIFT = KeyboardIconsSet.getIconId("shift_key");
|
||||||
|
private static final int ICON_DELETE = KeyboardIconsSet.getIconId("delete_key");
|
||||||
|
private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId("settings_key");
|
||||||
|
private static final int ICON_ENTER = KeyboardIconsSet.getIconId("enter_key");
|
||||||
|
private static final int ICON_EMOJI = KeyboardIconsSet.getIconId("emoji_key");
|
||||||
|
|
||||||
|
// Functional keys.
|
||||||
|
public static final ExpectedKey CAPSLOCK_MORE_KEY = key(" ", Constants.CODE_CAPSLOCK);
|
||||||
|
public static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT, Constants.CODE_SHIFT);
|
||||||
|
public static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE);
|
||||||
|
public static final ExpectedKey SYMBOLS_KEY = key("?123", Constants.CODE_SWITCH_ALPHA_SYMBOL);
|
||||||
|
public static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS);
|
||||||
|
public static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER);
|
||||||
|
public static final ExpectedKey EMOJI_KEY = key(ICON_EMOJI, Constants.CODE_EMOJI);
|
||||||
|
|
||||||
|
// Punctuation more keys for phone form factor.
|
||||||
|
public static final String[] PHONE_PUNCTUATION_MORE_KEYS = {
|
||||||
|
";", "/", "(", ")", "#", "!", ",", "?",
|
||||||
|
"&", "%", "+", "\"", "-", ":", "'", "@"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Punctuation more keys for tablet form factor.
|
||||||
|
public static final String[] TABLET_PUNCTUATION_MORE_KEYS = {
|
||||||
|
";", "/", "(", ")", "#", "'", ",",
|
||||||
|
"&", "%", "+", "\"", "-", ":", "@"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static ExpectedKeyboardBuilder toPhoneAlphabet(final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
.addKeysOnTheLeftOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY))
|
||||||
|
.addKeysOnTheRightOfRow(3, DELETE_KEY)
|
||||||
|
.setLabelsOfRow(4, ",", " ", ".")
|
||||||
|
.setMoreKeysOf(",", SETTINGS_KEY)
|
||||||
|
.setMoreKeysOf(".", PHONE_PUNCTUATION_MORE_KEYS)
|
||||||
|
.addKeysOnTheLeftOfRow(4, SYMBOLS_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create alphabet layout for tablet by adding special function keys except
|
||||||
|
// shift key.
|
||||||
|
public static ExpectedKeyboardBuilder toTabletAlphabetWithoutShiftKeys(
|
||||||
|
final ExpectedKeyboardBuilder builder) {
|
||||||
|
return builder
|
||||||
|
// U+00BF: "¿" INVERTED QUESTION MARK
|
||||||
|
// U+00A1: "¡" INVERTED EXCLAMATION MARK
|
||||||
|
.addKeysOnTheRightOfRow(3,
|
||||||
|
key("!", moreKey("\u00A1")), key("?", moreKey("\u00BF")))
|
||||||
|
.addKeysOnTheRightOfRow(1, DELETE_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(2, ENTER_KEY)
|
||||||
|
.setLabelsOfRow(4, "/", " ", ",", ".")
|
||||||
|
.setMoreKeysOf(".", TABLET_PUNCTUATION_MORE_KEYS)
|
||||||
|
.addKeysOnTheLeftOfRow(4, SYMBOLS_KEY, SETTINGS_KEY)
|
||||||
|
.addKeysOnTheRightOfRow(4, EMOJI_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to create alphabet layout by adding special function keys.
|
||||||
|
public static ExpectedKey[][] toCommonAlphabet(final ExpectedKey[][] common,
|
||||||
|
final boolean isPhone) {
|
||||||
|
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(common);
|
||||||
|
if (isPhone) {
|
||||||
|
toPhoneAlphabet(builder);
|
||||||
|
} else {
|
||||||
|
toTabletAlphabetWithoutShiftKeys(builder);
|
||||||
|
builder.addKeysOnTheLeftOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY))
|
||||||
|
.addKeysOnTheRightOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY));
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue