Merge "Extend hitbox of emoji keys"
This commit is contained in:
commit
984aa60e11
1 changed files with 23 additions and 13 deletions
|
@ -42,7 +42,6 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
private final SharedPreferences mPrefs;
|
private final SharedPreferences mPrefs;
|
||||||
private final int mLeftPadding;
|
|
||||||
private final int mHorizontalStep;
|
private final int mHorizontalStep;
|
||||||
private final int mVerticalStep;
|
private final int mVerticalStep;
|
||||||
private final int mColumnsNum;
|
private final int mColumnsNum;
|
||||||
|
@ -58,7 +57,6 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
super(templateKeyboard);
|
super(templateKeyboard);
|
||||||
final Key key0 = getTemplateKey(TEMPLATE_KEY_CODE_0);
|
final Key key0 = getTemplateKey(TEMPLATE_KEY_CODE_0);
|
||||||
final Key key1 = getTemplateKey(TEMPLATE_KEY_CODE_1);
|
final Key key1 = getTemplateKey(TEMPLATE_KEY_CODE_1);
|
||||||
mLeftPadding = key0.getX();
|
|
||||||
mHorizontalStep = Math.abs(key1.getX() - key0.getX());
|
mHorizontalStep = Math.abs(key1.getX() - key0.getX());
|
||||||
mVerticalStep = key0.getHeight() + mVerticalGap;
|
mVerticalStep = key0.getHeight() + mVerticalGap;
|
||||||
mColumnsNum = mBaseWidth / mHorizontalStep;
|
mColumnsNum = mBaseWidth / mHorizontalStep;
|
||||||
|
@ -122,9 +120,11 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (final GridKey gridKey : mGridKeys) {
|
for (final GridKey gridKey : mGridKeys) {
|
||||||
final int keyX = getKeyX(index);
|
final int keyX0 = getKeyX0(index);
|
||||||
final int keyY = getKeyY(index);
|
final int keyY0 = getKeyY0(index);
|
||||||
gridKey.updateCorrdinates(keyX, keyY);
|
final int keyX1 = getKeyX1(index);
|
||||||
|
final int keyY1 = getKeyY1(index);
|
||||||
|
gridKey.updateCorrdinates(keyX0, keyY0, keyX1, keyY1);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,14 +172,24 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getKeyX(final int index) {
|
private int getKeyX0(final int index) {
|
||||||
final int column = index % mColumnsNum;
|
final int column = index % mColumnsNum;
|
||||||
return column * mHorizontalStep + mLeftPadding;
|
return column * mHorizontalStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getKeyY(final int index) {
|
private int getKeyX1(final int index) {
|
||||||
|
final int column = index % mColumnsNum + 1;
|
||||||
|
return column * mHorizontalStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getKeyY0(final int index) {
|
||||||
final int row = index / mColumnsNum;
|
final int row = index / mColumnsNum;
|
||||||
return row * mVerticalStep + mTopPadding;
|
return row * mVerticalStep;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getKeyY1(final int index) {
|
||||||
|
final int row = index / mColumnsNum + 1;
|
||||||
|
return row * mVerticalStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -207,10 +217,10 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
super(originalKey);
|
super(originalKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCorrdinates(final int x, final int y) {
|
public void updateCorrdinates(final int x0, final int y0, final int x1, final int y1) {
|
||||||
mCurrentX = x;
|
mCurrentX = x0;
|
||||||
mCurrentY = y;
|
mCurrentY = y0;
|
||||||
getHitBox().set(x, y, x + getWidth(), y + getHeight());
|
getHitBox().set(x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue