aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-06-16 09:54:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-10 22:31:57 +0000
commit8a23703763fdbda06f1d272f47064334a5eeda14 (patch)
tree0026bf97e6c9cd1d3b546dc11c122090a290225d /java/src
parent37c49f63dfe5cd2385d808cd113a3b46603fc5d4 (diff)
parentdeccc23564304b11d58590041f25adffdf6e1b6a (diff)
downloadlatinime-8a23703763fdbda06f1d272f47064334a5eeda14.tar.gz
latinime-8a23703763fdbda06f1d272f47064334a5eeda14.tar.xz
latinime-8a23703763fdbda06f1d272f47064334a5eeda14.zip
Merge "[CM1] Let predictions be aware of capitalize mode."
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java14
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java3
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java28
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java19
4 files changed, 47 insertions, 17 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 5c55faa93..a8f9efb05 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1389,18 +1389,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
callback.onGetSuggestedWords(SuggestedWords.EMPTY);
return;
}
- final SettingsValues currentSettings = mSettings.getCurrent();
- final int[] additionalFeaturesOptions = currentSettings.mAdditionalFeaturesSettingValues;
- mInputLogic.mSuggest.getSuggestedWords(mInputLogic.mWordComposer,
- mInputLogic.getPrevWordsInfoFromNthPreviousWordForSuggestion(
- currentSettings.mSpacingAndPunctuations,
- // Get the word on which we should search the bigrams. If we are composing
- // a word, it's whatever is *before* the half-committed word in the buffer,
- // hence 2; if we aren't, we should just skip whitespace if any, so 1.
- mInputLogic.mWordComposer.isComposingWord() ? 2 : 1),
- keyboard.getProximityInfo(), currentSettings.mBlockPotentiallyOffensive,
- currentSettings.mAutoCorrectionEnabled, additionalFeaturesOptions, sessionId,
- sequenceNumber, callback);
+ mInputLogic.getSuggestedWords(mSettings.getCurrent(), keyboard.getProximityInfo(),
+ mKeyboardSwitcher.getKeyboardShiftMode(), sessionId, sequenceNumber, callback);
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 1ba5d5ea6..670d856e3 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -110,7 +110,8 @@ public final class Suggest {
wordComposer, prevWordsInfo, proximityInfo, blockOffensiveWords,
additionalFeaturesOptions, SESSION_TYPING, rawSuggestions);
- final boolean isOnlyFirstCharCapitalized = wordComposer.isOnlyFirstCharCapitalized();
+ final boolean isOnlyFirstCharCapitalized =
+ wordComposer.isOrWillBeOnlyFirstCharCapitalized();
// If resumed, then we don't want to upcase everything: resuming on a fully-capitalized
// words is rarely done to switch to another fully-capitalized word, but usually to a
// normal, non-capitalized suggestion.
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 6ce1f85c5..21fe7e0eb 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -310,12 +310,18 @@ public final class WordComposer {
}
/**
- * Whether or not the user typed a capital letter as the first letter in the word, and no
- * other letter is capitalized
+ * Whether this composer is composing or about to compose a word in which only the first letter
+ * is a capital.
+ *
+ * If we do have a composing word, we just return whether the word has indeed only its first
+ * character capitalized. If we don't, then we return a value based on the capitalized mode,
+ * which tell us what is likely to happen for the next composing word.
+ *
* @return capitalization preference
*/
- public boolean isOnlyFirstCharCapitalized() {
- return mIsOnlyFirstCharCapitalized;
+ public boolean isOrWillBeOnlyFirstCharCapitalized() {
+ return isComposingWord() ? mIsOnlyFirstCharCapitalized
+ : (CAPS_MODE_OFF != mCapitalizedMode);
}
/**
@@ -366,6 +372,20 @@ public final class WordComposer {
}
/**
+ * Before fetching suggestions, we don't necessarily know about the capitalized mode yet.
+ *
+ * If we don't have a composing word yet, we take a note of this mode so that we can then
+ * supply this information to the suggestion process. If we have a composing word, then
+ * the previous mode has priority over this.
+ * @param mode the mode just before fetching suggestions
+ */
+ public void adviseCapitalizedModeBeforeFetchingSuggestions(final int mode) {
+ if (!isComposingWord()) {
+ mCapitalizedMode = mode;
+ }
+ }
+
+ /**
* Returns whether the word was automatically capitalized.
* @return whether the word was automatically capitalized
*/
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 24cc1ef0d..de0c97a8f 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -30,6 +30,7 @@ import com.android.inputmethod.compat.SuggestionSpanUtils;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.event.InputTransaction;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
+import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.DictionaryFacilitator;
@@ -1917,4 +1918,22 @@ public final class InputLogic {
}
return true;
}
+
+ public void getSuggestedWords(final SettingsValues settingsValues,
+ final ProximityInfo proximityInfo, final int keyboardShiftMode, final int sessionId,
+ final int sequenceNumber, final OnGetSuggestedWordsCallback callback) {
+ mWordComposer.adviseCapitalizedModeBeforeFetchingSuggestions(
+ getActualCapsMode(settingsValues, keyboardShiftMode));
+ mSuggest.getSuggestedWords(mWordComposer,
+ getPrevWordsInfoFromNthPreviousWordForSuggestion(
+ settingsValues.mSpacingAndPunctuations,
+ // Get the word on which we should search the bigrams. If we are composing
+ // a word, it's whatever is *before* the half-committed word in the buffer,
+ // hence 2; if we aren't, we should just skip whitespace if any, so 1.
+ mWordComposer.isComposingWord() ? 2 : 1),
+ proximityInfo, settingsValues.mBlockPotentiallyOffensive,
+ settingsValues.mAutoCorrectionEnabled,
+ settingsValues.mAdditionalFeaturesSettingValues,
+ sessionId, sequenceNumber, callback);
+ }
}