Merge remote-tracking branch 'goog/master' into merge
commit
0dbb7e26d1
|
@ -33,12 +33,12 @@
|
|||
<string name="quick_fixes_summary" msgid="3405028402510332373">"修正一般打字錯誤"</string>
|
||||
<string name="prefs_show_suggestions" msgid="8026799663445531637">"顯示修正建議"</string>
|
||||
<string name="prefs_show_suggestions_summary" msgid="1583132279498502825">"輸入時顯示建議字詞"</string>
|
||||
<string name="prefs_suggestion_visibility_show_name" msgid="3219916594067551303">"永遠顯示"</string>
|
||||
<string name="prefs_suggestion_visibility_show_name" msgid="3219916594067551303">"一律顯示"</string>
|
||||
<string name="prefs_suggestion_visibility_show_only_portrait_name" msgid="3551821800439659812">"以垂直模式顯示"</string>
|
||||
<string name="prefs_suggestion_visibility_hide_name" msgid="6309143926422234673">"永遠隱藏"</string>
|
||||
<string name="prefs_settings_key" msgid="4623341240804046498">"顯示設定金鑰"</string>
|
||||
<string name="settings_key_mode_auto_name" msgid="2993460277873684680">"自動"</string>
|
||||
<string name="settings_key_mode_always_show_name" msgid="3047567041784760575">"永遠顯示"</string>
|
||||
<string name="settings_key_mode_always_show_name" msgid="3047567041784760575">"一律顯示"</string>
|
||||
<string name="settings_key_mode_always_hide_name" msgid="7833948046716923994">"永遠隱藏"</string>
|
||||
<string name="auto_correction" msgid="4979925752001319458">"自動修正"</string>
|
||||
<string name="auto_correction_summary" msgid="5625751551134658006">"自動插入空白鍵和標點符號鍵盤,以修正拼字錯誤"</string>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue