diff options
author | 2011-04-25 06:21:08 -0700 | |
---|---|---|
committer | 2011-04-25 06:21:08 -0700 | |
commit | 1123bcaf2e371fe99703e54a2716e4329016aec4 (patch) | |
tree | ae0639cd68ed49195ae633cc10ede6b9e67094a5 /java/src | |
parent | efb32f7e95caad98e048d62abcaafebe749e6723 (diff) | |
parent | cae6b1060e0c8547f9f7f64fbbf3a18a76035a53 (diff) | |
download | latinime-1123bcaf2e371fe99703e54a2716e4329016aec4.tar.gz latinime-1123bcaf2e371fe99703e54a2716e4329016aec4.tar.xz latinime-1123bcaf2e371fe99703e54a2716e4329016aec4.zip |
Merge "Display the language name on the spacebar if the full display locale name is too longer than the space bar"
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/LatinKeyboard.java | 27 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 4 |
2 files changed, 19 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index b54378725..c279769f6 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -194,8 +194,7 @@ public class LatinKeyboard extends Keyboard { // Layout local language name and left and right arrow on spacebar. private static String layoutSpacebar(Paint paint, Locale locale, Drawable lArrow, - Drawable rArrow, int width, int height, float origTextSize, - boolean allowVariableTextSize) { + Drawable rArrow, int width, int height, float origTextSize) { final float arrowWidth = lArrow.getIntrinsicWidth(); final float arrowHeight = lArrow.getIntrinsicHeight(); final float maxTextWidth = width - (arrowWidth + arrowWidth); @@ -206,17 +205,23 @@ public class LatinKeyboard extends Keyboard { int textWidth = getTextWidth(paint, language, origTextSize, bounds); // Assuming text width and text size are proportional to each other. float textSize = origTextSize * Math.min(maxTextWidth / textWidth, 1.0f); + // allow variable text size + textWidth = getTextWidth(paint, language, textSize, bounds); + // If text size goes too small or text does not fit, use middle or short name + final boolean useMiddleName = (textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME) + || (textWidth > maxTextWidth); final boolean useShortName; - if (allowVariableTextSize) { - textWidth = getTextWidth(paint, language, textSize, bounds); - // If text size goes too small or text does not fit, use short name - useShortName = textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME - || textWidth > maxTextWidth; + if (useMiddleName) { + language = SubtypeSwitcher.getMiddleDisplayLanguage(locale); + textWidth = getTextWidth(paint, language, origTextSize, bounds); + textSize = origTextSize * Math.min(maxTextWidth / textWidth, 1.0f); + useShortName = (textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME) + || (textWidth > maxTextWidth); } else { - useShortName = textWidth > maxTextWidth; - textSize = origTextSize; + useShortName = false; } + if (useShortName) { language = SubtypeSwitcher.getShortDisplayLanguage(locale); textWidth = getTextWidth(paint, language, origTextSize, bounds); @@ -276,11 +281,9 @@ public class LatinKeyboard extends Keyboard { defaultTextSize = 14; } - final boolean allowVariableTextSize = true; final String language = layoutSpacebar(paint, inputLocale, mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height, - getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize), - allowVariableTextSize); + getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize)); // Draw language text with shadow // In case there is no space icon, we will place the language text at the center of diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 160b677e1..158977927 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -607,6 +607,10 @@ public class SubtypeSwitcher { return toTitleCase(locale.getDisplayLanguage(locale)); } + public static String getMiddleDisplayLanguage(Locale locale) { + return toTitleCase(locale.getDisplayLanguage(new Locale(locale.getLanguage()))); + } + public static String getShortDisplayLanguage(Locale locale) { return toTitleCase(locale.getLanguage()); } |