diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png index 0c4820b34c55f88b8030693a2431cd553f7b9061..01fc8ca780342b16e22a395f702af499a2eb21b3 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png index 5a20da1dbb60d404790a46b704f8fccccaf995b4..af4017e2c6f7e8ec7b98fb9641d81b25e9bc138f 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_off.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png index 4ec703d6ceac885c2895b9b0f1919d615498cc90..4c35aca95dd88e92c4bc76673d2509917b0383c3 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_dark_normal_on.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png index 93322d2e279dc2efe8de56c94f008f6077520cb0..174f3452c684ba190fc3aa012a825ba1dd3c1e06 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png index 5a9c722cefb461a02dced268bf12e418a38f0e54..1fcbd9a887085ef01807d36e6309f95457beab4a 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_off.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png index 99b6cb17068737696c287a2f12f821afc8bb815f..072753f37dfc12ec6c24858aae888bbd9f58d426 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_dark_pressed_on.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png b/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png index 7dc59bf82268abee3656297857d3e43da52115e3..1ad746053df532f5b8fa9f87c5558456dc2bd725 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_light_normal.9.png differ diff --git a/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png b/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png index c150341e364f8a3a291a90e8f9c2767920775dbe..ccd59d5fa6e3b25756993299aac599a65e636685 100644 Binary files a/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png and b/java/res/drawable-hdpi/btn_keyboard_key_light_pressed.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png index 53fe9c97d4ab0b350bbefd61883ce63cc2a4e489..4e337fa0836e56404e74b1c9e250e9088dfc1794 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png index 649ef9773b893b964913e1b3aae6d734bffa72df..fe18497d82a1c7d9c1138230ffdd14c24b59ecba 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_off.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png index 93f7d87c2b238061186cc2a4a93cda10a4ecb3a3..00aab3d5af5cb97ad0bf3989b2a6f027887a3b40 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_dark_normal_on.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png index 8560b3ba70053c37e19ef7beb7d11e00ba082b6a..ac0bfd3c1e754d21c87d5e6f7e9ba1e93153dbe8 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png index 778abaf2491f0f97dadb4d71c3f50790c225f683..ea2f357895aa2c321234be50fe45c019bd8eb31e 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_off.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png index 2a23945e503eec0a6cb07ab6880123bea34d3d96..6195ac0d4f52af9ae965d5a31e1ad9b88f1e3b84 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_dark_pressed_on.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png b/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png index 6af2d8d0c2ee2ef405fa05dc3757b2541165fd7b..50cd06ae3685154ecdf450fe3055e3bc4adf5035 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_light_normal.9.png differ diff --git a/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png b/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png index fdaf69966a8e87e7781ce70303605907e4c549b7..7ce52f0f585605e632f2e9810677c62098b77419 100644 Binary files a/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png and b/java/res/drawable-mdpi/btn_keyboard_key_light_pressed.9.png differ diff --git a/java/res/layout/input_gingerbread.xml b/java/res/layout/input_gingerbread.xml index 8f59cae216235b2f7511a8aef85dcc64b09325df..73cf0a3fac35364b8b5ee19cd8ae85da080b606e 100644 --- a/java/res/layout/input_gingerbread.xml +++ b/java/res/layout/input_gingerbread.xml @@ -25,6 +25,7 @@ android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingBottom="@dimen/keyboard_bottom_padding" android:background="@drawable/keyboard_dark_background" android:textStyle="bold" diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index 1396bff9bcce2dfcdaef23329b7a0eec3030eabb..043f4b3632ff220141d3be476044d3875450356c 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -19,13 +19,17 @@ --> <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_fading_edge_length">63dip</dimen> <dimen name="spacebar_vertical_correction">2dip</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">79.9dip</dimen> - <!-- -key_height x 1.0 --> - <dimen name="mini_keyboard_vertical_correction">-47dip</dimen> + <!-- popup_key_height x 1.7 --> + <dimen name="mini_keyboard_slide_allowance">0.459in</dimen> + <!-- popup_key_height x 1.0 --> + <dimen name="mini_keyboard_vertical_correction">-0.270in</dimen> </resources> diff --git a/java/res/values-xlarge/dimens.xml b/java/res/values-xlarge/dimens.xml index 5674ef628629c2266c4a730ec4754eac813da036..d2cd6c7d1532646431f908ca8dc21389fe16a82e 100644 --- a/java/res/values-xlarge/dimens.xml +++ b/java/res/values-xlarge/dimens.xml @@ -19,18 +19,26 @@ --> <resources> - <dimen name="key_height">72dip</dimen> - <dimen name="candidate_strip_height">46dip</dimen> - <dimen name="spacebar_vertical_correction">0dip</dimen> - <dimen name="key_text_size">28sp</dimen> - <dimen name="key_label_text_size">16sp</dimen> - <dimen name="key_preview_height">40dip</dimen> + <!-- key_height + key_bottom_gap = popup_key_height --> + <dimen name="key_height">0.450in</dimen> + <dimen name="key_bottom_gap">0.0in</dimen> + <dimen name="popup_key_height">0.450in</dimen> + <dimen name="keyboard_bottom_padding">0.10in</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. --> - <!-- key_height x 1.7 --> - <dimen name="mini_keyboard_slide_allowance">122.4dip</dimen> - <!-- -key_height x 1.0 --> - <dimen name="mini_keyboard_vertical_correction">-72dip</dimen> + <!-- popup_key_height x 1.7 --> + <dimen name="mini_keyboard_slide_allowance">0.765in</dimen> + <!-- popup_key_height x 1.0 --> + <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 to user's finger. --> <dimen name="keyboard_vertical_correction">0.0in</dimen> + + <dimen name="candidate_strip_height">46dip</dimen> + <dimen name="spacebar_vertical_correction">0dip</dimen> </resources> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 1378be72cdc15b4db25fb32044c032cb589d7a06..2fa47ae5290cb11a9088342b3541a62562e423a5 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -19,26 +19,35 @@ --> <resources> - <dimen name="key_height">54dip</dimen> - <dimen name="bubble_pointer_offset">22dip</dimen> + <!-- key_height + key_bottom_gap = popup_key_height --> + <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_fading_edge_length">63dip</dimen> <dimen name="spacebar_vertical_correction">4dip</dimen> <!-- If the screen height in landscape is larger than the below value, then the keyboard will not go into extract (fullscreen) mode. --> <dimen name="max_height_for_fullscreen">2.5in</dimen> - <dimen name="key_text_size">22sp</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="bubble_pointer_offset">22dip</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> </resources> diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml index c66290c6244aa02fc7a08c5b8e786aa97f12dd77..66771c28752e19632763e67638375d9158678e6a 100644 --- a/java/res/xml-da/kbd_qwerty.xml +++ b/java/res/xml-da/kbd_qwerty.xml @@ -28,10 +28,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-da/kbd_qwerty_black.xml b/java/res/xml-da/kbd_qwerty_black.xml index 7f6ffaa2e5514cbbb94f9bc7eca62fbeec6f5436..d89204ae64f9c21db5110b401b5d9b3683ae5b6c 100644 --- a/java/res/xml-da/kbd_qwerty_black.xml +++ b/java/res/xml-da/kbd_qwerty_black.xml @@ -28,10 +28,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-de/kbd_qwerty.xml b/java/res/xml-de/kbd_qwerty.xml index 5d40d39b730bfa2a81b091a1c7d4bd4ee2819f85..30d8de0cffc22d5feef6a8b566d235becad2712f 100644 --- a/java/res/xml-de/kbd_qwerty.xml +++ b/java/res/xml-de/kbd_qwerty.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-de/kbd_qwerty_black.xml b/java/res/xml-de/kbd_qwerty_black.xml index 9842dd51d2b9b04359c512d89aac474629a6218f..f394c8d02f96e1dc2d31f886b73c170dc1257cc7 100644 --- a/java/res/xml-de/kbd_qwerty_black.xml +++ b/java/res/xml-de/kbd_qwerty_black.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-fr/kbd_qwerty.xml b/java/res/xml-fr/kbd_qwerty.xml index 9b82e824d32506f83064ca016b36a9f8cb040e93..9a4a8796bab91bd258cc5ded4e3b5f49ece09ae4 100644 --- a/java/res/xml-fr/kbd_qwerty.xml +++ b/java/res/xml-fr/kbd_qwerty.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="a" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-fr/kbd_qwerty_black.xml b/java/res/xml-fr/kbd_qwerty_black.xml index c3f122fa77c24ed78238129f7a82c67786fc073b..be2befbe8f07e21540e9571e0f90b192febcfb2a 100644 --- a/java/res/xml-fr/kbd_qwerty_black.xml +++ b/java/res/xml-fr/kbd_qwerty_black.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="a" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-iw/kbd_qwerty.xml b/java/res/xml-iw/kbd_qwerty.xml index 8ae7187a2b9b5e029ee0413f6f747a5aa8447f3c..7f66eef5698437d959344c8f70250dc909a0f4f2 100644 --- a/java/res/xml-iw/kbd_qwerty.xml +++ b/java/res/xml-iw/kbd_qwerty.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="ק" latin:horizontalGap="5%p" diff --git a/java/res/xml-iw/kbd_qwerty_black.xml b/java/res/xml-iw/kbd_qwerty_black.xml index 1435e1e13bc1214418eb4ec8c58892f2cdf91c3f..80ade2020ac6da5e895ee57a5124e2ec0e932fd1 100644 --- a/java/res/xml-iw/kbd_qwerty_black.xml +++ b/java/res/xml-iw/kbd_qwerty_black.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="ק" latin:horizontalGap="5%p" diff --git a/java/res/xml-nb/kbd_qwerty.xml b/java/res/xml-nb/kbd_qwerty.xml index 0efe2a1775bde89f31b57dc2b72e8c298506a0ec..96a86b0130a147e97f3c5d39595cc24965e3b6a8 100644 --- a/java/res/xml-nb/kbd_qwerty.xml +++ b/java/res/xml-nb/kbd_qwerty.xml @@ -28,10 +28,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-nb/kbd_qwerty_black.xml b/java/res/xml-nb/kbd_qwerty_black.xml index c7bbf943ebd05a08f032bf5f43f63e9d2d38bcb4..4adeb480160e0d25da25aae88be6bd7c7bef59db 100644 --- a/java/res/xml-nb/kbd_qwerty_black.xml +++ b/java/res/xml-nb/kbd_qwerty_black.xml @@ -28,10 +28,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-ru/kbd_qwerty.xml b/java/res/xml-ru/kbd_qwerty.xml index e4098285517974c1183edf0af24c639ff1548866..57114a8ea610148ce6b5ad425e301e74c0c7634c 100644 --- a/java/res/xml-ru/kbd_qwerty.xml +++ b/java/res/xml-ru/kbd_qwerty.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="й" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-ru/kbd_qwerty_black.xml b/java/res/xml-ru/kbd_qwerty_black.xml index 784f7457fd6d0e4cf00f0b00fac5b88bdd78a394..8f2f599c3ef890df3ebcd045771ac21637434245 100644 --- a/java/res/xml-ru/kbd_qwerty_black.xml +++ b/java/res/xml-ru/kbd_qwerty_black.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="й" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-sr/kbd_qwerty.xml b/java/res/xml-sr/kbd_qwerty.xml index 703c188ccb6e5ad5c3807f7dbfe9d894616ea57e..1a657055a643112ac70ccff942e258ed74e678bf 100644 --- a/java/res/xml-sr/kbd_qwerty.xml +++ b/java/res/xml-sr/kbd_qwerty.xml @@ -23,10 +23,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="љ" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-sr/kbd_qwerty_black.xml b/java/res/xml-sr/kbd_qwerty_black.xml index fe80ef676339c0caa5456d27b3546d116a2af4d5..e4b09c71702662b379556f9dd3290a41ff478c8f 100644 --- a/java/res/xml-sr/kbd_qwerty_black.xml +++ b/java/res/xml-sr/kbd_qwerty_black.xml @@ -23,10 +23,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="љ" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-sv/kbd_qwerty.xml b/java/res/xml-sv/kbd_qwerty.xml index 24a2e06579c814876106cda7a5fc5c6cb0d973bd..8819159e85a4db6e307583e237a3f96fde06fd90 100644 --- a/java/res/xml-sv/kbd_qwerty.xml +++ b/java/res/xml-sv/kbd_qwerty.xml @@ -30,10 +30,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-sv/kbd_qwerty_black.xml b/java/res/xml-sv/kbd_qwerty_black.xml index ec83dec2a4e5bbf1600a40f6d27d97a89799f41e..2532fca8cf0e885ee4fd34cc47408a2768c0b32a 100644 --- a/java/res/xml-sv/kbd_qwerty_black.xml +++ b/java/res/xml-sv/kbd_qwerty_black.xml @@ -30,10 +30,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="9.09%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml-xlarge/kbd_qwerty.xml b/java/res/xml-xlarge/kbd_qwerty.xml index 740e7f5f2ef956b231fe89de492eb6f3bf9054ea..b7250341456986db578b87c38393a72d7ee18ff2 100644 --- a/java/res/xml-xlarge/kbd_qwerty.xml +++ b/java/res/xml-xlarge/kbd_qwerty.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="7.5%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <!-- This row is intentionally not marked as a top row --> diff --git a/java/res/xml-xlarge/popup_smileys.xml b/java/res/xml-xlarge/popup_smileys.xml index cf30a2461f53dde14d7091ad139782e043ca3c31..2cfcf741ddc75b8fa94feff4a05ac44c1849df67 100644 --- a/java/res/xml-xlarge/popup_smileys.xml +++ b/java/res/xml-xlarge/popup_smileys.xml @@ -23,7 +23,7 @@ latin:keyWidth="7.5%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > <Row latin:rowEdgeFlags="top" diff --git a/java/res/xml/kbd_phone.xml b/java/res/xml/kbd_phone.xml index dc88e2b24eaa39d103e092a4cf55fbe021501af2..17e7ba20b2a97f1bae5a5eac3dd323d30a061d80 100644 --- a/java/res/xml/kbd_phone.xml +++ b/java/res/xml/kbd_phone.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="26.67%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_phone_black.xml b/java/res/xml/kbd_phone_black.xml index 52479459c85c20452fc2dd46fa70938a5b8a1e65..6ade277d93c085e2c6270932dfe978aa95076707 100644 --- a/java/res/xml/kbd_phone_black.xml +++ b/java/res/xml/kbd_phone_black.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="26.67%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_phone_symbols.xml b/java/res/xml/kbd_phone_symbols.xml index 1400d36708200c93d1850086b9fdf459e0a1c4f7..5062d4707f2f95a88062423c4c6fc9eecb4b8d33 100644 --- a/java/res/xml/kbd_phone_symbols.xml +++ b/java/res/xml/kbd_phone_symbols.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="26.67%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_phone_symbols_black.xml b/java/res/xml/kbd_phone_symbols_black.xml index 8b683cc6cfa7f452277963711893afd84d8f9137..2a6932a9ee1d209bd51d60a9a4990be3be753155 100644 --- a/java/res/xml/kbd_phone_symbols_black.xml +++ b/java/res/xml/kbd_phone_symbols_black.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="26.67%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_popup_narrow_template.xml b/java/res/xml/kbd_popup_narrow_template.xml index ed3b1300310b96e206843f9d567d5b83cc6825bf..23c686e8bc4670c60ed48cc40a0eca549fc32f08 100644 --- a/java/res/xml/kbd_popup_narrow_template.xml +++ b/java/res/xml/kbd_popup_narrow_template.xml @@ -22,6 +22,6 @@ android:keyWidth="9.45%p" android:horizontalGap="0px" android:verticalGap="0px" - android:keyHeight="@dimen/key_height" + android:keyHeight="@dimen/popup_key_height" > </Keyboard> diff --git a/java/res/xml/kbd_popup_template.xml b/java/res/xml/kbd_popup_template.xml index cbb705835b7a7e55b0a7f95c1b9499b49d383ed8..f1aa86f392029b977c4a461f0c14463a5e783a49 100644 --- a/java/res/xml/kbd_popup_template.xml +++ b/java/res/xml/kbd_popup_template.xml @@ -22,6 +22,6 @@ latin:keyWidth="10%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > </Keyboard> diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml index c14c7fa0c6d35afc5eed0f170f3c5eb9b74dcd7b..21a7ccb781a42404d3c93dbc04ca29a22c1a24b4 100644 --- a/java/res/xml/kbd_qwerty.xml +++ b/java/res/xml/kbd_qwerty.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml/kbd_qwerty_black.xml b/java/res/xml/kbd_qwerty_black.xml index e1aa4f323538e2f481dcaf5df3f79aa5a8750c21..adb10dcfb588efbfb02bd970f82490575f26c013 100644 --- a/java/res/xml/kbd_qwerty_black.xml +++ b/java/res/xml/kbd_qwerty_black.xml @@ -22,10 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > - <Row> + <Row + latin:rowEdgeFlags="top" + > <Key latin:keyLabel="q" latin:keyHintIcon="@drawable/keyboard_hint_1" diff --git a/java/res/xml/kbd_symbols.xml b/java/res/xml/kbd_symbols.xml index 4cdc53947cb4ed38ec0b054552ed0449253cbf29..4ce9a867b5ac32ad470aa532218e222a3a562c82 100644 --- a/java/res/xml/kbd_symbols.xml +++ b/java/res/xml/kbd_symbols.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_symbols_black.xml b/java/res/xml/kbd_symbols_black.xml index cb695f53418466b4c7836a7c3355631f656abefa..dedd2da08e8bca46c8d3c51bbb1d1ebaf29584f5 100644 --- a/java/res/xml/kbd_symbols_black.xml +++ b/java/res/xml/kbd_symbols_black.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml index e346384aaf04992d17bbf273abcf34cb22deaef6..52afa38e336f7371cca1197ea63bc1eee5a8d30b 100644 --- a/java/res/xml/kbd_symbols_shift.xml +++ b/java/res/xml/kbd_symbols_shift.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/kbd_symbols_shift_black.xml b/java/res/xml/kbd_symbols_shift_black.xml index a157492122db18a70bcbd8990fc15201c483c366..c1bd4e395aeda4e7b973b67477841056dc56676b 100644 --- a/java/res/xml/kbd_symbols_shift_black.xml +++ b/java/res/xml/kbd_symbols_shift_black.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="10%p" latin:horizontalGap="0px" - latin:verticalGap="0px" + latin:verticalGap="@dimen/key_bottom_gap" latin:keyHeight="@dimen/key_height" > <Row diff --git a/java/res/xml/popup_comma.xml b/java/res/xml/popup_comma.xml index 4e88f26c4458e9c9c3e18b800387a40d52429fd8..cef836acdea477fad1305afaf2912f935298b6a0 100644 --- a/java/res/xml/popup_comma.xml +++ b/java/res/xml/popup_comma.xml @@ -23,7 +23,7 @@ latin:keyWidth="10%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > <Row latin:rowEdgeFlags="top|bottom" diff --git a/java/res/xml/popup_domains.xml b/java/res/xml/popup_domains.xml index c110ef6c26943cb13ab75bd0ab07abf4072eb8a7..5f92e2f746607a7e29f1c551b8ef03ea0bbb19ce 100644 --- a/java/res/xml/popup_domains.xml +++ b/java/res/xml/popup_domains.xml @@ -23,7 +23,7 @@ latin:keyWidth="15%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > <Row latin:rowEdgeFlags="top|bottom" diff --git a/java/res/xml/popup_mic.xml b/java/res/xml/popup_mic.xml index f5ef6eeb00009218edd04afecd0714d927c20e6b..99c97ce39d4d7b45372c476ead2e978715b9ef2a 100644 --- a/java/res/xml/popup_mic.xml +++ b/java/res/xml/popup_mic.xml @@ -23,7 +23,7 @@ latin:keyWidth="10%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > <Row latin:rowEdgeFlags="top|bottom" diff --git a/java/res/xml/popup_punctuation.xml b/java/res/xml/popup_punctuation.xml index ecbf09f721bfba73fc46f3f2901938ceb30d263e..76572b06a1f46f23740dfaab37edfe91a7fbdcad 100644 --- a/java/res/xml/popup_punctuation.xml +++ b/java/res/xml/popup_punctuation.xml @@ -23,7 +23,7 @@ latin:keyWidth="10%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > <Row latin:rowEdgeFlags="top" diff --git a/java/res/xml/popup_smileys.xml b/java/res/xml/popup_smileys.xml index 33006f6ec29d38b57e4baad6036513db4fce01c9..2f082318adcc36cb295521fcb2e25298c390157b 100644 --- a/java/res/xml/popup_smileys.xml +++ b/java/res/xml/popup_smileys.xml @@ -23,7 +23,7 @@ latin:keyWidth="15%p" latin:horizontalGap="0px" latin:verticalGap="0px" - latin:keyHeight="@dimen/key_height" + latin:keyHeight="@dimen/popup_key_height" > <Row latin:rowEdgeFlags="top" diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index e10346570ea29fe82cde92c4f0ced6a89202ee11..246df5fc4e9fde582d51d9f84c9a755aa2944453 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -86,6 +86,10 @@ public class LatinKeyboard extends BaseKeyboard { // TODO: generalize for any keyboardId 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_ON = 1; private static final int SHIFT_LOCKED = 2; @@ -133,6 +137,8 @@ public class LatinKeyboard extends BaseKeyboard { mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black; mSpaceKeyIndex = indexOf(LatinIME.KEYCODE_SPACE); + // TODO remove this initialization after cleanup + mVerticalGap = super.getVerticalGap(); } @Override @@ -168,31 +174,30 @@ public class LatinKeyboard extends BaseKeyboard { } public void setImeOptions(Resources res, int mode, int options) { - if (mEnterKey != null) { - switch (options & (EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) { - case EditorInfo.IME_ACTION_GO: - resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key)); - break; - case EditorInfo.IME_ACTION_NEXT: - resetKeyAttributes(mEnterKey, res.getText(R.string.label_next_key)); - break; - case EditorInfo.IME_ACTION_DONE: - resetKeyAttributes(mEnterKey, res.getText(R.string.label_done_key)); - break; - case EditorInfo.IME_ACTION_SEARCH: - resetKeyAttributes(mEnterKey, null); - mEnterKey.iconPreview = res.getDrawable( - R.drawable.sym_keyboard_feedback_search); - mEnterKey.icon = res.getDrawable(mIsBlackSym ? - R.drawable.sym_bkeyboard_search : R.drawable.sym_keyboard_search); - break; - case EditorInfo.IME_ACTION_SEND: - resetKeyAttributes(mEnterKey, res.getText(R.string.label_send_key)); - break; - } - // Set the initial size of the preview icon - setDefaultBounds(mEnterKey.iconPreview); + if (mEnterKey == null) + return; + switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) { + case EditorInfo.IME_ACTION_GO: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key)); + break; + case EditorInfo.IME_ACTION_NEXT: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_next_key)); + break; + case EditorInfo.IME_ACTION_DONE: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_done_key)); + break; + case EditorInfo.IME_ACTION_SEARCH: + resetKeyAttributes(mEnterKey, null); + mEnterKey.iconPreview = res.getDrawable(R.drawable.sym_keyboard_feedback_search); + mEnterKey.icon = res.getDrawable(mIsBlackSym ? R.drawable.sym_bkeyboard_search + : R.drawable.sym_keyboard_search); + break; + case EditorInfo.IME_ACTION_SEND: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_send_key)); + break; } + // Set the initial size of the preview icon + setDefaultBounds(mEnterKey.iconPreview); } public void enableShiftLock() { @@ -663,6 +668,7 @@ public class LatinKeyboard extends BaseKeyboard { return textSize; } + // TODO LatinKey could be static class class LatinKey extends BaseKeyboard.Key { // functional normal state (with properties) @@ -711,6 +717,8 @@ public class LatinKeyboard extends BaseKeyboard { */ @Override 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); return result; } @@ -730,6 +738,15 @@ public class LatinKeyboard extends BaseKeyboard { } 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; + } } /** diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 83b76190446a1dd63de882f9ef8d0201c7c50c48..660fe0ed0bf0c0bd885259d075fbfa462dc84c20 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -47,6 +47,7 @@ import android.widget.PopupWindow; import android.widget.TextView; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.WeakHashMap; @@ -158,6 +159,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Miscellaneous constants /* 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 NUMBER_HINT_VERTICAL_ADJUSTMENT_PIXEL = -1; // XML attribute private int mKeyTextSize; @@ -178,6 +180,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Main keyboard private BaseKeyboard mKeyboard; private Key[] mKeys; + // TODO this attribute should be gotten from Keyboard. + private int mKeyboardVerticalGap; // Key preview popup private TextView mPreviewText; @@ -240,6 +244,11 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx private final Paint mPaint; private final Rect mPadding; 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(); @@ -468,7 +477,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx mPreviewPopup = new PopupWindow(context); if (previewLayout != 0) { 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.setBackgroundDrawable(null); } else { @@ -579,6 +588,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx LatinImeLogger.onSetKeyboard(keyboard); mKeys = mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection); + mKeyboardVerticalGap = (int)getResources().getDimension(R.dimen.key_bottom_gap); for (PointerTracker tracker : mPointerTrackers) { tracker.setKeyboard(keyboard, mKeys, mKeyHysteresisDistance); } @@ -723,7 +733,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx int dimensionSum = 0; for (int i = 0; i < length; 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; mKeyDetector.setProximityThreshold((int) (dimensionSum * 1.4f / length)); @@ -775,13 +785,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx paint.setColor(mKeyTextColor); boolean drawSingleKey = false; if (invalidKey != null && canvas.getClipBounds(clipRegion)) { - // Is clipRegion completely contained within the invalidated key? - if (invalidKey.x + kbdPaddingLeft - 1 <= clipRegion.left && - invalidKey.y + kbdPaddingTop - 1 <= clipRegion.top && - invalidKey.x + invalidKey.width + kbdPaddingLeft + 1 >= clipRegion.right && - invalidKey.y + invalidKey.height + kbdPaddingTop + 1 >= clipRegion.bottom) { - drawSingleKey = true; - } + // TODO we should use Rect.inset and Rect.contains here. + // Is clipRegion completely contained within the invalidated key? + if (invalidKey.x + kbdPaddingLeft - 1 <= clipRegion.left && + invalidKey.y + kbdPaddingTop - 1 <= clipRegion.top && + invalidKey.x + invalidKey.width + kbdPaddingLeft + 1 >= clipRegion.right && + invalidKey.y + invalidKey.height + kbdPaddingTop + 1 >= clipRegion.bottom) { + drawSingleKey = true; + } } canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR); 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(); final Rect bounds = keyBackground.getBounds(); - if (key.width != bounds.right || - key.height != bounds.bottom) { + if (key.width != bounds.right || key.height != bounds.bottom) { keyBackground.setBounds(0, 0, key.width, key.height); } 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. + final int labelSize; if (label.length() > 1 && key.codes.length < 2) { - paint.setTextSize(mLabelTextSize); + labelSize = mLabelTextSize; paint.setTypeface(Typeface.DEFAULT_BOLD); } else { - paint.setTextSize(mKeyTextSize); + labelSize = mKeyTextSize; 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 paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor); - // Draw the text - canvas.drawText(label, - (key.width - padding.left - padding.right) / 2 - + padding.left, - (key.height - padding.top - padding.bottom) / 2 - + (paint.getTextSize() - paint.descent()) / 2 + padding.top, - paint); + final int centerX = (key.width + padding.left - padding.right) / 2; + final int centerY = (key.height + padding.top - padding.bottom) / 2; + final float baseline = centerY + + labelHeight * KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR; + canvas.drawText(label, centerX, baseline, paint); // Turn off drop shadow 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) icon = key.hintIcon; if (icon != null) { - // Hack for key hint icon displaying at the top right corner of the key. - final int drawableWidth = icon == key.hintIcon - ? key.width : icon.getIntrinsicWidth(); - final int drawableHeight = icon == key.hintIcon - ? key.height : icon.getIntrinsicHeight(); - - final int drawableX = (key.width - padding.left - padding.right - - drawableWidth) / 2 + padding.left; - final int drawableY = (key.height - padding.top - padding.bottom - - drawableHeight) / 2 + padding.top; + // Special handing for the upper-right number hint icons + final int drawableWidth; + final int drawableHeight; + final int drawableX; + final int drawableY; + if (icon == key.hintIcon) { + drawableWidth = key.width; + drawableHeight = key.height; + drawableX = 0; + 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); icon.setBounds(0, 0, drawableWidth, drawableHeight); icon.draw(canvas); @@ -1020,6 +1048,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx if (key == null) return; 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(), key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop()); onBufferDraw();