am 179fa2c0: DO NOT MERGE. Add visual indicator that long press , or mic key will bring up Settings

Merge commit '179fa2c03e749df736f43e0838200bec52b4808a' into gingerbread-plus-aosp

* commit '179fa2c03e749df736f43e0838200bec52b4808a':
  DO NOT MERGE. Add visual indicator that long press , or mic key will bring up Settings
main
Ken Wakasa 2010-10-14 04:28:02 -07:00 committed by Android Git Automerger
commit bf0172d718
4 changed files with 42 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

View File

@ -61,6 +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 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;
@ -135,6 +136,7 @@ public class LatinKeyboard extends Keyboard {
mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic); m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic);
m123MicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic); m123MicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic);
mF1HintIcon = res.getDrawable(R.drawable.hint_settings);
setDefaultBounds(m123MicPreviewIcon); setDefaultBounds(m123MicPreviewIcon);
sSpacebarVerticalCorrection = res.getDimensionPixelOffset( sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
R.dimen.spacebar_vertical_correction); R.dimen.spacebar_vertical_correction);
@ -368,13 +370,18 @@ public class LatinKeyboard extends Keyboard {
if (mHasVoiceButton && mVoiceEnabled) { if (mHasVoiceButton && mVoiceEnabled) {
mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
mF1Key.label = null; 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.iconPreview = mMicPreviewIcon;
mF1Key.popupResId = R.xml.popup_mic; mF1Key.popupResId = R.xml.popup_mic;
} else { } else {
mF1Key.label = ","; mF1Key.label = ",";
mF1Key.codes = new int[] { ',' }; 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.iconPreview = null;
mF1Key.popupResId = R.xml.popup_comma; mF1Key.popupResId = R.xml.popup_comma;
} }
@ -424,6 +431,29 @@ public class LatinKeyboard extends Keyboard {
return bounds.width(); 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. // Layout local language name and left and right arrow on space bar.
private static String layoutSpaceBar(Paint paint, Locale locale, Drawable lArrow, private static String layoutSpaceBar(Paint paint, Locale locale, Drawable lArrow,
Drawable rArrow, int width, int height, float origTextSize, Drawable rArrow, int width, int height, float origTextSize,

View File

@ -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 // Usually don't draw icon if label is not null, but we draw icon for the number
// hint. // hint.
shouldDrawIcon = isNumberAtEdgeOfPopupChars(key); shouldDrawIcon = isCommaKeyLabelOrNumberAtEdgeOfPopupChars(key);
} }
if (key.icon != null && shouldDrawIcon) { if (key.icon != null && shouldDrawIcon) {
// Special handing for the upper-right number hint icons // Special handing for the upper-right number hint icons
@ -940,7 +940,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
if (key == null) if (key == null)
return; return;
// Should not draw number hint icons // Should not draw number hint icons
if (key.icon != null && !isNumberAtEdgeOfPopupChars(key)) { if (key.icon != null && !isCommaKeyLabelOrNumberAtEdgeOfPopupChars(key)) {
mPreviewText.setCompoundDrawables(null, null, null, mPreviewText.setCompoundDrawables(null, null, null,
key.iconPreview != null ? key.iconPreview : key.icon); key.iconPreview != null ? key.iconPreview : key.icon);
mPreviewText.setText(null); mPreviewText.setText(null);
@ -1221,6 +1221,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
return false; 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) { private static boolean isNumberAtEdgeOfPopupChars(Key key) {
return isNumberAtLeftmostPopupChar(key) || isNumberAtRightmostPopupChar(key); return isNumberAtLeftmostPopupChar(key) || isNumberAtRightmostPopupChar(key);
} }