am 6a4e9218: am 2a7a5740: am 0af2472a: Add new "keyboardTheme" <case> predicator

* commit '6a4e9218ca5a851764192e6fbb6242475e737383':
  Add new "keyboardTheme" <case> predicator
main
Tadashi G. Takaoka 2014-09-03 18:08:41 +00:00 committed by Android Git Automerger
commit 1763525c92
9 changed files with 75 additions and 22 deletions

View File

@ -207,7 +207,13 @@
</declare-styleable>
<declare-styleable name="Keyboard">
<attr name="themeId" format="integer" />
<attr name="themeId" format="enum">
<!-- This should be aligned with KeyboardTheme.THEME_ID_*. -->
<enum name="ICS" value="0" />
<enum name="KLP" value="2" />
<enum name="LXXLight" value="3" />
<enum name="LXXDark" value="4" />
</attr>
<!-- Touch position correction -->
<attr name="touchPositionCorrectionData" format="reference" />
<!-- Keyboard top, bottom, left, right edges paddings, in propotion of keyboard height. -->
@ -427,6 +433,13 @@
<enum name="emojiCategory5" value="15" />
<enum name="emojiCategory6" value="16" />
</attr>
<!-- This should be aligned with Keyboard.themeId and KeyboardTheme.THEME_ID_* -->
<attr name="keyboardTheme" format="enum|string">
<enum name="ICS" value="0" />
<enum name="KLP" value="2" />
<enum name="LXXLight" value="3" />
<enum name="LXXDark" value="4" />
</attr>
<!-- This should be aligned with KeyboardId.MODE_* -->
<attr name="mode" format="enum|string">
<enum name="text" value="0" />

View File

@ -33,8 +33,8 @@
name="Keyboard.ICS"
parent="Keyboard"
>
<!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
<item name="themeId">2</item>
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
<item name="themeId">ICS</item>
</style>
<style
name="KeyboardView.ICS"

View File

@ -33,8 +33,8 @@
name="Keyboard.KLP"
parent="Keyboard"
>
<!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
<item name="themeId">0</item>
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
<item name="themeId">KLP</item>
</style>
<style
name="KeyboardView.KLP"

View File

@ -33,8 +33,8 @@
name="Keyboard.LXX_Dark"
parent="Keyboard"
>
<!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
<item name="themeId">4</item>
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
<item name="themeId">LXXDark</item>
</style>
<style
name="KeyboardView.LXX_Dark"

View File

@ -33,8 +33,8 @@
name="Keyboard.LXX_Light"
parent="Keyboard"
>
<!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
<item name="themeId">3</item>
<!-- This should be aligned with KeyboardTheme.THEME_ID_* -->
<item name="themeId">LXXLight</item>
</style>
<style
name="KeyboardView.LXX_Light"

View File

@ -224,12 +224,24 @@
</case>
<case
latin:imeAction="actionCustomLabel"
latin:keyboardTheme="ICS|KLP"
>
<key-style
latin:styleName="enterKeyStyle"
latin:keySpec="dummy_label|!code/key_enter"
latin:keyLabelFlags="fromCustomActionLabel"
latin:backgroundType="customAction"
latin:backgroundType="action"
latin:parentStyle="defaultEnterKeyStyle" />
</case>
<case
latin:imeAction="actionCustomLabel"
latin:keyboardTheme="LXXLight|LXXDark"
>
<key-style
latin:styleName="enterKeyStyle"
latin:keySpec="dummy_label|!code/key_enter"
latin:keyLabelFlags="fromCustomActionLabel"
latin:backgroundType="functional"
latin:parentStyle="defaultEnterKeyStyle" />
</case>
<!-- imeAction is either actionNone or actionUnspecified. -->

View File

@ -393,12 +393,24 @@
</case>
<case
latin:imeAction="actionCustomLabel"
latin:keyboardTheme="ICS|KLP"
>
<key-style
latin:styleName="enterKeyStyle"
latin:keySpec="dummy_label|!code/key_enter"
latin:keyLabelFlags="fromCustomActionLabel"
latin:backgroundType="customAction"
latin:backgroundType="action"
latin:parentStyle="defaultEnterKeyStyle" />
</case>
<case
latin:imeAction="actionCustomLabel"
latin:keyboardTheme="LXXLight|LXXDark"
>
<key-style
latin:styleName="enterKeyStyle"
latin:keySpec="dummy_label|!code/key_enter"
latin:keyLabelFlags="fromCustomActionLabel"
latin:backgroundType="functional"
latin:parentStyle="defaultEnterKeyStyle" />
</case>
<!-- imeAction is either actionNone or actionUnspecified. -->

View File

