From 3939455c1dde7023c2f404b5702a23485defc942 Mon Sep 17 00:00:00 2001 From: Sandeep Siddhartha Date: Wed, 10 Sep 2014 10:32:24 +0900 Subject: [PATCH] Add a canSplitKeyboard attribute for specifying split keyboard layouts Change [1/3] This'll be used in conjunction with a user preference to split the keyboard when possible. Bug: 4968173 Change-Id: I7a05948d67b94a55024790115ae261d7fef7941a --- java/res/values/attrs.xml | 2 ++ java/res/xml/keyboard_layout_set_qwerty.xml | 3 ++- .../android/inputmethod/keyboard/KeyboardId.java | 16 +++++++++++----- .../inputmethod/keyboard/KeyboardLayoutSet.java | 8 +++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index f1253b40c..c5c632683 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -514,6 +514,8 @@ + + diff --git a/java/res/xml/keyboard_layout_set_qwerty.xml b/java/res/xml/keyboard_layout_set_qwerty.xml index 821517081..1aa6f010a 100644 --- a/java/res/xml/keyboard_layout_set_qwerty.xml +++ b/java/res/xml/keyboard_layout_set_qwerty.xml @@ -23,7 +23,8 @@ + latin:enableProximityCharsCorrection="true" + latin:supportsSplitLayout="false" /> diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 538e515bc..43c61443e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -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" : "") ); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index 3f4367313..1dbecdc81 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -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();