Merge "Tablet keyboard should always show "?123" as symbol key"

main
Tadashi G. Takaoka 2010-10-22 10:53:44 -07:00 committed by Android (Google) Code Review
commit 71cc4ef673
3 changed files with 38 additions and 29 deletions

View File

@ -22,4 +22,5 @@
<bool name="default_popup_preview">false</bool> <bool name="default_popup_preview">false</bool>
<bool name="config_enable_show_settings_key_option">false</bool> <bool name="config_enable_show_settings_key_option">false</bool>
<bool name="config_dynamic_key_top_enter_key">false</bool> <bool name="config_dynamic_key_top_enter_key">false</bool>
<bool name="config_dynamic_key_top_symbol_key">false</bool>
</resources> </resources>

View File

@ -32,4 +32,5 @@
<bool name="config_long_press_comma_for_settings_enabled">true</bool> <bool name="config_long_press_comma_for_settings_enabled">true</bool>
<bool name="config_enable_show_settings_key_option">true</bool> <bool name="config_enable_show_settings_key_option">true</bool>
<bool name="config_dynamic_key_top_enter_key">true</bool> <bool name="config_dynamic_key_top_enter_key">true</bool>
<bool name="config_dynamic_key_top_symbol_key">true</bool>
</resources> </resources>

View File

