Fix label of switch to symbols key when symbols has shortcut key
This change fixes the labels of switch to symbols key and switch back from more symbols key when symbols layout has shortcut key. Change-Id: I3fbbef2d929486d0f0542f4d89cb086d9f5bad82main
parent
ac3720ce6d
commit
8eaf75aa7b
|
@ -389,6 +389,7 @@
|
||||||
<attr name="passwordInput" format="boolean" />
|
<attr name="passwordInput" format="boolean" />
|
||||||
<attr name="clobberSettingsKey" format="boolean" />
|
<attr name="clobberSettingsKey" format="boolean" />
|
||||||
<attr name="shortcutKeyEnabled" format="boolean" />
|
<attr name="shortcutKeyEnabled" format="boolean" />
|
||||||
|
<attr name="shortcutKeyOnSymbols" format="boolean" />
|
||||||
<attr name="hasShortcutKey" format="boolean" />
|
<attr name="hasShortcutKey" format="boolean" />
|
||||||
<attr name="languageSwitchKeyEnabled" format="boolean" />
|
<attr name="languageSwitchKeyEnabled" format="boolean" />
|
||||||
<attr name="isMultiLine" format="boolean" />
|
<attr name="isMultiLine" format="boolean" />
|
||||||
|
|
|
@ -154,31 +154,30 @@
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toSymbolKeyStyle"
|
latin:styleName="baseForLayoutSwitchKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
|
||||||
latin:keyLabel="!text/label_to_symbol_key"
|
|
||||||
latin:keyLabelFlags="preserveCase"
|
latin:keyLabelFlags="preserveCase"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:keyActionFlags="noKeyPreview"
|
||||||
latin:backgroundType="functional" />
|
latin:backgroundType="functional" />
|
||||||
|
<key-style
|
||||||
|
latin:styleName="toSymbolKeyStyle"
|
||||||
|
latin:code="!code/key_switch_alpha_symbol"
|
||||||
|
latin:keyLabel="!text/label_to_symbol_key"
|
||||||
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toAlphaKeyStyle"
|
latin:styleName="toAlphaKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
latin:code="!code/key_switch_alpha_symbol"
|
||||||
latin:keyLabel="!text/label_to_alpha_key"
|
latin:keyLabel="!text/label_to_alpha_key"
|
||||||
latin:keyLabelFlags="preserveCase"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toMoreSymbolKeyStyle"
|
latin:styleName="toMoreSymbolKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
latin:code="!code/key_shift"
|
||||||
latin:keyLabel="!text/label_to_more_symbol_for_tablet_key"
|
latin:keyLabel="!text/label_to_more_symbol_for_tablet_key"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="backFromMoreSymbolKeyStyle"
|
latin:styleName="backFromMoreSymbolKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
latin:code="!code/key_shift"
|
||||||
latin:keyLabel="!text/label_to_symbol_key"
|
latin:keyLabel="!text/label_to_symbol_key"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="comKeyStyle"
|
latin:styleName="comKeyStyle"
|
||||||
latin:keyLabel="!text/keylabel_for_popular_domain"
|
latin:keyLabel="!text/keylabel_for_popular_domain"
|
||||||
|
|
|
@ -144,33 +144,30 @@
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toSymbolKeyStyle"
|
latin:styleName="baseForLayoutSwitchKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
|
||||||
latin:keyLabel="!text/label_to_symbol_key"
|
|
||||||
latin:keyLabelFlags="fontNormal|preserveCase"
|
latin:keyLabelFlags="fontNormal|preserveCase"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:keyActionFlags="noKeyPreview"
|
||||||
latin:backgroundType="functional" />
|
latin:backgroundType="functional" />
|
||||||
|
<key-style
|
||||||
|
latin:styleName="toSymbolKeyStyle"
|
||||||
|
latin:code="!code/key_switch_alpha_symbol"
|
||||||
|
latin:keyLabel="!text/label_to_symbol_key"
|
||||||
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toAlphaKeyStyle"
|
latin:styleName="toAlphaKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
latin:code="!code/key_switch_alpha_symbol"
|
||||||
latin:keyLabel="!text/label_to_alpha_key"
|
latin:keyLabel="!text/label_to_alpha_key"
|
||||||
latin:keyLabelFlags="fontNormal|preserveCase"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toMoreSymbolKeyStyle"
|
latin:styleName="toMoreSymbolKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
latin:code="!code/key_shift"
|
||||||
latin:keyLabel="!text/label_to_more_symbol_for_tablet_key"
|
latin:keyLabel="!text/label_to_more_symbol_for_tablet_key"
|
||||||
latin:keyLabelFlags="fontNormal"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="backFromMoreSymbolKeyStyle"
|
latin:styleName="backFromMoreSymbolKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
latin:code="!code/key_shift"
|
||||||
latin:keyLabel="!text/label_to_symbol_key"
|
latin:keyLabel="!text/label_to_symbol_key"
|
||||||
latin:keyLabelFlags="fontNormal"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="comKeyStyle"
|
latin:styleName="comKeyStyle"
|
||||||
latin:keyLabel="!text/keylabel_for_popular_domain"
|
latin:keyLabel="!text/keylabel_for_popular_domain"
|
||||||
|
|
|
@ -134,52 +134,50 @@
|
||||||
latin:code="!code/key_tab"
|
latin:code="!code/key_tab"
|
||||||
latin:keyIcon="!icon/tab_key"
|
latin:keyIcon="!icon/tab_key"
|
||||||
latin:keyIconPreview="!icon/tab_key_preview" />
|
latin:keyIconPreview="!icon/tab_key_preview" />
|
||||||
|
<key-style
|
||||||
|
latin:styleName="baseForLayoutSwitchKeyStyle"
|
||||||
|
latin:keyLabelFlags="preserveCase"
|
||||||
|
latin:keyActionFlags="noKeyPreview"
|
||||||
|
latin:backgroundType="functional" />
|
||||||
<switch>
|
<switch>
|
||||||
<!-- When this qwerty keyboard has no shortcut keys but shortcut key is enabled, then symbol
|
<!-- When this qwerty keyboard has no shortcut keys but shortcut key is enabled, then symbol
|
||||||
keyboard will have a shortcut key. That means we should use label_to_symbol_key label
|
keyboard will have a shortcut key. That means we should use label_to_symbol_key label
|
||||||
and shortcut_for_label icon. -->
|
and shortcut_for_label icon. -->
|
||||||
<case
|
<case
|
||||||
latin:shortcutKeyEnabled="true"
|
latin:shortcutKeyOnSymbols="true"
|
||||||
latin:hasShortcutKey="false"
|
|
||||||
>
|
>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toSymbolKeyStyle"
|
latin:styleName="baseForToSymbolKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
|
||||||
latin:keyIcon="!icon/shortcut_for_label"
|
latin:keyIcon="!icon/shortcut_for_label"
|
||||||
latin:keyLabel="!text/label_to_symbol_with_microphone_key"
|
latin:keyLabel="!text/label_to_symbol_with_microphone_key"
|
||||||
latin:keyLabelFlags="withIconRight|preserveCase"
|
latin:keyLabelFlags="withIconRight|preserveCase"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:backgroundType="functional" />
|
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toSymbolKeyStyle"
|
latin:styleName="baseForToSymbolKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
|
||||||
latin:keyLabel="!text/label_to_symbol_key"
|
latin:keyLabel="!text/label_to_symbol_key"
|
||||||
latin:keyLabelFlags="preserveCase"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
|
<key-style
|
||||||
|
latin:styleName="toSymbolKeyStyle"
|
||||||
|
latin:code="!code/key_switch_alpha_symbol"
|
||||||
|
latin:parentStyle="baseForToSymbolKeyStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toAlphaKeyStyle"
|
latin:styleName="toAlphaKeyStyle"
|
||||||
latin:code="!code/key_switch_alpha_symbol"
|
latin:code="!code/key_switch_alpha_symbol"
|
||||||
latin:keyLabel="!text/label_to_alpha_key"
|
latin:keyLabel="!text/label_to_alpha_key"
|
||||||
latin:keyLabelFlags="preserveCase"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="toMoreSymbolKeyStyle"
|
latin:styleName="toMoreSymbolKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
latin:code="!code/key_shift"
|
||||||
latin:keyLabel="!text/label_to_more_symbol_key"
|
latin:keyLabel="!text/label_to_more_symbol_key"
|
||||||
latin:keyActionFlags="noKeyPreview"
|
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="backFromMoreSymbolKeyStyle"
|
latin:styleName="backFromMoreSymbolKeyStyle"
|
||||||
latin:code="!code/key_shift"
|
latin:code="!code/key_shift"
|
||||||
latin:keyLabel="!text/label_to_symbol_key"
|
latin:parentStyle="baseForToSymbolKeyStyle" />
|
||||||
latin:keyActionFlags="noKeyPreview"
|
|
||||||
latin:backgroundType="functional" />
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="punctuationKeyStyle"
|
latin:styleName="punctuationKeyStyle"
|
||||||
latin:keyLabel="."
|
latin:keyLabel="."
|
||||||
|
|
|
@ -71,34 +71,39 @@ public final class KeyboardId {
|
||||||
private final EditorInfo mEditorInfo;
|
private final EditorInfo mEditorInfo;
|
||||||
public final boolean mClobberSettingsKey;
|
public final boolean mClobberSettingsKey;
|
||||||
public final boolean mShortcutKeyEnabled;
|
public final boolean mShortcutKeyEnabled;
|
||||||
public final boolean mHasShortcutKey;
|
public final boolean mShortcutKeyOnSymbols;
|
||||||
public final boolean mLanguageSwitchKeyEnabled;
|
public final boolean mLanguageSwitchKeyEnabled;
|
||||||
public final String mCustomActionLabel;
|
public final String mCustomActionLabel;
|
||||||
|
public final boolean mHasShortcutKey;
|
||||||
|
|
||||||
private final int mHashCode;
|
private final int mHashCode;
|
||||||
|
|
||||||
public KeyboardId(int elementId, InputMethodSubtype subtype, int deviceFormFactor,
|
public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
|
||||||
int orientation, int width, int mode, EditorInfo editorInfo, boolean clobberSettingsKey,
|
mSubtype = params.mSubtype;
|
||||||
boolean shortcutKeyEnabled, boolean hasShortcutKey, boolean languageSwitchKeyEnabled) {
|
mLocale = SubtypeLocale.getSubtypeLocale(mSubtype);
|
||||||
mSubtype = subtype;
|
mDeviceFormFactor = params.mDeviceFormFactor;
|
||||||
mLocale = SubtypeLocale.getSubtypeLocale(subtype);
|
mOrientation = params.mOrientation;
|
||||||
mDeviceFormFactor = deviceFormFactor;
|
mWidth = params.mWidth;
|
||||||
mOrientation = orientation;
|
mMode = params.mMode;
|
||||||
mWidth = width;
|
|
||||||
mMode = mode;
|
|
||||||
mElementId = elementId;
|
mElementId = elementId;
|
||||||
mEditorInfo = editorInfo;
|
mEditorInfo = params.mEditorInfo;
|
||||||
mClobberSettingsKey = clobberSettingsKey;
|
mClobberSettingsKey = params.mNoSettingsKey;
|
||||||
mShortcutKeyEnabled = shortcutKeyEnabled;
|
mShortcutKeyEnabled = params.mVoiceKeyEnabled;
|
||||||
mHasShortcutKey = hasShortcutKey;
|
mShortcutKeyOnSymbols = mShortcutKeyEnabled && !params.mVoiceKeyOnMain;
|
||||||
mLanguageSwitchKeyEnabled = languageSwitchKeyEnabled;
|
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
|
||||||
mCustomActionLabel = (editorInfo.actionLabel != null)
|
mCustomActionLabel = (mEditorInfo.actionLabel != null)
|
||||||
? editorInfo.actionLabel.toString() : null;
|
? mEditorInfo.actionLabel.toString() : null;
|
||||||
|
final boolean alphabetMayHaveShortcutKey = isAlphabetKeyboard(elementId)
|
||||||
|
&& !mShortcutKeyOnSymbols;
|
||||||
|
final boolean symbolsMayHaveShortcutKey = (elementId == KeyboardId.ELEMENT_SYMBOLS)
|
||||||
|
&& mShortcutKeyOnSymbols;
|
||||||
|
mHasShortcutKey = mShortcutKeyEnabled
|
||||||
|
&& (alphabetMayHaveShortcutKey || symbolsMayHaveShortcutKey);
|
||||||
|
|
||||||
mHashCode = computeHashCode(this);
|
mHashCode = computeHashCode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int computeHashCode(KeyboardId id) {
|
private static int computeHashCode(final KeyboardId id) {
|
||||||
return Arrays.hashCode(new Object[] {
|
return Arrays.hashCode(new Object[] {
|
||||||
id.mDeviceFormFactor,
|
id.mDeviceFormFactor,
|
||||||
id.mOrientation,
|
id.mOrientation,
|
||||||
|
@ -108,7 +113,7 @@ public final class KeyboardId {
|
||||||
id.passwordInput(),
|
id.passwordInput(),
|
||||||
id.mClobberSettingsKey,
|
id.mClobberSettingsKey,
|
||||||
id.mShortcutKeyEnabled,
|
id.mShortcutKeyEnabled,
|
||||||
id.mHasShortcutKey,
|
id.mShortcutKeyOnSymbols,
|
||||||
id.mLanguageSwitchKeyEnabled,
|
id.mLanguageSwitchKeyEnabled,
|
||||||
id.isMultiLine(),
|
id.isMultiLine(),
|
||||||
id.imeAction(),
|
id.imeAction(),
|
||||||
|
@ -119,7 +124,7 @@ public final class KeyboardId {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean equals(KeyboardId other) {
|
private boolean equals(final KeyboardId other) {
|
||||||
if (other == this)
|
if (other == this)
|
||||||
return true;
|
return true;
|
||||||
return other.mDeviceFormFactor == mDeviceFormFactor
|
return other.mDeviceFormFactor == mDeviceFormFactor
|
||||||
|
@ -130,7 +135,7 @@ public final class KeyboardId {
|
||||||
&& other.passwordInput() == passwordInput()
|
&& other.passwordInput() == passwordInput()
|
||||||
&& other.mClobberSettingsKey == mClobberSettingsKey
|
&& other.mClobberSettingsKey == mClobberSettingsKey
|
||||||
&& other.mShortcutKeyEnabled == mShortcutKeyEnabled
|
&& other.mShortcutKeyEnabled == mShortcutKeyEnabled
|
||||||
&& other.mHasShortcutKey == mHasShortcutKey
|
&& other.mShortcutKeyOnSymbols == mShortcutKeyOnSymbols
|
||||||
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
|
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
|
||||||
&& other.isMultiLine() == isMultiLine()
|
&& other.isMultiLine() == isMultiLine()
|
||||||
&& other.imeAction() == imeAction()
|
&& other.imeAction() == imeAction()
|
||||||
|
@ -140,8 +145,12 @@ public final class KeyboardId {
|
||||||
&& other.mSubtype.equals(mSubtype);
|
&& other.mSubtype.equals(mSubtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isAlphabetKeyboard(final int elementId) {
|
||||||
|
return elementId < ELEMENT_SYMBOLS;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAlphabetKeyboard() {
|
public boolean isAlphabetKeyboard() {
|
||||||
return mElementId < ELEMENT_SYMBOLS;
|
return isAlphabetKeyboard(mElementId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean navigateNext() {
|
public boolean navigateNext() {
|
||||||
|
@ -181,7 +190,7 @@ public final class KeyboardId {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(final Object other) {
|
||||||
return other instanceof KeyboardId && equals((KeyboardId) other);
|
return other instanceof KeyboardId && equals((KeyboardId) other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +201,7 @@ public final class KeyboardId {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("[%s %s:%s %s-%s:%d %s %s %s%s%s%s%s%s%s%s]",
|
return String.format("[%s %s:%s %s-%s:%d %s %s %s%s%s%s%s%s%s%s%s]",
|
||||||
elementIdToName(mElementId),
|
elementIdToName(mElementId),
|
||||||
mLocale,
|
mLocale,
|
||||||
mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
||||||
|
@ -204,13 +213,14 @@ public final class KeyboardId {
|
||||||
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
|
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
|
||||||
(passwordInput() ? " passwordInput" : ""),
|
(passwordInput() ? " passwordInput" : ""),
|
||||||
(mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""),
|
(mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""),
|
||||||
|
(mShortcutKeyOnSymbols ? " shortcutKeyOnSymbols" : ""),
|
||||||
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
||||||
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
|
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
|
||||||
(isMultiLine() ? "isMultiLine" : "")
|
(isMultiLine() ? "isMultiLine" : "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean equivalentEditorInfoForKeyboard(EditorInfo a, EditorInfo b) {
|
public static boolean equivalentEditorInfoForKeyboard(final EditorInfo a, final EditorInfo b) {
|
||||||
if (a == null && b == null) return true;
|
if (a == null && b == null) return true;
|
||||||
if (a == null || b == null) return false;
|
if (a == null || b == null) return false;
|
||||||
return a.inputType == b.inputType
|
return a.inputType == b.inputType
|
||||||
|
@ -218,7 +228,7 @@ public final class KeyboardId {
|
||||||
&& TextUtils.equals(a.privateImeOptions, b.privateImeOptions);
|
&& TextUtils.equals(a.privateImeOptions, b.privateImeOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String elementIdToName(int elementId) {
|
public static String elementIdToName(final int elementId) {
|
||||||
switch (elementId) {
|
switch (elementId) {
|
||||||
case ELEMENT_ALPHABET: return "alphabet";
|
case ELEMENT_ALPHABET: return "alphabet";
|
||||||
case ELEMENT_ALPHABET_MANUAL_SHIFTED: return "alphabetManualShifted";
|
case ELEMENT_ALPHABET_MANUAL_SHIFTED: return "alphabetManualShifted";
|
||||||
|
@ -234,8 +244,8 @@ public final class KeyboardId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String deviceFormFactor(int devoceFormFactor) {
|
public static String deviceFormFactor(final int deviceFormFactor) {
|
||||||
switch (devoceFormFactor) {
|
switch (deviceFormFactor) {
|
||||||
case FORM_FACTOR_PHONE: return "phone";
|
case FORM_FACTOR_PHONE: return "phone";
|
||||||
case FORM_FACTOR_TABLET7: return "tablet7";
|
case FORM_FACTOR_TABLET7: return "tablet7";
|
||||||
case FORM_FACTOR_TABLET10: return "tablet10";
|
case FORM_FACTOR_TABLET10: return "tablet10";
|
||||||
|
@ -243,7 +253,7 @@ public final class KeyboardId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String modeName(int mode) {
|
public static String modeName(final int mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_TEXT: return "text";
|
case MODE_TEXT: return "text";
|
||||||
case MODE_URL: return "url";
|
case MODE_URL: return "url";
|
||||||
|
@ -258,7 +268,7 @@ public final class KeyboardId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String actionName(int actionId) {
|
public static String actionName(final int actionId) {
|
||||||
return (actionId == IME_ACTION_CUSTOM_LABEL) ? "actionCustomLabel"
|
return (actionId == IME_ACTION_CUSTOM_LABEL) ? "actionCustomLabel"
|
||||||
: EditorInfoCompatUtils.imeActionName(actionId);
|
: EditorInfoCompatUtils.imeActionName(actionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public final class KeyboardLayoutSet {
|
||||||
CollectionUtils.newHashMap();
|
CollectionUtils.newHashMap();
|
||||||
private static final KeysCache sKeysCache = new KeysCache();
|
private static final KeysCache sKeysCache = new KeysCache();
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public static final class KeyboardLayoutSetException extends RuntimeException {
|
public static final class KeyboardLayoutSetException extends RuntimeException {
|
||||||
public final KeyboardId mKeyboardId;
|
public final KeyboardId mKeyboardId;
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ public final class KeyboardLayoutSet {
|
||||||
public ElementParams() {}
|
public ElementParams() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Params {
|
public static final class Params {
|
||||||
String mKeyboardLayoutSetName;
|
String mKeyboardLayoutSetName;
|
||||||
int mMode;
|
int mMode;
|
||||||
EditorInfo mEditorInfo;
|
EditorInfo mEditorInfo;
|
||||||
|
@ -109,7 +110,6 @@ public final class KeyboardLayoutSet {
|
||||||
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
|
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
|
||||||
final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
|
final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
|
||||||
CollectionUtils.newSparseArray();
|
CollectionUtils.newSparseArray();
|
||||||
public Params() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearKeyboardCache() {
|
public static void clearKeyboardCache() {
|
||||||
|
@ -149,7 +149,11 @@ public final class KeyboardLayoutSet {
|
||||||
elementParams = mParams.mKeyboardLayoutSetElementIdToParamsMap.get(
|
elementParams = mParams.mKeyboardLayoutSetElementIdToParamsMap.get(
|
||||||
KeyboardId.ELEMENT_ALPHABET);
|
KeyboardId.ELEMENT_ALPHABET);
|
||||||
}
|
}
|
||||||
final KeyboardId id = getKeyboardId(keyboardLayoutSetElementId);
|
// Note: The keyboard for each shift state, and mode are represented as an elementName
|
||||||
|
// attribute in a keyboard_layout_set XML file. Also each keyboard layout XML resource is
|
||||||
|
// specified as an elementKeyboard attribute in the file.
|
||||||
|
// The KeyboardId is an internal key for a Keyboard object.
|
||||||
|
final KeyboardId id = new KeyboardId(keyboardLayoutSetElementId, mParams);
|
||||||
try {
|
try {
|
||||||
return getKeyboard(elementParams, id);
|
return getKeyboard(elementParams, id);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
@ -187,22 +191,6 @@ public final class KeyboardLayoutSet {
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: The keyboard for each locale, shift state, and mode are represented as
|
|
||||||
// KeyboardLayoutSet element id that is a key in keyboard_set.xml. Also that file specifies
|
|
||||||
// which XML layout should be used for each keyboard. The KeyboardId is an internal key for
|
|
||||||
// Keyboard object.
|
|
||||||
private KeyboardId getKeyboardId(final int keyboardLayoutSetElementId) {
|
|
||||||
final Params params = mParams;
|
|
||||||
final boolean isSymbols = (keyboardLayoutSetElementId == KeyboardId.ELEMENT_SYMBOLS
|
|
||||||
|| keyboardLayoutSetElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED);
|
|
||||||
final boolean hasShortcutKey = params.mVoiceKeyEnabled
|
|
||||||
&& (isSymbols != params.mVoiceKeyOnMain);
|
|
||||||
return new KeyboardId(keyboardLayoutSetElementId, params.mSubtype, params.mDeviceFormFactor,
|
|
||||||
params.mOrientation, params.mWidth, params.mMode, params.mEditorInfo,
|
|
||||||
params.mNoSettingsKey, params.mVoiceKeyEnabled, hasShortcutKey,
|
|
||||||
params.mLanguageSwitchKeyEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final String mPackageName;
|
private final String mPackageName;
|
||||||
|
|
|
@ -622,6 +622,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
|
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
|
||||||
final boolean shortcutKeyEnabledMatched = matchBoolean(a,
|
final boolean shortcutKeyEnabledMatched = matchBoolean(a,
|
||||||
R.styleable.Keyboard_Case_shortcutKeyEnabled, id.mShortcutKeyEnabled);
|
R.styleable.Keyboard_Case_shortcutKeyEnabled, id.mShortcutKeyEnabled);
|
||||||
|
final boolean shortcutKeyOnSymbolsMatched = matchBoolean(a,
|
||||||
|
R.styleable.Keyboard_Case_shortcutKeyOnSymbols, id.mShortcutKeyOnSymbols);
|
||||||
final boolean hasShortcutKeyMatched = matchBoolean(a,
|
final boolean hasShortcutKeyMatched = matchBoolean(a,
|
||||||
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
||||||
final boolean languageSwitchKeyEnabledMatched = matchBoolean(a,
|
final boolean languageSwitchKeyEnabledMatched = matchBoolean(a,
|
||||||
|
@ -640,12 +642,12 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
final boolean selected = keyboardLayoutSetElementMatched && modeMatched
|
final boolean selected = keyboardLayoutSetElementMatched && modeMatched
|
||||||
&& navigateNextMatched && navigatePreviousMatched && passwordInputMatched
|
&& navigateNextMatched && navigatePreviousMatched && passwordInputMatched
|
||||||
&& clobberSettingsKeyMatched && shortcutKeyEnabledMatched
|
&& clobberSettingsKeyMatched && shortcutKeyEnabledMatched
|
||||||
&& hasShortcutKeyMatched && languageSwitchKeyEnabledMatched
|
&& shortcutKeyOnSymbolsMatched && hasShortcutKeyMatched
|
||||||
&& isMultiLineMatched && imeActionMatched && localeCodeMatched
|
&& languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched
|
||||||
&& languageCodeMatched && countryCodeMatched;
|
&& localeCodeMatched && languageCodeMatched && countryCodeMatched;
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
startTag("<%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", TAG_CASE,
|
||||||
textAttr(a.getString(
|
textAttr(a.getString(
|
||||||
R.styleable.Keyboard_Case_keyboardLayoutSetElement),
|
R.styleable.Keyboard_Case_keyboardLayoutSetElement),
|
||||||
"keyboardLayoutSetElement"),
|
"keyboardLayoutSetElement"),
|
||||||
|
@ -662,6 +664,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
"passwordInput"),
|
"passwordInput"),
|
||||||
booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyEnabled,
|
booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyEnabled,
|
||||||
"shortcutKeyEnabled"),
|
"shortcutKeyEnabled"),
|
||||||
|
booleanAttr(a, R.styleable.Keyboard_Case_shortcutKeyOnSymbols,
|
||||||
|
"shortcutKeyOnSymbols"),
|
||||||
booleanAttr(a, R.styleable.Keyboard_Case_hasShortcutKey,
|
booleanAttr(a, R.styleable.Keyboard_Case_hasShortcutKey,
|
||||||
"hasShortcutKey"),
|
"hasShortcutKey"),
|
||||||
booleanAttr(a, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
|
booleanAttr(a, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
|
||||||
|
|
Loading…
Reference in New Issue