am bab437fb: Another small cleanup for test code

* commit 'bab437fb3b1a58925e285c2e03ca2e125484bad9':
  Another small cleanup for test code
main
Tadashi G. Takaoka 2014-03-11 01:59:18 -07:00 committed by Android Git Automerger
commit a242d7593b
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));
}