Another small cleanup for test code

Change-Id: Ib0ded6f98a6ce9197c8af79778af59d894ee54a6
main
Tadashi G. Takaoka 2014-03-11 17:55:11 +09:00
parent 0722e6b3df
commit bab437fb3b
2 changed files with 18 additions and 6 deletions

View File

@ -25,7 +25,7 @@ import com.android.inputmethod.keyboard.layout.expected.LayoutBase;
*/
public final class Qwerty extends LayoutBase {
public static ExpectedKey[][] getLayout(final boolean isPhone) {
return toCommonAlphabet(ALPHABET_COMMON, isPhone);
return getDefaultAlphabetLayout(ALPHABET_COMMON, isPhone);
}
private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 3)

View File

@ -121,9 +121,10 @@ public class LayoutBase {
"&", "%", "+", "\"", "-", ":", "@"
};
// Helper method to create alphabet layout for phone by adding special function keys except
// shift key.
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)
@ -134,8 +135,7 @@ public class LayoutBase {
// Helper method to create alphabet layout for tablet by adding special function keys except
// shift key.
public static ExpectedKeyboardBuilder toTabletAlphabetWithoutShiftKeys(
final ExpectedKeyboardBuilder builder) {
private static ExpectedKeyboardBuilder toTabletAlphabet(final ExpectedKeyboardBuilder builder) {
return builder
// U+00BF: "¿" INVERTED QUESTION MARK
// U+00A1: "¡" INVERTED EXCLAMATION MARK
@ -150,13 +150,25 @@ public class LayoutBase {
}
// Helper method to create alphabet layout by adding special function keys.
public static ExpectedKey[][] toCommonAlphabet(final ExpectedKey[][] common,
public static ExpectedKey[][] getAlphabetLayoutWithoutShiftKeys(final ExpectedKey[][] common,
final boolean isPhone) {
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(common);
if (isPhone) {
toPhoneAlphabet(builder);
} else {
toTabletAlphabetWithoutShiftKeys(builder);
toTabletAlphabet(builder).build();
}
return builder.build();
}
// Helper method to create alphabet layout by adding special function keys.
public static ExpectedKey[][] getDefaultAlphabetLayout(final ExpectedKey[][] common,
final boolean isPhone) {
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(
getAlphabetLayoutWithoutShiftKeys(common, isPhone));
if (isPhone) {
builder.addKeysOnTheLeftOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY));
} else {
builder.addKeysOnTheLeftOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY))
.addKeysOnTheRightOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY));
}