From 3722bb9b4816babf34fff29c0b8b78219b7ffeeb Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 22 Apr 2011 12:20:20 -0700 Subject: [PATCH 1/4] Import revised translations. Change-Id: I4944120cd4a15f643f7c1619524dde8147fab0a3 --- java/res/values-zh-rTW/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/res/values-zh-rTW/strings.xml b/java/res/values-zh-rTW/strings.xml index 591c137f1..ea143f2d8 100644 --- a/java/res/values-zh-rTW/strings.xml +++ b/java/res/values-zh-rTW/strings.xml @@ -33,12 +33,12 @@ "修正一般打字錯誤" "顯示修正建議" "輸入時顯示建議字詞" - "永遠顯示" + "一律顯示" "以垂直模式顯示" "永遠隱藏" "顯示設定金鑰" "自動" - "永遠顯示" + "一律顯示" "永遠隱藏" "自動修正" "自動插入空白鍵和標點符號鍵盤,以修正拼字錯誤" From 4c82225ad6e3494d4b2b2cd5a35124f8074db7b5 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 25 Apr 2011 19:27:16 +0900 Subject: [PATCH 2/4] Disable sliding language switch on phone and number layout Bug: 4331621 Change-Id: Id02c64bb2724a5f990d6dcc548a8d98a1034d531 --- .../android/inputmethod/keyboard/LatinKeyboard.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index a1d0607bf..b54378725 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -294,9 +294,12 @@ public class LatinKeyboard extends Keyboard { paint.setColor(getSpacebarTextColor(mSpacebarTextColor, textFadeFactor)); canvas.drawText(language, width / 2, baseline - descent, paint); - // Put arrows that are already layed out on either side of the text + // Put arrows that are already laid out on either side of the text + // Because language switch is disabled on phone and number layouts, hide arrows. + // TODO: Sort out how to enable language switch on these layouts. if (mSubtypeSwitcher.useSpacebarLanguageSwitcher() - && mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1) { + && mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1 + && !(isPhoneKeyboard() || isNumberKeyboard())) { mButtonArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mButtonArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor)); mButtonArrowLeftIcon.draw(canvas); @@ -349,6 +352,10 @@ public class LatinKeyboard extends Keyboard { } public boolean shouldTriggerSpacebarSlidingLanguageSwitch(int diff) { + // On phone and number layouts, sliding language switch is disabled. + // TODO: Sort out how to enable language switch on these layouts. + if (isPhoneKeyboard() || isNumberKeyboard()) + return false; return Math.abs(diff) > mSpacebarLanguageSwitchThreshold; } From 97f855ba4582eb1304aa013e4abf94ae0a3cc480 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 25 Apr 2011 20:30:54 +0900 Subject: [PATCH 3/4] Refresh the dictionary when the language settings were changed on Dogfood keyboard Bug: 4339319 Change-Id: Id6361927f579797932c465988f6728191748f143 --- .../inputmethod/deprecated/LanguageSwitcherProxy.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/src/com/android/inputmethod/deprecated/LanguageSwitcherProxy.java b/java/src/com/android/inputmethod/deprecated/LanguageSwitcherProxy.java index 73f0b7a2d..e14a49c49 100644 --- a/java/src/com/android/inputmethod/deprecated/LanguageSwitcherProxy.java +++ b/java/src/com/android/inputmethod/deprecated/LanguageSwitcherProxy.java @@ -29,6 +29,7 @@ import java.util.Locale; // This class is used only when the IME doesn't use method.xml for language switching. public class LanguageSwitcherProxy implements SharedPreferences.OnSharedPreferenceChangeListener { private static final LanguageSwitcherProxy sInstance = new LanguageSwitcherProxy(); + private LatinIME mService; private LanguageSwitcher mLanguageSwitcher; private SharedPreferences mPrefs; @@ -43,6 +44,7 @@ public class LanguageSwitcherProxy implements SharedPreferences.OnSharedPreferen sInstance.mLanguageSwitcher = new LanguageSwitcher(service); sInstance.mLanguageSwitcher.loadLocales(prefs, conf.locale); sInstance.mPrefs = prefs; + sInstance.mService = service; prefs.registerOnSharedPreferenceChangeListener(sInstance); } @@ -80,6 +82,9 @@ public class LanguageSwitcherProxy implements SharedPreferences.OnSharedPreferen if (key.equals(Settings.PREF_SELECTED_LANGUAGES) || key.equals(Settings.PREF_INPUT_LANGUAGE)) { mLanguageSwitcher.loadLocales(prefs, null); + if (mService != null) { + mService.onRefreshKeyboard(); + } } } } From cae6b1060e0c8547f9f7f64fbbf3a18a76035a53 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 25 Apr 2011 20:55:58 +0900 Subject: [PATCH 4/4] Display the language name on the spacebar if the full display locale name is too longer than the space bar Bug: 4329512 Change-Id: I477684747bf9e70a6909c25877fbe9e622571fd4 --- .../inputmethod/keyboard/LatinKeyboard.java | 27 ++++++++++--------- .../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 a1d0607bf..28593676f 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()); }