Use non-bold text for Arabic and Thai keyboard

The key text style can be specified in each keyboard layout in
addition to by KeyboardView theme.

Bug: 6753168
Change-Id: I4b5abda9322600eb8c6421f20ceef136ef103c05
main
Tadashi G. Takaoka 2012-08-28 11:28:42 +09:00
parent 9879f65651
commit d20652c878
10 changed files with 59 additions and 33 deletions

View File

@ -109,7 +109,7 @@
<attr name="shadowRadius" format="float" /> <attr name="shadowRadius" format="float" />
<attr name="backgroundDimAlpha" format="integer" /> <attr name="backgroundDimAlpha" format="integer" />
<attr name="keyTextStyle" format="enum"> <attr name="keyTypeface" format="enum">
<!-- This should be aligned with Typeface.NORMAL etc. --> <!-- This should be aligned with Typeface.NORMAL etc. -->
<enum name="normal" value="0" /> <enum name="normal" value="0" />
<enum name="bold" value="1" /> <enum name="bold" value="1" />

View File

@ -42,7 +42,7 @@
<item name="keyHintLetterRatio">@fraction/key_hint_letter_ratio</item> <item name="keyHintLetterRatio">@fraction/key_hint_letter_ratio</item>
<item name="keyHintLabelRatio">@fraction/key_hint_label_ratio</item> <item name="keyHintLabelRatio">@fraction/key_hint_label_ratio</item>
<item name="keyShiftedLetterHintRatio">@fraction/key_uppercase_letter_ratio</item> <item name="keyShiftedLetterHintRatio">@fraction/key_uppercase_letter_ratio</item>
<item name="keyTextStyle">normal</item> <item name="keyTypeface">normal</item>
<item name="keyTextColor">#FFFFFFFF</item> <item name="keyTextColor">#FFFFFFFF</item>
<item name="keyTextInactivatedColor">#FFFFFFFF</item> <item name="keyTextInactivatedColor">#FFFFFFFF</item>
<item name="keyHintLetterColor">#80000000</item> <item name="keyHintLetterColor">#80000000</item>
@ -243,7 +243,7 @@
name="KeyboardView.Stone.Bold" name="KeyboardView.Stone.Bold"
parent="KeyboardView.Stone" parent="KeyboardView.Stone"
> >
<item name="keyTextStyle">bold</item> <item name="keyTypeface">bold</item>
</style> </style>
<style <style
name="MainKeyboardView.Stone.Bold" name="MainKeyboardView.Stone.Bold"
@ -272,7 +272,7 @@
> >
<item name="android:background">@drawable/keyboard_dark_background</item> <item name="android:background">@drawable/keyboard_dark_background</item>
<item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item> <item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item>
<item name="keyTextStyle">bold</item> <item name="keyTypeface">bold</item>
</style> </style>
<style <style
name="MainKeyboardView.Gingerbread" name="MainKeyboardView.Gingerbread"
@ -317,7 +317,7 @@
> >
<item name="android:background">@drawable/keyboard_background_holo</item> <item name="android:background">@drawable/keyboard_background_holo</item>
<item name="keyBackground">@drawable/btn_keyboard_key_ics</item> <item name="keyBackground">@drawable/btn_keyboard_key_ics</item>
<item name="keyTextStyle">bold</item> <item name="keyTypeface">bold</item>
<item name="keyTextInactivatedColor">#66E0E4E5</item> <item name="keyTextInactivatedColor">#66E0E4E5</item>
<item name="keyHintLetterColor">#80000000</item> <item name="keyHintLetterColor">#80000000</item>
<item name="keyHintLabelColor">#A0FFFFFF</item> <item name="keyHintLabelColor">#A0FFFFFF</item>

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:rowHeight="20%p" latin:rowHeight="20%p"
latin:verticalGap="3.20%p" latin:verticalGap="3.20%p"
latin:keyTypeface="normal"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@null"
> >
<include <include

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:rowHeight="20%p" latin:rowHeight="20%p"
latin:verticalGap="3.20%p" latin:verticalGap="3.20%p"
latin:keyTypeface="normal"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@null"
> >
<include <include

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:rowHeight="20%p" latin:rowHeight="20%p"
latin:verticalGap="2.65%p" latin:verticalGap="2.65%p"
latin:keyTypeface="normal"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@null"
> >
<include <include

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:rowHeight="20%p" latin:rowHeight="20%p"
latin:verticalGap="2.95%p" latin:verticalGap="2.95%p"
latin:keyTypeface="normal"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@null"
> >
<include <include

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyTypeface="normal"
> >
<include <include
latin:keyboardLayout="@xml/rows_arabic" /> latin:keyboardLayout="@xml/rows_arabic" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyTypeface="normal"
> >
<include <include
latin:keyboardLayout="@xml/rows_thai" /> latin:keyboardLayout="@xml/rows_thai" />

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.content.res.XmlResourceParser; import android.content.res.XmlResourceParser;
import android.graphics.Typeface;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
@ -120,6 +121,9 @@ public class Keyboard {
/** Default gap between rows */ /** Default gap between rows */
public final int mVerticalGap; public final int mVerticalGap;
/** Per keyboard key visual parameters */
public final Typeface mKeyTypeface;
public final int mMostCommonKeyHeight; public final int mMostCommonKeyHeight;
public final int mMostCommonKeyWidth; public final int mMostCommonKeyWidth;
@ -150,6 +154,8 @@ public class Keyboard {
mMoreKeysTemplate = params.mMoreKeysTemplate; mMoreKeysTemplate = params.mMoreKeysTemplate;
mMaxMoreKeysKeyboardColumn = params.mMaxMoreKeysKeyboardColumn; mMaxMoreKeysKeyboardColumn = params.mMaxMoreKeysKeyboardColumn;
mKeyTypeface = params.mKeyTypeface;
mTopPadding = params.mTopPadding; mTopPadding = params.mTopPadding;
mVerticalGap = params.mVerticalGap; mVerticalGap = params.mVerticalGap;
@ -225,6 +231,7 @@ public class Keyboard {
return mId.toString(); return mId.toString();
} }
// TODO: Move this class to internal package
public static class Params { public static class Params {
public KeyboardId mId; public KeyboardId mId;
public int mThemeId; public int mThemeId;
@ -244,6 +251,8 @@ public class Keyboard {
public int mHorizontalEdgesPadding; public int mHorizontalEdgesPadding;
public int mHorizontalCenterPadding; public int mHorizontalCenterPadding;
public Typeface mKeyTypeface = null;
public int mDefaultRowHeight; public int mDefaultRowHeight;
public int mDefaultKeyWidth; public int mDefaultKeyWidth;
public int mHorizontalGap; public int mHorizontalGap;
@ -497,6 +506,7 @@ public class Keyboard {
* </pre> * </pre>
*/ */
// TODO: Move this class to internal package.
public static class Builder<KP extends Params> { public static class Builder<KP extends Params> {
private static final String BUILDER_TAG = "Keyboard.Builder"; private static final String BUILDER_TAG = "Keyboard.Builder";
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
@ -744,6 +754,8 @@ public class Keyboard {
R.style.Keyboard); R.style.Keyboard);
final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard_Key); R.styleable.Keyboard_Key);
final TypedArray keyboardViewAttr = mResources.obtainAttributes(
Xml.asAttributeSet(parser), R.styleable.KeyboardView);
try { try {
final int displayHeight = mDisplayMetrics.heightPixels; final int displayHeight = mDisplayMetrics.heightPixels;
final String keyboardHeightString = ResourceUtils.getDeviceOverrideValue( final String keyboardHeightString = ResourceUtils.getDeviceOverrideValue(
@ -795,6 +807,11 @@ public class Keyboard {
R.styleable.Keyboard_rowHeight, params.mBaseHeight, R.styleable.Keyboard_rowHeight, params.mBaseHeight,
params.mBaseHeight / DEFAULT_KEYBOARD_ROWS); params.mBaseHeight / DEFAULT_KEYBOARD_ROWS);
if (keyboardViewAttr.hasValue(R.styleable.KeyboardView_keyTypeface)) {
params.mKeyTypeface = Typeface.defaultFromStyle(keyboardViewAttr.getInt(
R.styleable.KeyboardView_keyTypeface, Typeface.NORMAL));
}
params.mMoreKeysTemplate = keyboardAttr.getResourceId( params.mMoreKeysTemplate = keyboardAttr.getResourceId(
R.styleable.Keyboard_moreKeysTemplate, 0); R.styleable.Keyboard_moreKeysTemplate, 0);
params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt( params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt(
@ -825,6 +842,7 @@ public class Keyboard {
params.mTouchPositionCorrection.load(data); params.mTouchPositionCorrection.load(data);
} }
} finally { } finally {
keyboardViewAttr.recycle();
keyAttr.recycle(); keyAttr.recycle();
keyboardAttr.recycle(); keyboardAttr.recycle();
} }

View File

@ -65,7 +65,7 @@ import java.util.HashSet;
* @attr ref R.styleable#KeyboardView_keyHintLetterPadding * @attr ref R.styleable#KeyboardView_keyHintLetterPadding
* @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
* @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding * @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding
* @attr ref R.styleable#KeyboardView_keyTextStyle * @attr ref R.styleable#KeyboardView_keyTypeface
* @attr ref R.styleable#KeyboardView_keyPreviewLayout * @attr ref R.styleable#KeyboardView_keyPreviewLayout
* @attr ref R.styleable#KeyboardView_keyPreviewTextRatio * @attr ref R.styleable#KeyboardView_keyPreviewTextRatio
* @attr ref R.styleable#KeyboardView_keyPreviewOffset * @attr ref R.styleable#KeyboardView_keyPreviewOffset
@ -180,11 +180,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
} }
} }
// Move this class to internal package
protected static class KeyDrawParams { protected static class KeyDrawParams {
// XML attributes // XML attributes
public final int mKeyTextColor; public final int mKeyTextColor;
public final int mKeyTextInactivatedColor; public final int mKeyTextInactivatedColor;
public final Typeface mKeyTextStyle;
public final float mKeyLabelHorizontalPadding; public final float mKeyLabelHorizontalPadding;
public final float mKeyHintLetterPadding; public final float mKeyHintLetterPadding;
public final float mKeyPopupHintLetterPadding; public final float mKeyPopupHintLetterPadding;
@ -197,7 +197,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
public final int mKeyShiftedLetterHintInactivatedColor; public final int mKeyShiftedLetterHintInactivatedColor;
public final int mKeyShiftedLetterHintActivatedColor; public final int mKeyShiftedLetterHintActivatedColor;
/* package */ final float mKeyLetterRatio; private final Typeface mKeyTypefaceFromKeyboardView;
private final float mKeyLetterRatio;
private final float mKeyLargeLetterRatio; private final float mKeyLargeLetterRatio;
private final float mKeyLabelRatio; private final float mKeyLabelRatio;
private final float mKeyLargeLabelRatio; private final float mKeyLargeLabelRatio;
@ -206,6 +207,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private final float mKeyHintLabelRatio; private final float mKeyHintLabelRatio;
public final Rect mPadding = new Rect(); public final Rect mPadding = new Rect();
public Typeface mKeyTypeface;
public int mKeyLetterSize; public int mKeyLetterSize;
public int mKeyLargeLetterSize; public int mKeyLargeLetterSize;
public int mKeyLabelSize; public int mKeyLabelSize;
@ -248,15 +250,19 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
R.styleable.KeyboardView_keyShiftedLetterHintInactivatedColor, 0); R.styleable.KeyboardView_keyShiftedLetterHintInactivatedColor, 0);
mKeyShiftedLetterHintActivatedColor = a.getColor( mKeyShiftedLetterHintActivatedColor = a.getColor(
R.styleable.KeyboardView_keyShiftedLetterHintActivatedColor, 0); R.styleable.KeyboardView_keyShiftedLetterHintActivatedColor, 0);
mKeyTextStyle = Typeface.defaultFromStyle( mKeyTypefaceFromKeyboardView = Typeface.defaultFromStyle(
a.getInt(R.styleable.KeyboardView_keyTextStyle, Typeface.NORMAL)); a.getInt(R.styleable.KeyboardView_keyTypeface, Typeface.NORMAL));
mKeyTypeface = mKeyTypefaceFromKeyboardView;
mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor, 0); mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor, 0);
mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f); mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
mKeyBackground.getPadding(mPadding); mKeyBackground.getPadding(mPadding);
} }
public void updateKeyHeight(int keyHeight) { public void updateParams(final Keyboard keyboard) {
mKeyTypeface = (keyboard.mKeyTypeface != null)
? keyboard.mKeyTypeface : mKeyTypefaceFromKeyboardView;
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
if (isValidFraction(mKeyLetterRatio)) { if (isValidFraction(mKeyLetterRatio)) {
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
} }
@ -270,13 +276,14 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio); mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
} }
public void blendAlpha(Paint paint) { public void blendAlpha(final Paint paint) {
final int color = paint.getColor(); final int color = paint.getColor();
paint.setARGB((paint.getAlpha() * mAnimAlpha) / Constants.Color.ALPHA_OPAQUE, paint.setARGB((paint.getAlpha() * mAnimAlpha) / Constants.Color.ALPHA_OPAQUE,
Color.red(color), Color.green(color), Color.blue(color)); Color.red(color), Color.green(color), Color.blue(color));
} }
} }
// TODO: Move this class to internal package.
/* package */ static class KeyPreviewDrawParams { /* package */ static class KeyPreviewDrawParams {
// XML attributes. // XML attributes.
public final Drawable mPreviewBackground; public final Drawable mPreviewBackground;
@ -285,11 +292,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
public final int mPreviewTextColor; public final int mPreviewTextColor;
public final int mPreviewOffset; public final int mPreviewOffset;
public final int mPreviewHeight; public final int mPreviewHeight;
public final Typeface mKeyTextStyle;
public final int mLingerTimeout; public final int mLingerTimeout;
private final float mPreviewTextRatio; private final float mPreviewTextRatio;
private final float mKeyLetterRatio;
// The graphical geometry of the key preview. // The graphical geometry of the key preview.
// <-width-> // <-width->
@ -316,13 +321,14 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
// preview background. // preview background.
public int mPreviewVisibleOffset; public int mPreviewVisibleOffset;
public Typeface mKeyTypeface;
public int mPreviewTextSize; public int mPreviewTextSize;
public int mKeyLetterSize; public int mKeyLetterSize;
public final int[] mCoordinates = new int[2]; public final int[] mCoordinates = new int[2];
private static final int PREVIEW_ALPHA = 240; private static final int PREVIEW_ALPHA = 240;
public KeyPreviewDrawParams(TypedArray a, KeyDrawParams keyDrawParams) { public KeyPreviewDrawParams(final TypedArray a) {
mPreviewBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewBackground); mPreviewBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewBackground);
mPreviewLeftBackground = a.getDrawable( mPreviewLeftBackground = a.getDrawable(
R.styleable.KeyboardView_keyPreviewLeftBackground); R.styleable.KeyboardView_keyPreviewLeftBackground);
@ -338,21 +344,18 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mPreviewTextRatio = getFraction(a, R.styleable.KeyboardView_keyPreviewTextRatio); mPreviewTextRatio = getFraction(a, R.styleable.KeyboardView_keyPreviewTextRatio);
mPreviewTextColor = a.getColor(R.styleable.KeyboardView_keyPreviewTextColor, 0); mPreviewTextColor = a.getColor(R.styleable.KeyboardView_keyPreviewTextColor, 0);
mLingerTimeout = a.getInt(R.styleable.KeyboardView_keyPreviewLingerTimeout, 0); mLingerTimeout = a.getInt(R.styleable.KeyboardView_keyPreviewLingerTimeout, 0);
mKeyLetterRatio = keyDrawParams.mKeyLetterRatio;
mKeyTextStyle = keyDrawParams.mKeyTextStyle;
} }
public void updateKeyHeight(int keyHeight) { public void updateParams(final Keyboard keyboard, final KeyDrawParams keyDrawParams) {
if (mPreviewTextRatio >= 0.0f) { final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
if (isValidFraction(mPreviewTextRatio)) {
mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio); mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio);
} }
if (mKeyLetterRatio >= 0.0f) { mKeyLetterSize = keyDrawParams.mKeyLetterSize;
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); mKeyTypeface = keyDrawParams.mKeyTypeface;
}
} }
private static void setAlpha(Drawable drawable, int alpha) { private static void setAlpha(final Drawable drawable, final int alpha) {
if (drawable == null) return; if (drawable == null) return;
drawable.setAlpha(alpha); drawable.setAlpha(alpha);
} }
@ -368,7 +371,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
final TypedArray a = context.obtainStyledAttributes( final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView); attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
mKeyDrawParams = new KeyDrawParams(a); mKeyDrawParams = new KeyDrawParams(a);
mKeyPreviewDrawParams = new KeyPreviewDrawParams(a, mKeyDrawParams); mKeyPreviewDrawParams = new KeyPreviewDrawParams(a);
mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout; mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
mKeyPreviewLayoutId = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0); mKeyPreviewLayoutId = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
if (mKeyPreviewLayoutId == 0) { if (mKeyPreviewLayoutId == 0) {
@ -416,9 +419,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
LatinImeLogger.onSetKeyboard(keyboard); LatinImeLogger.onSetKeyboard(keyboard);
requestLayout(); requestLayout();
invalidateAllKeys(); invalidateAllKeys();
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; mKeyDrawParams.updateParams(keyboard);
mKeyDrawParams.updateKeyHeight(keyHeight); mKeyPreviewDrawParams.updateParams(keyboard, mKeyDrawParams);
mKeyPreviewDrawParams.updateKeyHeight(keyHeight);
} }
/** /**
@ -648,7 +650,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
if (key.mLabel != null) { if (key.mLabel != null) {
final String label = key.mLabel; final String label = key.mLabel;
// For characters, use large font. For labels like "Done", use smaller font. // For characters, use large font. For labels like "Done", use smaller font.
paint.setTypeface(key.selectTypeface(params.mKeyTextStyle)); paint.setTypeface(key.selectTypeface(params.mKeyTypeface));
final int labelSize = key.selectTextSize(params.mKeyLetterSize, final int labelSize = key.selectTextSize(params.mKeyLetterSize,
params.mKeyLargeLetterSize, params.mKeyLabelSize, params.mKeyLargeLabelSize, params.mKeyLargeLetterSize, params.mKeyLabelSize, params.mKeyLargeLabelSize,
params.mKeyHintLabelSize); params.mKeyHintLabelSize);
@ -812,7 +814,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight; final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
final int keyHeight = key.mHeight; final int keyHeight = key.mHeight;
paint.setTypeface(params.mKeyTextStyle); paint.setTypeface(params.mKeyTypeface);
paint.setTextSize(params.mKeyHintLetterSize); paint.setTextSize(params.mKeyHintLetterSize);
paint.setColor(params.mKeyHintLabelColor); paint.setColor(params.mKeyHintLabelColor);
paint.setTextAlign(Align.CENTER); paint.setTextAlign(Align.CENTER);
@ -911,7 +913,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
public Paint newDefaultLabelPaint() { public Paint newDefaultLabelPaint() {
final Paint paint = new Paint(); final Paint paint = new Paint();
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setTypeface(mKeyDrawParams.mKeyTextStyle); paint.setTypeface(mKeyDrawParams.mKeyTypeface);
paint.setTextSize(mKeyDrawParams.mKeyLabelSize); paint.setTextSize(mKeyDrawParams.mKeyLabelSize);
return paint; return paint;
} }
@ -1019,7 +1021,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
final KeyPreviewDrawParams params = mKeyPreviewDrawParams; final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
final String label = key.isShiftedLetterActivated() ? key.mHintLabel : key.mLabel; final String label = key.isShiftedLetterActivated() ? key.mHintLabel : key.mLabel;
// What we show as preview should match what we show on a key top in onBufferDraw(). // What we show as preview should match what we show on a key top in onDraw().
if (label != null) { if (label != null) {
// TODO Should take care of temporaryShiftLabel here. // TODO Should take care of temporaryShiftLabel here.
previewText.setCompoundDrawables(null, null, null, null); previewText.setCompoundDrawables(null, null, null, null);
@ -1028,7 +1030,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
previewText.setTypeface(Typeface.DEFAULT_BOLD); previewText.setTypeface(Typeface.DEFAULT_BOLD);
} else { } else {
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mPreviewTextSize); previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mPreviewTextSize);
previewText.setTypeface(params.mKeyTextStyle); previewText.setTypeface(params.mKeyTypeface);
} }
previewText.setText(label); previewText.setText(label);
} else { } else {