Merge "Reduce amount of empty space in which keypresses are detected" into jb-mr1-dev
commit
147a62a8a8
|
@ -41,6 +41,8 @@
|
||||||
latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
|
latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
|
||||||
<Key
|
<Key
|
||||||
latin:keyLabel="_" />
|
latin:keyLabel="_" />
|
||||||
<!-- Here is empty space. -->
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
latin:keyXPos="28.0%p"
|
latin:keyXPos="28.0%p"
|
||||||
latin:keyboardLayout="@xml/key_space"
|
latin:keyboardLayout="@xml/key_space"
|
||||||
latin:backgroundType="normal" />
|
latin:backgroundType="normal" />
|
||||||
<!-- Here is empty space. -->
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -153,5 +153,8 @@
|
||||||
<Key
|
<Key
|
||||||
latin:keyLabel="#"
|
latin:keyLabel="#"
|
||||||
latin:keyStyle="numKeyStyle" />
|
latin:keyStyle="numKeyStyle" />
|
||||||
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
latin:keyWidth="8.047%p"
|
latin:keyWidth="8.047%p"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
>
|
>
|
||||||
|
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="5.782%p" />
|
||||||
<include
|
<include
|
||||||
latin:keyXPos="5.782%p"
|
|
||||||
latin:keyboardLayout="@xml/key_settings" />
|
latin:keyboardLayout="@xml/key_settings" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_shortcut" />
|
latin:keyboardLayout="@xml/key_shortcut" />
|
||||||
|
@ -42,5 +44,8 @@
|
||||||
latin:keyboardLayout="@xml/key_dash" />
|
latin:keyboardLayout="@xml/key_dash" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_f2" />
|
latin:keyboardLayout="@xml/key_f2" />
|
||||||
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
latin:keyWidth="8.047%p"
|
latin:keyWidth="8.047%p"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
>
|
>
|
||||||
|
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="5.782%p" />
|
||||||
<include
|
<include
|
||||||
latin:keyXPos="5.782%p"
|
|
||||||
latin:keyboardLayout="@xml/key_settings" />
|
latin:keyboardLayout="@xml/key_settings" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_shortcut" />
|
latin:keyboardLayout="@xml/key_shortcut" />
|
||||||
|
@ -40,5 +42,8 @@
|
||||||
latin:keyboardLayout="@xml/keys_comma_period" />
|
latin:keyboardLayout="@xml/keys_comma_period" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_f2" />
|
latin:keyboardLayout="@xml/key_f2" />
|
||||||
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
latin:keyWidth="8.047%p"
|
latin:keyWidth="8.047%p"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
>
|
>
|
||||||
|
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="5.782%p" />
|
||||||
<include
|
<include
|
||||||
latin:keyXPos="5.782%p"
|
|
||||||
latin:keyboardLayout="@xml/key_settings" />
|
latin:keyboardLayout="@xml/key_settings" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_shortcut" />
|
latin:keyboardLayout="@xml/key_shortcut" />
|
||||||
|
@ -42,5 +44,8 @@
|
||||||
latin:keyboardLayout="@xml/key_dash" />
|
latin:keyboardLayout="@xml/key_dash" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_f2" />
|
latin:keyboardLayout="@xml/key_f2" />
|
||||||
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -25,8 +25,10 @@
|
||||||
latin:keyWidth="8.047%p"
|
latin:keyWidth="8.047%p"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
>
|
>
|
||||||
|
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="13.829%p" />
|
||||||
<Key
|
<Key
|
||||||
latin:keyXPos="13.829%p"
|
|
||||||
latin:keyLabel="/" />
|
latin:keyLabel="/" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/key_f1" />
|
latin:keyboardLayout="@xml/key_f1" />
|
||||||
|
@ -39,6 +41,8 @@
|
||||||
latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
|
latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
|
||||||
<Key
|
<Key
|
||||||
latin:keyLabel="_" />
|
latin:keyLabel="_" />
|
||||||
<!-- Here is empty space. -->
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -25,11 +25,14 @@
|
||||||
latin:keyWidth="8.047%p"
|
latin:keyWidth="8.047%p"
|
||||||
latin:backgroundType="functional"
|
latin:backgroundType="functional"
|
||||||
>
|
>
|
||||||
<!-- Here is empty space. -->
|
<!-- Note: This Spacer prevents the below key from being marked as a left edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="29.923%p" />
|
||||||
<include
|
<include
|
||||||
latin:keyXPos="29.923%p"
|
|
||||||
latin:keyboardLayout="@xml/key_space"
|
latin:keyboardLayout="@xml/key_space"
|
||||||
latin:backgroundType="normal" />
|
latin:backgroundType="normal" />
|
||||||
<!-- Here is empty space. -->
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -168,5 +168,8 @@
|
||||||
<Key
|
<Key
|
||||||
latin:keyLabel="#"
|
latin:keyLabel="#"
|
||||||
latin:keyStyle="numKeyStyle" />
|
latin:keyStyle="numKeyStyle" />
|
||||||
|
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||||
|
<Spacer
|
||||||
|
latin:keyWidth="fillRight" />
|
||||||
</Row>
|
</Row>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -83,11 +83,17 @@ public class KeyDetector {
|
||||||
int minDistance = Integer.MAX_VALUE;
|
int minDistance = Integer.MAX_VALUE;
|
||||||
Key primaryKey = null;
|
Key primaryKey = null;
|
||||||
for (final Key key: mKeyboard.getNearestKeys(touchX, touchY)) {
|
for (final Key key: mKeyboard.getNearestKeys(touchX, touchY)) {
|
||||||
final boolean isOnKey = key.isOnKey(touchX, touchY);
|
// An edge key always has its enlarged hitbox to respond to an event that occurred in
|
||||||
|
// the empty area around the key. (@see Key#markAsLeftEdge(KeyboardParams)} etc.)
|
||||||
|
if (!key.isOnKey(touchX, touchY)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final int distance = key.squaredDistanceToEdge(touchX, touchY);
|
final int distance = key.squaredDistanceToEdge(touchX, touchY);
|
||||||
|
if (distance > minDistance) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// To take care of hitbox overlaps, we compare mCode here too.
|
// To take care of hitbox overlaps, we compare mCode here too.
|
||||||
if (primaryKey == null || distance < minDistance
|
if (primaryKey == null || distance < minDistance || key.mCode > primaryKey.mCode) {
|
||||||
|| (distance == minDistance && isOnKey && key.mCode > primaryKey.mCode)) {
|
|
||||||
minDistance = distance;
|
minDistance = distance;
|
||||||
primaryKey = key;
|
primaryKey = key;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue