aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/WordComposer.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-11-29 00:48:29 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-11-29 00:48:29 -0800
commite30ceed86bd0bf12c86c8bf56d06c6f423cd8876 (patch)
tree97d7e0954012a10f3ce0d339e7d6103b0a039ddc /java/src/com/android/inputmethod/latin/WordComposer.java
parent0d8dde1185ab495eb3dee091f7a6ba2e131e7f54 (diff)
parent117fc18ed46496c81596f8207bba30a09c7317d1 (diff)
downloadlatinime-e30ceed86bd0bf12c86c8bf56d06c6f423cd8876.tar.gz
latinime-e30ceed86bd0bf12c86c8bf56d06c6f423cd8876.tar.xz
latinime-e30ceed86bd0bf12c86c8bf56d06c6f423cd8876.zip
am 117fc18e: Keep count of the trailing single quotes for suggestions
* commit '117fc18ed46496c81596f8207bba30a09c7317d1': Keep count of the trailing single quotes for suggestions
Diffstat (limited to 'java/src/com/android/inputmethod/latin/WordComposer.java')
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 612b16071..f4d0c1e4f 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -44,7 +44,7 @@ public class WordComposer {
private boolean mAutoCapitalized;
// Cache this value for performance
- private boolean mIsLastCharASingleQuote;
+ private int mTrailingSingleQuotesCount;
/**
* Whether the user chose to capitalize the first char of the word.
@@ -57,7 +57,7 @@ public class WordComposer {
mTypedWord = new StringBuilder(N);
mXCoordinates = new int[N];
mYCoordinates = new int[N];
- mIsLastCharASingleQuote = false;
+ mTrailingSingleQuotesCount = 0;
}
public WordComposer(WordComposer source) {
@@ -72,7 +72,7 @@ public class WordComposer {
mCapsCount = source.mCapsCount;
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized;
- mIsLastCharASingleQuote = source.mIsLastCharASingleQuote;
+ mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount;
}
/**
@@ -83,7 +83,7 @@ public class WordComposer {
mTypedWord.setLength(0);
mCapsCount = 0;
mIsFirstCharCapitalized = false;
- mIsLastCharASingleQuote = false;
+ mTrailingSingleQuotesCount = 0;
}
/**
@@ -133,7 +133,11 @@ public class WordComposer {
mIsFirstCharCapitalized = isFirstCharCapitalized(
newIndex, primaryCode, mIsFirstCharCapitalized);
if (Character.isUpperCase(primaryCode)) mCapsCount++;
- mIsLastCharASingleQuote = Keyboard.CODE_SINGLE_QUOTE == primaryCode;
+ if (Keyboard.CODE_SINGLE_QUOTE == primaryCode) {
+ ++mTrailingSingleQuotesCount;
+ } else {
+ mTrailingSingleQuotesCount = 0;
+ }
}
/**
@@ -165,10 +169,14 @@ public class WordComposer {
}
if (size() == 0) {
mIsFirstCharCapitalized = false;
- mIsLastCharASingleQuote = false;
+ }
+ if (mTrailingSingleQuotesCount > 0) {
+ --mTrailingSingleQuotesCount;
} else {
- mIsLastCharASingleQuote =
- Keyboard.CODE_SINGLE_QUOTE == mTypedWord.codePointAt(mTypedWord.length() - 1);
+ for (int i = mTypedWord.length() - 1; i >= 0; --i) {
+ if (Keyboard.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break;
+ ++mTrailingSingleQuotesCount;
+ }
}
}
@@ -191,8 +199,8 @@ public class WordComposer {
return mIsFirstCharCapitalized;
}
- public boolean isLastCharASingleQuote() {
- return mIsLastCharASingleQuote;
+ public int trailingSingleQuotesCount() {
+ return mTrailingSingleQuotesCount;
}
/**