aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/BaseKeyboardParser.java34
-rw-r--r--java/src/com/android/inputmethod/latin/KeyboardSwitcher.java6
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboard.java73
3 files changed, 23 insertions, 90 deletions
diff --git a/java/src/com/android/inputmethod/latin/BaseKeyboardParser.java b/java/src/com/android/inputmethod/latin/BaseKeyboardParser.java
index 3a2764968..621e875bf 100644
--- a/java/src/com/android/inputmethod/latin/BaseKeyboardParser.java
+++ b/java/src/com/android/inputmethod/latin/BaseKeyboardParser.java
@@ -407,23 +407,27 @@ public class BaseKeyboardParser {
R.styleable.BaseKeyboard_Case_hasVoiceKey, id.mHasVoiceKey);
final boolean colorSchemeMatched = matchInteger(viewAttr,
R.styleable.BaseKeyboardView_colorScheme, id.mColorScheme);
-
- final boolean selected = modeMatched && settingsKeyMatched
- && voiceEnabledMatched && voiceKeyMatched && colorSchemeMatched;
+ // As noted at KeyboardSwitcher.KeyboardId class, we are interested only in
+ // enum value masked by IME_MASK_ACTION and IME_FLAG_NO_ENTER_ACTION. So matching
+ // this attribute with id.mImeOptions as integer value is enough for our purpose.
+ final boolean imeOptionsMatched = matchInteger(a,
+ R.styleable.BaseKeyboard_Case_imeOptions, id.mImeOptions);
+ final boolean selected = modeMatched && settingsKeyMatched && voiceEnabledMatched
+ && voiceKeyMatched && colorSchemeMatched && imeOptionsMatched;
if (DEBUG_TAG) {
- Log.d(TAG, "parseCaseCondition: " + Boolean.toString(selected).toUpperCase()
- + debugInteger(a,
- R.styleable.BaseKeyboard_Case_mode, "mode")
- + debugBoolean(a,
- R.styleable.BaseKeyboard_Case_hasSettingsKey, "hasSettingsKey")
- + debugBoolean(a,
- R.styleable.BaseKeyboard_Case_voiceKeyEnabled, "voiceKeyEnabled")
- + debugBoolean(a,
- R.styleable.BaseKeyboard_Case_hasVoiceKey, "hasVoiceKey")
- + debugInteger(viewAttr,
- R.styleable.BaseKeyboardView_colorScheme, "colorScheme")
- );
+ Log.d(TAG, String.format(
+ "parseCaseCondition: %s%s%s%s%s%s%s",
+ Boolean.toString(selected).toUpperCase(),
+ debugInteger(a, R.styleable.BaseKeyboard_Case_mode, "mode"),
+ debugBoolean(a, R.styleable.BaseKeyboard_Case_hasSettingsKey,
+ "hasSettingsKey"),
+ debugBoolean(a, R.styleable.BaseKeyboard_Case_voiceKeyEnabled,
+ "voiceKeyEnabled"),
+ debugBoolean(a, R.styleable.BaseKeyboard_Case_hasVoiceKey, "hasVoiceKey"),
+ debugInteger(viewAttr, R.styleable.BaseKeyboardView_colorScheme,
+ "colorScheme"),
+ debugInteger(a, R.styleable.BaseKeyboard_Case_imeOptions, "imeOptions")));
}
return selected;
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index b90ea2471..68c35791c 100644
--- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -22,6 +22,7 @@ import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.InflateException;
+import android.view.inputmethod.EditorInfo;
import java.lang.ref.SoftReference;
import java.util.Arrays;
@@ -165,7 +166,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
this.mHasSettingsKey = hasSettingsKey;
this.mVoiceKeyEnabled = voiceKeyEnabled;
this.mHasVoiceKey = hasVoiceKey;
- this.mImeOptions = imeOptions;
+ // We are interested only in IME_MASK_ACTION enum value and IME_FLAG_NO_ENTER_ACTION.
+ this.mImeOptions = imeOptions
+ & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
this.mEnableShiftLock = enableShiftLock;
this.mHashCode = Arrays.hashCode(new Object[] {
@@ -301,7 +304,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mSubtypeSwitcher.getInputLocale());
keyboard = new LatinKeyboard(mInputMethodService, id);
- keyboard.setImeOptions(res, id.mMode, id.mImeOptions);
if (id.mEnableShiftLock) {
keyboard.enableShiftLock();
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java
index be00659b8..74aa899b6 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java
@@ -33,7 +33,6 @@ import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.Log;
import android.view.ViewConfiguration;
-import android.view.inputmethod.EditorInfo;
import java.util.HashMap;
import java.util.List;
@@ -54,9 +53,7 @@ public class LatinKeyboard extends BaseKeyboard {
private Drawable mSpacePreviewIcon;
private final Drawable mButtonArrowLeftIcon;
private final Drawable mButtonArrowRightIcon;
- private final Drawable mSearchIcon;
private final int mSpaceBarTextShadowColor;
- private Key mEnterKey;
private Key mSpaceKey;
private int mSpaceKeyIndex = -1;
private int mSpaceDragStartX;
@@ -71,12 +68,6 @@ public class LatinKeyboard extends BaseKeyboard {
private int mPrefLetterY;
private int mPrefDistance;
- // Default Enter key attributes
- private final Drawable mDefaultEnterIcon;
- private final Drawable mDefaultEnterPreview;
- private final CharSequence mDefaultEnterLabel;
- private final CharSequence mDefaultEnterText;
-
private LatinKeyboardShiftState mShiftState = new LatinKeyboardShiftState();
private static final float SPACEBAR_DRAG_THRESHOLD = 0.8f;
@@ -98,14 +89,10 @@ public class LatinKeyboard extends BaseKeyboard {
mContext = context;
mRes = res;
if (id.mColorScheme == BaseKeyboardView.COLOR_SCHEME_BLACK) {
- // TODO: use <case imeOptions> and <case colorScheme> in XML to load search icon
- mSearchIcon = res.getDrawable(R.drawable.sym_bkeyboard_search);
mShiftedIcon = res.getDrawable(R.drawable.sym_bkeyboard_shift_locked);
mSpaceBarTextShadowColor = res.getColor(
R.color.latinkeyboard_bar_language_shadow_black);
} else { // default color scheme is BaseKeyboardView.COLOR_SCHEME_WHITE
- // TODO: use <case imeOptions> and <case colorScheme> in XML to load search icon
- mSearchIcon = res.getDrawable(R.drawable.sym_keyboard_search);
mShiftedIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
mSpaceBarTextShadowColor = res.getColor(
R.color.latinkeyboard_bar_language_shadow_white);
@@ -118,16 +105,6 @@ public class LatinKeyboard extends BaseKeyboard {
sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
R.dimen.spacebar_vertical_correction);
mSpaceKeyIndex = indexOf(LatinIME.KEYCODE_SPACE);
-
- if (mEnterKey != null) {
- mDefaultEnterIcon = mEnterKey.icon;
- mDefaultEnterPreview = mEnterKey.iconPreview;
- mDefaultEnterLabel = mEnterKey.label;
- mDefaultEnterText = mEnterKey.text;
- } else {
- mDefaultEnterIcon = mDefaultEnterPreview = null;
- mDefaultEnterLabel = mDefaultEnterText = null;
- }
}
@Override
@@ -135,9 +112,6 @@ public class LatinKeyboard extends BaseKeyboard {
XmlResourceParser parser, KeyStyles keyStyles) {
Key key = new LatinKey(res, parent, x, y, parser, keyStyles);
switch (key.codes[0]) {
- case LatinIME.KEYCODE_ENTER:
- mEnterKey = key;
- break;
case LatinIME.KEYCODE_SPACE:
mSpaceKey = key;
mSpaceIcon = key.icon;
@@ -148,53 +122,6 @@ public class LatinKeyboard extends BaseKeyboard {
return key;
}
- private static void resetKeyAttributes(Key key, CharSequence label) {
- key.popupCharacters = null;
- key.popupResId = 0;
- key.text = null;
- key.iconPreview = null;
- key.icon = null;
- key.hintIcon = null;
- key.label = label;
- }
-
- // TODO: remove this method and use <case imeOptions> in XML
- public void setImeOptions(Resources res, int mode, int options) {
- if (mEnterKey == null)
- return;
- final boolean configDynamicKeyTopEnterKey = res.getBoolean(
- R.bool.config_dynamic_key_top_enter_key);
- if (configDynamicKeyTopEnterKey) {
- switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
- case EditorInfo.IME_ACTION_GO:
- resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key));
- break;
- case EditorInfo.IME_ACTION_NEXT:
- resetKeyAttributes(mEnterKey, res.getText(R.string.label_next_key));
- break;
- case EditorInfo.IME_ACTION_DONE:
- resetKeyAttributes(mEnterKey, res.getText(R.string.label_done_key));
- break;
- case EditorInfo.IME_ACTION_SEARCH:
- resetKeyAttributes(mEnterKey, null);
- mEnterKey.iconPreview = res.getDrawable(R.drawable.sym_keyboard_feedback_search);
- mEnterKey.icon = mSearchIcon;
- break;
- case EditorInfo.IME_ACTION_SEND:
- resetKeyAttributes(mEnterKey, res.getText(R.string.label_send_key));
- break;
- default:
- resetKeyAttributes(mEnterKey, mDefaultEnterLabel);
- mEnterKey.text = mDefaultEnterText;
- mEnterKey.icon = mDefaultEnterIcon;
- mEnterKey.iconPreview = mDefaultEnterPreview;
- break;
- }
- }
- // Set the initial size of the preview icon
- setDefaultBounds(mEnterKey.iconPreview);
- }
-
public void enableShiftLock() {
for (final Key key : getShiftKeys()) {
if (key instanceof LatinKey) {