Specify keyboard metrics with physical unit "inch"

Cherrypick I44f3b2eef8086d6e0b0db53d38f08487549060c6 from Gingerbread

This change also introduces the key background drawables which has no
fixed bottom padding.  Instead of relying on bottom padding in
drawable, this change also specifies Keyboard.verticalGap with
physical unit.  Other keyboard related length, distance and size are
also specified by physical unit.

Bug: 3066107
Change-Id: Ib38355ebfc2f8d5b1d26c4e90eba87196fbeddfa
main
Tadashi G. Takaoka 2010-10-12 15:02:44 +09:00
parent 65100ff39c
commit cd7b7d3e8f
57 changed files with 240 additions and 136 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 783 B

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 962 B

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 813 B

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 950 B

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 B

After

Width:  |  Height:  |  Size: 526 B

View File

@ -25,6 +25,7 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/keyboard_bottom_padding"
android:background="@drawable/keyboard_dark_background" android:background="@drawable/keyboard_dark_background"
android:textStyle="bold" android:textStyle="bold"

View File

@ -19,13 +19,17 @@
--> -->
<resources> <resources>
<dimen name="key_height">47dip</dimen> <!-- key_height + key_bottom_gap = popup_key_height -->
<dimen name="key_height">0.250in</dimen>
<dimen name="key_bottom_gap">0.020in</dimen>
<dimen name="popup_key_height">0.270in</dimen>
<dimen name="keyboard_bottom_padding">0.0in</dimen>
<dimen name="candidate_strip_height">38dip</dimen> <dimen name="candidate_strip_height">38dip</dimen>
<dimen name="candidate_strip_fading_edge_length">63dip</dimen> <dimen name="candidate_strip_fading_edge_length">63dip</dimen>
<dimen name="spacebar_vertical_correction">2dip</dimen> <dimen name="spacebar_vertical_correction">2dip</dimen>
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
<!-- key_height x 1.7 --> <!-- popup_key_height x 1.7 -->
<dimen name="mini_keyboard_slide_allowance">79.9dip</dimen> <dimen name="mini_keyboard_slide_allowance">0.459in</dimen>
<!-- -key_height x 1.0 --> <!-- popup_key_height x 1.0 -->
<dimen name="mini_keyboard_vertical_correction">-47dip</dimen> <dimen name="mini_keyboard_vertical_correction">-0.270in</dimen>
</resources> </resources>

View File

@ -19,18 +19,26 @@
--> -->
<resources> <resources>
<dimen name="key_height">72dip</dimen> <!-- key_height + key_bottom_gap = popup_key_height -->
<dimen name="candidate_strip_height">46dip</dimen> <dimen name="key_height">0.450in</dimen>
<dimen name="spacebar_vertical_correction">0dip</dimen> <dimen name="key_bottom_gap">0.0in</dimen>
<dimen name="key_text_size">28sp</dimen> <dimen name="popup_key_height">0.450in</dimen>
<dimen name="key_label_text_size">16sp</dimen> <dimen name="keyboard_bottom_padding">0.10in</dimen>
<dimen name="key_preview_height">40dip</dimen> <!-- key_height x 1.6 -->
<dimen name="key_preview_height">0.720in</dimen>
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
<!-- key_height x 1.7 --> <!-- popup_key_height x 1.7 -->
<dimen name="mini_keyboard_slide_allowance">122.4dip</dimen> <dimen name="mini_keyboard_slide_allowance">0.765in</dimen>
<!-- -key_height x 1.0 --> <!-- popup_key_height x 1.0 -->
<dimen name="mini_keyboard_vertical_correction">-72dip</dimen> <dimen name="mini_keyboard_vertical_correction">-0.450in</dimen>
<dimen name="key_text_size">0.175in</dimen>
<dimen name="key_label_text_size">0.100in</dimen>
<dimen name="key_preview_text_size_large">0.245in</dimen>
<!-- We use "inch", not "dip" because this value tries dealing with physical distance related <!-- We use "inch", not "dip" because this value tries dealing with physical distance related
to user's finger. --> to user's finger. -->
<dimen name="keyboard_vertical_correction">0.0in</dimen> <dimen name="keyboard_vertical_correction">0.0in</dimen>
<dimen name="candidate_strip_height">46dip</dimen>
<dimen name="spacebar_vertical_correction">0dip</dimen>
</resources> </resources>

