forked from extern/Unexpected-Keyboard
Fix mini crash + Can disable on keys
This commit is contained in:
parent
5bbdbcd522
commit
1115a34a19
@ -31,6 +31,8 @@ public class Keyboard2 extends InputMethodService
|
|||||||
{
|
{
|
||||||
int eventCode = key.getEventCode();
|
int eventCode = key.getEventCode();
|
||||||
|
|
||||||
|
if (getCurrentInputConnection() == null)
|
||||||
|
return ; // TODO wait a little before give up
|
||||||
switch (eventCode)
|
switch (eventCode)
|
||||||
{
|
{
|
||||||
case KeyValue.EVENT_NONE:
|
case KeyValue.EVENT_NONE:
|
||||||
|
@ -102,14 +102,14 @@ public class Keyboard2View extends View
|
|||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isKeyDown(KeyboardData.Key key)
|
private KeyDown getKeyDown(KeyboardData.Key key)
|
||||||
{
|
{
|
||||||
for (KeyDown k : _downKeys)
|
for (KeyDown k : _downKeys)
|
||||||
{
|
{
|
||||||
if (k.key == key)
|
if (k.key == key)
|
||||||
return (true);
|
return (k);
|
||||||
}
|
}
|
||||||
return (false);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTouchMove(float moveX, float moveY, int pointerId)
|
private void onTouchMove(float moveX, float moveY, int pointerId)
|
||||||
@ -138,6 +138,13 @@ public class Keyboard2View extends View
|
|||||||
keyW = _keyWidth * key.width;
|
keyW = _keyWidth * key.width;
|
||||||
if (touchX >= x && touchX < (x + keyW))
|
if (touchX >= x && touchX < (x + keyW))
|
||||||
{
|
{
|
||||||
|
KeyDown down = getKeyDown(key);
|
||||||
|
if (down != null)
|
||||||
|
{
|
||||||
|
if (down.pointerId == -1)
|
||||||
|
down.pointerId = pointerId;
|
||||||
|
}
|
||||||
|
else
|
||||||
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY));
|
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY));
|
||||||
updateFlags();
|
updateFlags();
|
||||||
invalidate();
|
invalidate();
|
||||||
@ -211,7 +218,7 @@ public class Keyboard2View extends View
|
|||||||
for (KeyboardData.Key k : row)
|
for (KeyboardData.Key k : row)
|
||||||
{
|
{
|
||||||
float keyW = _keyWidth * k.width;
|
float keyW = _keyWidth * k.width;
|
||||||
if (isKeyDown(k))
|
if (getKeyDown(k) != null)
|
||||||
canvas.drawRect(x + _keyBgPadding, y + _keyBgPadding,
|
canvas.drawRect(x + _keyBgPadding, y + _keyBgPadding,
|
||||||
x + keyW - _keyBgPadding, y + _keyHeight - _keyBgPadding, _keyDownBgPaint);
|
x + keyW - _keyBgPadding, y + _keyHeight - _keyBgPadding, _keyDownBgPaint);
|
||||||
else
|
else
|
||||||
@ -259,7 +266,7 @@ public class Keyboard2View extends View
|
|||||||
this.key = key;
|
this.key = key;
|
||||||
downX = x;
|
downX = x;
|
||||||
downY = y;
|
downY = y;
|
||||||
flags = value.getFlags();
|
flags = (value == null) ? 0 : value.getFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateDown(float x, float y)
|
public boolean updateDown(float x, float y)
|
||||||
|
Loading…
Reference in New Issue
Block a user