Ellipsis for "Space" key for triggering the IME switcher

bug:5136497
Change-Id: Iab7c68135500e9fed212521484090b52943550ca
main
Ken Wakasa 2011-08-09 19:50:21 +09:00
parent f098fbbef3
commit 11b7febc0b
5 changed files with 30 additions and 9 deletions

View File

@ -113,6 +113,8 @@ public class Key {
private boolean mHighlightOn; private boolean mHighlightOn;
/** Key is enabled and responds on press */ /** Key is enabled and responds on press */
private boolean mEnabled = true; private boolean mEnabled = true;
/** Whether this key needs to show the "..." popup hint for special purposes */
private boolean mNeedsSpecialPopupHint;
// keyWidth constants // keyWidth constants
private static final int KEYWIDTH_FILL_RIGHT = 0; private static final int KEYWIDTH_FILL_RIGHT = 0;
@ -402,6 +404,14 @@ public class Key {
return (mLabelOption & LABEL_OPTION_HAS_POPUP_HINT) != 0; return (mLabelOption & LABEL_OPTION_HAS_POPUP_HINT) != 0;
} }
public void setNeedsSpecialPopupHint(boolean needsSpecialPopupHint) {
mNeedsSpecialPopupHint = needsSpecialPopupHint;
}
public boolean needsSpecialPopupHint() {
return mNeedsSpecialPopupHint;
}
public boolean hasUppercaseLetter() { public boolean hasUppercaseLetter() {
return (mLabelOption & LABEL_OPTION_HAS_UPPERCASE_LETTER) != 0; return (mLabelOption & LABEL_OPTION_HAS_UPPERCASE_LETTER) != 0;
} }

View File

@ -657,7 +657,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
} }
// Draw popup hint "..." at the bottom right corner of the key. // Draw popup hint "..." at the bottom right corner of the key.
if (key.hasPopupHint() && key.mPopupCharacters != null && key.mPopupCharacters.length > 0) { if ((key.hasPopupHint() && key.mPopupCharacters != null && key.mPopupCharacters.length > 0)
|| key.needsSpecialPopupHint()) {
paint.setTextSize(params.mKeyHintLetterSize); paint.setTextSize(params.mKeyHintLetterSize);
paint.setColor(params.mKeyHintLabelColor); paint.setColor(params.mKeyHintLabelColor);
paint.setTextAlign(Align.CENTER); paint.setTextAlign(Align.CENTER);

View File

@ -31,10 +31,12 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder; import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardParams; import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.Utils;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.util.Arrays; import java.util.Arrays;
@ -59,6 +61,7 @@ public class LatinKeyboard extends Keyboard {
private float mSpacebarTextFadeFactor = 0.0f; private float mSpacebarTextFadeFactor = 0.0f;
private final HashMap<Integer, SoftReference<BitmapDrawable>> mSpaceDrawableCache = private final HashMap<Integer, SoftReference<BitmapDrawable>> mSpaceDrawableCache =
new HashMap<Integer, SoftReference<BitmapDrawable>>(); new HashMap<Integer, SoftReference<BitmapDrawable>>();
private final boolean mIsSpacebarTriggeringPopupByLongPress;
/* Shortcut key and its icons if available */ /* Shortcut key and its icons if available */
private final Key mShortcutKey; private final Key mShortcutKey;
@ -85,6 +88,9 @@ public class LatinKeyboard extends Keyboard {
mShortcutKey = params.mShortcutKey; mShortcutKey = params.mShortcutKey;
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null; mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
final int longPressSpaceKeyTimeout =
mRes.getInteger(R.integer.config_long_press_space_key_timeout);
mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0);
final TypedArray a = context.obtainStyledAttributes( final TypedArray a = context.obtainStyledAttributes(
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
@ -179,8 +185,13 @@ public class LatinKeyboard extends Keyboard {
} }
private void updateSpacebarForLocale(boolean isAutoCorrection) { private void updateSpacebarForLocale(boolean isAutoCorrection) {
if (mSpaceKey == null) if (mSpaceKey == null) return;
return; final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance();
if (imm == null) return;
// The "..." popup hint for triggering something by a long-pressing the spacebar
final boolean shouldShowInputMethodPicker = mIsSpacebarTriggeringPopupByLongPress
&& Utils.hasMultipleEnabledIMEsOrSubtypes(imm, true /* include aux subtypes */);
mSpaceKey.setNeedsSpecialPopupHint(shouldShowInputMethodPicker);
// If application locales are explicitly selected. // If application locales are explicitly selected.
if (mSubtypeSwitcher.needsToDisplayLanguage()) { if (mSubtypeSwitcher.needsToDisplayLanguage()) {
mSpaceKey.setIcon(getSpaceDrawable( mSpaceKey.setIcon(getSpaceDrawable(

View File

@ -1181,8 +1181,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (isShowingOptionDialog()) return; if (isShowingOptionDialog()) return;
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) { if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
showSubtypeSelectorAndSettings(); showSubtypeSelectorAndSettings();
} else if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, } else if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, false /* exclude aux subtypes */)) {
false /* should exclude auxiliary subtypes */)) {
showOptionsMenu(); showOptionsMenu();
} else { } else {
launchSettings(); launchSettings();
@ -1197,8 +1196,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (isShowingOptionDialog()) return false; if (isShowingOptionDialog()) return false;
switch (requestCode) { switch (requestCode) {
case CODE_SHOW_INPUT_METHOD_PICKER: case CODE_SHOW_INPUT_METHOD_PICKER:
if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, true /* include aux subtypes */)) {
true /* should include auxiliary subtypes */)) {
mImm.showInputMethodPicker(); mImm.showInputMethodPicker();
return true; return true;
} }

View File

@ -111,8 +111,9 @@ public class Utils {
} }
} }
public static boolean hasMultipleEnabledIMEsOrSubtypes(InputMethodManagerCompatWrapper imm, public static boolean hasMultipleEnabledIMEsOrSubtypes(
boolean shouldIncludeAuxiliarySubtypes) { final InputMethodManagerCompatWrapper imm,
final boolean shouldIncludeAuxiliarySubtypes) {
final List<InputMethodInfoCompatWrapper> enabledImis = imm.getEnabledInputMethodList(); final List<InputMethodInfoCompatWrapper> enabledImis = imm.getEnabledInputMethodList();
// Number of the filtered IMEs // Number of the filtered IMEs