@ -121,8 +121,8 @@ public class LatinKeyboard extends BaseKeyboard {
super(context, xmlLayoutResId, mode); super(context, xmlLayoutResId, mode);
final Resources res = context.getResources(); final Resources res = context.getResources();
mContext = context; mContext = context;
mMode = mode;
mRes = res; mRes = res;
mMode = mode;
mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked); mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
setDefaultBounds(mShiftLockPreviewIcon); setDefaultBounds(mShiftLockPreviewIcon);
@ -192,9 +192,9 @@ public class LatinKeyboard extends BaseKeyboard {
mMode = mode; mMode = mode;
if (mEnterKey == null) if (mEnterKey == null)
return; return;
final boolean configDynamicKeyToEnterKey = res.getBoolean( final boolean configDynamicKeyTopEnterKey = res.getBoolean(
R.bool.config_dynamic_key_top_enter_key); R.bool.config_dynamic_key_top_enter_key);
if (configDynamicKeyToEnterKey) { if (configDynamicKeyTopEnterKey) {
switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) { switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO: case EditorInfo.IME_ACTION_GO:
resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key)); resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key));
@ -291,16 +291,17 @@ public class LatinKeyboard extends BaseKeyboard {
public void setColorOfSymbolIcons(boolean isAutoCompletion, boolean isBlack) { public void setColorOfSymbolIcons(boolean isAutoCompletion, boolean isBlack) {
mIsBlackSym = isBlack; mIsBlackSym = isBlack;
final Resources res = mRes;
if (isBlack) { if (isBlack) {
mShiftLockIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_shift_locked); mShiftLockIcon = res.getDrawable(R.drawable.sym_bkeyboard_shift_locked);
mSpaceIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_space); mSpaceIcon = res.getDrawable(R.drawable.sym_bkeyboard_space);
mMicIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_mic); mMicIcon = res.getDrawable(R.drawable.sym_bkeyboard_mic);
m123MicIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_123_mic); m123MicIcon = res.getDrawable(R.drawable.sym_bkeyboard_123_mic);
} else { } else {
mShiftLockIcon = mRes.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
mSpaceIcon = mRes.getDrawable(R.drawable.sym_keyboard_space); mSpaceIcon = res.getDrawable(R.drawable.sym_keyboard_space);
mMicIcon = mRes.getDrawable(R.drawable.sym_keyboard_mic); mMicIcon = res.getDrawable(R.drawable.sym_keyboard_mic);
m123MicIcon = mRes.getDrawable(R.drawable.sym_keyboard_123_mic); m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic);
} }
updateDynamicKeys(); updateDynamicKeys();
if (mSpaceKey != null) { if (mSpaceKey != null) {
@ -320,9 +321,11 @@ public class LatinKeyboard extends BaseKeyboard {
} }
private void update123Key() { private void update123Key() {
final boolean configDynamicKeyTopSymbolKey = mRes.getBoolean(
R.bool.config_dynamic_key_top_symbol_key);
// Update KEYCODE_MODE_CHANGE key only on alphabet mode, not on symbol mode. // Update KEYCODE_MODE_CHANGE key only on alphabet mode, not on symbol mode.
if (m123Key != null && mIsAlphaKeyboard) { if (m123Key != null && mIsAlphaKeyboard) {
if (mVoiceEnabled && !mHasVoiceButton) { if (configDynamicKeyTopSymbolKey && mVoiceEnabled && !mHasVoiceButton) {
m123Key.icon = m123MicIcon; m123Key.icon = m123MicIcon;
m123Key.iconPreview = m123MicPreviewIcon; m123Key.iconPreview = m123MicPreviewIcon;
m123Key.label = null; m123Key.label = null;
@ -391,18 +394,19 @@ public class LatinKeyboard extends BaseKeyboard {
} }
private void updateSpaceBarForLocale(boolean isAutoCompletion, boolean isBlack) { private void updateSpaceBarForLocale(boolean isAutoCompletion, boolean isBlack) {
final Resources res = mRes;
// If application locales are explicitly selected. // If application locales are explicitly selected.
if (mLocale != null) { if (mLocale != null) {
mSpaceKey.icon = new BitmapDrawable(mRes, mSpaceKey.icon = new BitmapDrawable(res,
drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCompletion, isBlack)); drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCompletion, isBlack));
} else { } else {
// sym_keyboard_space_led can be shared with Black and White symbol themes. // sym_keyboard_space_led can be shared with Black and White symbol themes.
if (isAutoCompletion) { if (isAutoCompletion) {
mSpaceKey.icon = new BitmapDrawable(mRes, mSpaceKey.icon = new BitmapDrawable(res,
drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCompletion, isBlack)); drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCompletion, isBlack));
} else { } else {
mSpaceKey.icon = isBlack ? mRes.getDrawable(R.drawable.sym_bkeyboard_space) mSpaceKey.icon = isBlack ? res.getDrawable(R.drawable.sym_bkeyboard_space)
: mRes.getDrawable(R.drawable.sym_keyboard_space); : res.getDrawable(R.drawable.sym_keyboard_space);
} }
} }
} }
@ -462,7 +466,8 @@ public class LatinKeyboard extends BaseKeyboard {
final int height = mSpaceIcon.getIntrinsicHeight(); final int height = mSpaceIcon.getIntrinsicHeight();
final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(buffer); final Canvas canvas = new Canvas(buffer);
canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); final Resources res = mRes;
canvas.drawColor(res.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR);
// If application locales are explicitly selected. // If application locales are explicitly selected.
if (mLocale != null) { if (mLocale != null) {
@ -478,14 +483,14 @@ public class LatinKeyboard extends BaseKeyboard {
allowVariableTextSize); allowVariableTextSize);
// Draw language text with shadow // Draw language text with shadow
final int shadowColor = mRes.getColor(isBlack final int shadowColor = res.getColor(isBlack
? R.color.latinkeyboard_bar_language_shadow_black ? R.color.latinkeyboard_bar_language_shadow_black
: R.color.latinkeyboard_bar_language_shadow_white); : R.color.latinkeyboard_bar_language_shadow_white);
final float baseline = height * SPACEBAR_LANGUAGE_BASELINE; final float baseline = height * SPACEBAR_LANGUAGE_BASELINE;
final float descent = paint.descent(); final float descent = paint.descent();
paint.setColor(shadowColor); paint.setColor(shadowColor);
canvas.drawText(language, width / 2, baseline - descent - 1, paint); canvas.drawText(language, width / 2, baseline - descent - 1, paint);
paint.setColor(mRes.getColor(R.color.latinkeyboard_bar_language_text)); paint.setColor(res.getColor(R.color.latinkeyboard_bar_language_text));
canvas.drawText(language, width / 2, baseline - descent, paint); 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 layed out on either side of the text
@ -824,17 +829,19 @@ public class LatinKeyboard extends BaseKeyboard {
setDefaultBounds(mBackground); setDefaultBounds(mBackground);
mWidth = width; mWidth = width;
mHeight = height; mHeight = height;
mTextPaint = new TextPaint(); final TextPaint textPaint = new TextPaint();
mTextPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18)); textPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18));
mTextPaint.setColor(R.color.latinkeyboard_transparent); textPaint.setColor(R.color.latinkeyboard_transparent);
mTextPaint.setTextAlign(Align.CENTER); textPaint.setTextAlign(Align.CENTER);
mTextPaint.setAlpha(OPACITY_FULLY_OPAQUE); textPaint.setAlpha(OPACITY_FULLY_OPAQUE);
mTextPaint.setAntiAlias(true); textPaint.setAntiAlias(true);
mTextPaint = textPaint;
mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2; mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
mLeftDrawable = final Resources res = mRes;
mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_left); mLeftDrawable = res.getDrawable(
mRightDrawable = R.drawable.sym_keyboard_feedback_language_arrows_left);
mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_right); mRightDrawable = res.getDrawable(
R.drawable.sym_keyboard_feedback_language_arrows_right);
mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop(); mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop();
} }