diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml index 6e2e69208..70eab096d 100644 --- a/java/res/xml-da/kbd_qwerty.xml +++ b/java/res/xml-da/kbd_qwerty.xml @@ -209,7 +209,7 @@ android:isModifier="true" android:keyEdgeFlags="left" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + android:codes="@integer/key_f1" /> + + + + + + + + diff --git a/java/res/xml/popup_slash.xml b/java/res/xml/popup_slash.xml new file mode 100644 index 000000000..a38fde0e4 --- /dev/null +++ b/java/res/xml/popup_slash.xml @@ -0,0 +1,39 @@ + + + + + + + + + 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; } } + } - // 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; + private void updateF1Key() { + // Update KEYCODE_F1 key. Please note that some keyboard layouts have no F1 key. + if (mF1Key == null) + return; + + 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 { - 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; + if (mVoiceEnabled && mHasVoiceButton) { + setMicF1Key(mF1Key); + } else { + setNonMicF1Key(mF1Key, ",", R.xml.popup_comma); + } + } + } else { // Symbols keyboard + if (mVoiceEnabled && mHasVoiceButton) { + setMicF1Key(mF1Key); + } else { + 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) {