Update other alt keys' graphics

Change-Id: I12699907a514f5fc2e110a0a711fb91c14a8756f
main
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 */
public final Key[] mKeys;
public final Key[] mShiftKeys;
public final Key[] mAltCodeKeysWhileTyping;
public final KeyboardIconsSet mIconsSet;
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()]);
mShiftKeys = params.mShiftKeys.toArray(new Key[params.mShiftKeys.size()]);
mAltCodeKeysWhileTyping = params.mAltCodeKeysWhileTyping.toArray(
new Key[params.mAltCodeKeysWhileTyping.size()]);
mIconsSet = params.mIconsSet;
mAdditionalProximityChars = params.mAdditionalProximityChars;
@ -224,6 +227,7 @@ public class Keyboard {
public final ArrayList<Key> mKeys = 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();
// TODO: Should be in Key instead of Keyboard.Params?
public final Map<Integer, List<Integer>> mAdditionalProximityChars =
@ -305,6 +309,9 @@ public class Keyboard {
if (key.mCode == Keyboard.CODE_SHIFT) {
mShiftKeys.add(key);
}
if (key.altCodeWhileTyping()) {
mAltCodeKeysWhileTyping.add(key);
}
}
private int mMaxHeightCount = 0;

View File

@ -322,57 +322,76 @@ public class PointerTracker {
private void setReleasedKeyGraphics(Key key) {
mDrawingProxy.dismissKeyPreview(this);
if (key != null && key.isEnabled()) {
key.onReleased();
mDrawingProxy.invalidateKey(key);
if (key == null || !key.isEnabled()) {
return;
}
updateReleaseKeyGraphics(key);
if (key.isShift()) {
for (final Key shiftKey : mKeyboard.mShiftKeys) {
if (shiftKey != key) {
shiftKey.onReleased();
mDrawingProxy.invalidateKey(shiftKey);
updateReleaseKeyGraphics(shiftKey);
}
}
}
if (key.altCodeWhileTyping()) {
final Key altKey = mKeyboard.getKey(key.mAltCode);
final int altCode = key.mAltCode;
final Key altKey = mKeyboard.getKey(altCode);
if (altKey != null) {
altKey.onReleased();
mDrawingProxy.invalidateKey(altKey);
updateReleaseKeyGraphics(altKey);
}
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
if (k != key && k.mAltCode == altCode) {
updateReleaseKeyGraphics(k);
}
}
}
}
private void setPressedKeyGraphics(Key key) {
if (key != null && key.isEnabled()) {
if (key == null || !key.isEnabled()) {
return;
}
if (!key.noKeyPreview()) {
mDrawingProxy.showKeyPreview(this);
}
key.onPressed();
mDrawingProxy.invalidateKey(key);
updatePressKeyGraphics(key);
if (key.isShift()) {
for (final Key shiftKey : mKeyboard.mShiftKeys) {
if (shiftKey != key) {
shiftKey.onPressed();
mDrawingProxy.invalidateKey(shiftKey);
updatePressKeyGraphics(shiftKey);
}
}
}
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) {
// TODO: Show altKey's preview.
altKey.onPressed();
mDrawingProxy.invalidateKey(altKey);
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() {
return mLastX;
}