LatinIME: add attr for vertical hint padding

Change-Id: I1d754a114f937cd6e7884ca20406213c0f70e0e6
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 8ff5a87..c6369f0 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -59,6 +59,8 @@
         <attr name="spacebarIconWidthRatio" format="float" />
         <!-- Right padding of hint letter to the edge of the key.-->
         <attr name="keyHintLetterPadding" format="dimension" />
+        <!-- Top padding of hint letter to the edge of the key.-->
+        <attr name="keyHintLetterPaddingVertical" format="dimension" />
         <!-- Popup hint letter string-->
         <attr name="keyPopupHintLetter" format="string" />
         <!-- Bottom padding of popup hint letter to the edge of the key.-->
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index e4901b1..d8fcc37 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -61,6 +61,7 @@
     <fraction name="config_key_shifted_letter_hint_ratio_lxx">35%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">33.735%</fraction>
     <dimen name="config_key_hint_letter_padding">1dp</dimen>
+    <dimen name="config_key_hint_letter_padding_vertical">0dp</dimen>
     <dimen name="config_key_shifted_letter_hint_padding">2dp</dimen>
 
     <!-- For 5-row keyboard -->
diff --git a/java/res/values/themes-common.xml b/java/res/values/themes-common.xml
index 7367318..c4f6940 100644
--- a/java/res/values/themes-common.xml
+++ b/java/res/values/themes-common.xml
@@ -42,6 +42,7 @@
         <!-- A negative value to disable key text shadow layer. -->
         <item name="keyTextShadowRadius">-1.0</item>
         <item name="keyHintLetterPadding">@dimen/config_key_hint_letter_padding</item>
+        <item name="keyHintLetterPaddingVertical">@dimen/config_key_hint_letter_padding_vertical</item>
         <item name="keyPopupHintLetterPadding">@dimen/config_key_popup_hint_letter_padding</item>
         <item name="keyShiftedLetterHintPadding">@dimen/config_key_shifted_letter_hint_padding</item>
         <item name="keyPreviewTextRatio">@fraction/config_key_preview_text_ratio</item>
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 0dd6401..cd5073d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -52,6 +52,7 @@
  * @attr ref R.styleable#KeyboardView_spacebarIconWidthRatio
  * @attr ref R.styleable#Keyboard_Key_keyLabelFlags
  * @attr ref R.styleable#KeyboardView_keyHintLetterPadding
+ * @attr ref R.styleable#KeyboardView_keyHintLetterPaddingVertical
  * @attr ref R.styleable#KeyboardView_keyPopupHintLetter
  * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
  * @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding
@@ -83,7 +84,8 @@
     // Default keyLabelFlags from {@link KeyboardTheme}.
     // Currently only "alignHintLabelToBottom" is supported.
     private final int mDefaultKeyLabelFlags;
-    private final float mKeyHintLetterPadding;
+    private final float mKeyHintLetterPaddingX;
+    private final float mKeyHintLetterPaddingY;
     private final String mKeyPopupHintLetter;
     private final float mKeyPopupHintLetterPadding;
     private final float mKeyShiftedLetterHintPadding;
@@ -142,8 +144,10 @@
         mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground : mKeyBackground;
         mSpacebarIconWidthRatio = keyboardViewAttr.getFloat(
                 R.styleable.KeyboardView_spacebarIconWidthRatio, 1.0f);
-        mKeyHintLetterPadding = keyboardViewAttr.getDimension(
+        mKeyHintLetterPaddingX = keyboardViewAttr.getDimension(
                 R.styleable.KeyboardView_keyHintLetterPadding, 0.0f);
+        mKeyHintLetterPaddingY = keyboardViewAttr.getDimension(
+                R.styleable.KeyboardView_keyHintLetterPaddingVertical, 0.0f);
         mKeyPopupHintLetter = keyboardViewAttr.getString(
                 R.styleable.KeyboardView_keyPopupHintLetter);
         mKeyPopupHintLetterPadding = keyboardViewAttr.getDimension(
@@ -467,9 +471,9 @@
                 // The hint letter is placed at top-right corner of the key. Used mainly on phone.
                 final float hintDigitWidth = TypefaceUtils.getReferenceDigitWidth(paint);
                 final float hintLabelWidth = TypefaceUtils.getStringWidth(hintLabel, paint);
-                hintX = keyWidth - mKeyHintLetterPadding
+                hintX = keyWidth - mKeyHintLetterPaddingX
                         - Math.max(hintDigitWidth, hintLabelWidth) / 2.0f;
-                hintBaseline = -paint.ascent();
+                hintBaseline = -paint.ascent() + mKeyHintLetterPaddingY;
                 paint.setTextAlign(Align.CENTER);
             }
             final float adjustmentY = params.mHintLabelVerticalAdjustment * labelCharHeight;
@@ -514,7 +518,7 @@
         paint.setTextSize(params.mHintLetterSize);
         paint.setColor(params.mHintLabelColor);
         paint.setTextAlign(Align.CENTER);
-        final float hintX = keyWidth - mKeyHintLetterPadding
+        final float hintX = keyWidth - mKeyHintLetterPaddingX
                 - TypefaceUtils.getReferenceCharWidth(paint) / 2.0f;
         final float hintY = keyHeight - mKeyPopupHintLetterPadding;
         canvas.drawText(mKeyPopupHintLetter, hintX, hintY, paint);