am 23f38149: Merge "Add a canSplitKeyboard attribute for specifying split keyboard layouts"
* commit '23f38149c6d83e10f9b60fa1e6653f421df3f539': Add a canSplitKeyboard attribute for specifying split keyboard layoutsmain
commit
cd25535929
|
@ -514,6 +514,8 @@
|
|||
<attr name="elementKeyboard" format="reference"/>
|
||||
<!-- Enable proximity characters correction. Disabled by default. -->
|
||||
<attr name="enableProximityCharsCorrection" format="boolean" />
|
||||
<!-- Indicates if the keyboard layout supports being split or not. false by default -->
|
||||
<attr name="supportsSplitLayout" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="KeyboardLayoutSet_Feature">
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
latin:enableProximityCharsCorrection="true"
|
||||
latin:supportsSplitLayout="false" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
|
|
@ -73,10 +73,12 @@ public final class KeyboardId {
|
|||
public final boolean mLanguageSwitchKeyEnabled;
|
||||
public final String mCustomActionLabel;
|
||||
public final boolean mHasShortcutKey;
|
||||
public final boolean mIsSplitLayout;
|
||||
|
||||
private final int mHashCode;
|
||||
|
||||
public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
|
||||
public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params,
|
||||
boolean isSplitLayout) {
|
||||
mSubtype = params.mSubtype;
|
||||
mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype);
|
||||
mWidth = params.mKeyboardWidth;
|
||||
|
@ -89,6 +91,7 @@ public final class KeyboardId {
|
|||
mCustomActionLabel = (mEditorInfo.actionLabel != null)
|
||||
? mEditorInfo.actionLabel.toString() : null;
|
||||
mHasShortcutKey = params.mVoiceInputKeyEnabled;
|
||||
mIsSplitLayout = isSplitLayout;
|
||||
|
||||
mHashCode = computeHashCode(this);
|
||||
}
|
||||
|
@ -108,7 +111,8 @@ public final class KeyboardId {
|
|||
id.mCustomActionLabel,
|
||||
id.navigateNext(),
|
||||
id.navigatePrevious(),
|
||||
id.mSubtype
|
||||
id.mSubtype,
|
||||
id.mIsSplitLayout
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,7 +132,8 @@ public final class KeyboardId {
|
|||
&& TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
|
||||
&& other.navigateNext() == navigateNext()
|
||||
&& other.navigatePrevious() == navigatePrevious()
|
||||
&& other.mSubtype.equals(mSubtype);
|
||||
&& other.mSubtype.equals(mSubtype)
|
||||
&& other.mIsSplitLayout == mIsSplitLayout;
|
||||
}
|
||||
|
||||
private static boolean isAlphabetKeyboard(final int elementId) {
|
||||
|
@ -175,7 +180,7 @@ public final class KeyboardId {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s]",
|
||||
return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s%s]",
|
||||
elementIdToName(mElementId),
|
||||
mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
||||
mWidth, mHeight,
|
||||
|
@ -187,7 +192,8 @@ public final class KeyboardId {
|
|||
(passwordInput() ? " passwordInput" : ""),
|
||||
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
||||
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
|
||||
(isMultiLine() ? " isMultiLine" : "")
|
||||
(isMultiLine() ? " isMultiLine" : ""),
|
||||
(mIsSplitLayout ? " isSplitLayout" : "")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ public final class KeyboardLayoutSet {
|
|||
private static final class ElementParams {
|
||||
int mKeyboardXmlId;
|
||||
boolean mProximityCharsCorrectionEnabled;
|
||||
boolean mSupportsSplitLayout;
|
||||
public ElementParams() {}
|
||||
}
|
||||
|
||||
|
@ -168,7 +169,10 @@ public final class KeyboardLayoutSet {
|
|||
// 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);
|
||||
|
||||
// TODO: AND mSupportsSplitLayout with the user preference that forces a split.
|
||||
final KeyboardId id = new KeyboardId(keyboardLayoutSetElementId, mParams,
|
||||
elementParams.mSupportsSplitLayout);
|
||||
try {
|
||||
return getKeyboard(elementParams, id);
|
||||
} catch (final RuntimeException e) {
|
||||
|
@ -376,6 +380,8 @@ public final class KeyboardLayoutSet {
|
|||
elementParams.mProximityCharsCorrectionEnabled = a.getBoolean(
|
||||
R.styleable.KeyboardLayoutSet_Element_enableProximityCharsCorrection,
|
||||
false);
|
||||
elementParams.mSupportsSplitLayout = a.getBoolean(
|
||||
R.styleable.KeyboardLayoutSet_Element_supportsSplitLayout, false);
|
||||
mParams.mKeyboardLayoutSetElementIdToParamsMap.put(elementName, elementParams);
|
||||
} finally {
|
||||
a.recycle();
|
||||
|
|
Loading…
Reference in New Issue