aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java2
-rw-r--r--java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java21
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java17
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardParser.java18
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java6
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java5
7 files changed, 40 insertions, 37 deletions
diff --git a/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
index 2789bcb39..bcdcef7dc 100644
--- a/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/EditorInfoCompatUtils.java
@@ -27,7 +27,7 @@ public class EditorInfoCompatUtils {
private static final Field FIELD_IME_FLAG_NAVIGATE_PREVIOUS = CompatUtils.getField(
EditorInfo.class, "IME_FLAG_NAVIGATE_PREVIOUS");
private static final Field FIELD_IME_ACTION_PREVIOUS = CompatUtils.getField(
- EditorInfo.class, "IME_FLAG_ACTION_PREVIOUS");
+ EditorInfo.class, "IME_ACTION_PREVIOUS");
private static final Integer OBJ_IME_FLAG_NAVIGATE_NEXT = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_FLAG_NAVIGATE_NEXT);
private static final Integer OBJ_IME_FLAG_NAVIGATE_PREVIOUS = (Integer) CompatUtils
diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
index 5d89669b7..4929dd948 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
@@ -30,12 +30,14 @@ import java.util.ArrayList;
import java.util.Locale;
public class SuggestionSpanUtils {
+ // TODO: Use reflection to get field values
public static final String ACTION_SUGGESTION_PICKED =
"android.text.style.SUGGESTION_PICKED";
public static final String SUGGESTION_SPAN_PICKED_AFTER = "after";
public static final String SUGGESTION_SPAN_PICKED_BEFORE = "before";
public static final String SUGGESTION_SPAN_PICKED_HASHCODE = "hashcode";
public static final int SUGGESTION_MAX_SIZE = 5;
+ public static final boolean SUGGESTION_SPAN_IS_SUPPORTED;
private static final Class<?> CLASS_SuggestionSpan = CompatUtils
.getClass("android.text.style.SuggestionSpan");
@@ -43,24 +45,23 @@ public class SuggestionSpanUtils {
Context.class, Locale.class, String[].class, int.class, Class.class };
private static final Constructor<?> CONSTRUCTOR_SuggestionSpan = CompatUtils
.getConstructor(CLASS_SuggestionSpan, INPUT_TYPE_SuggestionSpan);
- public static final boolean SUGGESTION_SPAN_IS_SUPPORTED;
static {
SUGGESTION_SPAN_IS_SUPPORTED =
CLASS_SuggestionSpan != null && CONSTRUCTOR_SuggestionSpan != null;
}
public static CharSequence getTextWithSuggestionSpan(Context context,
- CharSequence suggestion, SuggestedWords suggestedWords) {
- if (TextUtils.isEmpty(suggestion) || CONSTRUCTOR_SuggestionSpan == null
+ CharSequence pickedWord, SuggestedWords suggestedWords) {
+ if (TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null
|| suggestedWords == null || suggestedWords.size() == 0) {
- return suggestion;
+ return pickedWord;
}
final Spannable spannable;
- if (suggestion instanceof Spannable) {
- spannable = (Spannable) suggestion;
+ if (pickedWord instanceof Spannable) {
+ spannable = (Spannable) pickedWord;
} else {
- spannable = new SpannableString(suggestion);
+ spannable = new SpannableString(pickedWord);
}
final ArrayList<String> suggestionsList = new ArrayList<String>();
for (int i = 0; i < suggestedWords.size(); ++i) {
@@ -68,7 +69,7 @@ public class SuggestionSpanUtils {
break;
}
final CharSequence word = suggestedWords.getWord(i);
- if (!TextUtils.equals(suggestion, word)) {
+ if (!TextUtils.equals(pickedWord, word)) {
suggestionsList.add(word.toString());
}
}
@@ -78,9 +79,9 @@ public class SuggestionSpanUtils {
(Class<?>) SuggestionSpanPickedNotificationReceiver.class };
final Object ss = CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan, args);
if (ss == null) {
- return suggestion;
+ return pickedWord;
}
- spannable.setSpan(ss, 0, suggestion.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ spannable.setSpan(ss, 0, pickedWord.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannable;
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 3db214ec9..58629ba51 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.Log;
@@ -173,11 +172,6 @@ public class Keyboard {
mDefaultHeight = mDefaultWidth;
mId = id;
mProximityInfo = new ProximityInfo(GRID_WIDTH, GRID_HEIGHT);
-
- final TypedArray attrs = context.obtainStyledAttributes(
- null, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
- attrs.recycle();
-
loadKeyboard(context, xmlLayoutResId);
}
@@ -440,7 +434,7 @@ public class Keyboard {
private void loadKeyboard(Context context, int xmlLayoutResId) {
try {
- KeyboardParser parser = new KeyboardParser(this, context.getResources());
+ KeyboardParser parser = new KeyboardParser(this, context);
parser.parseKeyboard(xmlLayoutResId);
// mMinWidth is the width of this keyboard which is maximum width of row.
mMinWidth = parser.getMaxRowWidth();
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index 7c03ec71e..d97bb6730 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -16,12 +16,12 @@
package com.android.inputmethod.keyboard;
+import android.view.inputmethod.EditorInfo;
+
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.latin.R;
-import android.view.inputmethod.EditorInfo;
-
import java.util.Arrays;
import java.util.Locale;
@@ -43,7 +43,7 @@ public class KeyboardId {
public final int mMode;
public final int mXmlId;
public final int mColorScheme;
- public final boolean mWebInput;
+ public final boolean mNavigateAction;
public final boolean mPasswordInput;
public final boolean mHasSettingsKey;
public final boolean mVoiceKeyEnabled;
@@ -67,7 +67,10 @@ public class KeyboardId {
this.mMode = mode;
this.mXmlId = xmlId;
this.mColorScheme = colorScheme;
- this.mWebInput = InputTypeCompatUtils.isWebInputType(inputType);
+ // Note: Turn off checking navigation flag to show TAB key for now.
+ this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType);
+// || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions)
+// || EditorInfoCompatUtils.hasFlagNavigatePrevious(imeOptions);
this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType)
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType);
this.mHasSettingsKey = hasSettingsKey;
@@ -89,7 +92,7 @@ public class KeyboardId {
mode,
xmlId,
colorScheme,
- mWebInput,
+ mNavigateAction,
mPasswordInput,
hasSettingsKey,
voiceKeyEnabled,
@@ -143,7 +146,7 @@ public class KeyboardId {
&& other.mMode == this.mMode
&& other.mXmlId == this.mXmlId
&& other.mColorScheme == this.mColorScheme
- && other.mWebInput == this.mWebInput
+ && other.mNavigateAction == this.mNavigateAction
&& other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey
&& other.mVoiceKeyEnabled == this.mVoiceKeyEnabled
@@ -166,7 +169,7 @@ public class KeyboardId {
modeName(mMode),
EditorInfoCompatUtils.imeOptionsName(mImeAction),
colorSchemeName(mColorScheme),
- (mWebInput ? " webInput" : ""),
+ (mNavigateAction ? " navigateAction" : ""),
(mPasswordInput ? " passwordInput" : ""),
(mHasSettingsKey ? " hasSettingsKey" : ""),
(mVoiceKeyEnabled ? " voiceKeyEnabled" : ""),
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
index 07166b1db..20af12bc5 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
@@ -121,6 +121,7 @@ public class KeyboardParser {
public static final String TAG_KEY_STYLE = "key-style";
private final Keyboard mKeyboard;
+ private final Context mContext;
private final Resources mResources;
private int mHorizontalEdgesPadding;
@@ -131,8 +132,10 @@ public class KeyboardParser {
private Row mCurrentRow = null;
private final KeyStyles mKeyStyles = new KeyStyles();
- public KeyboardParser(Keyboard keyboard, Resources res) {
+ public KeyboardParser(Keyboard keyboard, Context context) {
mKeyboard = keyboard;
+ mContext = context;
+ final Resources res = context.getResources();
mResources = res;
mHorizontalEdgesPadding = (int)res.getDimension(R.dimen.keyboard_horizontal_edges_padding);
}
@@ -187,8 +190,9 @@ public class KeyboardParser {
private void parseKeyboardAttributes(XmlResourceParser parser) {
final Keyboard keyboard = mKeyboard;
- final TypedArray keyboardAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
- R.styleable.Keyboard);
+ final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
+ Xml.asAttributeSet(parser), R.styleable.Keyboard, R.attr.keyboardStyle,
+ R.style.Keyboard);
final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard_Key);
try {
@@ -469,8 +473,8 @@ public class KeyboardParser {
try {
final boolean modeMatched = matchTypedValue(a,
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
- final boolean webInputMatched = matchBoolean(a,
- R.styleable.Keyboard_Case_webInput, id.mWebInput);
+ final boolean navigateActionMatched = matchBoolean(a,
+ R.styleable.Keyboard_Case_navigateAction, id.mNavigateAction);
final boolean passwordInputMatched = matchBoolean(a,
R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput);
final boolean settingsKeyMatched = matchBoolean(a,
@@ -493,7 +497,7 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage());
final boolean countryCodeMatched = matchString(a,
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
- final boolean selected = modeMatched && webInputMatched && passwordInputMatched
+ final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched
&& settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
&& colorSchemeMatched && imeActionMatched && localeCodeMatched
&& languageCodeMatched && countryCodeMatched;
@@ -503,7 +507,7 @@ public class KeyboardParser {
textAttr(KeyboardId.colorSchemeName(
viewAttr.getInt(
R.styleable.KeyboardView_colorScheme, -1)), "colorScheme"),
- booleanAttr(a, R.styleable.Keyboard_Case_webInput, "webInput"),
+ booleanAttr(a, R.styleable.Keyboard_Case_navigateAction, "navigateAction"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"),
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index 2a29e1f8f..92d26a01c 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -349,9 +349,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
dv.setTextColor(0xff808080);
dv.setText(info.getDebugString());
// TODO: debug view for candidate strip needed.
- mCandidatesPane.addView(dv);
- LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)dv.getLayoutParams();
- lp.gravity = Gravity.BOTTOM;
+// mCandidatesPane.addView(dv);
+// LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)dv.getLayoutParams();
+// lp.gravity = Gravity.BOTTOM;
}
}
if (x != 0) {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 87912eb00..fc01d3976 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -518,8 +518,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
LatinKeyboardView inputView = switcher.getKeyboardView();
if (DEBUG) {
- Log.d(TAG, "onStartInputView: inputType=" + ((attribute == null) ? "none"
- : String.format("0x%08x", attribute.inputType)));
+ Log.d(TAG, "onStartInputView: attribute:" + ((attribute == null) ? "none"
+ : String.format("inputType=0x%08x imeOptions=0x%08x",
+ attribute.inputType, attribute.imeOptions)));
}
// In landscape mode, this method gets called without the input view being created.
if (inputView == null) {