DO NOT MERGE. Add visual indicator that long press , or mic key will bring up Settings
bug:3084022 Change-Id: I8b38e2803eb32469653484701882af35108eb69a
This commit is contained in:
parent
3d20d99902
commit
179fa2c03e
4 changed files with 42 additions and 4 deletions
BIN
java/res/drawable-hdpi/hint_settings.9.png
Normal file
BIN
java/res/drawable-hdpi/hint_settings.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 236 B |
BIN
java/res/drawable-mdpi/hint_settings.9.png
Normal file
BIN
java/res/drawable-mdpi/hint_settings.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 222 B |
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue