From 179fa2c03e749df736f43e0838200bec52b4808a Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Tue, 12 Oct 2010 16:16:38 +0900 Subject: [PATCH] DO NOT MERGE. Add visual indicator that long press , or mic key will bring up Settings bug:3084022 Change-Id: I8b38e2803eb32469653484701882af35108eb69a --- java/res/drawable-hdpi/hint_settings.9.png | Bin 0 -> 236 bytes java/res/drawable-mdpi/hint_settings.9.png | Bin 0 -> 222 bytes .../inputmethod/latin/LatinKeyboard.java | 34 ++++++++++++++++-- .../latin/LatinKeyboardBaseView.java | 12 +++++-- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 java/res/drawable-hdpi/hint_settings.9.png create mode 100644 java/res/drawable-mdpi/hint_settings.9.png 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 0000000000000000000000000000000000000000..85c183a61728680e7cb9f9291c791606a498d2a6 GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^MnLSs!3HD`yQJj;DajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_d9MSY$wjv*Dd-rP3iI-tPA8W3D{L~e8W7Nxfl1)jQ}{weuA zoaidl6P10^$K?ytTE8XNPPWyE3P8bxJ#V~A7Vq6K{RIamIFaM=a`&G*sr&jGKtSc` zj`PJI{&C$rrL=J#8zUV2G=1_j&O}>z@&)e(Muz*TUr!fZ4QdCvjKR~@&t;ucLK6U4 C;87+3 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5077f3e6a833fa57a5eddb62a6b7a82523869b1f GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^ia@N(!3HE1)R;tolw^r(L`iUdT1k0gQ7VIDN`6wR zf@f}GdTLN=VoGJ<$y6Jlq6SYF$B>F!Z>BqP9Z(Qp_I)Y*`~UhIY*ixq8+T0M)TxMS zTjLh`ey{4JCv0B7WOS!rV$)Vgnw!~NGADHo15-zl0G~CG=1^z=5&sw;PCpxbd#=Fa z59S3&&HFAJUif+~C-ySu+k3)&>_V46sT2TJW!+yiS>?BqS374dw*iADmvl(Kcg9wr PTNpfD{an^LB{Ts5pQ}sY literal 0 HcmV?d00001 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); }