am 86953d17: DO NOT MERGE. Revise the setting hint visual and its handling code. This is a follow up change to I8b38e280.

Merge commit '86953d170d3a1c189628a373a5987cfc4c17c997' into gingerbread-plus-aosp

* commit '86953d170d3a1c189628a373a5987cfc4c17c997':
  DO NOT MERGE.  Revise the setting hint visual and its handling code.
main
Ken Wakasa 2010-10-17 01:32:15 -07:00 committed by Android Git Automerger
commit 5446b281b6
4 changed files with 30 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 202 B

View File

@ -61,7 +61,7 @@ public class LatinKeyboard extends Keyboard {
private Key mShiftKey; private Key mShiftKey;
private Key mEnterKey; private Key mEnterKey;
private Key mF1Key; private Key mF1Key;
private Drawable mF1HintIcon; private final Drawable mF1HintIcon;
private Key mSpaceKey; private Key mSpaceKey;
private Key m123Key; private Key m123Key;
private final int NUMBER_HINT_COUNT = 10; private final int NUMBER_HINT_COUNT = 10;
@ -405,8 +405,7 @@ public class LatinKeyboard extends Keyboard {
private void setMicF1Key(Key key) { private void setMicF1Key(Key key) {
// HACK: draw mMicIcon and mF1HintIcon at the same time // HACK: draw mMicIcon and mF1HintIcon at the same time
final Drawable micWithSettingsHintDrawable = new BitmapDrawable(mRes, final Drawable micWithSettingsHintDrawable = new BitmapDrawable(mRes,
drawSynthesizedSettingsHintImage(key.width, key.height + mVerticalGap, drawSynthesizedSettingsHintImage(key.width, key.height, mMicIcon, mF1HintIcon));
mMicIcon, mF1HintIcon));
key.label = null; key.label = null;
key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
@ -416,16 +415,10 @@ public class LatinKeyboard extends Keyboard {
} }
private void setNonMicF1Key(Key key, String label, int popupResId) { private void setNonMicF1Key(Key key, String label, int popupResId) {
// HACK: draw only mF1HintIcon on offscreen buffer to adjust position of '...' to
// the mic+hint synthesized icon
final Drawable onlySettingsHintDrawable = new BitmapDrawable(mRes,
drawSynthesizedSettingsHintImage(key.width, key.height + mVerticalGap,
null, mF1HintIcon));
key.label = label; key.label = label;
key.codes = new int[] { label.charAt(0) }; key.codes = new int[] { label.charAt(0) };
key.popupResId = popupResId; key.popupResId = popupResId;
key.icon = onlySettingsHintDrawable; key.icon = mF1HintIcon;
key.iconPreview = null; key.iconPreview = null;
} }
@ -477,24 +470,29 @@ public class LatinKeyboard extends Keyboard {
return bounds.width(); return bounds.width();
} }
// Overlay two images. Note that mainIcon can be null. // Overlay two images: mainIcon and hintIcon.
private Bitmap drawSynthesizedSettingsHintImage( private Bitmap drawSynthesizedSettingsHintImage(
int width, int height, Drawable mainIcon, Drawable hintIcon) { int width, int height, Drawable mainIcon, Drawable hintIcon) {
if (hintIcon == null) if (mainIcon == null || hintIcon == null)
return null; return null;
Rect hintIconPadding = new Rect(0, 0, 0, 0);
hintIcon.getPadding(hintIconPadding);
final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(buffer); final Canvas canvas = new Canvas(buffer);
canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR);
// draw main icon at centered position
if (mainIcon != null) { // Draw main icon at the center of the key visual
// Assuming the hintIcon shares the same padding with the key's background drawable
final int drawableX = (width + hintIconPadding.left - hintIconPadding.right
- mainIcon.getIntrinsicWidth()) / 2;
final int drawableY = (height + hintIconPadding.top - hintIconPadding.bottom
- mainIcon.getIntrinsicHeight()) / 2;
setDefaultBounds(mainIcon); setDefaultBounds(mainIcon);
final int drawableX = (width - mainIcon.getIntrinsicWidth()) / 2;
final int drawableY = (height - mainIcon.getIntrinsicHeight()) / 2;
canvas.translate(drawableX, drawableY); canvas.translate(drawableX, drawableY);
mainIcon.draw(canvas); mainIcon.draw(canvas);
canvas.translate(-drawableX, -drawableY); canvas.translate(-drawableX, -drawableY);
}
// draw hint icon fully in the key // Draw hint icon fully in the key
hintIcon.setBounds(0, 0, width, height); hintIcon.setBounds(0, 0, width, height);
hintIcon.draw(canvas); hintIcon.draw(canvas);
return buffer; return buffer;

View File

@ -858,7 +858,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
final int drawableHeight; final int drawableHeight;
final int drawableX; final int drawableX;
final int drawableY; final int drawableY;
if (isNumberAtEdgeOfPopupChars(key)) { if (isLatinF1KeyOrNumberAtEdgeOfPopupChars(key)) {
drawableWidth = key.width; drawableWidth = key.width;
drawableHeight = key.height; drawableHeight = key.height;
drawableX = 0; drawableX = 0;
@ -1226,13 +1226,20 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
return false; return false;
} }
private boolean isLatinF1KeyOrNumberAtEdgeOfPopupChars(Key key) {
return isNumberAtEdgeOfPopupChars(key) || isLatinF1Key(key);
}
private boolean isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(Key key) { private boolean isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(Key key) {
return isNumberAtEdgeOfPopupChars(key) || isNonMicLatinF1Key(key); return isNumberAtEdgeOfPopupChars(key) || isNonMicLatinF1Key(key);
} }
private boolean isLatinF1Key(Key key) {
return (mKeyboard instanceof LatinKeyboard) && ((LatinKeyboard)mKeyboard).isF1Key(key);
}
private boolean isNonMicLatinF1Key(Key key) { private boolean isNonMicLatinF1Key(Key key) {
return (mKeyboard instanceof LatinKeyboard) return isLatinF1Key(key) && key.label != null;
&& ((LatinKeyboard)mKeyboard).isF1Key(key) && key.label != null;
} }
private static boolean isNumberAtEdgeOfPopupChars(Key key) { private static boolean isNumberAtEdgeOfPopupChars(Key key) {