aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-12-20 02:40:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-12-20 02:40:53 +0000
commit00a2f21eeb0296124b65581b83a7364c2befe3d9 (patch)
tree6f653a0284b51fa3f93c97b4f84a43ab93de0cae /java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
parentc34b4c0744fd952f51034265971ff8b1dab5ebf1 (diff)
parent48ba1f25ffb40780fb97093ee9a8ce118a801740 (diff)
downloadlatinime-00a2f21eeb0296124b65581b83a7364c2befe3d9.tar.gz
latinime-00a2f21eeb0296124b65581b83a7364c2befe3d9.tar.xz
latinime-00a2f21eeb0296124b65581b83a7364c2befe3d9.zip
Merge "[IL14] Move getCurrent*Caps* to InputLogic"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java48
1 files changed, 43 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 2f9221071..54d789859 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -373,7 +373,7 @@ public final class InputLogic {
// We pass 1 to getPreviousWordForSuggestion because we were not composing a word
// yet, so the word we want is the 1st word before the cursor.
mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime(
- getActualCapsMode(keyboardSwitcher),
+ getActualCapsMode(settingsValues, keyboardSwitcher),
getNthPreviousWordForSuggestion(settingsValues, 1 /* nthPreviousWord */));
}
mConnection.setComposingText(getTextWithUnderline(
@@ -644,7 +644,7 @@ public final class InputLogic {
* Handle a press on the language switch key (the "globe key")
*/
private void handleLanguageSwitchKey() {
- mLatinIME.handleLanguageSwitchKey();
+ mLatinIME.switchToNextSubtype();
}
/**
@@ -907,14 +907,15 @@ public final class InputLogic {
/**
* Factor in auto-caps and manual caps and compute the current caps mode.
+ * @param settingsValues the current settings values.
* @param keyboardSwitcher the keyboard switcher. Caps mode depends on its mode.
* @return the actual caps mode the keyboard is in right now.
*/
- // TODO: Make this private
- public int getActualCapsMode(final KeyboardSwitcher keyboardSwitcher) {
+ public int getActualCapsMode(final SettingsValues settingsValues,
+ final KeyboardSwitcher keyboardSwitcher) {
final int keyboardShiftMode = keyboardSwitcher.getKeyboardShiftMode();
if (keyboardShiftMode != WordComposer.CAPS_MODE_AUTO_SHIFTED) return keyboardShiftMode;
- final int auto = mLatinIME.getCurrentAutoCapsState();
+ final int auto = getCurrentAutoCapsState(settingsValues);
if (0 != (auto & TextUtils.CAP_MODE_CHARACTERS)) {
return WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED;
}
@@ -925,6 +926,43 @@ public final class InputLogic {
}
/**
+ * Gets the current auto-caps state, factoring in the space state.
+ *
+ * This method tries its best to do this in the most efficient possible manner. It avoids
+ * getting text from the editor if possible at all.
+ * This is called from the KeyboardSwitcher (through a trampoline in LatinIME) because it
+ * needs to know auto caps state to display the right layout.
+ *
+ * @param optionalSettingsValues settings values, or null if we should just get the current ones
+ * from the singleton.
+ * @return a caps mode from TextUtils.CAP_MODE_* or Constants.TextUtils.CAP_MODE_OFF.
+ */
+ public int getCurrentAutoCapsState(final SettingsValues optionalSettingsValues) {
+ // If we are in a batch edit, we need to use the same settings values as the outside
+ // code, that will pass it to us. Otherwise, we can just take the current values.
+ final SettingsValues settingsValues = null != optionalSettingsValues
+ ? optionalSettingsValues : Settings.getInstance().getCurrent();
+ if (!settingsValues.mAutoCap) return Constants.TextUtils.CAP_MODE_OFF;
+
+ final EditorInfo ei = getCurrentInputEditorInfo();
+ if (ei == null) return Constants.TextUtils.CAP_MODE_OFF;
+ final int inputType = ei.inputType;
+ // Warning: this depends on mSpaceState, which may not be the most current value. If
+ // mSpaceState gets updated later, whoever called this may need to be told about it.
+ return mConnection.getCursorCapsMode(inputType, settingsValues,
+ SpaceState.PHANTOM == mSpaceState);
+ }
+
+ public int getCurrentRecapitalizeState() {
+ if (!mRecapitalizeStatus.isActive()
+ || !mRecapitalizeStatus.isSetAt(mLastSelectionStart, mLastSelectionEnd)) {
+ // Not recapitalizing at the moment
+ return RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE;
+ }
+ return mRecapitalizeStatus.getCurrentMode();
+ }
+
+ /**
* @return the editor info for the current editor
*/
private EditorInfo getCurrentInputEditorInfo() {