diff --git a/java/res/drawable-hdpi/hint_settings.9.png b/java/res/drawable-hdpi/hint_settings.9.png new file mode 100644 index 000000000..85c183a61 Binary files /dev/null and b/java/res/drawable-hdpi/hint_settings.9.png differ diff --git a/java/res/drawable-mdpi/hint_settings.9.png b/java/res/drawable-mdpi/hint_settings.9.png new file mode 100644 index 000000000..5077f3e6a Binary files /dev/null and b/java/res/drawable-mdpi/hint_settings.9.png differ diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index f0d5ef60a..cf702f391 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -61,6 +61,7 @@ public class LatinKeyboard extends Keyboard { private Key mShiftKey; private Key mEnterKey; private Key mF1Key; + private Drawable mF1HintIcon; private Key mSpaceKey; private Key m123Key; private final int NUMBER_HINT_COUNT = 10; @@ -135,6 +136,7 @@ public class LatinKeyboard extends Keyboard { mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic); m123MicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic); + mF1HintIcon = res.getDrawable(R.drawable.hint_settings); setDefaultBounds(m123MicPreviewIcon); sSpacebarVerticalCorrection = res.getDimensionPixelOffset( R.dimen.spacebar_vertical_correction); @@ -368,13 +370,18 @@ public class LatinKeyboard extends Keyboard { if (mHasVoiceButton && mVoiceEnabled) { mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; mF1Key.label = null; - mF1Key.icon = mMicIcon; + // HACK: draw mMicIcon and mF1HintIcon at the same time + mF1Key.icon = new BitmapDrawable(mRes, drawSynthesizedSettingsHintImage( + mF1Key.width, mF1Key.height + mVerticalGap, mMicIcon, mF1HintIcon)); mF1Key.iconPreview = mMicPreviewIcon; mF1Key.popupResId = R.xml.popup_mic; } else { mF1Key.label = ","; mF1Key.codes = new int[] { ',' }; - mF1Key.icon = null; + // HACK: draw only mF1HintIcon on offscreen buffer to adjust position of '...' to the + // above synthesized icon + mF1Key.icon = new BitmapDrawable(mRes, drawSynthesizedSettingsHintImage( + mF1Key.width, mF1Key.height + mVerticalGap, null, mF1HintIcon)); mF1Key.iconPreview = null; mF1Key.popupResId = R.xml.popup_comma; } @@ -424,6 +431,29 @@ public class LatinKeyboard extends Keyboard { return bounds.width(); } + // Overlay two images. Note that mainIcon can be null. + private Bitmap drawSynthesizedSettingsHintImage( + int width, int height, Drawable mainIcon, Drawable hintIcon) { + if (hintIcon == null) + return null; + final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + final Canvas canvas = new Canvas(buffer); + canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); + // draw main icon at centered position + if (mainIcon != null) { + setDefaultBounds(mainIcon); + final int drawableX = (width - mainIcon.getIntrinsicWidth()) / 2; + final int drawableY = (height - mainIcon.getIntrinsicHeight()) / 2; + canvas.translate(drawableX, drawableY); + mainIcon.draw(canvas); + canvas.translate(-drawableX, -drawableY); + } + // draw hint icon fully in the key + hintIcon.setBounds(0, 0, width, height); + hintIcon.draw(canvas); + return buffer; + } + // Layout local language name and left and right arrow on space bar. private static String layoutSpaceBar(Paint paint, Locale locale, Drawable lArrow, Drawable rArrow, int width, int height, float origTextSize, diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index 9ff7b9aef..b3f1364d8 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -847,7 +847,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx // Usually don't draw icon if label is not null, but we draw icon for the number // hint. - shouldDrawIcon = isNumberAtEdgeOfPopupChars(key); + shouldDrawIcon = isCommaKeyLabelOrNumberAtEdgeOfPopupChars(key); } if (key.icon != null && shouldDrawIcon) { // Special handing for the upper-right number hint icons @@ -940,7 +940,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx if (key == null) return; // Should not draw number hint icons - if (key.icon != null && !isNumberAtEdgeOfPopupChars(key)) { + if (key.icon != null && !isCommaKeyLabelOrNumberAtEdgeOfPopupChars(key)) { mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon); mPreviewText.setText(null); @@ -1221,6 +1221,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return false; } + private static boolean isCommaKeyLabelOrNumberAtEdgeOfPopupChars(Key key) { + return isNumberAtEdgeOfPopupChars(key) || isCommaKeyLabel(key); + } + + private static boolean isCommaKeyLabel(Key key) { + return ",".equals(key.label); + } + private static boolean isNumberAtEdgeOfPopupChars(Key key) { return isNumberAtLeftmostPopupChar(key) || isNumberAtRightmostPopupChar(key); }