Update other alt keys' graphics
Change-Id: I12699907a514f5fc2e110a0a711fb91c14a8756f
This commit is contained in:
parent
b4fbbe57f5
commit
faad353fea
2 changed files with 60 additions and 34 deletions
|
@ -125,6 +125,7 @@ public class Keyboard {
|
||||||
/** Array of keys and icons in this keyboard */
|
/** Array of keys and icons in this keyboard */
|
||||||
public final Key[] mKeys;
|
public final Key[] mKeys;
|
||||||
public final Key[] mShiftKeys;
|
public final Key[] mShiftKeys;
|
||||||
|
public final Key[] mAltCodeKeysWhileTyping;
|
||||||
public final KeyboardIconsSet mIconsSet;
|
public final KeyboardIconsSet mIconsSet;
|
||||||
|
|
||||||
private final HashMap<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
|
private final HashMap<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
|
||||||
|
@ -148,6 +149,8 @@ public class Keyboard {
|
||||||
|
|
||||||
mKeys = params.mKeys.toArray(new Key[params.mKeys.size()]);
|
mKeys = params.mKeys.toArray(new Key[params.mKeys.size()]);
|
||||||
mShiftKeys = params.mShiftKeys.toArray(new Key[params.mShiftKeys.size()]);
|
mShiftKeys = params.mShiftKeys.toArray(new Key[params.mShiftKeys.size()]);
|
||||||
|
mAltCodeKeysWhileTyping = params.mAltCodeKeysWhileTyping.toArray(
|
||||||
|
new Key[params.mAltCodeKeysWhileTyping.size()]);
|
||||||
mIconsSet = params.mIconsSet;
|
mIconsSet = params.mIconsSet;
|
||||||
mAdditionalProximityChars = params.mAdditionalProximityChars;
|
mAdditionalProximityChars = params.mAdditionalProximityChars;
|
||||||
|
|
||||||
|
@ -224,6 +227,7 @@ public class Keyboard {
|
||||||
|
|
||||||
public final ArrayList<Key> mKeys = new ArrayList<Key>();
|
public final ArrayList<Key> mKeys = new ArrayList<Key>();
|
||||||
public final ArrayList<Key> mShiftKeys = new ArrayList<Key>();
|
public final ArrayList<Key> mShiftKeys = new ArrayList<Key>();
|
||||||
|
public final ArrayList<Key> mAltCodeKeysWhileTyping = new ArrayList<Key>();
|
||||||
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
|
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
|
||||||
// TODO: Should be in Key instead of Keyboard.Params?
|
// TODO: Should be in Key instead of Keyboard.Params?
|
||||||
public final Map<Integer, List<Integer>> mAdditionalProximityChars =
|
public final Map<Integer, List<Integer>> mAdditionalProximityChars =
|
||||||
|
@ -305,6 +309,9 @@ public class Keyboard {
|
||||||
if (key.mCode == Keyboard.CODE_SHIFT) {
|
if (key.mCode == Keyboard.CODE_SHIFT) {
|
||||||
mShiftKeys.add(key);
|
mShiftKeys.add(key);
|
||||||
}
|
}
|
||||||
|
if (key.altCodeWhileTyping()) {
|
||||||
|
mAltCodeKeysWhileTyping.add(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mMaxHeightCount = 0;
|
private int mMaxHeightCount = 0;
|
||||||
|
|
|
@ -322,57 +322,76 @@ public class PointerTracker {
|
||||||
|
|
||||||
private void setReleasedKeyGraphics(Key key) {
|
private void setReleasedKeyGraphics(Key key) {
|
||||||
mDrawingProxy.dismissKeyPreview(this);
|
mDrawingProxy.dismissKeyPreview(this);
|
||||||
if (key != null && key.isEnabled()) {
|
if (key == null || !key.isEnabled()) {
|
||||||
key.onReleased();
|
return;
|
||||||
mDrawingProxy.invalidateKey(key);
|
}
|
||||||
|
|
||||||
|
updateReleaseKeyGraphics(key);
|
||||||
|
|
||||||
if (key.isShift()) {
|
if (key.isShift()) {
|
||||||
for (final Key shiftKey : mKeyboard.mShiftKeys) {
|
for (final Key shiftKey : mKeyboard.mShiftKeys) {
|
||||||
if (shiftKey != key) {
|
if (shiftKey != key) {
|
||||||
shiftKey.onReleased();
|
updateReleaseKeyGraphics(shiftKey);
|
||||||
mDrawingProxy.invalidateKey(shiftKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.altCodeWhileTyping()) {
|
if (key.altCodeWhileTyping()) {
|
||||||
final Key altKey = mKeyboard.getKey(key.mAltCode);
|
final int altCode = key.mAltCode;
|
||||||
|
final Key altKey = mKeyboard.getKey(altCode);
|
||||||
if (altKey != null) {
|
if (altKey != null) {
|
||||||
altKey.onReleased();
|
updateReleaseKeyGraphics(altKey);
|
||||||
mDrawingProxy.invalidateKey(altKey);
|
}
|
||||||
|
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
|
||||||
|
if (k != key && k.mAltCode == altCode) {
|
||||||
|
updateReleaseKeyGraphics(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPressedKeyGraphics(Key key) {
|
private void setPressedKeyGraphics(Key key) {
|
||||||
if (key != null && key.isEnabled()) {
|
if (key == null || !key.isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!key.noKeyPreview()) {
|
if (!key.noKeyPreview()) {
|
||||||
mDrawingProxy.showKeyPreview(this);
|
mDrawingProxy.showKeyPreview(this);
|
||||||
}
|
}
|
||||||
key.onPressed();
|
updatePressKeyGraphics(key);
|
||||||
mDrawingProxy.invalidateKey(key);
|
|
||||||
|
|
||||||
if (key.isShift()) {
|
if (key.isShift()) {
|
||||||
for (final Key shiftKey : mKeyboard.mShiftKeys) {
|
for (final Key shiftKey : mKeyboard.mShiftKeys) {
|
||||||
if (shiftKey != key) {
|
if (shiftKey != key) {
|
||||||
shiftKey.onPressed();
|
updatePressKeyGraphics(shiftKey);
|
||||||
mDrawingProxy.invalidateKey(shiftKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.altCodeWhileTyping() && mTimerProxy.isTyping()) {
|
if (key.altCodeWhileTyping() && mTimerProxy.isTyping()) {
|
||||||
final Key altKey = mKeyboard.getKey(key.mAltCode);
|
final int altCode = key.mAltCode;
|
||||||
|
final Key altKey = mKeyboard.getKey(altCode);
|
||||||
if (altKey != null) {
|
if (altKey != null) {
|
||||||
// TODO: Show altKey's preview.
|
updatePressKeyGraphics(altKey);
|
||||||
altKey.onPressed();
|
}
|
||||||
mDrawingProxy.invalidateKey(altKey);
|
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
|
||||||
|
if (k != key && k.mAltCode == altCode) {
|
||||||
|
updatePressKeyGraphics(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateReleaseKeyGraphics(Key key) {
|
||||||
|
key.onReleased();
|
||||||
|
mDrawingProxy.invalidateKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePressKeyGraphics(Key key) {
|
||||||
|
key.onPressed();
|
||||||
|
mDrawingProxy.invalidateKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
public int getLastX() {
|
public int getLastX() {
|
||||||
return mLastX;
|
return mLastX;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue