From 6b38a5fd4c7697c962bff9f3964f20e00c470b1b Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 27 May 2011 02:38:11 +0900 Subject: [PATCH] Adaptive keyboard width/position parser (DO NOT MERGE) This change introduces the following features to Keyboard XML format. * "keyXPos" can specify the key X coordinate directly. * "keyXPos" can be negative. The X coordinate will be calcluated from the right edge of the keyboard toward left. * "keyWidth" can be zero to be filled up to the right side. * "keyWidth can be negative. The key will be filled up to both sides. * Spacer's horizontalGap is renamed as keyWidth, and can be inherited from key-style. * Spacer can have keyXPos attribute. Using these syntax, all keyboard layouts have been re-written. Bug: 4442045 Change-Id: I314b2e8ca2aa145ff9506cbf927140a15685af42 --- java/res/values/attrs.xml | 10 +- java/res/xml-iw/kbd_qwerty.xml | 6 +- java/res/xml-sw600dp/kbd_azerty_rows.xml | 53 +++++-- java/res/xml-sw600dp/kbd_key_styles.xml | 108 +++++++------- java/res/xml-sw600dp/kbd_number.xml | 108 ++++++-------- java/res/xml-sw600dp/kbd_phone.xml | 66 ++++----- java/res/xml-sw600dp/kbd_phone_symbols.xml | 59 ++++---- java/res/xml-sw600dp/kbd_qwerty_row1.xml | 5 +- java/res/xml-sw600dp/kbd_qwerty_row2.xml | 6 +- java/res/xml-sw600dp/kbd_qwerty_row3.xml | 8 +- java/res/xml-sw600dp/kbd_qwerty_row4.xml | 139 ++++-------------- .../kbd_qwerty_rows_scandinavia.xml | 21 ++- java/res/xml-sw600dp/kbd_qwertz_rows.xml | 44 ++++-- java/res/xml-sw600dp/kbd_row3_right.xml | 68 +++++++++ java/res/xml-sw600dp/kbd_ru_rows.xml | 35 +++-- java/res/xml-sw600dp/kbd_settings.xml | 89 ----------- java/res/xml-sw600dp/kbd_sr_rows.xml | 50 +++++-- java/res/xml-sw600dp/kbd_symbols.xml | 44 +++--- java/res/xml-sw600dp/kbd_symbols_shift.xml | 35 +++-- java/res/xml-sw768dp/kbd_azerty_rows.xml | 19 ++- java/res/xml-sw768dp/kbd_number.xml | 110 ++++++-------- java/res/xml-sw768dp/kbd_phone.xml | 69 ++++----- java/res/xml-sw768dp/kbd_phone_symbols.xml | 77 +++++----- java/res/xml-sw768dp/kbd_qwerty_row1.xml | 7 +- java/res/xml-sw768dp/kbd_qwerty_row2.xml | 7 +- java/res/xml-sw768dp/kbd_qwerty_row3.xml | 7 +- java/res/xml-sw768dp/kbd_qwerty_row4.xml | 38 +++-- .../kbd_qwerty_rows_scandinavia.xml | 15 +- java/res/xml-sw768dp/kbd_qwertz_rows.xml | 14 +- java/res/xml-sw768dp/kbd_ru_rows.xml | 46 +++--- java/res/xml-sw768dp/kbd_sr_rows.xml | 21 +-- java/res/xml-sw768dp/kbd_symbols.xml | 40 ++--- java/res/xml-sw768dp/kbd_symbols_shift.xml | 37 +++-- java/res/xml/kbd_azerty_rows.xml | 4 +- java/res/xml/kbd_number.xml | 22 +-- java/res/xml/kbd_phone.xml | 8 +- java/res/xml/kbd_phone_symbols.xml | 8 +- java/res/xml/kbd_qwerty_row1.xml | 1 + java/res/xml/kbd_qwerty_row2.xml | 4 +- java/res/xml/kbd_qwerty_row3.xml | 2 +- java/res/xml/kbd_qwerty_row4.xml | 16 +- java/res/xml/kbd_qwerty_rows_scandinavia.xml | 4 +- java/res/xml/kbd_qwertz_rows.xml | 3 +- java/res/xml/kbd_ru_rows.xml | 6 +- java/res/xml/kbd_sr_rows.xml | 4 +- java/res/xml/kbd_symbols.xml | 4 +- java/res/xml/kbd_symbols_row4.xml | 9 +- java/res/xml/kbd_symbols_shift.xml | 4 +- java/res/xml/kbd_symbols_shift_row4.xml | 9 +- .../com/android/inputmethod/keyboard/Key.java | 49 ++++-- .../inputmethod/keyboard/KeyboardId.java | 6 +- .../inputmethod/keyboard/KeyboardParser.java | 40 +++-- 52 files changed, 837 insertions(+), 827 deletions(-) create mode 100644 java/res/xml-sw600dp/kbd_row3_right.xml delete mode 100644 java/res/xml-sw600dp/kbd_settings.xml diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 3bd6619d8..c63ecbe1a 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -83,7 +83,12 @@ + keyboard height. + If the value is zero, the actual key width will be determined to fill out the area up + to the right edge of the keyboard. + If the value is negative, the actual key width will be determined to fill out the + area between the nearest key on the left hand side and the right edge of the keyboard. + --> @@ -142,6 +147,9 @@ + + diff --git a/java/res/xml-iw/kbd_qwerty.xml b/java/res/xml-iw/kbd_qwerty.xml index 98bfd7e0b..6c2504e65 100644 --- a/java/res/xml-iw/kbd_qwerty.xml +++ b/java/res/xml-iw/kbd_qwerty.xml @@ -35,7 +35,7 @@ latin:rowEdgeFlags="top" > + latin:keyWidth="5%p" /> @@ -54,7 +54,7 @@ + latin:keyWidth="1.25%p" /> + latin:keyWidth="5%p" /> diff --git a/java/res/xml-sw600dp/kbd_azerty_rows.xml b/java/res/xml-sw600dp/kbd_azerty_rows.xml index 5ad11470e..3d57ae715 100644 --- a/java/res/xml-sw600dp/kbd_azerty_rows.xml +++ b/java/res/xml-sw600dp/kbd_azerty_rows.xml @@ -24,7 +24,7 @@ + + - - + + + + + + + + + + + + diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml index 6be6a2c30..0612cfd62 100644 --- a/java/res/xml-sw600dp/kbd_key_styles.xml +++ b/java/res/xml-sw600dp/kbd_key_styles.xml @@ -23,7 +23,7 @@ > - - - - - - - - - - - - - - - + + + + + + + + - - + + + + + + + + + - + latin:keyStyle="num1KeyStyle" + latin:keyXPos="29.5%p" /> - - + latin:keyStyle="num4KeyStyle" + latin:keyXPos="29.5%p" /> - - + latin:keyStyle="num7KeyStyle" + latin:keyXPos="29.5%p" /> - + + latin:keyXPos="29.5%p" /> - - + + - - + latin:keyLabel="1" + latin:keyXPos="43.3%p" /> - - - + latin:keyXPos="43.3%p" /> - - - + latin:keyLabel="7" + latin:keyXPos="43.3%p" /> - - - + - + latin:keyLabel="*" + latin:keyXPos="43.3%p" /> - - + diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml index f77fc7e43..d13fa851d 100644 --- a/java/res/xml-sw600dp/kbd_phone.xml +++ b/java/res/xml-sw600dp/kbd_phone.xml @@ -23,7 +23,7 @@ latin:keyboardHeight="@dimen/keyboardHeight" latin:maxKeyboardHeight="50%p" latin:rowHeight="25%p" - latin:keyWidth="13.7%p" + latin:keyWidth="12.7%p" latin:horizontalGap="@dimen/key_horizontal_gap" latin:verticalGap="@dimen/key_bottom_gap" latin:popupKeyboardTemplate="@xml/kbd_popup_template" @@ -35,55 +35,49 @@ latin:keyboardLayout="@xml/kbd_numkey_styles" /> - - + latin:keyStyle="num1KeyStyle" + latin:keyXPos="43.3%p" /> - - - + latin:keyStyle="num4KeyStyle" + latin:keyXPos="43.3%p" /> - @@ -91,52 +85,46 @@ latin:keyStyle="moreKeyStyle" latin:keyWidth="10.0%p" latin:keyEdgeFlags="left" /> - - + latin:keyStyle="num7KeyStyle" + latin:keyXPos="43.3%p" /> - - - + - + latin:keyXPos="43.3%p" /> > + latin:keyStyle="num0KeyStyle" /> - - + latin:keyStyle="numPoundKeyStyle" /> + diff --git a/java/res/xml-sw600dp/kbd_phone_symbols.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml index 63ef4128f..895ca63fc 100644 --- a/java/res/xml-sw600dp/kbd_phone_symbols.xml +++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml @@ -23,7 +23,7 @@ latin:keyboardHeight="@dimen/keyboardHeight" latin:maxKeyboardHeight="50%p" latin:rowHeight="25%p" - latin:keyWidth="13.7%p" + latin:keyWidth="12.7%p" latin:horizontalGap="@dimen/key_horizontal_gap" latin:verticalGap="@dimen/key_bottom_gap" latin:popupKeyboardTemplate="@xml/kbd_popup_template" @@ -35,11 +35,10 @@ latin:keyboardLayout="@xml/kbd_numkey_styles" /> - - + latin:keyStyle="num1KeyStyle" + latin:keyXPos="43.3%p" /> - - - + latin:keyStyle="num4KeyStyle" + latin:keyXPos="43.3%p" /> - @@ -104,6 +98,7 @@ - + latin:keyStyle="num7KeyStyle" + latin:keyXPos="43.3%p" /> - - - + - + latin:keyStyle="numStarKeyStyle" + latin:keyXPos="43.3%p" /> - - + diff --git a/java/res/xml-sw600dp/kbd_qwerty_row1.xml b/java/res/xml-sw600dp/kbd_qwerty_row1.xml index d3d5b25e6..af1bd5d50 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_row1.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_row1.xml @@ -22,7 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > diff --git a/java/res/xml-sw600dp/kbd_qwerty_row2.xml b/java/res/xml-sw600dp/kbd_qwerty_row2.xml index aecb4f4a9..1e6011cde 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_row2.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_row2.xml @@ -24,11 +24,10 @@ - diff --git a/java/res/xml-sw600dp/kbd_qwerty_row3.xml b/java/res/xml-sw600dp/kbd_qwerty_row3.xml index e50f9079c..700bcf005 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_row3.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_row3.xml @@ -26,7 +26,7 @@ > - + diff --git a/java/res/xml-sw600dp/kbd_qwerty_row4.xml b/java/res/xml-sw600dp/kbd_qwerty_row4.xml index 57367462a..648775c97 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_row4.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_row4.xml @@ -23,129 +23,45 @@ > + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + latin:keyXPos="30.8%p" + latin:keyWidth="41.0%p" /> - + diff --git a/java/res/xml-sw600dp/kbd_qwerty_rows_scandinavia.xml b/java/res/xml-sw600dp/kbd_qwerty_rows_scandinavia.xml index 7e4635b8c..0974a9d7c 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_rows_scandinavia.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_rows_scandinavia.xml @@ -24,14 +24,14 @@ + + + - + + + + + + + + + + + - diff --git a/java/res/xml-sw600dp/kbd_row3_right.xml b/java/res/xml-sw600dp/kbd_row3_right.xml new file mode 100644 index 000000000..7867e175a --- /dev/null +++ b/java/res/xml-sw600dp/kbd_row3_right.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml-sw600dp/kbd_ru_rows.xml b/java/res/xml-sw600dp/kbd_ru_rows.xml index 0c7a997a6..95f297dd1 100644 --- a/java/res/xml-sw600dp/kbd_ru_rows.xml +++ b/java/res/xml-sw600dp/kbd_ru_rows.xml @@ -24,14 +24,14 @@ + @@ -100,16 +102,19 @@ + @@ -131,9 +136,13 @@ + latin:keyLabel="." + latin:manualTemporaryUpperCaseCode="44" + latin:keyHintIcon="@drawable/key_hint_comma_holo" + latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_comma_large_holo" + latin:popupCharacters="," /> + diff --git a/java/res/xml-sw600dp/kbd_settings.xml b/java/res/xml-sw600dp/kbd_settings.xml deleted file mode 100644 index 4f679ca93..000000000 --- a/java/res/xml-sw600dp/kbd_settings.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/res/xml-sw600dp/kbd_sr_rows.xml b/java/res/xml-sw600dp/kbd_sr_rows.xml index 71d0e60f1..8c8539ec2 100644 --- a/java/res/xml-sw600dp/kbd_sr_rows.xml +++ b/java/res/xml-sw600dp/kbd_sr_rows.xml @@ -24,13 +24,14 @@ + + @@ -124,10 +134,32 @@ latin:keyLabel="ђ" /> - + + + + + + + + + + + diff --git a/java/res/xml-sw600dp/kbd_symbols.xml b/java/res/xml-sw600dp/kbd_symbols.xml index c89cd2fba..2daaadd02 100644 --- a/java/res/xml-sw600dp/kbd_symbols.xml +++ b/java/res/xml-sw600dp/kbd_symbols.xml @@ -34,7 +34,7 @@ latin:keyboardLayout="@xml/kbd_currency_key_styles" /> - + latin:keyLabel="#" + latin:keyXPos="4.5%p" /> + latin:keyLabel="/" + latin:keyWidth="0%p" /> + latin:keyStyle="tabKeyStyle" /> + latin:keyXPos="30.8%p" + latin:keyWidth="41.0%p" /> + latin:keyLabel="_" + latin:keyWidth="9.1%p" /> + latin:keyLabel="-" + latin:keyWidth="9.1%p" /> + latin:popupCharacters="“,”,«,»,‘,’,‚,‛" + latin:keyWidth="9.1%p" /> + latin:keyLabel="_" + latin:keyWidth="9.1%p" /> - + diff --git a/java/res/xml-sw600dp/kbd_symbols_shift.xml b/java/res/xml-sw600dp/kbd_symbols_shift.xml index 7195f6a7e..111718a4d 100644 --- a/java/res/xml-sw600dp/kbd_symbols_shift.xml +++ b/java/res/xml-sw600dp/kbd_symbols_shift.xml @@ -32,7 +32,7 @@ latin:keyboardLayout="@xml/kbd_key_styles" /> @@ -66,17 +66,17 @@ latin:keyLabel="Δ" /> - + latin:keyLabel="£" + latin:keyXPos="4.5%p" /> @@ -103,7 +103,8 @@ latin:keyLabel="}" /> @@ -137,10 +138,6 @@ - - + - - + latin:keyXPos="30.8%p" + latin:keyWidth="41.0%p" /> + diff --git a/java/res/xml-sw768dp/kbd_azerty_rows.xml b/java/res/xml-sw768dp/kbd_azerty_rows.xml index 564f77629..f6ebfe612 100644 --- a/java/res/xml-sw768dp/kbd_azerty_rows.xml +++ b/java/res/xml-sw768dp/kbd_azerty_rows.xml @@ -24,12 +24,12 @@ - + latin:keyStyle="tabKeyStyle" + latin:keyLabelOption="alignLeft" + latin:keyWidth="7.969%p" + latin:keyEdgeFlags="left" /> + - - + latin:keyStyle="num4KeyStyle" + latin:keyXPos="32.076%p" /> - - + latin:keyStyle="num7KeyStyle" + latin:keyXPos="32.076%p" /> + latin:keyXPos="32.076%p" /> - + latin:keyXPos="13.829%p" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyWidth="8.047%p" /> + latin:keyLabel="7" + latin:keyXPos="45.0%p" /> - - + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyXPos="13.829%p" + latin:keyWidth="24.14%p" /> + latin:keyLabel="*" + latin:keyXPos="45.0%p" /> + latin:keyXPos="-8.047%p" + latin:keyWidth="0%p" /> - diff --git a/java/res/xml-sw768dp/kbd_phone.xml b/java/res/xml-sw768dp/kbd_phone.xml index 49e105d4f..a3dfec099 100644 --- a/java/res/xml-sw768dp/kbd_phone.xml +++ b/java/res/xml-sw768dp/kbd_phone.xml @@ -23,7 +23,7 @@ latin:keyboardHeight="@dimen/keyboardHeight" latin:maxKeyboardHeight="50%p" latin:rowHeight="25%p" - latin:keyWidth="11.949%p" + latin:keyWidth="11.954%p" latin:horizontalGap="@dimen/key_horizontal_gap" latin:verticalGap="@dimen/key_bottom_gap" latin:popupKeyboardTemplate="@xml/kbd_popup_template" @@ -38,63 +38,59 @@ - + latin:keyXPos="20.4%p" + latin:keyWidth="8.047%p" /> - + latin:keyWidth="8.047%p" /> + latin:keyStyle="num1KeyStyle" + latin:keyXPos="45.0%p" /> - - + latin:keyXPos="20.4%p" + latin:keyWidth="8.047%p" /> - + latin:keyWidth="8.047%p" /> + latin:keyStyle="num4KeyStyle" + latin:keyXPos="45.0%p" /> - @@ -102,20 +98,18 @@ and ')'. --> - + latin:keyXPos="20.4%p" + latin:keyWidth="8.047%p" /> - + latin:keyWidth="8.047%p" /> + latin:keyStyle="num7KeyStyle" + latin:keyXPos="45.0%p" /> - - + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyStyle="numStarKeyStyle" + latin:keyXPos="45.0%p" /> + latin:keyXPos="-8.047%p" + latin:keyWidth="0%p" /> - diff --git a/java/res/xml-sw768dp/kbd_phone_symbols.xml b/java/res/xml-sw768dp/kbd_phone_symbols.xml index f73fb5dc8..931c3c934 100644 --- a/java/res/xml-sw768dp/kbd_phone_symbols.xml +++ b/java/res/xml-sw768dp/kbd_phone_symbols.xml @@ -23,7 +23,7 @@ latin:keyboardHeight="@dimen/keyboardHeight" latin:maxKeyboardHeight="50%p" latin:rowHeight="25%p" - latin:keyWidth="11.949%p" + latin:keyWidth="11.954%p" latin:horizontalGap="@dimen/key_horizontal_gap" latin:verticalGap="@dimen/key_bottom_gap" latin:popupKeyboardTemplate="@xml/kbd_popup_template" @@ -38,71 +38,67 @@ - + latin:keyXPos="13.829%p" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyStyle="num1KeyStyle" + latin:keyXPos="45.0%p" /> - - + latin:keyXPos="13.829%p" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyStyle="num4KeyStyle" + latin:keyXPos="45.0%p" /> - @@ -110,24 +106,22 @@ char 'N', '(' and ')'. --> - + latin:keyXPos="13.829%p" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyWidth="8.047%p" /> + latin:keyStyle="num7KeyStyle" + latin:keyXPos="45.0%p" /> - - + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> - + latin:keyXPos="13.829%p" + latin:keyWidth="24.14%p" /> + latin:keyStyle="numStarKeyStyle" + latin:keyXPos="45.0%p" /> + latin:keyXPos="-8.047%p" + latin:keyWidth="0%p" /> - diff --git a/java/res/xml-sw768dp/kbd_qwerty_row1.xml b/java/res/xml-sw768dp/kbd_qwerty_row1.xml index f5135591c..0a793028e 100644 --- a/java/res/xml-sw768dp/kbd_qwerty_row1.xml +++ b/java/res/xml-sw768dp/kbd_qwerty_row1.xml @@ -23,12 +23,12 @@ > diff --git a/java/res/xml-sw768dp/kbd_qwerty_row2.xml b/java/res/xml-sw768dp/kbd_qwerty_row2.xml index 02bd0a6c9..aeeab235e 100644 --- a/java/res/xml-sw768dp/kbd_qwerty_row2.xml +++ b/java/res/xml-sw768dp/kbd_qwerty_row2.xml @@ -22,12 +22,12 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > diff --git a/java/res/xml-sw768dp/kbd_qwerty_row3.xml b/java/res/xml-sw768dp/kbd_qwerty_row3.xml index b7e9bcff9..e488cf32d 100644 --- a/java/res/xml-sw768dp/kbd_qwerty_row3.xml +++ b/java/res/xml-sw768dp/kbd_qwerty_row3.xml @@ -22,11 +22,11 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > diff --git a/java/res/xml-sw768dp/kbd_qwerty_row4.xml b/java/res/xml-sw768dp/kbd_qwerty_row4.xml index e5bc342ae..44e8e10e1 100644 --- a/java/res/xml-sw768dp/kbd_qwerty_row4.xml +++ b/java/res/xml-sw768dp/kbd_qwerty_row4.xml @@ -23,18 +23,17 @@ > - + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> @@ -47,13 +46,15 @@ latin:mode="email" > + latin:keyStyle="comKeyStyle" + latin:keyXPos="15.157%p" /> + latin:keyStyle="comKeyStyle" + latin:keyXPos="15.157%p" /> + latin:popupCharacters="+" + latin:keyXPos="15.157%p" /> + latin:keyStyle="smileyKeyStyle" + latin:keyXPos="15.157%p" /> @@ -105,6 +108,7 @@ > @@ -113,7 +117,8 @@ latin:mode="email" > + latin:keyStyle="comKeyStyle" + latin:keyXPos="15.157%p" /> + latin:popupCharacters="+" + latin:keyXPos="15.157%p" /> + latin:keyStyle="smileyKeyStyle" + latin:keyXPos="15.157%p" /> @@ -152,7 +159,8 @@ + latin:keyXPos="31.250%p" + latin:keyWidth="37.500%p" /> + latin:keyStyle="micKeyStyle" + latin:keyXPos="-8.047%p" + latin:keyWidth="0%p" /> diff --git a/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml b/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml index fb2034fb7..363de4b8c 100644 --- a/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml +++ b/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml @@ -24,12 +24,12 @@ + diff --git a/java/res/xml-sw768dp/kbd_qwertz_rows.xml b/java/res/xml-sw768dp/kbd_qwertz_rows.xml index 3e99f0511..9a8b66177 100644 --- a/java/res/xml-sw768dp/kbd_qwertz_rows.xml +++ b/java/res/xml-sw768dp/kbd_qwertz_rows.xml @@ -24,12 +24,12 @@ + latin:keyLabel="й" /> + latin:keyLabel="ц" /> + latin:keyLabel="у" /> + latin:keyLabel="к" /> + latin:keyLabel="н" /> + latin:keyLabel="г" /> + latin:keyLabel="ш" /> + latin:keyLabel="щ" /> + latin:keyLabel="з" /> @@ -101,11 +93,12 @@ latin:keyLabel="э" /> @@ -101,15 +102,16 @@ latin:keyLabel="ћ" /> @@ -143,7 +145,8 @@ latin:popupCharacters="\?" /> @@ -107,15 +108,16 @@ latin:popupCharacters="],},>" /> - + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> + latin:keyLabel="/" + latin:keyXPos="15.157%p" /> + latin:keyXPos="31.250%p" + latin:keyWidth="37.500%p" /> + latin:keyStyle="micKeyStyle" + latin:keyXPos="-8.047%p" + latin:keyWidth="0%p" /> diff --git a/java/res/xml-sw768dp/kbd_symbols_shift.xml b/java/res/xml-sw768dp/kbd_symbols_shift.xml index cc23358a5..44340ab81 100644 --- a/java/res/xml-sw768dp/kbd_symbols_shift.xml +++ b/java/res/xml-sw768dp/kbd_symbols_shift.xml @@ -32,12 +32,12 @@ latin:keyboardLayout="@xml/kbd_key_styles" /> @@ -71,16 +71,17 @@ latin:keyLabel="Δ" /> @@ -147,34 +149,37 @@ latin:keyLabel="¿" /> - + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="8.047%p" /> + latin:keyWidth="8.047%p" /> + latin:keyXPos="31.250%p" + latin:keyWidth="37.500%p" /> + latin:keyStyle="micKeyStyle" + latin:keyXPos="-8.047%p" + latin:keyWidth="0%p" /> diff --git a/java/res/xml/kbd_azerty_rows.xml b/java/res/xml/kbd_azerty_rows.xml index cc5fb5720..4a766987d 100644 --- a/java/res/xml/kbd_azerty_rows.xml +++ b/java/res/xml/kbd_azerty_rows.xml @@ -68,6 +68,7 @@ latin:keyLabel="p" latin:keyHintIcon="@drawable/key_hint_num0" latin:popupCharacters="@string/alternates_for_p" + latin:keyWidth="0%p" latin:keyEdgeFlags="right" /> - - - + - + @@ -103,7 +97,7 @@ @@ -117,7 +111,7 @@ @@ -130,7 +124,7 @@ latin:keyLabel="9" /> diff --git a/java/res/xml/kbd_phone.xml b/java/res/xml/kbd_phone.xml index 62fbdeeec..7af8d07b4 100644 --- a/java/res/xml/kbd_phone.xml +++ b/java/res/xml/kbd_phone.xml @@ -46,7 +46,7 @@ @@ -60,7 +60,7 @@ @@ -73,7 +73,7 @@ latin:keyStyle="num9KeyStyle" /> diff --git a/java/res/xml/kbd_phone_symbols.xml b/java/res/xml/kbd_phone_symbols.xml index 67cd330e7..4b6319ef7 100644 --- a/java/res/xml/kbd_phone_symbols.xml +++ b/java/res/xml/kbd_phone_symbols.xml @@ -46,7 +46,7 @@ @@ -63,7 +63,7 @@ @@ -78,7 +78,7 @@ latin:keyStyle="numPoundKeyStyle" /> diff --git a/java/res/xml/kbd_qwerty_row1.xml b/java/res/xml/kbd_qwerty_row1.xml index 3964d3c3e..9ee164313 100644 --- a/java/res/xml/kbd_qwerty_row1.xml +++ b/java/res/xml/kbd_qwerty_row1.xml @@ -66,6 +66,7 @@ latin:keyLabel="p" latin:keyHintIcon="@drawable/key_hint_num0" latin:popupCharacters="@string/alternates_for_p" + latin:keyWidth="0%p" latin:keyEdgeFlags="right" /> diff --git a/java/res/xml/kbd_qwerty_row2.xml b/java/res/xml/kbd_qwerty_row2.xml index 9ed4553c4..cf9b3049b 100644 --- a/java/res/xml/kbd_qwerty_row2.xml +++ b/java/res/xml/kbd_qwerty_row2.xml @@ -24,10 +24,9 @@ - diff --git a/java/res/xml/kbd_qwerty_row3.xml b/java/res/xml/kbd_qwerty_row3.xml index 26608fd71..ffbf06133 100644 --- a/java/res/xml/kbd_qwerty_row3.xml +++ b/java/res/xml/kbd_qwerty_row3.xml @@ -48,7 +48,7 @@ latin:keyLabel="m" /> diff --git a/java/res/xml/kbd_qwerty_row4.xml b/java/res/xml/kbd_qwerty_row4.xml index 1e7a3fc5b..67a1a76a1 100644 --- a/java/res/xml/kbd_qwerty_row4.xml +++ b/java/res/xml/kbd_qwerty_row4.xml @@ -64,13 +64,13 @@ > @@ -114,21 +114,13 @@ > - - - diff --git a/java/res/xml/kbd_qwerty_rows_scandinavia.xml b/java/res/xml/kbd_qwerty_rows_scandinavia.xml index 06bb286a2..be841dccd 100644 --- a/java/res/xml/kbd_qwerty_rows_scandinavia.xml +++ b/java/res/xml/kbd_qwerty_rows_scandinavia.xml @@ -71,7 +71,7 @@ latin:popupCharacters="@string/alternates_for_p" /> @@ -94,6 +95,7 @@ @@ -124,7 +126,7 @@ latin:popupCharacters="¿" /> diff --git a/java/res/xml/kbd_symbols_row4.xml b/java/res/xml/kbd_symbols_row4.xml index a5981bfbc..e92e58bcb 100644 --- a/java/res/xml/kbd_symbols_row4.xml +++ b/java/res/xml/kbd_symbols_row4.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > @@ -49,13 +50,13 @@ > @@ -86,13 +87,13 @@ > diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml index b99d97084..0f9ea3b77 100644 --- a/java/res/xml/kbd_symbols_shift.xml +++ b/java/res/xml/kbd_symbols_shift.xml @@ -62,6 +62,7 @@ latin:keyLabel="{" /> @@ -93,6 +94,7 @@ latin:keyLabel="[" /> @@ -123,7 +125,7 @@ latin:popupCharacters="≥,»,›" /> diff --git a/java/res/xml/kbd_symbols_shift_row4.xml b/java/res/xml/kbd_symbols_shift_row4.xml index e4b5403b5..3ed76ea58 100644 --- a/java/res/xml/kbd_symbols_shift_row4.xml +++ b/java/res/xml/kbd_symbols_shift_row4.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > @@ -47,13 +48,13 @@ > @@ -82,13 +83,13 @@ > diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 8eadf4ba4..eccd0c822 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -16,10 +16,6 @@ package com.android.inputmethod.keyboard; -import com.android.inputmethod.keyboard.KeyStyles.KeyStyle; -import com.android.inputmethod.keyboard.KeyboardParser.ParseException; -import com.android.inputmethod.latin.R; - import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; @@ -27,6 +23,10 @@ import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.Xml; +import com.android.inputmethod.keyboard.KeyStyles.KeyStyle; +import com.android.inputmethod.keyboard.KeyboardParser.ParseException; +import com.android.inputmethod.latin.R; + import java.util.ArrayList; /** @@ -137,7 +137,7 @@ public class Key { }; /** - * This constructor is being used only for key in mini popup keyboard. + * This constructor is being used only for key in popup mini keyboard. */ public Key(Resources res, Keyboard keyboard, CharSequence popupCharacter, int x, int y, int width, int height, int edgeFlags) { @@ -174,6 +174,7 @@ public class Key { * @param x the x coordinate of the top-left * @param y the y coordinate of the top-left * @param parser the XML parser containing the attributes for this key + * @param keyStyles active key styles set */ public Key(Resources res, Row row, int x, int y, XmlResourceParser parser, KeyStyles keyStyles) { @@ -181,6 +182,7 @@ public class Key { final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard); + int keyWidth; try { mHeight = KeyboardParser.getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_rowHeight, @@ -188,17 +190,13 @@ public class Key { mGap = KeyboardParser.getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_horizontalGap, mKeyboard.getDisplayWidth(), row.mDefaultHorizontalGap); - mWidth = KeyboardParser.getDimensionOrFraction(keyboardAttr, + keyWidth = KeyboardParser.getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyWidth, - mKeyboard.getDisplayWidth(), row.mDefaultWidth) - mGap; + mKeyboard.getDisplayWidth(), row.mDefaultWidth); } finally { keyboardAttr.recycle(); } - // Horizontal gap is divided equally to both sides of the key. - mX = x + mGap / 2; - mY = y; - final TypedArray keyAttr = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard_Key); try { @@ -212,6 +210,35 @@ public class Key { style = keyStyles.getEmptyKeyStyle(); } + final int keyboardWidth = mKeyboard.getDisplayWidth(); + int keyXPos = KeyboardParser.getDimensionOrFraction(keyAttr, + R.styleable.Keyboard_Key_keyXPos, keyboardWidth, x); + if (keyXPos < 0) { + // If keyXPos is negative, the actual x-coordinate will be k + keyXPos. + keyXPos += keyboardWidth; + if (keyXPos < x) { + // keyXPos shouldn't be less than x because drawable area for this key starts + // at x. Or, this key will overlaps the adjacent key on its left hand side. + keyXPos = x; + } + } + if (keyWidth == 0) { + // If keyWidth is zero, the actual key width will be determined to fill out the + // area up to the right edge of the keyboard. + keyWidth = keyboardWidth - keyXPos; + } else if (keyWidth < 0) { + // If keyWidth is negative, the actual key width will be determined to fill out the + // area between the nearest key on the left hand side and the right edge of the + // keyboard. + keyXPos = x; + keyWidth = keyboardWidth - keyXPos; + } + + // Horizontal gap is divided equally to both sides of the key. + mX = keyXPos + mGap / 2; + mY = y; + mWidth = keyWidth - mGap; + final CharSequence[] popupCharacters = style.getTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters); if (res.getBoolean(R.bool.config_digit_popup_characters_enabled)) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index bb2c0e3ba..d0e8b32c3 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -138,19 +138,19 @@ public class KeyboardId { @Override public String toString() { - return String.format("[%s.xml %s %s %s imeAction=%s %s%s%s%s%s%s%s]", + return String.format("[%s.xml %s %s %s %s %s%s%s%s%s%s%s]", mXmlName, mLocale, (mOrientation == 1 ? "port" : "land"), modeName(mMode), imeOptionsName(mImeAction), + colorSchemeName(mColorScheme), (mWebInput ? " webInput" : ""), (mPasswordInput ? " passwordInput" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""), (mVoiceKeyEnabled ? " voiceKeyEnabled" : ""), (mHasVoiceKey ? " hasVoiceKey" : ""), - (mEnableShiftLock ? " enableShiftLock" : ""), - colorSchemeName(mColorScheme) + (mEnableShiftLock ? " enableShiftLock" : "") ); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java index bc9e8f0a0..308651a9e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java @@ -243,7 +243,7 @@ public class KeyboardParser { if (TAG_KEY.equals(tag)) { parseKey(parser, row, keys); } else if (TAG_SPACER.equals(tag)) { - parseSpacer(parser, keys); + parseSpacer(parser, row, keys); } else if (TAG_INCLUDE.equals(tag)) { parseIncludeRowContent(parser, row, keys); } else if (TAG_SWITCH.equals(tag)) { @@ -290,19 +290,32 @@ public class KeyboardParser { } } - private void parseSpacer(XmlResourceParser parser, List keys) + private void parseSpacer(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { if (keys == null) { checkEndTag(TAG_SPACER, parser); } else { if (DEBUG) Log.d(TAG, String.format("<%s />", TAG_SPACER)); - final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser), + final TypedArray keyboardAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard); - final int gap = getDimensionOrFraction(a, R.styleable.Keyboard_horizontalGap, - mKeyboard.getDisplayWidth(), 0); - a.recycle(); + if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) + throw new IllegalAttribute(parser, "horizontalGap"); + final int defaultWidth = (row != null) ? row.mDefaultWidth : 0; + final int keyWidth = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyWidth, + mKeyboard.getDisplayWidth(), defaultWidth); + keyboardAttr.recycle(); + + final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), + R.styleable.Keyboard_Key); + int keyXPos = KeyboardParser.getDimensionOrFraction(keyAttr, + R.styleable.Keyboard_Key_keyXPos, mKeyboard.getDisplayWidth(), mCurrentX); + if (keyXPos < 0) { + // If keyXPos is negative, the actual x-coordinate will be display_width + keyXPos. + keyXPos += mKeyboard.getDisplayWidth(); + } + checkEndTag(TAG_SPACER, parser); - setSpacer(gap); + setSpacer(keyXPos, keyWidth); } } @@ -536,7 +549,7 @@ public class KeyboardParser { } private void endKey(Key key) { - mCurrentX += key.mGap + key.mWidth; + mCurrentX = key.mX + key.mGap + key.mWidth; if (mCurrentX > mMaxRowWidth) mMaxRowWidth = mCurrentX; } @@ -545,8 +558,8 @@ public class KeyboardParser { mTotalHeight = mCurrentY - defaultVerticalGap; } - private void setSpacer(int gap) { - mCurrentX += gap; + private void setSpacer(int keyXPos, int width) { + mCurrentX = keyXPos + width; } public static int getDimensionOrFraction(TypedArray a, int index, int base, int defValue) { @@ -583,6 +596,13 @@ public class KeyboardParser { } } + @SuppressWarnings("serial") + private static class IllegalAttribute extends ParseException { + public IllegalAttribute(XmlResourceParser parser, String attribute) { + super("Tag " + parser.getName() + " has illegal attribute " + attribute, parser); + } + } + @SuppressWarnings("serial") private static class NonEmptyTag extends ParseException { public NonEmptyTag(String tag, XmlResourceParser parser) {