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 @@ "修正一般打字錯誤" "顯示修正建議" "輸入時顯示建議字詞" - "永遠顯示" + "一律顯示" "以垂直模式顯示" "永遠隱藏" "顯示設定金鑰" "自動" - "永遠顯示" + "一律顯示" "永遠隱藏" "自動修正" "自動插入空白鍵和標點符號鍵盤,以修正拼字錯誤" 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(); + } } } } diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index a1d0607bf..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 @@ -294,9 +297,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 +355,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; } 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()); }