View File

@ -19,26 +19,35 @@
--> -->
<resources> <resources>
<dimen name="key_height">54dip</dimen> <!-- key_height + key_bottom_gap = popup_key_height -->
<dimen name="bubble_pointer_offset">22dip</dimen> <dimen name="key_height">0.290in</dimen>
<dimen name="key_bottom_gap">0.035in</dimen>
<dimen name="popup_key_height">0.325in</dimen>
<dimen name="keyboard_bottom_padding">0.06in</dimen>
<!-- key_height x 1.6 -->
<dimen name="key_preview_height">0.464in</dimen>
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
<!-- popup_key_height x 1.7 -->
<dimen name="mini_keyboard_slide_allowance">0.553in</dimen>
<!-- popup_key_height x 1.0 -->
<dimen name="mini_keyboard_vertical_correction">-0.325in</dimen>
<dimen name="key_text_size">0.13in</dimen>
<dimen name="key_label_text_size">0.083in</dimen>
<dimen name="key_preview_text_size_large">0.236in</dimen>
<dimen name="key_preview_offset">0.000in</dimen>
<!-- We use "inch", not "dip" because this value tries dealing with physical distance related
to user's finger. -->
<dimen name="keyboard_vertical_correction">-0.05in</dimen>
<dimen name="candidate_strip_height">42dip</dimen> <dimen name="candidate_strip_height">42dip</dimen>
<dimen name="candidate_strip_fading_edge_length">63dip</dimen> <dimen name="candidate_strip_fading_edge_length">63dip</dimen>
<dimen name="spacebar_vertical_correction">4dip</dimen> <dimen name="spacebar_vertical_correction">4dip</dimen>
<!-- If the screen height in landscape is larger than the below value, then the keyboard <!-- If the screen height in landscape is larger than the below value, then the keyboard
will not go into extract (fullscreen) mode. --> will not go into extract (fullscreen) mode. -->
<dimen name="max_height_for_fullscreen">2.5in</dimen> <dimen name="max_height_for_fullscreen">2.5in</dimen>
<dimen name="key_text_size">22sp</dimen> <dimen name="bubble_pointer_offset">22dip</dimen>
<dimen name="key_label_text_size">14sp</dimen>
<dimen name="key_preview_offset">0dip</dimen>
<dimen name="key_preview_height">80dip</dimen>
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
<!-- key_height x 1.7 -->
<dimen name="mini_keyboard_slide_allowance">91.8dip</dimen>
<!-- -key_height x 1.0 -->
<dimen name="mini_keyboard_vertical_correction">-54dip</dimen>
<dimen name="key_hysteresis_distance">0.05in</dimen> <dimen name="key_hysteresis_distance">0.05in</dimen>
<!-- We use "inch", not "dip" because this value tries dealing with physical distance related
to user's finger. -->
<dimen name="keyboard_vertical_correction">-0.06in</dimen>
<dimen name="candidate_min_touchable_width">0.3in</dimen> <dimen name="candidate_min_touchable_width">0.3in</dimen>
</resources> </resources>

View File

@ -28,10 +28,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -28,10 +28,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="a" latin:keyLabel="a"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="a" latin:keyLabel="a"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="ק" latin:keyLabel="ק"
latin:horizontalGap="5%p" latin:horizontalGap="5%p"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="ק" latin:keyLabel="ק"
latin:horizontalGap="5%p" latin:horizontalGap="5%p"

View File

@ -28,10 +28,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -28,10 +28,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="й" latin:keyLabel="й"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="й" latin:keyLabel="й"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -23,10 +23,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="љ" latin:keyLabel="љ"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -23,10 +23,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="љ" latin:keyLabel="љ"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -30,10 +30,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -30,10 +30,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="9.09%p" latin:keyWidth="9.09%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="7.5%p" latin:keyWidth="7.5%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<!-- This row is intentionally not marked as a top row --> <!-- This row is intentionally not marked as a top row -->

