From e49a987c23e2de67618edf12d66dd1a69f4614af Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 21 Mar 2012 18:17:21 +0900 Subject: [PATCH] Override the keyboard height per device Bug: 6183561 Change-Id: I7432552fbe41212e8f412962b16877a2af07eb9c --- java/res/values-land/dimens.xml | 6 ++-- java/res/values-land/keyboard-heights.xml | 34 +++++++++++++++++++ java/res/values-sw600dp-land/dimens.xml | 6 ++-- .../values-sw600dp-land/keyboard-heights.xml | 28 +++++++++++++++ java/res/values-sw600dp/dimens.xml | 6 ++-- java/res/values-sw600dp/keyboard-heights.xml | 28 +++++++++++++++ java/res/values-sw768dp-land/dimens.xml | 6 ++-- .../values-sw768dp-land/keyboard-heights.xml | 28 +++++++++++++++ java/res/values-sw768dp/dimens.xml | 6 ++-- java/res/values-sw768dp/keyboard-heights.xml | 28 +++++++++++++++ java/res/values/dimens.xml | 6 ++-- java/res/values/keyboard-heights.xml | 34 +++++++++++++++++++ java/res/values/styles.xml | 1 - .../inputmethod/keyboard/Keyboard.java | 21 ++++++++---- 14 files changed, 213 insertions(+), 25 deletions(-) create mode 100644 java/res/values-land/keyboard-heights.xml create mode 100644 java/res/values-sw600dp-land/keyboard-heights.xml create mode 100644 java/res/values-sw600dp/keyboard-heights.xml create mode 100644 java/res/values-sw768dp-land/keyboard-heights.xml create mode 100644 java/res/values-sw768dp/keyboard-heights.xml create mode 100644 java/res/values/keyboard-heights.xml 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 @@ --> - - 1.100in + + + 176.0dp 45%p @@ -31,7 +32,6 @@ 4.330%p 0.405%p - 0.984in 5.010%p 1.159%p 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 @@ + + + + + + + + + sholes,194.3333 + + mahimahi,186.2667 + + herring,171.9385 + + tuna,173.4207 + + diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml index 5dce47ee3..d84f843c1 100644 --- a/java/res/values-sw600dp-land/dimens.xml +++ b/java/res/values-sw600dp-land/dimens.xml @@ -19,8 +19,9 @@ --> - - 45.0mm + + + 283.5dp 45%p 2.444%p @@ -28,7 +29,6 @@ 4.911%p 1.284%p - 45.0mm 4.355%p 1.505%p 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 @@ + + + + + + + + + stingray,265.4378 + + diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index 0f256a302..1b24b6ba8 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -19,8 +19,9 @@ --> - - 48.0mm + + + 302.4dp 50%p -35.0%p @@ -31,7 +32,6 @@ 3.750%p 1.857%p - 48.0mm 3.75%p 1.602%p 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 @@ + + + + + + + + + stingray,283.1337 + + 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 @@ --> - - 58.0mm + + + 365.4dp 45%p 1.896%p @@ -29,7 +30,6 @@ 4.103%p 1.034%p - 58.0mm 3.379%p 1.062%p 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 @@ + + + + + + + + + stingray,342.1198 + + 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 @@ --> - - 48.0mm + + + 302.4dp 50%p -35.0%p @@ -30,7 +31,6 @@ 4.270%p 1.551%p - 48.0mm 3.75%p 1.059%p 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 @@ + + + + + + + + + stingray,283.1337 + + 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 @@ --> - - 1.285in + + + 205.6dp 50%p -61.8%p @@ -35,7 +36,6 @@ 6.250%p 1.352%p - 1.317in 1.556%p 0.778%p 7.506%p 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 @@ + + + + + + + + + sholes,227.0167 + + mahimahi,217.5932 + + herring,200.8554 + + tuna,202.5869 + + 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 @@ > 6 - @dimen/keyboardHeight_stone @fraction/keyboard_top_padding_stone @fraction/keyboard_bottom_padding_stone @fraction/key_horizontal_gap_stone 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,