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"/>
|
<attr name="elementKeyboard" format="reference"/>
|
||||||
<!-- Enable proximity characters correction. Disabled by default. -->
|
<!-- Enable proximity characters correction. Disabled by default. -->
|
||||||
<attr name="enableProximityCharsCorrection" format="boolean" />
|
<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>
|
||||||
|
|
||||||
<declare-styleable name="KeyboardLayoutSet_Feature">
|
<declare-styleable name="KeyboardLayoutSet_Feature">
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
<Element
|
<Element
|
||||||
latin:elementName="alphabet"
|
latin:elementName="alphabet"
|
||||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||||
latin:enableProximityCharsCorrection="true" />
|
latin:enableProximityCharsCorrection="true"
|
||||||
|
latin:supportsSplitLayout="false" />
|
||||||
<Element
|
<Element
|
||||||
latin:elementName="symbols"
|
latin:elementName="symbols"
|
||||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||||
|
|
|
@ -73,10 +73,12 @@ public final class KeyboardId {
|
||||||
public final boolean mLanguageSwitchKeyEnabled;
|
public final boolean mLanguageSwitchKeyEnabled;
|
||||||
public final String mCustomActionLabel;
|
public final String mCustomActionLabel;
|
||||||
public final boolean mHasShortcutKey;
|
public final boolean mHasShortcutKey;
|
||||||
|
public final boolean mIsSplitLayout;
|
||||||
|
|
||||||
private final int mHashCode;
|
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;
|
mSubtype = params.mSubtype;
|
||||||
mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype);
|
mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype);
|
||||||
mWidth = params.mKeyboardWidth;
|
mWidth = params.mKeyboardWidth;
|
||||||
|
@ -89,6 +91,7 @@ public final class KeyboardId {
|
||||||
mCustomActionLabel = (mEditorInfo.actionLabel != null)
|
mCustomActionLabel = (mEditorInfo.actionLabel != null)
|
||||||
? mEditorInfo.actionLabel.toString() : null;
|
? mEditorInfo.actionLabel.toString() : null;
|
||||||
mHasShortcutKey = params.mVoiceInputKeyEnabled;
|
mHasShortcutKey = params.mVoiceInputKeyEnabled;
|
||||||
|
mIsSplitLayout = isSplitLayout;
|
||||||
|
|
||||||
mHashCode = computeHashCode(this);
|
mHashCode = computeHashCode(this);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +111,8 @@ public final class KeyboardId {
|
||||||
id.mCustomActionLabel,
|
id.mCustomActionLabel,
|
||||||
id.navigateNext(),
|
id.navigateNext(),
|
||||||
id.navigatePrevious(),
|
id.navigatePrevious(),
|
||||||
id.mSubtype
|
id.mSubtype,
|
||||||
|
id.mIsSplitLayout
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +132,8 @@ public final class KeyboardId {
|
||||||
&& TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
|
&& TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
|
||||||
&& other.navigateNext() == navigateNext()
|
&& other.navigateNext() == navigateNext()
|
||||||
&& other.navigatePrevious() == navigatePrevious()
|
&& other.navigatePrevious() == navigatePrevious()
|
||||||
&& other.mSubtype.equals(mSubtype);
|
&& other.mSubtype.equals(mSubtype)
|
||||||
|
&& other.mIsSplitLayout == mIsSplitLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAlphabetKeyboard(final int elementId) {
|
private static boolean isAlphabetKeyboard(final int elementId) {
|
||||||
|
@ -175,7 +180,7 @@ public final class KeyboardId {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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),
|
elementIdToName(mElementId),
|
||||||
mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
||||||
mWidth, mHeight,
|
mWidth, mHeight,
|
||||||
|
@ -187,7 +192,8 @@ public final class KeyboardId {
|
||||||
(passwordInput() ? " passwordInput" : ""),
|
(passwordInput() ? " passwordInput" : ""),
|
||||||
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
||||||
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
|
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
|
||||||
(isMultiLine() ? " isMultiLine" : "")
|
(isMultiLine() ? " isMultiLine" : ""),
|
||||||
|
(mIsSplitLayout ? " isSplitLayout" : "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ public final class KeyboardLayoutSet {
|
||||||
private static final class ElementParams {
|
private static final class ElementParams {
|
||||||
int mKeyboardXmlId;
|
int mKeyboardXmlId;
|
||||||
boolean mProximityCharsCorrectionEnabled;
|
boolean mProximityCharsCorrectionEnabled;
|
||||||
|
boolean mSupportsSplitLayout;
|
||||||
public ElementParams() {}
|
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
|
// attribute in a keyboard_layout_set XML file. Also each keyboard layout XML resource is
|
||||||
// specified as an elementKeyboard attribute in the file.
|
// specified as an elementKeyboard attribute in the file.
|
||||||
// The KeyboardId is an internal key for a Keyboard object.
|
// 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 {
|
try {
|
||||||
return getKeyboard(elementParams, id);
|
return getKeyboard(elementParams, id);
|
||||||
} catch (final RuntimeException e) {
|
} catch (final RuntimeException e) {
|
||||||
|
@ -376,6 +380,8 @@ public final class KeyboardLayoutSet {
|
||||||
elementParams.mProximityCharsCorrectionEnabled = a.getBoolean(
|
elementParams.mProximityCharsCorrectionEnabled = a.getBoolean(
|
||||||
R.styleable.KeyboardLayoutSet_Element_enableProximityCharsCorrection,
|
R.styleable.KeyboardLayoutSet_Element_enableProximityCharsCorrection,
|
||||||
false);
|
false);
|
||||||
|
elementParams.mSupportsSplitLayout = a.getBoolean(
|
||||||
|
R.styleable.KeyboardLayoutSet_Element_supportsSplitLayout, false);
|
||||||
mParams.mKeyboardLayoutSetElementIdToParamsMap.put(elementName, elementParams);
|
mParams.mKeyboardLayoutSetElementIdToParamsMap.put(elementName, elementParams);
|
||||||
} finally {
|
} finally {
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
Loading…
Reference in New Issue