Cleanup key label case adjustment
Bug: 5023981 Change-Id: Ida06fc6a588c4eb8543455d932e71ac2797d27e5main
parent
cb1cc0d0de
commit
c499866948
|
@ -365,10 +365,6 @@ public class Key {
|
||||||
mEdgeFlags |= flags;
|
mEdgeFlags |= flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence getCaseAdjustedLabel() {
|
|
||||||
return mKeyboard.adjustLabelCase(mLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Typeface selectTypeface(Typeface defaultTypeface) {
|
public Typeface selectTypeface(Typeface defaultTypeface) {
|
||||||
// TODO: Handle "bold" here too?
|
// TODO: Handle "bold" here too?
|
||||||
if ((mLabelOption & LABEL_OPTION_FONT_NORMAL) != 0) {
|
if ((mLabelOption & LABEL_OPTION_FONT_NORMAL) != 0) {
|
||||||
|
|
|
@ -443,7 +443,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
+ getPaddingLeft();
|
+ getPaddingLeft();
|
||||||
final int keyDrawY = mInvalidatedKey.mY + getPaddingTop();
|
final int keyDrawY = mInvalidatedKey.mY + getPaddingTop();
|
||||||
canvas.translate(keyDrawX, keyDrawY);
|
canvas.translate(keyDrawX, keyDrawY);
|
||||||
onBufferDrawKey(mInvalidatedKey, canvas, mPaint, params, isManualTemporaryUpperCase);
|
onBufferDrawKey(mInvalidatedKey, mKeyboard, canvas, mPaint, params,
|
||||||
|
isManualTemporaryUpperCase);
|
||||||
canvas.translate(-keyDrawX, -keyDrawY);
|
canvas.translate(-keyDrawX, -keyDrawY);
|
||||||
} else {
|
} else {
|
||||||
// Draw all keys.
|
// Draw all keys.
|
||||||
|
@ -451,7 +452,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
final int keyDrawX = key.mX + key.mVisualInsetsLeft + getPaddingLeft();
|
final int keyDrawX = key.mX + key.mVisualInsetsLeft + getPaddingLeft();
|
||||||
final int keyDrawY = key.mY + getPaddingTop();
|
final int keyDrawY = key.mY + getPaddingTop();
|
||||||
canvas.translate(keyDrawX, keyDrawY);
|
canvas.translate(keyDrawX, keyDrawY);
|
||||||
onBufferDrawKey(key, canvas, mPaint, params, isManualTemporaryUpperCase);
|
onBufferDrawKey(key, mKeyboard, canvas, mPaint, params, isManualTemporaryUpperCase);
|
||||||
canvas.translate(-keyDrawX, -keyDrawY);
|
canvas.translate(-keyDrawX, -keyDrawY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,8 +471,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onBufferDrawKey(final Key key, final Canvas canvas, Paint paint,
|
private static void onBufferDrawKey(final Key key, final Keyboard keyboard, final Canvas canvas,
|
||||||
KeyDrawParams params, boolean isManualTemporaryUpperCase) {
|
Paint paint, KeyDrawParams params, boolean isManualTemporaryUpperCase) {
|
||||||
final boolean debugShowAlign = LatinImeLogger.sVISUALDEBUG;
|
final boolean debugShowAlign = LatinImeLogger.sVISUALDEBUG;
|
||||||
// Draw key background.
|
// Draw key background.
|
||||||
final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight
|
final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight
|
||||||
|
@ -507,7 +508,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
float positionX = centerX;
|
float positionX = centerX;
|
||||||
if (key.mLabel != null) {
|
if (key.mLabel != null) {
|
||||||
// Switch the character to uppercase if shift is pressed
|
// Switch the character to uppercase if shift is pressed
|
||||||
final CharSequence label = key.getCaseAdjustedLabel();
|
final CharSequence label = keyboard.adjustLabelCase(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.mKeyTextStyle));
|
||||||
final int labelSize = key.selectTextSize(params.mKeyLetterSize,
|
final int labelSize = key.selectTextSize(params.mKeyLetterSize,
|
||||||
|
@ -798,7 +799,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mPreviewTextSize);
|
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mPreviewTextSize);
|
||||||
previewText.setTypeface(params.mKeyTextStyle);
|
previewText.setTypeface(params.mKeyTextStyle);
|
||||||
}
|
}
|
||||||
previewText.setText(key.getCaseAdjustedLabel());
|
previewText.setText(mKeyboard.adjustLabelCase(key.mLabel));
|
||||||
} else {
|
} else {
|
||||||
final Drawable previewIcon = key.getPreviewIcon();
|
final Drawable previewIcon = key.getPreviewIcon();
|
||||||
previewText.setCompoundDrawables(null, null, null,
|
previewText.setCompoundDrawables(null, null, null,
|
||||||
|
|
Loading…
Reference in New Issue