Reduce amount of empty space in which keypresses are detected
Bug: 6942329 Change-Id: Ie92ccf43f307b8ceb9a311c30390d0cb2abf2cd7main
parent
2c0c1cc677
commit
3f00c6151f
|
@ -41,6 +41,8 @@
|
|||
latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
|
||||
<Key
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
latin:keyXPos="28.0%p"
|
||||
latin:keyboardLayout="@xml/key_space"
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -153,5 +153,8 @@
|
|||
<Key
|
||||
latin:keyLabel="#"
|
||||
latin:keyStyle="numKeyStyle" />
|
||||
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||
<Spacer
|
||||
latin:keyWidth="fillRight" />
|
||||
</Row>
|
||||
</merge>
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
latin:keyWidth="8.047%p"
|
||||
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
|
||||
latin:keyXPos="5.782%p"
|
||||
latin:keyboardLayout="@xml/key_settings" />
|
||||
<include
|
||||
latin:keyboardLayout="@xml/key_shortcut" />
|
||||
|
@ -42,5 +44,8 @@
|
|||
latin:keyboardLayout="@xml/key_dash" />
|
||||
<include
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
latin:keyWidth="8.047%p"
|
||||
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
|
||||
latin:keyXPos="5.782%p"
|
||||
latin:keyboardLayout="@xml/key_settings" />
|
||||
<include
|
||||
latin:keyboardLayout="@xml/key_shortcut" />
|
||||
|
@ -40,5 +42,8 @@
|
|||
latin:keyboardLayout="@xml/keys_comma_period" />
|
||||
<include
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
latin:keyWidth="8.047%p"
|
||||
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
|
||||
latin:keyXPos="5.782%p"
|
||||
latin:keyboardLayout="@xml/key_settings" />
|
||||
<include
|
||||
latin:keyboardLayout="@xml/key_shortcut" />
|
||||
|
@ -42,5 +44,8 @@
|
|||
latin:keyboardLayout="@xml/key_dash" />
|
||||
<include
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
latin:keyWidth="8.047%p"
|
||||
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
|
||||
latin:keyXPos="13.829%p"
|
||||
latin:keyLabel="/" />
|
||||
<include
|
||||
latin:keyboardLayout="@xml/key_f1" />
|
||||
|
@ -39,6 +41,8 @@
|
|||
latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
|
||||
<Key
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -25,11 +25,14 @@
|
|||
latin:keyWidth="8.047%p"
|
||||
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
|
||||
latin:keyXPos="29.923%p"
|
||||
latin:keyboardLayout="@xml/key_space"
|
||||
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>
|
||||
</merge>
|
||||
|
|
|
@ -168,5 +168,8 @@
|
|||
<Key
|
||||
latin:keyLabel="#"
|
||||
latin:keyStyle="numKeyStyle" />
|
||||
<!-- Note: This Spacer prevents the above key from being marked as a right edge key. -->
|
||||
<Spacer
|
||||
latin:keyWidth="fillRight" />
|
||||
</Row>
|
||||
</merge>
|
||||
|
|
|
@ -83,11 +83,17 @@ public class KeyDetector {
|
|||
int minDistance = Integer.MAX_VALUE;
|
||||
Key primaryKey = null;
|
||||
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);
|
||||
if (distance > minDistance) {
|
||||
continue;
|
||||
}
|
||||
// To take care of hitbox overlaps, we compare mCode here too.
|
||||
if (primaryKey == null || distance < minDistance
|
||||
|| (distance == minDistance && isOnKey && key.mCode > primaryKey.mCode)) {
|
||||
if (primaryKey == null || distance < minDistance || key.mCode > primaryKey.mCode) {
|
||||
minDistance = distance;
|
||||
primaryKey = key;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue