Merge "Reduce amount of empty space in which keypresses are detected" into jb-mr1-dev

main
Tadashi G. Takaoka 2012-09-04 00:55:25 -07:00 committed by Android (Google) Code Review
commit 147a62a8a8
10 changed files with 51 additions and 13 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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;
}