am 280990bc: Merge "Address a couple more issues in Khmer layout"

* commit '280990bcb19dde8b5d8298fa0b8313e8167802b2':
  Address a couple more issues in Khmer layout
main
Ken Wakasa 2013-09-20 00:34:53 -07:00 committed by Android Git Automerger
commit e6c6df9017
2 changed files with 14 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import android.graphics.Paint.Align;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Region; import android.graphics.Region;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
@ -445,6 +446,8 @@ public class KeyboardView extends View {
if (hintLabel != null) { if (hintLabel != null) {
paint.setTextSize(key.selectHintTextSize(params)); paint.setTextSize(key.selectHintTextSize(params));
paint.setColor(key.selectHintTextColor(params)); paint.setColor(key.selectHintTextColor(params));
// TODO: Should add a way to specify type face for hint letters
paint.setTypeface(Typeface.DEFAULT_BOLD);
blendAlpha(paint, params.mAnimAlpha); blendAlpha(paint, params.mAnimAlpha);
final float hintX, hintY; final float hintX, hintY;
if (key.hasHintLabel()) { if (key.hasHintLabel()) {
@ -465,9 +468,13 @@ public class KeyboardView extends View {
paint.setTextAlign(Align.CENTER); paint.setTextAlign(Align.CENTER);
} else { // key.hasHintLetter() } else { // key.hasHintLetter()
// The hint letter is placed at top-right corner of the key. Used mainly on phone. // The hint letter is placed at top-right corner of the key. Used mainly on phone.
final float keyNumericHintLabelReferenceCharWidth =
TypefaceUtils.getCharWidth(KEY_NUMERIC_HINT_LABEL_REFERENCE_CHAR, paint);
final float keyHintLabelStringWidth =
TypefaceUtils.getStringWidth(hintLabel, paint);
hintX = keyWidth - mKeyHintLetterPadding hintX = keyWidth - mKeyHintLetterPadding
- TypefaceUtils.getCharWidth(KEY_NUMERIC_HINT_LABEL_REFERENCE_CHAR, paint) - Math.max(keyNumericHintLabelReferenceCharWidth, keyHintLabelStringWidth)
/ 2.0f; / 2.0f;
hintY = -paint.ascent(); hintY = -paint.ascent();
paint.setTextAlign(Align.CENTER); paint.setTextAlign(Align.CENTER);
} }

View File

@ -66,6 +66,11 @@ public final class TypefaceUtils {
} }
} }
public static float getStringWidth(final String string, final Paint paint) {
paint.getTextBounds(string, 0, string.length(), sTextWidthBounds);
return sTextWidthBounds.width();
}
private static int getCharGeometryCacheKey(final char referenceChar, final Paint paint) { private static int getCharGeometryCacheKey(final char referenceChar, final Paint paint) {
final int labelSize = (int)paint.getTextSize(); final int labelSize = (int)paint.getTextSize();
final Typeface face = paint.getTypeface(); final Typeface face = paint.getTypeface();