aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java3
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java30
-rw-r--r--java/src/com/android/inputmethod/latin/DebugSettings.java8
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java87
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputMethodManager.java5
5 files changed, 85 insertions, 48 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index e08536b43..203036998 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -1086,6 +1086,9 @@ public final class KeyboardTextsSet {
/* 101 */ null,
// U+00BF: "¿" INVERTED QUESTION MARK
/* 102 */ "?,\u00BF",
+ /* 103 */ "\"",
+ /* 104 */ "\'",
+ /* 105 */ "\'",
};
/* Language et: Estonian */
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index bed31a7d1..5eab292fc 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -160,6 +160,9 @@ public final class BinaryDictionaryFileDumper {
for (int mode = MODE_MIN; mode <= MODE_MAX; ++mode) {
InputStream originalSourceStream = null;
InputStream inputStream = null;
+ InputStream uncompressedStream = null;
+ InputStream decryptedStream = null;
+ BufferedInputStream bufferedStream = null;
File outputFile = null;
FileOutputStream outputStream = null;
AssetFileDescriptor afd = null;
@@ -179,18 +182,19 @@ public final class BinaryDictionaryFileDumper {
// Get the appropriate decryption method for this try
switch (mode) {
case COMPRESSED_CRYPTED_COMPRESSED:
- inputStream = FileTransforms.getUncompressedStream(
- FileTransforms.getDecryptedStream(
- FileTransforms.getUncompressedStream(
- originalSourceStream)));
+ uncompressedStream =
+ FileTransforms.getUncompressedStream(originalSourceStream);
+ decryptedStream = FileTransforms.getDecryptedStream(uncompressedStream);
+ inputStream = FileTransforms.getUncompressedStream(decryptedStream);
break;
case CRYPTED_COMPRESSED:
- inputStream = FileTransforms.getUncompressedStream(
- FileTransforms.getDecryptedStream(originalSourceStream));
+ decryptedStream = FileTransforms.getDecryptedStream(originalSourceStream);
+ inputStream = FileTransforms.getUncompressedStream(decryptedStream);
break;
case COMPRESSED_CRYPTED:
- inputStream = FileTransforms.getDecryptedStream(
- FileTransforms.getUncompressedStream(originalSourceStream));
+ uncompressedStream =
+ FileTransforms.getUncompressedStream(originalSourceStream);
+ inputStream = FileTransforms.getDecryptedStream(uncompressedStream);
break;
case COMPRESSED_ONLY:
inputStream = FileTransforms.getUncompressedStream(originalSourceStream);
@@ -201,8 +205,9 @@ public final class BinaryDictionaryFileDumper {
case NONE:
inputStream = originalSourceStream;
break;
- }
- checkMagicAndCopyFileTo(new BufferedInputStream(inputStream), outputStream);
+ }
+ bufferedStream = new BufferedInputStream(inputStream);
+ checkMagicAndCopyFileTo(bufferedStream, outputStream);
outputStream.flush();
outputStream.close();
final File finalFile = new File(finalFileName);
@@ -234,8 +239,11 @@ public final class BinaryDictionaryFileDumper {
try {
// inputStream.close() will close afd, we should not call afd.close().
if (null != inputStream) inputStream.close();
+ if (null != uncompressedStream) uncompressedStream.close();
+ if (null != decryptedStream) decryptedStream.close();
+ if (null != bufferedStream) bufferedStream.close();
} catch (Exception e) {
- Log.e(TAG, "Exception while closing a cross-process file descriptor : " + e);
+ Log.e(TAG, "Exception while closing a file descriptor : " + e);
}
try {
if (null != outputStream) outputStream.close();
diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java
index 3af3cab2c..731b9baf5 100644
--- a/java/src/com/android/inputmethod/latin/DebugSettings.java
+++ b/java/src/com/android/inputmethod/latin/DebugSettings.java
@@ -37,6 +37,8 @@ public final class DebugSettings extends PreferenceFragment
private static final String DEBUG_MODE_KEY = "debug_mode";
public static final String FORCE_NON_DISTINCT_MULTITOUCH_KEY = "force_non_distinct_multitouch";
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
+ private static final String PREF_STATISTICS_LOGGING_KEY = "enable_logging";
+ private static final boolean SHOW_STATISTICS_LOGGING = false;
private boolean mServiceNeedsRestart = false;
private CheckBoxPreference mDebugMode;
@@ -55,6 +57,12 @@ public final class DebugSettings extends PreferenceFragment
ResearchLogger.DEFAULT_USABILITY_STUDY_MODE));
checkbox.setSummary(R.string.settings_warning_researcher_mode);
}
+ final Preference statisticsLoggingPref = findPreference(PREF_STATISTICS_LOGGING_KEY);
+ if (statisticsLoggingPref instanceof CheckBoxPreference) {
+ if (!SHOW_STATISTICS_LOGGING) {
+ getPreferenceScreen().removePreference(statisticsLoggingPref);
+ }
+ }
mServiceNeedsRestart = false;
mDebugMode = (CheckBoxPreference) findPreference(DEBUG_MODE_KEY);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3dfffc4a6..5f7907326 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -56,7 +56,6 @@ import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.accessibility.AccessibilityUtils;
@@ -142,7 +141,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private SharedPreferences mPrefs;
@UsedForTesting final KeyboardSwitcher mKeyboardSwitcher;
private final SubtypeSwitcher mSubtypeSwitcher;
- private boolean mShouldSwitchToLastSubtype = true;
+ private final SubtypeState mSubtypeState = new SubtypeState();
private boolean mIsMainDictionaryAvailable;
private UserBinaryDictionary mUserDictionary;
@@ -366,6 +365,33 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
}
}
+ static final class SubtypeState {
+ private InputMethodSubtype mLastActiveSubtype;
+ private boolean mCurrentSubtypeUsed;
+
+ public void currentSubtypeUsed() {
+ mCurrentSubtypeUsed = true;
+ }
+
+ public void switchSubtype(final IBinder token, final RichInputMethodManager richImm) {
+ final InputMethodSubtype currentSubtype = richImm.getInputMethodManager()
+ .getCurrentInputMethodSubtype();
+ final InputMethodSubtype lastActiveSubtype = mLastActiveSubtype;
+ final boolean currentSubtypeUsed = mCurrentSubtypeUsed;
+ if (currentSubtypeUsed) {
+ mLastActiveSubtype = currentSubtype;
+ mCurrentSubtypeUsed = false;
+ }
+ if (currentSubtypeUsed
+ && richImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastActiveSubtype)
+ && !currentSubtype.equals(lastActiveSubtype)) {
+ richImm.setInputMethodAndSubtype(token, lastActiveSubtype);
+ return;
+ }
+ richImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
+ }
+ }
+
public LatinIME() {
super();
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
@@ -710,21 +736,17 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
updateFullscreenMode();
mApplicationSpecifiedCompletions = null;
- if (isDifferentTextField || selectionChanged) {
- // If the selection changed, we reset the input state. Essentially, we come here with
- // restarting == true when the app called setText() or similar. We should reset the
- // state if the app set the text to something else, but keep it if it set a suggestion
- // or something.
- mEnteredText = null;
- resetComposingState(true /* alsoResetLastComposedWord */);
- mDeleteCount = 0;
- mSpaceState = SPACE_STATE_NONE;
+ // The app calling setText() has the effect of clearing the composing
+ // span, so we should reset our state unconditionally, even if restarting is true.
+ mEnteredText = null;
+ resetComposingState(true /* alsoResetLastComposedWord */);
+ mDeleteCount = 0;
+ mSpaceState = SPACE_STATE_NONE;
- if (mSuggestionStripView != null) {
- // This will set the punctuation suggestions if next word suggestion is off;
- // otherwise it will clear the suggestion strip.
- setPunctuationSuggestions();
- }
+ if (mSuggestionStripView != null) {
+ // This will set the punctuation suggestions if next word suggestion is off;
+ // otherwise it will clear the suggestion strip.
+ setPunctuationSuggestions();
}
mConnection.resetCachesUponCursorMove(editorInfo.initialSelStart);
@@ -897,6 +919,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// Make a note of the cursor position
mLastSelectionStart = newSelStart;
mLastSelectionEnd = newSelEnd;
+ mSubtypeState.currentSubtypeUsed();
}
/**
@@ -1244,20 +1267,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mRichImm.switchToNextInputMethod(token, false /* onlyCurrentIme */);
return;
}
- if (mShouldSwitchToLastSubtype) {
- final InputMethodManager imm = mRichImm.getInputMethodManager();
- final InputMethodSubtype lastSubtype = imm.getLastInputMethodSubtype();
- final boolean lastSubtypeBelongsToThisIme =
- mRichImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastSubtype);
- if (lastSubtypeBelongsToThisIme && imm.switchToLastInputMethod(token)) {
- mShouldSwitchToLastSubtype = false;
- } else {
- mRichImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
- mShouldSwitchToLastSubtype = true;
- }
- } else {
- mRichImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
- }
+ mSubtypeState.switchSubtype(token, mRichImm);
}
private void sendDownUpKeyEventForBackwardCompatibility(final int code) {
@@ -1326,7 +1336,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
handleBackspace(spaceState);
mDeleteCount++;
mExpectingUpdateSelection = true;
- mShouldSwitchToLastSubtype = true;
LatinImeLogger.logOnDelete(x, y);
break;
case Constants.CODE_SHIFT:
@@ -1382,7 +1391,6 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
handleCharacter(primaryCode, keyX, keyY, spaceState);
}
mExpectingUpdateSelection = true;
- mShouldSwitchToLastSubtype = true;
break;
}
switcher.onCodeInput(primaryCode);
@@ -1411,7 +1419,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mHandler.postUpdateSuggestionStrip();
final String text = specificTldProcessingOnTextInput(rawText);
if (SPACE_STATE_PHANTOM == mSpaceState) {
- sendKeyCodePoint(Constants.CODE_SPACE);
+ promotePhantomSpace();
}
mConnection.commitText(text, 1);
mConnection.endBatchEdit();
@@ -1574,7 +1582,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mWordComposer.setBatchInputWord(batchInputText);
mConnection.beginBatchEdit();
if (SPACE_STATE_PHANTOM == mSpaceState) {
- sendKeyCodePoint(Constants.CODE_SPACE);
+ promotePhantomSpace();
}
mConnection.setComposingText(batchInputText, 1);
mExpectingUpdateSelection = true;
@@ -1729,7 +1737,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// Sanity check
throw new RuntimeException("Should not be composing here");
}
- sendKeyCodePoint(Constants.CODE_SPACE);
+ promotePhantomSpace();
}
// NOTE: isCursorTouchingWord() is a blocking IPC call, so it often takes several
@@ -1806,7 +1814,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
if (SPACE_STATE_PHANTOM == spaceState &&
mCurrentSettings.isPhantomSpacePromotingSymbol(primaryCode)) {
- sendKeyCodePoint(Constants.CODE_SPACE);
+ promotePhantomSpace();
}
sendKeyCodePoint(primaryCode);
@@ -2070,7 +2078,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
int firstChar = Character.codePointAt(suggestion, 0);
if ((!mCurrentSettings.isWeakSpaceStripper(firstChar))
&& (!mCurrentSettings.isWeakSpaceSwapper(firstChar))) {
- sendKeyCodePoint(Constants.CODE_SPACE);
+ promotePhantomSpace();
}
}
@@ -2247,6 +2255,11 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mHandler.postUpdateSuggestionStrip();
}
+ // This essentially inserts a space, and that's it.
+ public void promotePhantomSpace() {
+ sendKeyCodePoint(Constants.CODE_SPACE);
+ }
+
// Used by the RingCharBuffer
public boolean isWordSeparator(final int code) {
return mCurrentSettings.isWordSeparator(code);
diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
index d7055f747..b3832303d 100644
--- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
+++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
@@ -206,6 +206,11 @@ public final class RichInputMethodManager {
return null;
}
+ public void setInputMethodAndSubtype(final IBinder token, final InputMethodSubtype subtype) {
+ mImmWrapper.mImm.setInputMethodAndSubtype(
+ token, mInputMethodInfoOfThisIme.getId(), subtype);
+ }
+
public void setAdditionalInputMethodSubtypes(final InputMethodSubtype[] subtypes) {
mImmWrapper.mImm.setAdditionalInputMethodSubtypes(
mInputMethodInfoOfThisIme.getId(), subtypes);