View File

@ -23,7 +23,7 @@
latin:keyWidth="7.5%p" latin:keyWidth="7.5%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
<Row <Row
latin:rowEdgeFlags="top" latin:rowEdgeFlags="top"

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,6 +22,6 @@
android:keyWidth="9.45%p" android:keyWidth="9.45%p"
android:horizontalGap="0px" android:horizontalGap="0px"
android:verticalGap="0px" android:verticalGap="0px"
android:keyHeight="@dimen/key_height" android:keyHeight="@dimen/popup_key_height"
> >
</Keyboard> </Keyboard>

View File

@ -22,6 +22,6 @@
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
</Keyboard> </Keyboard>

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,10 +22,12 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row> <Row
latin:rowEdgeFlags="top"
>
<Key <Key
latin:keyLabel="q" latin:keyLabel="q"
latin:keyHintIcon="@drawable/keyboard_hint_1" latin:keyHintIcon="@drawable/keyboard_hint_1"

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -22,7 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="@dimen/key_bottom_gap"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/key_height"
> >
<Row <Row

View File

@ -23,7 +23,7 @@
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
<Row <Row
latin:rowEdgeFlags="top|bottom" latin:rowEdgeFlags="top|bottom"

View File

@ -23,7 +23,7 @@
latin:keyWidth="15%p" latin:keyWidth="15%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
<Row <Row
latin:rowEdgeFlags="top|bottom" latin:rowEdgeFlags="top|bottom"

View File

@ -23,7 +23,7 @@
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
<Row <Row
latin:rowEdgeFlags="top|bottom" latin:rowEdgeFlags="top|bottom"

View File

@ -23,7 +23,7 @@
latin:keyWidth="10%p" latin:keyWidth="10%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
<Row <Row
latin:rowEdgeFlags="top" latin:rowEdgeFlags="top"

View File

@ -23,7 +23,7 @@
latin:keyWidth="15%p" latin:keyWidth="15%p"
latin:horizontalGap="0px" latin:horizontalGap="0px"
latin:verticalGap="0px" latin:verticalGap="0px"
latin:keyHeight="@dimen/key_height" latin:keyHeight="@dimen/popup_key_height"
> >
<Row <Row
latin:rowEdgeFlags="top" latin:rowEdgeFlags="top"

View File

