diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index 4a5c5a44c..dcbfe463e 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -53,6 +53,7 @@ 52% 40% 90% + 40.000% 0.08in 0.01in diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml index 1b8c8a64a..1c725a484 100644 --- a/java/res/values-sw600dp-land/dimens.xml +++ b/java/res/values-sw600dp-land/dimens.xml @@ -48,6 +48,7 @@ 23% 34% 29% + 33.33% 40.0mm 5 diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml index 1854a8696..1dd93121d 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw600dp/config.xml @@ -38,6 +38,5 @@ 0 5 - medium 5 diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index 31830239d..e393be579 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -59,6 +59,7 @@ 28% 26% 50% + 32.14% 15.0mm 0.1in diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml index 664e8c159..ef39f4393 100644 --- a/java/res/values-sw768dp-land/dimens.xml +++ b/java/res/values-sw768dp-land/dimens.xml @@ -52,6 +52,7 @@ 23% 28% 24% + 24.00% 17.0mm 26.5mm diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index c25139a42..06553a7c9 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -36,7 +36,6 @@ 0 5 - medium 5 + + diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 8b99a1fcb..55f35f0c5 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -66,7 +66,6 @@ 2.0mm 5 - small 5 diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 352141ca6..e46ff7718 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -66,6 +66,7 @@ 44% 35% 82% + 33.735% 80sp 0.1in diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 2025a7dac..ed8795ade 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -33,6 +33,7 @@ diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index d5f8e333b..655f16c8e 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard; import android.content.Context; import android.content.res.Resources; -import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -45,13 +44,13 @@ public class LatinKeyboard extends Keyboard { private static final int SPACE_LED_LENGTH_PERCENT = 80; private final Resources mRes; - private final Theme mTheme; /* Space key and its icons, drawables and colors. */ private final Key mSpaceKey; private final Drawable mSpaceIcon; private final boolean mAutoCorrectionSpacebarLedEnabled; private final Drawable mAutoCorrectionSpacebarLedIcon; + private final float mSpacebarTextSize; private final int mSpacebarTextColor; private final int mSpacebarTextShadowColor; private final HashMap mSpaceDrawableCache = @@ -74,13 +73,9 @@ public class LatinKeyboard extends Keyboard { // its short language name will be used instead. private static final float MINIMUM_SCALE_OF_LANGUAGE_NAME = 0.8f; - private static final String SMALL_TEXT_SIZE_OF_LANGUAGE_ON_SPACEBAR = "small"; - private static final String MEDIUM_TEXT_SIZE_OF_LANGUAGE_ON_SPACEBAR = "medium"; - private LatinKeyboard(Context context, KeyboardParams params) { super(params); mRes = context.getResources(); - mTheme = context.getTheme(); // The index of space key is available only after Keyboard constructor has finished. mSpaceKey = getKey(CODE_SPACE); @@ -99,6 +94,10 @@ public class LatinKeyboard extends Keyboard { mAutoCorrectionSpacebarLedIcon = a.getDrawable( R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon); mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon); + final float spacebarTextRatio = a.getFraction(R.styleable.LatinKeyboard_spacebarTextRatio, + 1000, 1000, 1) / 1000.0f; + final int keyHeight = mMostCommonKeyHeight - mVerticalGap; + mSpacebarTextSize = keyHeight * spacebarTextRatio; mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0); mSpacebarTextShadowColor = a.getColor( R.styleable.LatinKeyboard_spacebarTextShadowColor, 0); @@ -122,6 +121,8 @@ public class LatinKeyboard extends Keyboard { } } + // TODO: Move this drawing method to LatinKeyboardView. + // TODO: Use Key.keyLabel to draw language name of spacebar. public Key updateSpacebarLanguage(float fadeFactor, boolean multipleEnabledIMEsOrSubtypes, boolean needsToDisplayLanguage) { mSpacebarTextFadeFactor = fadeFactor; @@ -137,6 +138,7 @@ public class LatinKeyboard extends Keyboard { return newColor; } + // TODO: Move this drawing method to LatinKeyboardView. public Key updateShortcutKey(boolean available) { if (mShortcutKey == null) return null; @@ -145,10 +147,12 @@ public class LatinKeyboard extends Keyboard { return mShortcutKey; } + // TODO: Get rid of this method public boolean needsAutoCorrectionSpacebarLed() { return mAutoCorrectionSpacebarLedEnabled; } + // TODO: Move this drawing method to LatinKeyboardView. /** * @return a key which should be invalidated. */ @@ -244,7 +248,6 @@ public class LatinKeyboard extends Keyboard { final int height = mSpaceIcon != null ? mSpaceIcon.getIntrinsicHeight() : mSpaceKey.mHeight; final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(buffer); - final Resources res = mRes; canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); // If application locales are explicitly selected. @@ -253,25 +256,7 @@ public class LatinKeyboard extends Keyboard { paint.setAntiAlias(true); paint.setTextAlign(Align.CENTER); - final String textSizeOfLanguageOnSpacebar = res.getString( - R.string.config_text_size_of_language_on_spacebar, - SMALL_TEXT_SIZE_OF_LANGUAGE_ON_SPACEBAR); - final int textStyle; - final int defaultTextSize; - if (MEDIUM_TEXT_SIZE_OF_LANGUAGE_ON_SPACEBAR.equals(textSizeOfLanguageOnSpacebar)) { - // TODO: TextAppearance_Medium depends on the current system wide font size - // settings. Probably should stop using this. - textStyle = android.R.style.TextAppearance_Medium; - defaultTextSize = 18; - } else { - // TODO: TextAppearance_Small depends on the current system wide font size - // settings. Probably should stop using this. - textStyle = android.R.style.TextAppearance_Small; - defaultTextSize = 14; - } - - final String language = layoutSpacebar(paint, inputLocale, width, getTextSizeFromTheme( - mTheme, textStyle, defaultTextSize)); + final String language = layoutSpacebar(paint, inputLocale, width, mSpacebarTextSize); // Draw language text with shadow // In case there is no space icon, we will place the language text at the center of @@ -311,15 +296,4 @@ public class LatinKeyboard extends Keyboard { return super.getNearestKeys(Math.max(0, Math.min(x, mOccupiedWidth - 1)), Math.max(0, Math.min(y, mOccupiedHeight - 1))); } - - private static final int[] ATTR_TEXT_SIZE = { android.R.attr.textSize }; - - private static int getTextSizeFromTheme(Theme theme, int style, int defValue) { - // TODO: This method should return text size that is independent from the current - // system wide font size settings. - final TypedArray a = theme.obtainStyledAttributes(style, ATTR_TEXT_SIZE); - final int textSize = a.getDimensionPixelSize(a.getResourceId(0, 0), defValue); - a.recycle(); - return textSize; - } }