aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/compat/CursorAnchorInfoCompatWrapper.java38
-rw-r--r--java/src/com/android/inputmethod/compat/InputConnectionCompatUtils.java32
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardTheme.java20
-rw-r--r--java/src/com/android/inputmethod/keyboard/TextDecorator.java11
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java18
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java6
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java2
8 files changed, 67 insertions, 70 deletions
diff --git a/java/src/com/android/inputmethod/compat/CursorAnchorInfoCompatWrapper.java b/java/src/com/android/inputmethod/compat/CursorAnchorInfoCompatWrapper.java
index 24eaec85c..3a86ccbda 100644
--- a/java/src/com/android/inputmethod/compat/CursorAnchorInfoCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/CursorAnchorInfoCompatWrapper.java
@@ -23,34 +23,16 @@ import com.android.inputmethod.annotations.UsedForTesting;
@UsedForTesting
public final class CursorAnchorInfoCompatWrapper {
- public static final int CHARACTER_RECT_TYPE_MASK = 0x0f;
/**
- * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the editor did not specify any type of this
- * character. Editor authors should not use this flag.
+ * The insertion marker or character bounds have at least one visible region.
*/
- public static final int CHARACTER_RECT_TYPE_UNSPECIFIED = 0;
+ public static final int FLAG_HAS_VISIBLE_REGION = 0x01;
/**
- * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely visible.
+ * The insertion marker or character bounds have at least one invisible (clipped) region.
*/
- public static final int CHARACTER_RECT_TYPE_FULLY_VISIBLE = 1;
-
- /**
- * Type for {@link #CHARACTER_RECT_TYPE_MASK}: some area of the character is invisible.
- */
- public static final int CHARACTER_RECT_TYPE_PARTIALLY_VISIBLE = 2;
-
- /**
- * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the character is entirely invisible.
- */
- public static final int CHARACTER_RECT_TYPE_INVISIBLE = 3;
-
- /**
- * Type for {@link #CHARACTER_RECT_TYPE_MASK}: the editor gave up to calculate the rectangle
- * for this character. Input method authors should ignore the returned rectangle.
- */
- public static final int CHARACTER_RECT_TYPE_NOT_FEASIBLE = 4;
+ public static final int FLAG_HAS_INVISIBLE_REGION = 0x02;
// Note that CursorAnchorInfo has been introduced in API level XX (Build.VERSION_CODE.LXX).
private static final CompatUtils.ClassWrapper sCursorAnchorInfoClass;
@@ -63,7 +45,7 @@ public final class CursorAnchorInfoCompatWrapper {
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerHorizontalMethod;
private static final CompatUtils.ToFloatMethodWrapper sGetInsertionMarkerTopMethod;
private static final CompatUtils.ToObjectMethodWrapper<Matrix> sGetMatrixMethod;
- private static final CompatUtils.ToBooleanMethodWrapper sIsInsertionMarkerClippedMethod;
+ private static final CompatUtils.ToIntMethodWrapper sGetInsertionMarkerFlagsMethod;
private static int COMPOSING_TEXT_START_DEFAULT = -1;
static {
@@ -72,7 +54,7 @@ public final class CursorAnchorInfoCompatWrapper {
sGetCharacterRectMethod = sCursorAnchorInfoClass.getMethod(
"getCharacterRect", (RectF)null, int.class);
sGetCharacterRectFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
- "getCharacterRectFlags", CHARACTER_RECT_TYPE_UNSPECIFIED, int.class);
+ "getCharacterRectFlags", 0, int.class);
sGetComposingTextMethod = sCursorAnchorInfoClass.getMethod(
"getComposingText", (CharSequence)null);
sGetComposingTextStartMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
@@ -86,8 +68,8 @@ public final class CursorAnchorInfoCompatWrapper {
sGetInsertionMarkerTopMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
"getInsertionMarkerTop", 0.0f);
sGetMatrixMethod = sCursorAnchorInfoClass.getMethod("getMatrix", (Matrix)null);
- sIsInsertionMarkerClippedMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
- "isInsertionMarkerClipped", false);
+ sGetInsertionMarkerFlagsMethod = sCursorAnchorInfoClass.getPrimitiveMethod(
+ "getInsertionMarkerFlags", 0);
}
@UsedForTesting
@@ -154,7 +136,7 @@ public final class CursorAnchorInfoCompatWrapper {
return sGetInsertionMarkerTopMethod.invoke(mInstance);
}
- public boolean isInsertionMarkerClipped() {
- return sIsInsertionMarkerClippedMethod.invoke(mInstance);
+ public int getInsertionMarkerFlags() {
+ return sGetInsertionMarkerFlagsMethod.invoke(mInstance);
}
}
diff --git a/java/src/com/android/inputmethod/compat/InputConnectionCompatUtils.java b/java/src/com/android/inputmethod/compat/InputConnectionCompatUtils.java
index 862ec8a58..a5c71b22f 100644
--- a/java/src/com/android/inputmethod/compat/InputConnectionCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/InputConnectionCompatUtils.java
@@ -21,30 +21,29 @@ import android.view.inputmethod.InputMethodManager;
public final class InputConnectionCompatUtils {
private static final CompatUtils.ClassWrapper sInputConnectionType;
- private static final CompatUtils.ToBooleanMethodWrapper sRequestUpdateCursorAnchorInfoMethod;
+ private static final CompatUtils.ToBooleanMethodWrapper sRequestCursorUpdatesMethod;
static {
sInputConnectionType = new CompatUtils.ClassWrapper(InputConnection.class);
- sRequestUpdateCursorAnchorInfoMethod = sInputConnectionType.getPrimitiveMethod(
- "requestUpdateCursorAnchorInfo", false, int.class);
+ sRequestCursorUpdatesMethod = sInputConnectionType.getPrimitiveMethod(
+ "requestCursorUpdates", false, int.class);
}
- public static boolean isRequestUpdateCursorAnchorInfoAvailable() {
- return sRequestUpdateCursorAnchorInfoMethod != null;
+ public static boolean isRequestCursorUpdatesAvailable() {
+ return sRequestCursorUpdatesMethod != null;
}
/**
- * Local copies of some constants in CursorAnchorInfoRequest until the SDK becomes publicly
- * available.
+ * Local copies of some constants in InputConnection until the SDK becomes publicly available.
*/
- private static int REQUEST_UPDATE_CURSOR_UPDATE_IMMEDIATE = 1 << 0;
- private static int REQUEST_UPDATE_CURSOR_UPDATE_MONITOR = 1 << 1;
+ private static int CURSOR_UPDATE_IMMEDIATE = 1 << 0;
+ private static int CURSOR_UPDATE_MONITOR = 1 << 1;
- private static boolean requestUpdateCursorAnchorInfoImpl(final InputConnection inputConnection,
+ private static boolean requestCursorUpdatesImpl(final InputConnection inputConnection,
final int cursorUpdateMode) {
- if (!isRequestUpdateCursorAnchorInfoAvailable()) {
+ if (!isRequestCursorUpdatesAvailable()) {
return false;
}
- return sRequestUpdateCursorAnchorInfoMethod.invoke(inputConnection, cursorUpdateMode);
+ return sRequestCursorUpdatesMethod.invoke(inputConnection, cursorUpdateMode);
}
/**
@@ -56,11 +55,10 @@ public final class InputConnectionCompatUtils {
* as soon as possible to notify the current cursor/anchor position to the input method.
* @return {@code false} if the request is not handled. Otherwise returns {@code true}.
*/
- public static boolean requestUpdateCursorAnchorInfo(final InputConnection inputConnection,
+ public static boolean requestCursorUpdates(final InputConnection inputConnection,
final boolean enableMonitor, final boolean requestImmediateCallback) {
- final int cursorUpdateMode = (enableMonitor ? REQUEST_UPDATE_CURSOR_UPDATE_MONITOR : 0)
- | (requestImmediateCallback ? REQUEST_UPDATE_CURSOR_UPDATE_IMMEDIATE : 0);
- return requestUpdateCursorAnchorInfoImpl(inputConnection, cursorUpdateMode);
+ final int cursorUpdateMode = (enableMonitor ? CURSOR_UPDATE_MONITOR : 0)
+ | (requestImmediateCallback ? CURSOR_UPDATE_IMMEDIATE : 0);
+ return requestCursorUpdatesImpl(inputConnection, cursorUpdateMode);
}
-
}
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 05334c7f4..efa527e15 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -139,7 +139,7 @@ public class Key implements Comparable<Key> {
public static final int BACKGROUND_TYPE_STICKY_OFF = 3;
public static final int BACKGROUND_TYPE_STICKY_ON = 4;
public static final int BACKGROUND_TYPE_ACTION = 5;
- public static final int BACKGROUND_TYPE_CUSTOM_ACTION = 6;
+ public static final int BACKGROUND_TYPE_SPACEBAR = 6;
private final int mActionFlags;
private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01;
@@ -506,7 +506,7 @@ public class Key implements Comparable<Key> {
case BACKGROUND_TYPE_STICKY_OFF: return "stickyOff";
case BACKGROUND_TYPE_STICKY_ON: return "stickyOn";
case BACKGROUND_TYPE_ACTION: return "action";
- case BACKGROUND_TYPE_CUSTOM_ACTION: return "customAction";
+ case BACKGROUND_TYPE_SPACEBAR: return "spacebar";
default: return null;
}
}
@@ -889,8 +889,8 @@ public class Key implements Comparable<Key> {
new KeyBackgroundState(android.R.attr.state_checkable, android.R.attr.state_checked),
// 5: BACKGROUND_TYPE_ACTION
new KeyBackgroundState(android.R.attr.state_active),
- // 6: BACKGROUND_TYPE_CUSTOM_ACTION
- new KeyBackgroundState(android.R.attr.state_active, android.R.attr.state_checked)
+ // 6: BACKGROUND_TYPE_SPACEBAR
+ new KeyBackgroundState(),
};
}
@@ -904,7 +904,7 @@ public class Key implements Comparable<Key> {
final Drawable background;
if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
background = functionalKeyBackground;
- } else if (getCode() == Constants.CODE_SPACE) {
+ } else if (mBackgroundType == BACKGROUND_TYPE_SPACEBAR) {
background = spacebarBackground;
} else {
background = keyBackground;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java b/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java
index 0cd606d19..7161d3f26 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardTheme.java
@@ -32,6 +32,8 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
static final String KLP_KEYBOARD_THEME_KEY = "pref_keyboard_layout_20110916";
static final String LXX_KEYBOARD_THEME_KEY = "pref_keyboard_theme_20140509";
+ // These should be aligned with Keyboard.themeId and Keyboard.Case.keyboardTheme
+ // attributes' values in attrs.xml.
public static final int THEME_ID_ICS = 0;
public static final int THEME_ID_KLP = 2;
public static final int THEME_ID_LXX_LIGHT = 3;
@@ -39,16 +41,16 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
public static final int DEFAULT_THEME_ID = THEME_ID_KLP;
private static final KeyboardTheme[] KEYBOARD_THEMES = {
- new KeyboardTheme(THEME_ID_ICS, R.style.KeyboardTheme_ICS,
+ new KeyboardTheme(THEME_ID_ICS, "ICS", R.style.KeyboardTheme_ICS,
// This has never been selected because we support ICS or later.
VERSION_CODES.BASE),
- new KeyboardTheme(THEME_ID_KLP, R.style.KeyboardTheme_KLP,
+ new KeyboardTheme(THEME_ID_KLP, "KLP", R.style.KeyboardTheme_KLP,
// Default theme for ICS, JB, and KLP.
VERSION_CODES.ICE_CREAM_SANDWICH),
- new KeyboardTheme(THEME_ID_LXX_LIGHT, R.style.KeyboardTheme_LXX_Light,
+ new KeyboardTheme(THEME_ID_LXX_LIGHT, "LXXLight", R.style.KeyboardTheme_LXX_Light,
// Default theme for LXX.
BuildCompatUtils.VERSION_CODES_LXX),
- new KeyboardTheme(THEME_ID_LXX_DARK, R.style.KeyboardTheme_LXX_Dark,
+ new KeyboardTheme(THEME_ID_LXX_DARK, "LXXDark", R.style.KeyboardTheme_LXX_Dark,
VERSION_CODES.BASE),
};
@@ -59,12 +61,15 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
public final int mThemeId;
public final int mStyleId;
+ public final String mThemeName;
private final int mMinApiVersion;
// Note: The themeId should be aligned with "themeId" attribute of Keyboard style
// in values/themes-<style>.xml.
- private KeyboardTheme(final int themeId, final int styleId, final int minApiVersion) {
+ private KeyboardTheme(final int themeId, final String themeName, final int styleId,
+ final int minApiVersion) {
mThemeId = themeId;
+ mThemeName = themeName;
mStyleId = styleId;
mMinApiVersion = minApiVersion;
}
@@ -128,6 +133,11 @@ public final class KeyboardTheme implements Comparable<KeyboardTheme> {
return searchKeyboardThemeById(DEFAULT_THEME_ID);
}
+ public static String getKeyboardThemeName(final int themeId) {
+ final KeyboardTheme theme = searchKeyboardThemeById(themeId);
+ return theme.mThemeName;
+ }
+
public static void saveKeyboardThemeId(final String themeIdString,
final SharedPreferences prefs) {
saveKeyboardThemeId(themeIdString, prefs, BuildCompatUtils.EFFECTIVE_SDK_INT);
diff --git a/java/src/com/android/inputmethod/keyboard/TextDecorator.java b/java/src/com/android/inputmethod/keyboard/TextDecorator.java
index 178516134..9192853ca 100644
--- a/java/src/com/android/inputmethod/keyboard/TextDecorator.java
+++ b/java/src/com/android/inputmethod/keyboard/TextDecorator.java
@@ -276,10 +276,10 @@ public class TextDecorator {
final int lastCharRectIndex = composingTextStart + composingText.length() - 1;
final RectF lastCharRect = info.getCharacterRect(lastCharRectIndex);
final int lastCharRectFlag = info.getCharacterRectFlags(lastCharRectIndex);
- final int lastCharRectType =
- lastCharRectFlag & CursorAnchorInfoCompatWrapper.CHARACTER_RECT_TYPE_MASK;
- if (lastCharRect == null || matrix == null || lastCharRectType !=
- CursorAnchorInfoCompatWrapper.CHARACTER_RECT_TYPE_FULLY_VISIBLE) {
+ final boolean hasInvisibleRegionInLastCharRect =
+ (lastCharRectFlag & CursorAnchorInfoCompatWrapper.FLAG_HAS_INVISIBLE_REGION)
+ != 0;
+ if (lastCharRect == null || matrix == null || hasInvisibleRegionInLastCharRect) {
mUiOperator.hideUi();
return;
}
@@ -336,7 +336,8 @@ public class TextDecorator {
}
// In MODE_ADD_TO_DICTIONARY, we cannot retrieve the character position at all because
// of the lack of composing text. We will use the insertion marker position instead.
- if (info.isInsertionMarkerClipped()) {
+ if ((info.getInsertionMarkerFlags() &
+ CursorAnchorInfoCompatWrapper.FLAG_HAS_INVISIBLE_REGION) != 0) {
mUiOperator.hideUi();
return;
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index 8bff27574..fa4192790 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -31,6 +31,7 @@ import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
+import com.android.inputmethod.keyboard.KeyboardTheme;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.ResourceUtils;
@@ -643,6 +644,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean keyboardLayoutSetElementMatched = matchTypedValue(caseAttr,
R.styleable.Keyboard_Case_keyboardLayoutSetElement, id.mElementId,
KeyboardId.elementIdToName(id.mElementId));
+ final boolean keyboardThemeMacthed = matchTypedValue(caseAttr,
+ R.styleable.Keyboard_Case_keyboardTheme, mParams.mThemeId,
+ KeyboardTheme.getKeyboardThemeName(mParams.mThemeId));
final boolean modeMatched = matchTypedValue(caseAttr,
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
final boolean navigateNextMatched = matchBoolean(caseAttr,
@@ -671,19 +675,21 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean countryCodeMatched = matchString(caseAttr,
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
- && modeMatched && navigateNextMatched && navigatePreviousMatched
- && passwordInputMatched && clobberSettingsKeyMatched && hasShortcutKeyMatched
- && languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched
- && isIconDefinedMatched && localeCodeMatched && languageCodeMatched
- && countryCodeMatched;
+ && keyboardThemeMacthed && modeMatched && navigateNextMatched
+ && navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched
+ && hasShortcutKeyMatched && languageSwitchKeyEnabledMatched
+ && isMultiLineMatched && imeActionMatched && isIconDefinedMatched
+ && localeCodeMatched && languageCodeMatched && countryCodeMatched;
if (DEBUG) {
- startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
+ startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
textAttr(caseAttr.getString(
R.styleable.Keyboard_Case_keyboardLayoutSet), "keyboardLayoutSet"),
textAttr(caseAttr.getString(
R.styleable.Keyboard_Case_keyboardLayoutSetElement),
"keyboardLayoutSetElement"),
+ textAttr(caseAttr.getString(
+ R.styleable.Keyboard_Case_keyboardTheme), "keyboardTheme"),
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_mode), "mode"),
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_imeAction),
"imeAction"),
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index f1c7f4340..6b6384c48 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -922,13 +922,13 @@ public final class RichInputConnection {
* prevents the application from fulfilling the request. (TODO: Improve the API when it turns
* out that we actually need more detailed error codes)
*/
- public boolean requestUpdateCursorAnchorInfo(final boolean enableMonitor,
+ public boolean requestCursorUpdates(final boolean enableMonitor,
final boolean requestImmediateCallback) {
mIC = mParent.getCurrentInputConnection();
final boolean scheduled;
if (null != mIC) {
- scheduled = InputConnectionCompatUtils.requestUpdateCursorAnchorInfo(mIC,
- enableMonitor, requestImmediateCallback);
+ scheduled = InputConnectionCompatUtils.requestCursorUpdates(mIC, enableMonitor,
+ requestImmediateCallback);
} else {
scheduled = false;
}
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 4b5edb076..233a22512 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -167,7 +167,7 @@ public final class InputLogic {
if (ProductionFlags.ENABLE_CURSOR_ANCHOR_INFO_CALLBACK) {
// AcceptTypedWord feature relies on CursorAnchorInfo.
if (settingsValues.mShouldShowUiToAcceptTypedWord) {
- mConnection.requestUpdateCursorAnchorInfo(true /* enableMonitor */,
+ mConnection.requestCursorUpdates(true /* enableMonitor */,
true /* requestImmediateCallback */);
}
}