@ -86,6 +86,10 @@ public class LatinKeyboard extends BaseKeyboard {
// TODO: generalize for any keyboardId // TODO: generalize for any keyboardId
private boolean mIsBlackSym; private boolean mIsBlackSym;
// TODO: remove this attribute when either Keyboard.mDefaultVerticalGap or Key.parent becomes
// non-private.
private final int mVerticalGap;
private static final int SHIFT_OFF = 0; private static final int SHIFT_OFF = 0;
private static final int SHIFT_ON = 1; private static final int SHIFT_ON = 1;
private static final int SHIFT_LOCKED = 2; private static final int SHIFT_LOCKED = 2;
@ -133,6 +137,8 @@ public class LatinKeyboard extends BaseKeyboard {
mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty
|| xmlLayoutResId == R.xml.kbd_qwerty_black; || xmlLayoutResId == R.xml.kbd_qwerty_black;
mSpaceKeyIndex = indexOf(LatinIME.KEYCODE_SPACE); mSpaceKeyIndex = indexOf(LatinIME.KEYCODE_SPACE);
// TODO remove this initialization after cleanup
mVerticalGap = super.getVerticalGap();
} }
@Override @Override
@ -168,31 +174,30 @@ public class LatinKeyboard extends BaseKeyboard {
} }
public void setImeOptions(Resources res, int mode, int options) { public void setImeOptions(Resources res, int mode, int options) {
if (mEnterKey != null) { if (mEnterKey == null)
switch (options & (EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) { return;
case EditorInfo.IME_ACTION_GO: switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key)); case EditorInfo.IME_ACTION_GO:
break; resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key));
case EditorInfo.IME_ACTION_NEXT: break;
resetKeyAttributes(mEnterKey, res.getText(R.string.label_next_key)); case EditorInfo.IME_ACTION_NEXT:
break; resetKeyAttributes(mEnterKey, res.getText(R.string.label_next_key));
case EditorInfo.IME_ACTION_DONE: break;
resetKeyAttributes(mEnterKey, res.getText(R.string.label_done_key)); case EditorInfo.IME_ACTION_DONE:
break; resetKeyAttributes(mEnterKey, res.getText(R.string.label_done_key));
case EditorInfo.IME_ACTION_SEARCH: break;
resetKeyAttributes(mEnterKey, null); case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.iconPreview = res.getDrawable( resetKeyAttributes(mEnterKey, null);
R.drawable.sym_keyboard_feedback_search); mEnterKey.iconPreview = res.getDrawable(R.drawable.sym_keyboard_feedback_search);
mEnterKey.icon = res.getDrawable(mIsBlackSym ? mEnterKey.icon = res.getDrawable(mIsBlackSym ? R.drawable.sym_bkeyboard_search
R.drawable.sym_bkeyboard_search : R.drawable.sym_keyboard_search); : R.drawable.sym_keyboard_search);
break; break;
case EditorInfo.IME_ACTION_SEND: case EditorInfo.IME_ACTION_SEND:
resetKeyAttributes(mEnterKey, res.getText(R.string.label_send_key)); resetKeyAttributes(mEnterKey, res.getText(R.string.label_send_key));
break; break;
}
// Set the initial size of the preview icon
setDefaultBounds(mEnterKey.iconPreview);
} }
// Set the initial size of the preview icon
setDefaultBounds(mEnterKey.iconPreview);
} }
public void enableShiftLock() { public void enableShiftLock() {
@ -663,6 +668,7 @@ public class LatinKeyboard extends BaseKeyboard {
return textSize; return textSize;
} }
// TODO LatinKey could be static class
class LatinKey extends BaseKeyboard.Key { class LatinKey extends BaseKeyboard.Key {
// functional normal state (with properties) // functional normal state (with properties)
@ -711,6 +717,8 @@ public class LatinKeyboard extends BaseKeyboard {
*/ */
@Override @Override
public boolean isInside(int x, int y) { public boolean isInside(int x, int y) {
// TODO This should be done by parent.isInside(this, x, y)
// if Key.parent were protected.
boolean result = LatinKeyboard.this.isInside(this, x, y); boolean result = LatinKeyboard.this.isInside(this, x, y);
return result; return result;
} }
@ -730,6 +738,15 @@ public class LatinKeyboard extends BaseKeyboard {
} }
return super.getCurrentDrawableState(); return super.getCurrentDrawableState();
} }
@Override
public int squaredDistanceFrom(int x, int y) {
// We should count vertical gap between rows to calculate the center of this Key.
final int verticalGap = LatinKeyboard.this.mVerticalGap;
final int xDist = this.x + width / 2 - x;
final int yDist = this.y + (height + verticalGap) / 2 - y;
return xDist * xDist + yDist * yDist;
}
} }
/** /**

View File

@ -47,6 +47,7 @@ import android.widget.PopupWindow;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@ -158,6 +159,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
// Miscellaneous constants // Miscellaneous constants
/* package */ static final int NOT_A_KEY = -1; /* package */ static final int NOT_A_KEY = -1;
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable }; private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
private static final int NUMBER_HINT_VERTICAL_ADJUSTMENT_PIXEL = -1;
// XML attribute // XML attribute
private int mKeyTextSize; private int mKeyTextSize;
@ -178,6 +180,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
// Main keyboard // Main keyboard
private BaseKeyboard mKeyboard; private BaseKeyboard mKeyboard;
private Key[] mKeys; private Key[] mKeys;
// TODO this attribute should be gotten from Keyboard.
private int mKeyboardVerticalGap;
// Key preview popup // Key preview popup
private TextView mPreviewText; private TextView mPreviewText;
@ -240,6 +244,11 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
private final Paint mPaint; private final Paint mPaint;
private final Rect mPadding; private final Rect mPadding;
private final Rect mClipRegion = new Rect(0, 0, 0, 0); private final Rect mClipRegion = new Rect(0, 0, 0, 0);
// This map caches key label text height in pixel as value and key label text size as map key.
private final HashMap<Integer, Integer> mTextHeightCache = new HashMap<Integer, Integer>();
// Distance from horizontal center of the key, proportional to key label text height.
private final float KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR = 0.55f;
private final String KEY_LABEL_HEIGHT_REFERENCE_CHAR = "H";
private final UIHandler mHandler = new UIHandler(); private final UIHandler mHandler = new UIHandler();
@ -468,7 +477,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
mPreviewPopup = new PopupWindow(context); mPreviewPopup = new PopupWindow(context);
if (previewLayout != 0) { if (previewLayout != 0) {
mPreviewText = (TextView) inflate.inflate(previewLayout, null); mPreviewText = (TextView) inflate.inflate(previewLayout, null);
mPreviewTextSizeLarge = (int) mPreviewText.getTextSize(); mPreviewTextSizeLarge = (int) res.getDimension(R.dimen.key_preview_text_size_large);
mPreviewPopup.setContentView(mPreviewText); mPreviewPopup.setContentView(mPreviewText);
mPreviewPopup.setBackgroundDrawable(null); mPreviewPopup.setBackgroundDrawable(null);
} else { } else {
@ -579,6 +588,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
LatinImeLogger.onSetKeyboard(keyboard); LatinImeLogger.onSetKeyboard(keyboard);
mKeys = mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(), mKeys = mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
-getPaddingTop() + mVerticalCorrection); -getPaddingTop() + mVerticalCorrection);
mKeyboardVerticalGap = (int)getResources().getDimension(R.dimen.key_bottom_gap);
for (PointerTracker tracker : mPointerTrackers) { for (PointerTracker tracker : mPointerTrackers) {
tracker.setKeyboard(keyboard, mKeys, mKeyHysteresisDistance); tracker.setKeyboard(keyboard, mKeys, mKeyHysteresisDistance);
} }
@ -723,7 +733,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
int dimensionSum = 0; int dimensionSum = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Key key = keys[i]; Key key = keys[i];
dimensionSum += Math.min(key.width, key.height) + key.gap; dimensionSum += Math.min(key.width, key.height + mKeyboardVerticalGap) + key.gap;
} }
if (dimensionSum < 0 || length == 0) return; if (dimensionSum < 0 || length == 0) return;
mKeyDetector.setProximityThreshold((int) (dimensionSum * 1.4f / length)); mKeyDetector.setProximityThreshold((int) (dimensionSum * 1.4f / length));
@ -775,13 +785,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
paint.setColor(mKeyTextColor); paint.setColor(mKeyTextColor);
boolean drawSingleKey = false; boolean drawSingleKey = false;
if (invalidKey != null && canvas.getClipBounds(clipRegion)) { if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
// Is clipRegion completely contained within the invalidated key? // TODO we should use Rect.inset and Rect.contains here.
if (invalidKey.x + kbdPaddingLeft - 1 <= clipRegion.left && // Is clipRegion completely contained within the invalidated key?
invalidKey.y + kbdPaddingTop - 1 <= clipRegion.top && if (invalidKey.x + kbdPaddingLeft - 1 <= clipRegion.left &&
invalidKey.x + invalidKey.width + kbdPaddingLeft + 1 >= clipRegion.right && invalidKey.y + kbdPaddingTop - 1 <= clipRegion.top &&
invalidKey.y + invalidKey.height + kbdPaddingTop + 1 >= clipRegion.bottom) { invalidKey.x + invalidKey.width + kbdPaddingLeft + 1 >= clipRegion.right &&
drawSingleKey = true; invalidKey.y + invalidKey.height + kbdPaddingTop + 1 >= clipRegion.bottom) {
} drawSingleKey = true;
}
} }
canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR); canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
final int keyCount = keys.length; final int keyCount = keys.length;
@ -797,8 +808,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
String label = key.label == null? null : adjustCase(key.label).toString(); String label = key.label == null? null : adjustCase(key.label).toString();
final Rect bounds = keyBackground.getBounds(); final Rect bounds = keyBackground.getBounds();
if (key.width != bounds.right || if (key.width != bounds.right || key.height != bounds.bottom) {
key.height != bounds.bottom) {
keyBackground.setBounds(0, 0, key.width, key.height); keyBackground.setBounds(0, 0, key.width, key.height);
} }
canvas.translate(key.x + kbdPaddingLeft, key.y + kbdPaddingTop); canvas.translate(key.x + kbdPaddingLeft, key.y + kbdPaddingTop);
@ -818,22 +828,34 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
} }
// For characters, use large font. For labels like "Done", use small font. // For characters, use large font. For labels like "Done", use small font.
final int labelSize;
if (label.length() > 1 && key.codes.length < 2) { if (label.length() > 1 && key.codes.length < 2) {
paint.setTextSize(mLabelTextSize); labelSize = mLabelTextSize;
paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setTypeface(Typeface.DEFAULT_BOLD);
} else { } else {
paint.setTextSize(mKeyTextSize); labelSize = mKeyTextSize;
paint.setTypeface(mKeyTextStyle); paint.setTypeface(mKeyTextStyle);
} }
paint.setTextSize(labelSize);
Integer labelHeightValue = mTextHeightCache.get(labelSize);
final int labelHeight;
if (labelHeightValue != null) {
labelHeight = labelHeightValue;
} else {
Rect textBounds = new Rect();
paint.getTextBounds(KEY_LABEL_HEIGHT_REFERENCE_CHAR, 0, 1, textBounds);
labelHeight = textBounds.height();
mTextHeightCache.put(labelSize, labelHeight);
}
// Draw a drop shadow for the text // Draw a drop shadow for the text
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor); paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
// Draw the text final int centerX = (key.width + padding.left - padding.right) / 2;
canvas.drawText(label, final int centerY = (key.height + padding.top - padding.bottom) / 2;
(key.width - padding.left - padding.right) / 2 final float baseline = centerY
+ padding.left, + labelHeight * KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR;
(key.height - padding.top - padding.bottom) / 2 canvas.drawText(label, centerX, baseline, paint);
+ (paint.getTextSize() - paint.descent()) / 2 + padding.top,
paint);
// Turn off drop shadow // Turn off drop shadow
paint.setShadowLayer(0, 0, 0, 0); paint.setShadowLayer(0, 0, 0, 0);
} }
@ -843,16 +865,22 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
if (icon == null && key.hintIcon != null && drawHintIcon) if (icon == null && key.hintIcon != null && drawHintIcon)
icon = key.hintIcon; icon = key.hintIcon;
if (icon != null) { if (icon != null) {
// Hack for key hint icon displaying at the top right corner of the key. // Special handing for the upper-right number hint icons
final int drawableWidth = icon == key.hintIcon final int drawableWidth;
? key.width : icon.getIntrinsicWidth(); final int drawableHeight;
final int drawableHeight = icon == key.hintIcon final int drawableX;
? key.height : icon.getIntrinsicHeight(); final int drawableY;
if (icon == key.hintIcon) {
final int drawableX = (key.width - padding.left - padding.right drawableWidth = key.width;
- drawableWidth) / 2 + padding.left; drawableHeight = key.height;
final int drawableY = (key.height - padding.top - padding.bottom drawableX = 0;
- drawableHeight) / 2 + padding.top; drawableY = NUMBER_HINT_VERTICAL_ADJUSTMENT_PIXEL;
} else {
drawableWidth = key.icon.getIntrinsicWidth();
drawableHeight = key.icon.getIntrinsicHeight();
drawableX = (key.width + padding.left - padding.right - drawableWidth) / 2;
drawableY = (key.height + padding.top - padding.bottom - drawableHeight) / 2;
}
canvas.translate(drawableX, drawableY); canvas.translate(drawableX, drawableY);
icon.setBounds(0, 0, drawableWidth, drawableHeight); icon.setBounds(0, 0, drawableWidth, drawableHeight);
icon.draw(canvas); icon.draw(canvas);
@ -1020,6 +1048,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
if (key == null) if (key == null)
return; return;
mInvalidatedKey = key; mInvalidatedKey = key;
// TODO we should clean up this and record key's region to use in onBufferDraw.
mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(), mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(),
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop()); key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
onBufferDraw(); onBufferDraw();