Merge "Place language name at center of spacebar if no space icon" into honeycomb

main
Tadashi G. Takaoka 2011-01-17 00:39:01 -08:00 committed by Android (Google) Code Review
commit 9d446fc13f
3 changed files with 14 additions and 5 deletions

View File

@ -35,6 +35,7 @@
<!-- The language is never displayed if == 0, always displayed if < 0 -->
<integer name="config_delay_before_fadeout_language_on_spacebar">-1</integer>
<integer name="config_duration_of_fadeout_language_on_spacebar">50</integer>
<integer name="config_final_fadeout_percentage_of_language_on_spacebar">15</integer>
<integer name="config_delay_before_preview">0</integer>
<integer name="config_delay_after_preview">10</integer>
<integer name="config_preview_fadein_anim_time">0</integer>

View File

@ -70,7 +70,6 @@ public class LatinKeyboard extends Keyboard {
private static final float SPACEBAR_POPUP_MIN_RATIO = 0.4f;
// Height in space key the language name will be drawn. (proportional to space key height)
public static final float SPACEBAR_LANGUAGE_BASELINE = 0.6f;
private static final float SPACEBAR_LANGUAGE_BASELINE_WITHOUT_ICON = 0.65f;
// If the full language name needs to be smaller than this value to be drawn on space key,
// its short language name will be used instead.
private static final float MINIMUM_SCALE_OF_LANGUAGE_NAME = 0.8f;
@ -225,9 +224,12 @@ public class LatinKeyboard extends Keyboard {
allowVariableTextSize);
// Draw language text with shadow
final float baseline = height * (mSpaceIcon != null ? SPACEBAR_LANGUAGE_BASELINE
: SPACEBAR_LANGUAGE_BASELINE_WITHOUT_ICON);
// In case there is no space icon, we will place the language text at the center of
// spacebar.
final float descent = paint.descent();
final float textHeight = -paint.ascent() + descent;
final float baseline = (mSpaceIcon != null) ? height * SPACEBAR_LANGUAGE_BASELINE
: height / 2 + textHeight / 2;
paint.setColor(getSpacebarTextColor(mSpacebarTextShadowColor, mSpacebarTextFadeFactor));
canvas.drawText(language, width / 2, baseline - descent - 1, paint);
paint.setColor(getSpacebarTextColor(mSpacebarTextColor, mSpacebarTextFadeFactor));

View File

@ -154,6 +154,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean mConfigSwipeDownDismissKeyboardEnabled;
private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
private int mConfigDurationOfFadeoutLanguageOnSpacebar;
private float mConfigFinalFadeoutFactorOfLanugageOnSpacebar;
private int mCorrectionMode;
private int mCommittedLength;
@ -267,13 +268,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
break;
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
if (inputView != null)
inputView.setSpacebarTextFadeFactor(0.5f, (LatinKeyboard)msg.obj);
inputView.setSpacebarTextFadeFactor(
(1.0f + mConfigFinalFadeoutFactorOfLanugageOnSpacebar) / 2,
(LatinKeyboard)msg.obj);
sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj),
mConfigDurationOfFadeoutLanguageOnSpacebar);
break;
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
if (inputView != null)
inputView.setSpacebarTextFadeFactor(0.0f, (LatinKeyboard)msg.obj);
inputView.setSpacebarTextFadeFactor(
mConfigFinalFadeoutFactorOfLanugageOnSpacebar, (LatinKeyboard)msg.obj);
break;
}
}
@ -356,6 +360,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
R.integer.config_delay_before_fadeout_language_on_spacebar);
mConfigDurationOfFadeoutLanguageOnSpacebar = res.getInteger(
R.integer.config_duration_of_fadeout_language_on_spacebar);
mConfigFinalFadeoutFactorOfLanugageOnSpacebar = res.getInteger(
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
Utils.GCUtils.getInstance().reset();
boolean tryGC = true;