aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2010-10-15 18:21:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-15 18:21:40 -0700
commit863d1ac94898f2f770645baecc21184e18581267 (patch)
treea944bb92c2200f0228a03186c59a1308ec84c5d1 /java/src
parentc247df2d05932f36ca1ebbba34b57a92254f433e (diff)
parent1cbfc6c968378f2e0a20b41677ec2a96bf69b621 (diff)
downloadlatinime-863d1ac94898f2f770645baecc21184e18581267.tar.gz
latinime-863d1ac94898f2f770645baecc21184e18581267.tar.xz
latinime-863d1ac94898f2f770645baecc21184e18581267.zip
am 1cbfc6c9: DO NOT MERGE. Follow up change to I8b38e280 Add visual indicator that long press / or @ on F1 key will bring up Settings
Merge commit '1cbfc6c968378f2e0a20b41677ec2a96bf69b621' into gingerbread-plus-aosp * commit '1cbfc6c968378f2e0a20b41677ec2a96bf69b621': DO NOT MERGE. Follow up change to I8b38e280
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboard.java79
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java13
2 files changed, 68 insertions, 24 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java
index e33ae145b..8060ac996 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java
@@ -74,6 +74,7 @@ public class LatinKeyboard extends Keyboard {
private LanguageSwitcher mLanguageSwitcher;
private final Resources mRes;
private final Context mContext;
+ private int mMode;
// Whether this keyboard has voice icon on it
private boolean mHasVoiceButton;
// Whether voice icon is enabled at all
@@ -122,6 +123,7 @@ public class LatinKeyboard extends Keyboard {
super(context, xmlLayoutResId, mode);
final Resources res = context.getResources();
mContext = context;
+ mMode = mode;
mRes = res;
mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
@@ -202,6 +204,7 @@ public class LatinKeyboard extends Keyboard {
}
void setImeOptions(Resources res, int mode, int options) {
+ mMode = mode;
// TODO should clean up this method
if (mEnterKey != null) {
// Reset some of the rarely used attributes.
@@ -354,6 +357,11 @@ public class LatinKeyboard extends Keyboard {
}
private void updateDynamicKeys() {
+ update123Key();
+ updateF1Key();
+ }
+
+ private void update123Key() {
// Update KEYCODE_MODE_CHANGE key only on alphabet mode, not on symbol mode.
if (m123Key != null && mIsAlphaKeyboard) {
if (mVoiceEnabled && !mHasVoiceButton) {
@@ -366,30 +374,65 @@ public class LatinKeyboard extends Keyboard {
m123Key.label = m123Label;
}
}
+ }
+
+ private void updateF1Key() {
+ // Update KEYCODE_F1 key. Please note that some keyboard layouts have no F1 key.
+ if (mF1Key == null)
+ return;
- // Update KEYCODE_F1 key. Please note that some keyboard layout has no F1 key.
- if (mF1Key != null) {
- if (mHasVoiceButton && mVoiceEnabled) {
- mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
- mF1Key.label = null;
- // 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;
+ if (mIsAlphaKeyboard) {
+ if (mMode == KeyboardSwitcher.MODE_URL) {
+ setNonMicF1Key(mF1Key, "/", R.xml.popup_slash);
+ } else if (mMode == KeyboardSwitcher.MODE_EMAIL) {
+ setNonMicF1Key(mF1Key, "@", R.xml.popup_at);
+ } else {
+ if (mVoiceEnabled && mHasVoiceButton) {
+ setMicF1Key(mF1Key);
+ } else {
+ setNonMicF1Key(mF1Key, ",", R.xml.popup_comma);
+ }
+ }
+ } else { // Symbols keyboard
+ if (mVoiceEnabled && mHasVoiceButton) {
+ setMicF1Key(mF1Key);
} else {
- mF1Key.label = ",";
- mF1Key.codes = new int[] { ',' };
- // 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;
+ setNonMicF1Key(mF1Key, ",", R.xml.popup_comma);
}
}
}
+ private void setMicF1Key(Key key) {
+ // HACK: draw mMicIcon and mF1HintIcon at the same time
+ final Drawable micWithSettingsHintDrawable = new BitmapDrawable(mRes,
+ drawSynthesizedSettingsHintImage(key.width, key.height + mVerticalGap,
+ mMicIcon, mF1HintIcon));
+
+ key.label = null;
+ key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
+ key.popupResId = R.xml.popup_mic;
+ key.icon = micWithSettingsHintDrawable;
+ key.iconPreview = mMicPreviewIcon;
+ }
+
+ 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.codes = new int[] { label.charAt(0) };
+ key.popupResId = popupResId;
+ key.icon = onlySettingsHintDrawable;
+ key.iconPreview = null;
+ }
+
+ public boolean isF1Key(Key key) {
+ return key == mF1Key;
+ }
+
/**
* @return a key which should be invalidated.
*/
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index c1b1008b0..832c76880 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -850,7 +850,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 = isCommaKeyLabelOrNumberAtEdgeOfPopupChars(key);
+ shouldDrawIcon = isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(key);
}
if (key.icon != null && shouldDrawIcon) {
// Special handing for the upper-right number hint icons
@@ -943,7 +943,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
if (key == null)
return;
// Should not draw number hint icons
- if (key.icon != null && !isCommaKeyLabelOrNumberAtEdgeOfPopupChars(key)) {
+ if (key.icon != null && !isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(key)) {
mPreviewText.setCompoundDrawables(null, null, null,
key.iconPreview != null ? key.iconPreview : key.icon);
mPreviewText.setText(null);
@@ -1226,12 +1226,13 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
return false;
}
- private static boolean isCommaKeyLabelOrNumberAtEdgeOfPopupChars(Key key) {
- return isNumberAtEdgeOfPopupChars(key) || isCommaKeyLabel(key);
+ private boolean isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(Key key) {
+ return isNumberAtEdgeOfPopupChars(key) || isNonMicLatinF1Key(key);
}
- private static boolean isCommaKeyLabel(Key key) {
- return ",".equals(key.label);
+ private boolean isNonMicLatinF1Key(Key key) {
+ return (mKeyboard instanceof LatinKeyboard)
+ && ((LatinKeyboard)mKeyboard).isF1Key(key) && key.label != null;
}
private static boolean isNumberAtEdgeOfPopupChars(Key key) {