aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-04-15 17:33:48 +0900
committerJean Chalard <jchalard@google.com>2013-04-16 18:03:49 +0900
commit73ec85b8ad3102ce1c7e6013be73afe83475e589 (patch)
tree7d1545c756bf5ab4cd1f6a2e14acc11645808a58 /java/src/com/android/inputmethod/latin/RichInputConnection.java
parent252412d7eb4573f91588b06b0fe49ef9f0ac38ac (diff)
downloadlatinime-73ec85b8ad3102ce1c7e6013be73afe83475e589.tar.gz
latinime-73ec85b8ad3102ce1c7e6013be73afe83475e589.tar.xz
latinime-73ec85b8ad3102ce1c7e6013be73afe83475e589.zip
Don't insert automatic spaces when text looks like a URL
This is about as ad-hoc as it gets, but then again, what we want is probably as ad-hoc as it gets. All URL boxes I know of double as search bars, and not adding automatic spaces there sucks (e.g. in Chrome URL bar). And in other boxes actually you don't want to add a space if it looks like a URL. QSB isn't even a search box, and it behaves like this. So I think this is actually the right answer to the problem. Bug: 7062925 Change-Id: Ib09472b34644fd5bf2dc84bb97cedeeba28bcd02
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index e17846618..8ed7ab264 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
import android.inputmethodservice.InputMethodService;
import android.text.SpannableString;
import android.text.TextUtils;
-import android.text.style.SuggestionSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
@@ -721,4 +720,15 @@ public final class RichInputConnection {
// position and the expected position, then it must be a belated update.
return (newSelStart - oldSelStart) * (mCurrentCursorPosition - newSelStart) >= 0;
}
+
+ /**
+ * Looks at the text just before the cursor to find out if it looks like a URL.
+ *
+ * The weakest point here is, if we don't have enough text bufferized, we may fail to realize
+ * we are in URL situation, but other places in this class have the same limitation and it
+ * does not matter too much in the practice.
+ */
+ public boolean textBeforeCursorLooksLikeURL() {
+ return StringUtils.lastPartLooksLikeURL(mCommittedTextBeforeComposingText);
+ }
}