diff options
Diffstat (limited to 'java')
26 files changed, 494 insertions, 66 deletions
diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index 6cdcf891c..550d29f76 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -19,8 +19,9 @@ --> <resources> - <!-- keyboardHeight = key_height*4 + key_bottom_gap*3, key_height=0.260in --> - <dimen name="keyboardHeight">1.100in</dimen> + <!-- Preferable keyboard height in absolute scale: 1.100in --> + <!-- This keyboardHeight value should match with keyboard-heights.xml --> + <dimen name="keyboardHeight">176.0dp</dimen> <fraction name="minKeyboardHeight">45%p</fraction> <!-- key_height + key_bottom_gap = popup_key_height --> <!-- <dimen name="key_height">0.260in</dimen>--> @@ -31,7 +32,6 @@ <fraction name="key_bottom_gap">4.330%p</fraction> <fraction name="key_horizontal_gap">0.405%p</fraction> - <dimen name="keyboardHeight_stone">0.984in</dimen> <fraction name="key_bottom_gap_stone">5.010%p</fraction> <fraction name="key_horizontal_gap_stone">1.159%p</fraction> diff --git a/java/res/values-land/keyboard-heights.xml b/java/res/values-land/keyboard-heights.xml new file mode 100644 index 000000000..12c3e3951 --- /dev/null +++ b/java/res/values-land/keyboard-heights.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Preferable keyboard height in absolute scale: 1.100in --> +<resources> + <!-- Build.HARDWARE,keyboard_height_in_dp --> + <string-array name="keyboard_heights" translatable="false"> + <!-- Droid --> + <item>sholes,194.3333</item> + <!-- Nexus One --> + <item>mahimahi,186.2667</item> + <!-- Nexus S --> + <item>herring,171.9385</item> + <!-- Galaxy Nexus --> + <item>tuna,173.4207</item> + </string-array> +</resources> diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml index 5dce47ee3..c6c6f2b3b 100644 --- a/java/res/values-sw600dp-land/dimens.xml +++ b/java/res/values-sw600dp-land/dimens.xml @@ -19,8 +19,9 @@ --> <resources> - <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 --> - <dimen name="keyboardHeight">45.0mm</dimen> + <!-- Preferable keyboard height in absolute scale: 45.0mm --> + <!-- This keyboardHeight value should match with keyboard-heights.xml --> + <dimen name="keyboardHeight">283.5dp</dimen> <fraction name="minKeyboardHeight">45%p</fraction> <fraction name="keyboard_top_padding">2.444%p</fraction> @@ -28,13 +29,13 @@ <fraction name="key_bottom_gap">4.911%p</fraction> <fraction name="key_horizontal_gap">1.284%p</fraction> - <dimen name="keyboardHeight_stone">45.0mm</dimen> <fraction name="key_bottom_gap_stone">4.355%p</fraction> <fraction name="key_horizontal_gap_stone">1.505%p</fraction> <fraction name="key_bottom_gap_gb">5.200%p</fraction> <fraction name="key_horizontal_gap_gb">1.447%p</fraction> + <fraction name="key_bottom_gap_ics">4.0%p</fraction> <fraction name="keyboard_bottom_padding_ics">0.0%p</fraction> <dimen name="popup_key_height">13.0mm</dimen> diff --git a/java/res/values-sw600dp-land/keyboard-heights.xml b/java/res/values-sw600dp-land/keyboard-heights.xml new file mode 100644 index 000000000..93f9824d1 --- /dev/null +++ b/java/res/values-sw600dp-land/keyboard-heights.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Preferable keyboard height in absolute scale: 45.0mm --> +<resources> + <!-- Build.HARDWARE,keyboard_height_in_dp --> + <string-array name="keyboard_heights" translatable="false"> + <!-- Xoom --> + <item>stingray,265.4378</item> + </string-array> +</resources> diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index 0f256a302..ebe388263 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -19,8 +19,9 @@ --> <resources> - <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 --> - <dimen name="keyboardHeight">48.0mm</dimen> + <!-- Preferable keyboard height in absolute scale: 48.0mm --> + <!-- This keyboardHeight value should match with keyboard-heights.xml --> + <dimen name="keyboardHeight">302.4dp</dimen> <fraction name="maxKeyboardHeight">50%p</fraction> <fraction name="minKeyboardHeight">-35.0%p</fraction> @@ -31,13 +32,13 @@ <fraction name="key_bottom_gap">3.750%p</fraction> <fraction name="key_horizontal_gap">1.857%p</fraction> - <dimen name="keyboardHeight_stone">48.0mm</dimen> <fraction name="key_bottom_gap_stone">3.75%p</fraction> <fraction name="key_horizontal_gap_stone">1.602%p</fraction> <fraction name="key_bottom_gap_gb">4.625%p</fraction> <fraction name="key_horizontal_gap_gb">2.113%p</fraction> + <fraction name="key_bottom_gap_ics">4.0%p</fraction> <fraction name="keyboard_bottom_padding_ics">0.0%p</fraction> <dimen name="more_keys_keyboard_key_horizontal_padding">6dp</dimen> diff --git a/java/res/values-sw600dp/keyboard-heights.xml b/java/res/values-sw600dp/keyboard-heights.xml new file mode 100644 index 000000000..77e52be2f --- /dev/null +++ b/java/res/values-sw600dp/keyboard-heights.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Preferable keyboard height in absolute scale: 48.0mm --> +<resources> + <!-- Build.HARDWARE,keyboard_height_in_dp --> + <string-array name="keyboard_heights" translatable="false"> + <!-- Xoom --> + <item>stingray,283.1337</item> + </string-array> +</resources> diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml index 535c62308..597ed5102 100644 --- a/java/res/values-sw768dp-land/dimens.xml +++ b/java/res/values-sw768dp-land/dimens.xml @@ -19,8 +19,9 @@ --> <resources> - <!-- keyboardHeight = key_height*4 + key_bottom_gap*3, key_height=14.5mm --> - <dimen name="keyboardHeight">58.0mm</dimen> + <!-- Preferable keyboard height in absolute scale: 58.0mm --> + <!-- This keyboardHeight value should match with keyboard-heights.xml --> + <dimen name="keyboardHeight">365.4dp</dimen> <fraction name="minKeyboardHeight">45%p</fraction> <fraction name="keyboard_top_padding">1.896%p</fraction> @@ -29,7 +30,6 @@ <fraction name="key_bottom_gap">4.103%p</fraction> <fraction name="key_horizontal_gap">1.034%p</fraction> - <dimen name="keyboardHeight_stone">58.0mm</dimen> <fraction name="key_bottom_gap_stone">3.379%p</fraction> <fraction name="key_horizontal_gap_stone">1.062%p</fraction> diff --git a/java/res/values-sw768dp-land/keyboard-heights.xml b/java/res/values-sw768dp-land/keyboard-heights.xml new file mode 100644 index 000000000..692c5a0fb --- /dev/null +++ b/java/res/values-sw768dp-land/keyboard-heights.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Preferable keyboard height in absolute scale: 58.0mm --> +<resources> + <!-- Build.HARDWARE,keyboard_height_in_dp --> + <string-array name="keyboard_heights" translatable="false"> + <!-- Xoom --> + <item>stingray,342.1198</item> + </string-array> +</resources> diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml index 7aefa26af..a9f0c00aa 100644 --- a/java/res/values-sw768dp/dimens.xml +++ b/java/res/values-sw768dp/dimens.xml @@ -19,8 +19,9 @@ --> <resources> - <!-- keyboardHeight = key_height*4 + key_bottom_gap*3, key_height=12mm --> - <dimen name="keyboardHeight">48.0mm</dimen> + <!-- Preferable keyboard height in absolute scale: 48.0mm --> + <!-- This keyboardHeight value should match with keyboard-heights.xml --> + <dimen name="keyboardHeight">302.4dp</dimen> <fraction name="maxKeyboardHeight">50%p</fraction> <fraction name="minKeyboardHeight">-35.0%p</fraction> @@ -30,7 +31,6 @@ <fraction name="key_bottom_gap">4.270%p</fraction> <fraction name="key_horizontal_gap">1.551%p</fraction> - <dimen name="keyboardHeight_stone">48.0mm</dimen> <fraction name="key_bottom_gap_stone">3.75%p</fraction> <fraction name="key_horizontal_gap_stone">1.059%p</fraction> diff --git a/java/res/values-sw768dp/keyboard-heights.xml b/java/res/values-sw768dp/keyboard-heights.xml new file mode 100644 index 000000000..77e52be2f --- /dev/null +++ b/java/res/values-sw768dp/keyboard-heights.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Preferable keyboard height in absolute scale: 48.0mm --> +<resources> + <!-- Build.HARDWARE,keyboard_height_in_dp --> + <string-array name="keyboard_heights" translatable="false"> + <!-- Xoom --> + <item>stingray,283.1337</item> + </string-array> +</resources> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index cf55fbe4a..e33f0ba8a 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -202,9 +202,10 @@ <!-- Default height of a row (key height + vertical gap), in pixels or percentage of keyboard height. --> <attr name="rowHeight" format="dimension|fraction" /> - <!-- Default horizontal gap between keys. --> + <!-- Default horizontal gap between keys, in pixels or percentage of keyboard width. --> <attr name="horizontalGap" format="dimension|fraction" /> - <!-- Default vertical gap between rows of keys. --> + <!-- Default vertical gap between rows of keys, in pixels or percentage of keyboard + height. --> <attr name="verticalGap" format="dimension|fraction" /> <!-- More keys keyboard layout template --> <attr name="moreKeysTemplate" format="reference" /> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 5f74fa746..9d64a618a 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -19,8 +19,9 @@ --> <resources> - <!-- keyboardHeight = row_height*4 + key_bottom_gap*3 --> - <dimen name="keyboardHeight">1.285in</dimen> + <!-- Preferable keyboard height in absolute scale: 1.285in --> + <!-- This keyboardHeight value should match with keyboard-heights.xml --> + <dimen name="keyboardHeight">205.6dp</dimen> <fraction name="maxKeyboardHeight">50%p</fraction> <fraction name="minKeyboardHeight">-61.8%p</fraction> @@ -35,7 +36,6 @@ <fraction name="key_bottom_gap">6.250%p</fraction> <fraction name="key_horizontal_gap">1.352%p</fraction> - <dimen name="keyboardHeight_stone">1.317in</dimen> <fraction name="keyboard_top_padding_stone">1.556%p</fraction> <fraction name="keyboard_bottom_padding_stone">0.778%p</fraction> <fraction name="key_bottom_gap_stone">7.506%p</fraction> diff --git a/java/res/values/keyboard-heights.xml b/java/res/values/keyboard-heights.xml new file mode 100644 index 000000000..7d5b58372 --- /dev/null +++ b/java/res/values/keyboard-heights.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- Preferable keyboard height in absolute scale: 1.285in --> +<resources> + <!-- Build.HARDWARE,keyboard_height_in_dp --> + <string-array name="keyboard_heights" translatable="false"> + <!-- Droid --> + <item>sholes,227.0167</item> + <!-- Nexus One --> + <item>mahimahi,217.5932</item> + <!-- Nexus S --> + <item>herring,200.8554</item> + <!-- Galaxy Nexus --> + <item>tuna,202.5869</item> + </string-array> +</resources> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 691f98ae2..b08ff3b90 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -173,7 +173,6 @@ > <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> <item name="themeId">6</item> - <item name="keyboardHeight">@dimen/keyboardHeight_stone</item> <item name="keyboardTopPadding">@fraction/keyboard_top_padding_stone</item> <item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_stone</item> <item name="horizontalGap">@fraction/key_horizontal_gap_stone</item> diff --git a/java/res/xml-sw600dp-land/kbd_thai.xml b/java/res/xml-sw600dp-land/kbd_thai.xml new file mode 100644 index 000000000..ac36ea5ff --- /dev/null +++ b/java/res/xml-sw600dp-land/kbd_thai.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:rowHeight="20%p" + latin:verticalGap="3.20%p" +> + <include + latin:keyboardLayout="@xml/rows_thai" /> +</Keyboard> diff --git a/java/res/xml-sw600dp/kbd_thai.xml b/java/res/xml-sw600dp/kbd_thai.xml index 06d98e19d..ac36ea5ff 100644 --- a/java/res/xml-sw600dp/kbd_thai.xml +++ b/java/res/xml-sw600dp/kbd_thai.xml @@ -21,6 +21,7 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" + latin:verticalGap="3.20%p" > <include latin:keyboardLayout="@xml/rows_thai" /> diff --git a/java/res/xml-sw768dp-land/kbd_thai.xml b/java/res/xml-sw768dp-land/kbd_thai.xml new file mode 100644 index 000000000..4bfc9cb48 --- /dev/null +++ b/java/res/xml-sw768dp-land/kbd_thai.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:rowHeight="20%p" + latin:verticalGap="2.65%p" +> + <include + latin:keyboardLayout="@xml/rows_thai" /> +</Keyboard> diff --git a/java/res/xml-sw768dp-land/kbd_thai_symbols.xml b/java/res/xml-sw768dp-land/kbd_thai_symbols.xml new file mode 100644 index 000000000..a3feeaae3 --- /dev/null +++ b/java/res/xml-sw768dp-land/kbd_thai_symbols.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:rowHeight="20%p" + latin:verticalGap="2.65%p" +> + <include + latin:keyboardLayout="@xml/rows_thai_symbols" /> +</Keyboard> diff --git a/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml b/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml new file mode 100644 index 000000000..8b4a8ea5b --- /dev/null +++ b/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:rowHeight="20%p" + latin:verticalGap="2.65%p" +> + <include + latin:keyboardLayout="@xml/rows_thai_symbols_shift" /> +</Keyboard> diff --git a/java/res/xml-sw768dp/kbd_thai.xml b/java/res/xml-sw768dp/kbd_thai.xml new file mode 100644 index 000000000..dd0ac36a6 --- /dev/null +++ b/java/res/xml-sw768dp/kbd_thai.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:rowHeight="20%p" + latin:verticalGap="2.95%p" +> + <include + latin:keyboardLayout="@xml/rows_thai" /> +</Keyboard> diff --git a/java/res/xml-sw768dp/kbd_thai_symbols.xml b/java/res/xml-sw768dp/kbd_thai_symbols.xml index f02033431..91cf8084f 100644 --- a/java/res/xml-sw768dp/kbd_thai_symbols.xml +++ b/java/res/xml-sw768dp/kbd_thai_symbols.xml @@ -21,6 +21,7 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" + latin:verticalGap="2.95%p" > <include latin:keyboardLayout="@xml/rows_thai_symbols" /> diff --git a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml index af24da0f5..85745ac3d 100644 --- a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml +++ b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml @@ -21,6 +21,7 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" + latin:verticalGap="2.95%p" > <include latin:keyboardLayout="@xml/rows_thai_symbols_shift" /> diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 2b1cc43cd..07b9c1e8c 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -31,6 +31,7 @@ import com.android.inputmethod.keyboard.internal.KeyStyles; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.XmlParseUtils; import org.xmlpull.v1.XmlPullParser; @@ -715,22 +716,30 @@ public class Keyboard { R.styleable.Keyboard_Key); try { final int displayHeight = mDisplayMetrics.heightPixels; - final int keyboardHeight = (int)keyboardAttr.getDimension( - R.styleable.Keyboard_keyboardHeight, displayHeight / 2); - final int maxKeyboardHeight = (int)getDimensionOrFraction(keyboardAttr, + final String keyboardHeightString = Utils.getDeviceOverrideValue( + mResources, R.array.keyboard_heights, null); + final float keyboardHeight; + if (keyboardHeightString != null) { + keyboardHeight = Float.parseFloat(keyboardHeightString) + * mDisplayMetrics.density; + } else { + keyboardHeight = keyboardAttr.getDimension( + R.styleable.Keyboard_keyboardHeight, displayHeight / 2); + } + final float maxKeyboardHeight = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_maxKeyboardHeight, displayHeight, displayHeight / 2); - int minKeyboardHeight = (int)getDimensionOrFraction(keyboardAttr, + float minKeyboardHeight = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_minKeyboardHeight, displayHeight, displayHeight / 2); if (minKeyboardHeight < 0) { // Specified fraction was negative, so it should be calculated against display // width. - minKeyboardHeight = -(int)getDimensionOrFraction(keyboardAttr, + minKeyboardHeight = -getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_minKeyboardHeight, displayWidth, displayWidth / 2); } final Params params = mParams; // Keyboard height will not exceed maxKeyboardHeight and will not be less than // minKeyboardHeight. - params.mOccupiedHeight = Math.max( + params.mOccupiedHeight = (int)Math.max( Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight); params.mOccupiedWidth = params.mId.mWidth; params.mTopPadding = (int)getDimensionOrFraction(keyboardAttr, diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7903820f7..175d953a6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -503,7 +503,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private void initSuggest() { final String localeStr = mSubtypeSwitcher.getInputLocaleStr(); - final Locale keyboardLocale = LocaleUtils.constructLocaleFromString(localeStr); + final Locale keyboardLocale = mSubtypeSwitcher.getInputLocale(); final Resources res = mResources; final Locale savedLocale = LocaleUtils.setSystemLocale(res, keyboardLocale); @@ -567,8 +567,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } /* package private */ void resetSuggestMainDict() { - final String localeStr = mSubtypeSwitcher.getInputLocaleStr(); - final Locale keyboardLocale = LocaleUtils.constructLocaleFromString(localeStr); + final Locale keyboardLocale = mSubtypeSwitcher.getInputLocale(); int mainDicResId = DictionaryFactory.getMainDictionaryResourceId(mResources); mSuggest.resetMainDict(this, mainDicResId, keyboardLocale); } @@ -1007,10 +1006,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final int touchHeight = inputView.getHeight() + extraHeight // Extend touchable region below the keyboard. + EXTENDED_TOUCHABLE_REGION_HEIGHT; - if (DEBUG) { - Log.d(TAG, "Touchable region: y=" + touchY + " width=" + touchWidth - + " height=" + touchHeight); - } setTouchableRegionCompat(outInsets, 0, touchY, touchWidth, touchHeight); } outInsets.contentTopInsets = touchY; @@ -1995,7 +1990,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void addToUserHistoryDictionary(final CharSequence suggestion) { - if (suggestion == null || suggestion.length() < 1) return; + if (TextUtils.isEmpty(suggestion)) return; // Only auto-add to dictionary if auto-correct is ON. Otherwise we'll be // adding words in situations where the user or application really didn't diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index ffbbf9bb8..3524c72f6 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -47,13 +47,13 @@ public class SubtypeSwitcher { private static final String TAG = SubtypeSwitcher.class.getSimpleName(); public static final String KEYBOARD_MODE = "keyboard"; - private static final char LOCALE_SEPARATER = '_'; + private static final char LOCALE_SEPARATOR = '_'; private static final String VOICE_MODE = "voice"; private static final String SUBTYPE_EXTRAVALUE_REQUIRE_NETWORK_CONNECTIVITY = "requireNetworkConnectivity"; private final TextUtils.SimpleStringSplitter mLocaleSplitter = - new TextUtils.SimpleStringSplitter(LOCALE_SEPARATER); + new TextUtils.SimpleStringSplitter(LOCALE_SEPARATOR); private static final SubtypeSwitcher sInstance = new SubtypeSwitcher(); private /* final */ LatinIME mService; diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index 70530c338..64fcd7f1a 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -59,7 +59,7 @@ public class FusionDictionary implements Iterable<Word> { */ public static class WeightedString { final String mWord; - final int mFrequency; + int mFrequency; public WeightedString(String word, int frequency) { mWord = word; mFrequency = frequency; @@ -94,10 +94,10 @@ public class FusionDictionary implements Iterable<Word> { public static class CharGroup { public static final int NOT_A_TERMINAL = -1; final int mChars[]; - final ArrayList<WeightedString> mShortcutTargets; - final ArrayList<WeightedString> mBigrams; - final int mFrequency; // NOT_A_TERMINAL == mFrequency indicates this is not a terminal. - final boolean mIsShortcutOnly; // Only valid if this is a terminal. + ArrayList<WeightedString> mShortcutTargets; + ArrayList<WeightedString> mBigrams; + int mFrequency; // NOT_A_TERMINAL == mFrequency indicates this is not a terminal. + boolean mIsShortcutOnly; // Only valid if this is a terminal. Node mChildren; // The two following members to help with binary generation int mCachedSize; @@ -146,6 +146,102 @@ public class FusionDictionary implements Iterable<Word> { assert(mChars.length > 0); return 1 < mChars.length; } + + /** + * Adds a word to the bigram list. Updates the frequency if the word already + * exists. + */ + public void addBigram(final String word, final int frequency) { + if (mBigrams == null) { + mBigrams = new ArrayList<WeightedString>(); + } + WeightedString bigram = getBigram(word); + if (bigram != null) { + bigram.mFrequency = frequency; + } else { + bigram = new WeightedString(word, frequency); + mBigrams.add(bigram); + } + } + + /** + * Gets the shortcut target for the given word. Returns null if the word is not in the + * shortcut list. + */ + public WeightedString getShortcut(final String word) { + if (mShortcutTargets != null) { + final int size = mShortcutTargets.size(); + for (int i = 0; i < size; ++i) { + WeightedString shortcut = mShortcutTargets.get(i); + if (shortcut.mWord.equals(word)) { + return shortcut; + } + } + } + return null; + } + + /** + * Gets the bigram for the given word. + * Returns null if the word is not in the bigrams list. + */ + public WeightedString getBigram(final String word) { + if (mBigrams != null) { + final int size = mBigrams.size(); + for (int i = 0; i < size; ++i) { + WeightedString bigram = mBigrams.get(i); + if (bigram.mWord.equals(word)) { + return bigram; + } + } + } + return null; + } + + /** + * Updates the CharGroup with the given properties. Adds the shortcut and bigram lists to + * the existing ones if any. Note: unigram, bigram, and shortcut frequencies are only + * updated if they are higher than the existing ones. + */ + public void update(int frequency, ArrayList<WeightedString> shortcutTargets, + ArrayList<WeightedString> bigrams, boolean isShortcutOnly) { + if (frequency > mFrequency) { + mFrequency = frequency; + } + if (shortcutTargets != null) { + if (mShortcutTargets == null) { + mShortcutTargets = shortcutTargets; + } else { + final int size = shortcutTargets.size(); + for (int i = 0; i < size; ++i) { + final WeightedString shortcut = shortcutTargets.get(i); + final WeightedString existingShortcut = getShortcut(shortcut.mWord); + if (existingShortcut == null) { + mShortcutTargets.add(shortcut); + } else if (existingShortcut.mFrequency < shortcut.mFrequency) { + existingShortcut.mFrequency = shortcut.mFrequency; + } + } + } + } + if (bigrams != null) { + if (mBigrams == null) { + mBigrams = bigrams; + } else { + final int size = bigrams.size(); + for (int i = 0; i < size; ++i) { + final WeightedString bigram = bigrams.get(i); + final WeightedString existingBigram = getBigram(bigram.mWord); + if (existingBigram == null) { + mBigrams.add(bigram); + } else if (existingBigram.mFrequency < bigram.mFrequency) { + existingBigram.mFrequency = bigram.mFrequency; + } + } + } + } + mIsShortcutOnly = isShortcutOnly; + } } /** @@ -259,6 +355,27 @@ public class FusionDictionary implements Iterable<Word> { } /** + * Helper method to add a new bigram to the dictionary. + * + * @param word1 the previous word of the context + * @param word2 the next word of the context + * @param frequency the bigram frequency + */ + public void setBigram(final String word1, final String word2, final int frequency) { + CharGroup charGroup = findWordInTree(mRoot, word1); + if (charGroup != null) { + final CharGroup charGroup2 = findWordInTree(mRoot, word2); + if (charGroup2 == null) { + // TODO: refactor with the identical code in addNeutralWords + add(getCodePoints(word2), 0, null, null, false /* isShortcutOnly */); + } + charGroup.addBigram(word2, frequency); + } else { + throw new RuntimeException("First word of bigram not found"); + } + } + + /** * Add a word to this dictionary. * * The shortcuts and bigrams, if any, have to be in the dictionary already. If they aren't, @@ -306,17 +423,9 @@ public class FusionDictionary implements Iterable<Word> { if (differentCharIndex == currentGroup.mChars.length) { if (charIndex + differentCharIndex >= word.length) { // The new word is a prefix of an existing word, but the node on which it - // should end already exists as is. - if (currentGroup.mFrequency > 0) { - throw new RuntimeException("Such a word already exists in the dictionary : " - + new String(word, 0, word.length)); - } else { - final CharGroup newNode = new CharGroup(currentGroup.mChars, - shortcutTargets, bigrams, frequency, currentGroup.mChildren, - isShortcutOnly); - currentNode.mData.set(nodeIndex, newNode); - checkStack(currentNode); - } + // should end already exists as is. Since the old CharNode was not a terminal, + // make it one by filling in its frequency and other attributes + currentGroup.update(frequency, shortcutTargets, bigrams, isShortcutOnly); } else { // The new word matches the full old word and extends past it. // We only have to create a new node and add it to the end of this. @@ -328,19 +437,9 @@ public class FusionDictionary implements Iterable<Word> { } } else { if (0 == differentCharIndex) { - // Exact same word. Check the frequency is 0 or NOT_A_TERMINAL, and update. - if (0 != frequency) { - if (0 < currentGroup.mFrequency) { - throw new RuntimeException("This word already exists with frequency " - + currentGroup.mFrequency + " : " - + new String(word, 0, word.length)); - } - final CharGroup newGroup = new CharGroup(word, - currentGroup.mShortcutTargets, currentGroup.mBigrams, - frequency, currentGroup.mChildren, - currentGroup.mIsShortcutOnly && isShortcutOnly); - currentNode.mData.set(nodeIndex, newGroup); - } + // Exact same word. Update the frequency if higher. This will also add the + // new bigrams to the existing bigram list if it already exists. + currentGroup.update(frequency, shortcutTargets, bigrams, isShortcutOnly); } else { // Partial prefix match only. We have to replace the current node with a node // containing the current prefix and create two new ones for the tails. |