@ -32,6 +32,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
static final String KLP_KEYBOARD_THEME_KEY = "pref_keyboard_layout_20110916";
static final String LXX_KEYBOARD_THEME_KEY = "pref_keyboard_theme_20140509";
// These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme
// attributes' values in attrs.xml.
public static final int THEME_ID_ICS = 0;
public static final int THEME_ID_KLP = 2;
public static final int THEME_ID_LXX_LIGHT = 3;
@ -39,16 +41,16 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
public static final int DEFAULT_THEME_ID = THEME_ID_KLP;
private static final KeyboardTheme[] KEYBOARD_THEMES = {
new KeyboardTheme(THEME_ID_ICS, R.style.KeyboardTheme_ICS,
new KeyboardTheme(THEME_ID_ICS, "ICS", R.style.KeyboardTheme_ICS,
// This has never been selected because we support ICS or later.
VERSION_CODES.BASE),
new KeyboardTheme(THEME_ID_KLP, R.style.KeyboardTheme_KLP,
new KeyboardTheme(THEME_ID_KLP, "KLP", R.style.KeyboardTheme_KLP,
// Default theme for ICS, JB, and KLP.
VERSION_CODES.ICE_CREAM_SANDWICH),
new KeyboardTheme(THEME_ID_LXX_LIGHT, R.style.KeyboardTheme_LXX_Light,
new KeyboardTheme(THEME_ID_LXX_LIGHT, "LXXLight", R.style.KeyboardTheme_LXX_Light,
// Default theme for LXX.
BuildCompatUtils.VERSION_CODES_LXX),
new KeyboardTheme(THEME_ID_LXX_DARK, R.style.KeyboardTheme_LXX_Dark,
new KeyboardTheme(THEME_ID_LXX_DARK, "LXXDark", R.style.KeyboardTheme_LXX_Dark,
VERSION_CODES.BASE),
};
@ -59,12 +61,15 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
public final int mThemeId;
public final int mStyleId;
public final String mThemeName;
private final int mMinApiVersion;
// Note: The themeId should be aligned with "themeId" attribute of Keyboard style
// in values/themes-<style>.xml.
private KeyboardTheme(final int themeId, final int styleId, final int minApiVersion) {
private KeyboardTheme(final int themeId, final String themeName, final int styleId,
final int minApiVersion) {
mThemeId = themeId;
mThemeName = themeName;
mStyleId = styleId;
mMinApiVersion = minApiVersion;
}
@ -128,6 +133,11 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
return searchKeyboardThemeById(DEFAULT_THEME_ID);
}
public static String getKeyboardThemeName(final int themeId) {
final KeyboardTheme theme = searchKeyboardThemeById(themeId);
return theme.mThemeName;
}
public static void saveKeyboardThemeId(final String themeIdString,
final SharedPreferences prefs) {
saveKeyboardThemeId(themeIdString, prefs, BuildCompatUtils.EFFECTIVE_SDK_INT);

View File

@ -31,6 +31,7 @@ import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardTheme;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.ResourceUtils;
@ -643,6 +644,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean keyboardLayoutSetElementMatched = matchTypedValue(caseAttr,
R.styleable.Keyboard_Case_keyboardLayoutSetElement, id.mElementId,
KeyboardId.elementIdToName(id.mElementId));
final boolean keyboardThemeMacthed = matchTypedValue(caseAttr,
R.styleable.Keyboard_Case_keyboardTheme, mParams.mThemeId,
KeyboardTheme.getKeyboardThemeName(mParams.mThemeId));
final boolean modeMatched = matchTypedValue(caseAttr,
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
final boolean navigateNextMatched = matchBoolean(caseAttr,
@ -671,19 +675,21 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean countryCodeMatched = matchString(caseAttr,
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
&& modeMatched && navigateNextMatched && navigatePreviousMatched
&& passwordInputMatched && clobberSettingsKeyMatched && hasShortcutKeyMatched
&& languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched
&& isIconDefinedMatched && localeCodeMatched && languageCodeMatched
&& countryCodeMatched;
&& keyboardThemeMacthed && modeMatched && navigateNextMatched
&& navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched
&& hasShortcutKeyMatched && languageSwitchKeyEnabledMatched
&& isMultiLineMatched && imeActionMatched && isIconDefinedMatched
&& localeCodeMatched && languageCodeMatched && countryCodeMatched;
if (DEBUG) {
startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
textAttr(caseAttr.getString(
R.styleable.Keyboard_Case_keyboardLayoutSet), "keyboardLayoutSet"),
textAttr(caseAttr.getString(
R.styleable.Keyboard_Case_keyboardLayoutSetElement),
"keyboardLayoutSetElement"),
textAttr(caseAttr.getString(
R.styleable.Keyboard_Case_keyboardTheme), "keyboardTheme"),
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_mode), "mode"),
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_imeAction),
"imeAction"),