mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add copy constructor to Keyboard
Change-Id: Ib207039f53346f420cca050080e3c4f452e63ff6
This commit is contained in:
parent
af9c8892da
commit
0b3d5e12e3
@ -157,7 +157,7 @@ public final class AccessibilityEntityProvider extends AccessibilityNodeProvider
|
||||
|
||||
// Add the virtual children of the root View.
|
||||
final Keyboard keyboard = mKeyboardView.getKeyboard();
|
||||
final Key[] keys = keyboard.mKeys;
|
||||
final Key[] keys = keyboard.getKeys();
|
||||
for (Key key : keys) {
|
||||
final int childVirtualViewId = generateVirtualViewIdForKey(key);
|
||||
rootInfo.addChild(mKeyboardView, childVirtualViewId);
|
||||
@ -300,7 +300,7 @@ public final class AccessibilityEntityProvider extends AccessibilityNodeProvider
|
||||
}
|
||||
mVirtualViewIdToKey.clear();
|
||||
|
||||
final Key[] keys = keyboard.mKeys;
|
||||
final Key[] keys = keyboard.getKeys();
|
||||
for (Key key : keys) {
|
||||
final int virtualViewId = generateVirtualViewIdForKey(key);
|
||||
mVirtualViewIdToKey.put(virtualViewId, key);
|
||||
|
@ -69,7 +69,7 @@ public class Keyboard {
|
||||
public final int mMaxMoreKeysKeyboardColumn;
|
||||
|
||||
/** Array of keys and icons in this keyboard */
|
||||
public final Key[] mKeys;
|
||||
private final Key[] mKeys;
|
||||
public final Key[] mShiftKeys;
|
||||
public final Key[] mAltCodeKeysWhileTyping;
|
||||
public final KeyboardIconsSet mIconsSet;
|
||||
@ -104,6 +104,28 @@ public class Keyboard {
|
||||
mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled;
|
||||
}
|
||||
|
||||
protected Keyboard(final Keyboard keyboard) {
|
||||
mId = keyboard.mId;
|
||||
mThemeId = keyboard.mThemeId;
|
||||
mOccupiedHeight = keyboard.mOccupiedHeight;
|
||||
mOccupiedWidth = keyboard.mOccupiedWidth;
|
||||
mMostCommonKeyHeight = keyboard.mMostCommonKeyHeight;
|
||||
mMostCommonKeyWidth = keyboard.mMostCommonKeyWidth;
|
||||
mMoreKeysTemplate = keyboard.mMoreKeysTemplate;
|
||||
mMaxMoreKeysKeyboardColumn = keyboard.mMaxMoreKeysKeyboardColumn;
|
||||
mKeyVisualAttributes = keyboard.mKeyVisualAttributes;
|
||||
mTopPadding = keyboard.mTopPadding;
|
||||
mVerticalGap = keyboard.mVerticalGap;
|
||||
|
||||
mKeys = keyboard.mKeys;
|
||||
mShiftKeys = keyboard.mShiftKeys;
|
||||
mAltCodeKeysWhileTyping = keyboard.mAltCodeKeysWhileTyping;
|
||||
mIconsSet = keyboard.mIconsSet;
|
||||
|
||||
mProximityInfo = keyboard.mProximityInfo;
|
||||
mProximityCharsCorrectionEnabled = keyboard.mProximityCharsCorrectionEnabled;
|
||||
}
|
||||
|
||||
public boolean hasProximityCharsCorrection(final int code) {
|
||||
if (!mProximityCharsCorrectionEnabled) {
|
||||
return false;
|
||||
@ -120,6 +142,10 @@ public class Keyboard {
|
||||
return mProximityInfo;
|
||||
}
|
||||
|
||||
public Key[] getKeys() {
|
||||
return mKeys;
|
||||
}
|
||||
|
||||
public Key getKey(final int code) {
|
||||
if (code == Constants.CODE_UNSPECIFIED) {
|
||||
return null;
|
||||
@ -130,7 +156,7 @@ public class Keyboard {
|
||||
return mKeyCache.valueAt(index);
|
||||
}
|
||||
|
||||
for (final Key key : mKeys) {
|
||||
for (final Key key : getKeys()) {
|
||||
if (key.getCode() == code) {
|
||||
mKeyCache.put(code, key);
|
||||
return key;
|
||||
@ -146,7 +172,7 @@ public class Keyboard {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (final Key key : mKeys) {
|
||||
for (final Key key : getKeys()) {
|
||||
if (key == aKey) {
|
||||
mKeyCache.put(key.getCode(), key);
|
||||
return true;
|
||||
|
@ -285,7 +285,7 @@ public class KeyboardView extends View {
|
||||
// TODO: Confirm if it's really required to draw all keys when hardware acceleration is on.
|
||||
if (drawAllKeys || isHardwareAccelerated) {
|
||||
// Draw all keys.
|
||||
for (final Key key : mKeyboard.mKeys) {
|
||||
for (final Key key : mKeyboard.getKeys()) {
|
||||
onDrawKey(key, canvas, paint);
|
||||
}
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ public final class MoreKeysDetector extends KeyDetector {
|
||||
|
||||
Key nearestKey = null;
|
||||
int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
|
||||
for (final Key key : getKeyboard().mKeys) {
|
||||
for (final Key key : getKeyboard().getKeys()) {
|
||||
final int dist = key.squaredDistanceToEdge(touchX, touchY);
|
||||
if (dist < nearestDist) {
|
||||
nearestKey = key;
|
||||
|
Loading…
Reference in New Issue
Block a user