From 5166e9f0ff2e5df0d82983b19ea2cd1c2df16da2 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 2 Sep 2014 15:55:44 +0900 Subject: [PATCH] Refactor action label/icon definitions Bug: 15782668 Change-Id: Ibf1205d46e9293d516a56030ba10841128f57450 --- java/res/xml-sw600dp/key_styles_enter.xml | 124 ++---------- java/res/xml/key_styles_actions.xml | 133 +++++++++++++ java/res/xml/key_styles_enter.xml | 185 +++--------------- .../res/xml/key_styles_navigate_more_keys.xml | 86 ++++++++ ...KeyboardLayoutSetNavigateMoreKeysBase.java | 19 +- ...oardLayoutSetNavigateMoreKeysLxxTests.java | 12 ++ .../keyboard/KeyboardLayoutSetTestsBase.java | 1 + 7 files changed, 292 insertions(+), 268 deletions(-) create mode 100644 java/res/xml/key_styles_actions.xml create mode 100644 java/res/xml/key_styles_navigate_more_keys.xml diff --git a/java/res/xml-sw600dp/key_styles_enter.xml b/java/res/xml-sw600dp/key_styles_enter.xml index 0227d811b..d066d2d12 100644 --- a/java/res/xml-sw600dp/key_styles_enter.xml +++ b/java/res/xml-sw600dp/key_styles_enter.xml @@ -22,20 +22,18 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > + - + latin:parentStyle="navigatePreviousMoreKeysStyle" /> @@ -46,12 +44,10 @@ > + latin:parentStyle="navigateNextMoreKeysStyle" /> @@ -62,33 +58,21 @@ > + latin:parentStyle="navigatePreviousNextMoreKeysStyle" /> + latin:parentStyle="navigateNextMoreKeysStyle" /> - - - + latin:parentStyle="navigatePreviousMoreKeysStyle" /> + - - - - - - + latin:parentStyle="goActionKeyStyle" /> - - - + latin:parentStyle="nextActionKeyStyle" /> - - - + latin:parentStyle="previousActionKeyStyle" /> - - - + latin:parentStyle="doneActionKeyStyle" /> - - - + latin:parentStyle="sendActionKeyStyle" /> + latin:parentStyle="searchActionKeyStyle" /> - - - + latin:parentStyle="customLabelActionKeyStyle" /> diff --git a/java/res/xml/key_styles_actions.xml b/java/res/xml/key_styles_actions.xml new file mode 100644 index 000000000..83901cad9 --- /dev/null +++ b/java/res/xml/key_styles_actions.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/key_styles_enter.xml b/java/res/xml/key_styles_enter.xml index 7aea1ceff..d6d01b862 100644 --- a/java/res/xml/key_styles_enter.xml +++ b/java/res/xml/key_styles_enter.xml @@ -21,8 +21,8 @@ - + + latin:parentStyle="navigatePreviousMoreKeysStyle" /> + latin:parentStyle="navigateNextMoreKeysStyle" /> + latin:parentStyle="navigatePreviousNextMoreKeysStyle" /> + latin:parentStyle="navigateNextMoreKeysStyle" /> + latin:parentStyle="navigatePreviousMoreKeysStyle" /> + latin:parentStyle="navigatePreviousMoreKeysStyle" /> + latin:parentStyle="navigateNextMoreKeysStyle" /> + latin:parentStyle="navigatePreviousNextMoreKeysStyle" /> + latin:parentStyle="navigateNextMoreKeysStyle" /> + latin:parentStyle="navigatePreviousMoreKeysStyle" /> + latin:parentStyle="navigateEmojiPreviousMoreKeysStyle" /> + latin:parentStyle="navigateEmojiMoreKeysStyle" /> + latin:parentStyle="navigateEmojiNextMoreKeysStyle" /> + latin:parentStyle="navigateEmojiMoreKeysStyle" /> + latin:parentStyle="navigateEmojiPreviousNextMoreKeysStyle" /> + latin:parentStyle="navigateEmojiNextMoreKeysStyle" /> - - - + latin:parentStyle="navigateEmojiPreviousMoreKeysStyle" /> + latin:styleName="navigateMoreKeysStyle" + latin:parentStyle="navigateEmojiMoreKeysStyle" /> @@ -260,10 +219,7 @@ latin:keyActionFlags="noKeyPreview" latin:backgroundType="action" latin:parentStyle="navigateMoreKeysStyle" /> - + + latin:keySpec="!icon/enter_key|!code/key_shift_enter" + latin:parentStyle="defaultEnterKeyStyle" /> @@ -285,139 +242,57 @@ - - - - - - + latin:parentStyle="goActionKeyStyle" /> - - - + latin:parentStyle="nextActionKeyStyle" /> - - - + latin:parentStyle="previousActionKeyStyle" /> - - - + latin:parentStyle="doneActionKeyStyle" /> - - - + latin:parentStyle="sendActionKeyStyle" /> + latin:parentStyle="searchActionKeyStyle" /> - - - + latin:parentStyle="customLabelActionKeyStyle" /> diff --git a/java/res/xml/key_styles_navigate_more_keys.xml b/java/res/xml/key_styles_navigate_more_keys.xml new file mode 100644 index 000000000..f97114db9 --- /dev/null +++ b/java/res/xml/key_styles_navigate_more_keys.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java index 1fce362b5..8a55455d0 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java @@ -35,12 +35,24 @@ abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTe private ExpectedMoreKey mExpectedNavigatePreviousMoreKey; private ExpectedMoreKey mExpectedEmojiMoreKey; + protected ExpectedMoreKey getExpectedNavigateNextMoreKey() { + return new ExpectedMoreKey(R.string.label_next_key); + } + + protected ExpectedMoreKey getExpectedNavigatePreviousMoreKey() { + return new ExpectedMoreKey(R.string.label_previous_key); + } + + protected ExpectedMoreKey getExpectedEmojiMoreKey() { + return new ExpectedMoreKey(KeyboardIconsSet.NAME_EMOJI_ACTION_KEY); + } + @Override protected void setUp() throws Exception { super.setUp(); - mExpectedNavigateNextMoreKey = new ExpectedMoreKey(R.string.label_next_key); - mExpectedNavigatePreviousMoreKey = new ExpectedMoreKey(R.string.label_previous_key); - mExpectedEmojiMoreKey = new ExpectedMoreKey(KeyboardIconsSet.NAME_EMOJI_ACTION_KEY); + mExpectedNavigateNextMoreKey = getExpectedNavigateNextMoreKey(); + mExpectedNavigatePreviousMoreKey = getExpectedNavigatePreviousMoreKey(); + mExpectedEmojiMoreKey = getExpectedEmojiMoreKey(); } /** @@ -90,6 +102,7 @@ abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTe assertEquals(tag + " column", expectedMoreKeys.length, actualKey.getMoreKeysColumnNumber()); } + assertNotNull(tag + " moreKeys", actualMoreKeys); assertEquals(tag, expectedMoreKeys.length, actualMoreKeys.length); for (int index = 0; index < actualMoreKeys.length; index++) { final int expectedLabelResId = expectedMoreKeys[index].mLabelResId; diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java index 02593cb49..d2bb41e5d 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java @@ -18,6 +18,8 @@ package com.android.inputmethod.keyboard; import android.test.suitebuilder.annotation.SmallTest; +import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; + @SmallTest public class KeyboardLayoutSetNavigateMoreKeysLxxTests extends KeyboardLayoutSetNavigateMoreKeysBase { @@ -25,4 +27,14 @@ public class KeyboardLayoutSetNavigateMoreKeysLxxTests protected int getKeyboardThemeForTests() { return KeyboardTheme.THEME_ID_LXX_LIGHT; } + + @Override + protected ExpectedMoreKey getExpectedNavigateNextMoreKey() { + return new ExpectedMoreKey(KeyboardIconsSet.NAME_NEXT_KEY); + } + + @Override + protected ExpectedMoreKey getExpectedNavigatePreviousMoreKey() { + return new ExpectedMoreKey(KeyboardIconsSet.NAME_PREVIOUS_KEY); + } } diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java index f95ba3cac..a002bbe48 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java @@ -52,6 +52,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( getKeyboardThemeForTests()); setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId)); + KeyboardLayoutSet.onKeyboardThemeChanged(); final Context context = getContext(); mScreenMetrics = context.getResources().getInteger(R.integer.config_screen_metrics);