summaryrefslogtreecommitdiff
path: root/java/src/com/android/inputmethod/keyboard/KeyboardView.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-08-07 14:12:01 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-08-07 14:39:57 +0900
commitba49920e8046ca592d6c914b2e3f7394bf9c281c (patch)
tree49303d11cb6e4543fe607f250176a1e294be3658 /java/src/com/android/inputmethod/keyboard/KeyboardView.java
parente19c520b419faaf96180984528ae32b514a1bc77 (diff)
Add Key label off center attribute
This CL adds two Key attributes to control how much a label should be off centered. - keyLabelOffCenterRatio - keyHintLabelOffCenterRatio Bug: 14419121 Change-Id: I26650eefdd375f0eeca8a1ca6034a8339d2a3182
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/KeyboardView.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 4a791f325..72b254756 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -369,9 +369,9 @@ public class KeyboardView extends View {
final float baseline = centerY + labelCharHeight / 2.0f;
// Horizontal label text alignment
- if (key.isAlignLeftOfCenter()) {
- // TODO: Parameterise this?
- positionX = centerX - labelCharWidth * 7.0f / 4.0f;
+ if (key.isAlignLabelOffCenter()) {
+ // The label is placed off center of the key. Used mainly on "phone number" layout.
+ positionX = centerX + params.mLabelOffCenterRatio * labelCharWidth;
paint.setTextAlign(Align.LEFT);
} else {
positionX = centerX;
@@ -418,15 +418,12 @@ public class KeyboardView extends View {
blendAlpha(paint, params.mAnimAlpha);
final float labelCharHeight = TypefaceUtils.getReferenceCharHeight(paint);
final float labelCharWidth = TypefaceUtils.getReferenceCharWidth(paint);
- final KeyVisualAttributes visualAttr = key.getVisualAttributes();
- final float adjustmentY = (visualAttr == null) ? 0.0f
- : visualAttr.mHintLabelVerticalAdjustment * labelCharHeight;
+ final float adjustmentY = params.mHintLabelVerticalAdjustment * labelCharHeight;
final float hintX, hintY;
if (key.hasHintLabel()) {
// The hint label is placed just right of the key label. Used mainly on
// "phone number" layout.
- // TODO: Generalize the following calculations.
- hintX = positionX + labelCharWidth * 2.0f;
+ hintX = positionX + params.mHintLabelOffCenterRatio * labelCharWidth;
hintY = centerY + labelCharHeight / 2.0f;
paint.setTextAlign(Align.LEFT);
} else if (key.hasShiftedLetterHint()) {