Fix mini crash + Can disable on keys

This commit is contained in:
juloo 2015-08-02 19:56:23 +02:00
parent 5bbdbcd522
commit 1115a34a19
2 changed files with 15 additions and 6 deletions

View File

@ -31,6 +31,8 @@ public class Keyboard2 extends InputMethodService
{
int eventCode = key.getEventCode();
if (getCurrentInputConnection() == null)
return ; // TODO wait a little before give up
switch (eventCode)
{
case KeyValue.EVENT_NONE:

View File

@ -102,14 +102,14 @@ public class Keyboard2View extends View
return (null);
}
private boolean isKeyDown(KeyboardData.Key key)
private KeyDown getKeyDown(KeyboardData.Key key)
{
for (KeyDown k : _downKeys)
{
if (k.key == key)
return (true);
return (k);
}
return (false);
return (null);
}
private void onTouchMove(float moveX, float moveY, int pointerId)
@ -138,7 +138,14 @@ public class Keyboard2View extends View
keyW = _keyWidth * key.width;
if (touchX >= x && touchX < (x + keyW))
{
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY));
KeyDown down = getKeyDown(key);
if (down != null)
{
if (down.pointerId == -1)
down.pointerId = pointerId;
}
else
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY));
updateFlags();
invalidate();
return ;
@ -211,7 +218,7 @@ public class Keyboard2View extends View
for (KeyboardData.Key k : row)
{
float keyW = _keyWidth * k.width;
if (isKeyDown(k))
if (getKeyDown(k) != null)
canvas.drawRect(x + _keyBgPadding, y + _keyBgPadding,
x + keyW - _keyBgPadding, y + _keyHeight - _keyBgPadding, _keyDownBgPaint);
else
@ -259,7 +266,7 @@ public class Keyboard2View extends View
this.key = key;
downX = x;
downY = y;
flags = value.getFlags();
flags = (value == null) ? 0 : value.getFlags();
}
public boolean updateDown(float x, float y)