Update other alt keys' graphics

Change-Id: I12699907a514f5fc2e110a0a711fb91c14a8756f
This commit is contained in:
Tadashi G. Takaoka 2012-03-13 17:15:05 +09:00
parent b4fbbe57f5
commit faad353fea
2 changed files with 60 additions and 34 deletions

View file

@ -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;

View file

@ -322,55 +322,74 @@ 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); }
if (key.isShift()) { updateReleaseKeyGraphics(key);
for (final Key shiftKey : mKeyboard.mShiftKeys) {
if (shiftKey != key) { if (key.isShift()) {
shiftKey.onReleased(); for (final Key shiftKey : mKeyboard.mShiftKeys) {
mDrawingProxy.invalidateKey(shiftKey); if (shiftKey != key) {
} updateReleaseKeyGraphics(shiftKey);
} }
} }
}
if (key.altCodeWhileTyping()) { if (key.altCodeWhileTyping()) {
final Key altKey = mKeyboard.getKey(key.mAltCode); final int altCode = key.mAltCode;
if (altKey != null) { final Key altKey = mKeyboard.getKey(altCode);
altKey.onReleased(); if (altKey != null) {
mDrawingProxy.invalidateKey(altKey); updateReleaseKeyGraphics(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()) {
if (!key.noKeyPreview()) { return;
mDrawingProxy.showKeyPreview(this); }
}
key.onPressed();
mDrawingProxy.invalidateKey(key);
if (key.isShift()) { if (!key.noKeyPreview()) {
for (final Key shiftKey : mKeyboard.mShiftKeys) { mDrawingProxy.showKeyPreview(this);
if (shiftKey != key) { }
shiftKey.onPressed(); updatePressKeyGraphics(key);
mDrawingProxy.invalidateKey(shiftKey);
}
}
}
if (key.altCodeWhileTyping() && mTimerProxy.isTyping()) { if (key.isShift()) {
final Key altKey = mKeyboard.getKey(key.mAltCode); for (final Key shiftKey : mKeyboard.mShiftKeys) {
if (altKey != null) { if (shiftKey != key) {
// TODO: Show altKey's preview. updatePressKeyGraphics(shiftKey);
altKey.onPressed();
mDrawingProxy.invalidateKey(altKey);
} }
} }
} }
if (key.altCodeWhileTyping() && mTimerProxy.isTyping()) {
final int altCode = key.mAltCode;
final Key altKey = mKeyboard.getKey(altCode);
if (altKey != null) {
updatePressKeyGraphics(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() {