aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-11-21 13:07:31 +0900
committerJean Chalard <jchalard@google.com>2012-11-21 13:07:31 +0900
commite36af707c8a8705ebd19fcc359c51181f7ebd171 (patch)
treefbae289dfb76e703f53ace1afea4ebdea7d52b99 /java/src
parent41a77f9e6ef6470f7f947e08466983c055a516e7 (diff)
parentb7e6bbaebcfc0707890cd17a15f70688a01217a7 (diff)
downloadlatinime-e36af707c8a8705ebd19fcc359c51181f7ebd171.tar.gz
latinime-e36af707c8a8705ebd19fcc359c51181f7ebd171.tar.xz
latinime-e36af707c8a8705ebd19fcc359c51181f7ebd171.zip
resolved conflicts for merge of b7e6bbae to master
Change-Id: Ic02809190721472d138532d2189328519117e042
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/InputAttributes.java5
-rw-r--r--java/src/com/android/inputmethod/latin/InputTypeUtils.java33
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java4
4 files changed, 36 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/InputAttributes.java b/java/src/com/android/inputmethod/latin/InputAttributes.java
index 6c1e0301a..1c5bff383 100644
--- a/java/src/com/android/inputmethod/latin/InputAttributes.java
+++ b/java/src/com/android/inputmethod/latin/InputAttributes.java
@@ -29,6 +29,7 @@ public final class InputAttributes {
final public boolean mInputTypeNoAutoCorrect;
final public boolean mIsSettingsSuggestionStripOn;
final public boolean mApplicationSpecifiedCompletionOn;
+ final public boolean mShouldInsertSpacesAutomatically;
final private int mInputType;
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) {
@@ -54,6 +55,7 @@ public final class InputAttributes {
mIsSettingsSuggestionStripOn = false;
mInputTypeNoAutoCorrect = false;
mApplicationSpecifiedCompletionOn = false;
+ mShouldInsertSpacesAutomatically = false;
} else {
final int variation = inputType & InputType.TYPE_MASK_VARIATION;
final boolean flagNoSuggestions =
@@ -65,6 +67,7 @@ public final class InputAttributes {
final boolean flagAutoComplete =
0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
+ // TODO: Have a helper method in InputTypeUtils
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
if (InputTypeUtils.isPasswordInputType(inputType)
|| InputTypeUtils.isVisiblePasswordInputType(inputType)
@@ -78,6 +81,8 @@ public final class InputAttributes {
mIsSettingsSuggestionStripOn = true;
}
+ mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);
+
// If it's a browser edit field and auto correct is not ON explicitly, then
// disable auto correction, but keep suggestions on.
// If NO_SUGGESTIONS is set, don't do prediction.
diff --git a/java/src/com/android/inputmethod/latin/InputTypeUtils.java b/java/src/com/android/inputmethod/latin/InputTypeUtils.java
index 500866a13..9a4503bf4 100644
--- a/java/src/com/android/inputmethod/latin/InputTypeUtils.java
+++ b/java/src/com/android/inputmethod/latin/InputTypeUtils.java
@@ -29,31 +29,37 @@ public final class InputTypeUtils implements InputType {
TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD;
private static final int TEXT_VISIBLE_PASSWORD_INPUT_TYPE =
TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
+ private static final int[] SUPPRESSING_AUTO_SPACES_FIELD_VARIATION = {
+ InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS,
+ InputType.TYPE_TEXT_VARIATION_PASSWORD,
+ InputType.TYPE_TEXT_VARIATION_URI,
+ InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD,
+ InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD };
private InputTypeUtils() {
// This utility class is not publicly instantiable.
}
- private static boolean isWebEditTextInputType(int inputType) {
+ private static boolean isWebEditTextInputType(final int inputType) {
return inputType == (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
}
- private static boolean isWebPasswordInputType(int inputType) {
+ private static boolean isWebPasswordInputType(final int inputType) {
return WEB_TEXT_PASSWORD_INPUT_TYPE != 0
&& inputType == WEB_TEXT_PASSWORD_INPUT_TYPE;
}
- private static boolean isWebEmailAddressInputType(int inputType) {
+ private static boolean isWebEmailAddressInputType(final int inputType) {
return WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE != 0
&& inputType == WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE;
}
- private static boolean isNumberPasswordInputType(int inputType) {
+ private static boolean isNumberPasswordInputType(final int inputType) {
return NUMBER_PASSWORD_INPUT_TYPE != 0
&& inputType == NUMBER_PASSWORD_INPUT_TYPE;
}
- private static boolean isTextPasswordInputType(int inputType) {
+ private static boolean isTextPasswordInputType(final int inputType) {
return inputType == TEXT_PASSWORD_INPUT_TYPE;
}
@@ -61,12 +67,12 @@ public final class InputTypeUtils implements InputType {
return variation == TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
}
- public static boolean isEmailVariation(int variation) {
+ public static boolean isEmailVariation(final int variation) {
return variation == TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|| isWebEmailAddressVariation(variation);
}
- public static boolean isWebInputType(int inputType) {
+ public static boolean isWebInputType(final int inputType) {
final int maskedInputType =
inputType & (TYPE_MASK_CLASS | TYPE_MASK_VARIATION);
return isWebEditTextInputType(maskedInputType) || isWebPasswordInputType(maskedInputType)
@@ -74,7 +80,7 @@ public final class InputTypeUtils implements InputType {
}
// Please refer to TextView.isPasswordInputType
- public static boolean isPasswordInputType(int inputType) {
+ public static boolean isPasswordInputType(final int inputType) {
final int maskedInputType =
inputType & (TYPE_MASK_CLASS | TYPE_MASK_VARIATION);
return isTextPasswordInputType(maskedInputType) || isWebPasswordInputType(maskedInputType)
@@ -82,9 +88,18 @@ public final class InputTypeUtils implements InputType {
}
// Please refer to TextView.isVisiblePasswordInputType
- public static boolean isVisiblePasswordInputType(int inputType) {
+ public static boolean isVisiblePasswordInputType(final int inputType) {
final int maskedInputType =
inputType & (TYPE_MASK_CLASS | TYPE_MASK_VARIATION);
return maskedInputType == TEXT_VISIBLE_PASSWORD_INPUT_TYPE;
}
+
+ public static boolean isAutoSpaceFriendlyType(final int inputType) {
+ if (TYPE_CLASS_TEXT != (TYPE_MASK_CLASS & inputType)) return false;
+ final int variation = TYPE_MASK_VARIATION & inputType;
+ for (final int fieldVariation : SUPPRESSING_AUTO_SPACES_FIELD_VARIATION) {
+ if (variation == fieldVariation) return false;
+ }
+ return true;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index f6c5f8277..e3508ac44 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2252,7 +2252,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// This essentially inserts a space, and that's it.
public void promotePhantomSpace() {
- sendKeyCodePoint(Constants.CODE_SPACE);
+ if (mCurrentSettings.shouldInsertSpacesAutomatically()) {
+ sendKeyCodePoint(Constants.CODE_SPACE);
+ }
}
// Used by the RingCharBuffer
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 61536b573..d6daa0d26 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -271,6 +271,10 @@ public final class SettingsValues {
return mPhantomSpacePromotingSymbols.contains(String.valueOf((char)code));
}
+ public boolean shouldInsertSpacesAutomatically() {
+ return mInputAttributes.mShouldInsertSpacesAutomatically;
+ }
+
private static boolean isAutoCorrectEnabled(final Resources res,
final String currentAutoCorrectionSetting) {
final String autoCorrectionOff = res.getString(