aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java21
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java2
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java18
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java47
-rw-r--r--java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java2
5 files changed, 30 insertions, 60 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index ad30b746e..e7be6de4c 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -146,7 +146,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// More keys keyboard
private final Paint mBackgroundDimAlphaPaint = new Paint();
- private boolean mNeedsToDimEntireKeyboard;
private final View mMoreKeysKeyboardContainer;
private final View mMoreKeysKeyboardForActionContainer;
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = new WeakHashMap<>();
@@ -673,7 +672,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
locatePreviewPlacerView();
panel.showInParent(mDrawingPreviewPlacerView);
mMoreKeysPanel = panel;
- dimEntireKeyboard(true /* dimmed */);
}
public boolean isShowingMoreKeysPanel() {
@@ -687,7 +685,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override
public void onDismissMoreKeysPanel() {
- dimEntireKeyboard(false /* dimmed */);
if (isShowingMoreKeysPanel()) {
mMoreKeysPanel.removeFromParent();
mMoreKeysPanel = null;
@@ -815,24 +812,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
invalidateKey(mSpaceKey);
}
- private void dimEntireKeyboard(final boolean dimmed) {
- final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed;
- mNeedsToDimEntireKeyboard = dimmed;
- if (needsRedrawing) {
- invalidateAllKeys();
- }
- }
-
- @Override
- protected void onDraw(final Canvas canvas) {
- super.onDraw(canvas);
-
- // Overlay a dark rectangle to dim.
- if (mNeedsToDimEntireKeyboard) {
- canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mBackgroundDimAlphaPaint);
- }
- }
-
@Override
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
final KeyDrawParams params) {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 77477d2d3..ec45462c4 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1539,7 +1539,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void setSuggestedWords(final SuggestedWords suggestedWords) {
final SettingsValues currentSettingsValues = mSettings.getCurrent();
- mInputLogic.setSuggestedWords(suggestedWords, currentSettingsValues, mHandler);
+ mInputLogic.setSuggestedWords(suggestedWords);
// TODO: Modify this when we support suggestions with hard keyboard
if (!hasSuggestionStripView()) {
return;
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 157bd1565..5eb338eb3 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.event.CombinerChain;
import com.android.inputmethod.event.Event;
+import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@@ -48,8 +49,7 @@ public final class WordComposer {
// The list of events that served to compose this string.
private final ArrayList<Event> mEvents;
private final InputPointers mInputPointers = new InputPointers(MAX_WORD_LENGTH);
- private String mAutoCorrection;
- private String mAutoCorrectionDictionaryType;
+ private SuggestedWordInfo mAutoCorrection;
private boolean mIsResumed;
private boolean mIsBatchMode;
// A memory of the last rejected batch mode suggestion, if any. This goes like this: the user
@@ -418,26 +418,18 @@ public final class WordComposer {
/**
* Sets the auto-correction for this word.
*/
- public void setAutoCorrection(final String correction, String dictType) {
- mAutoCorrection = correction;
- mAutoCorrectionDictionaryType = dictType;
+ public void setAutoCorrection(final SuggestedWordInfo autoCorrection) {
+ mAutoCorrection = autoCorrection;
}
/**
* @return the auto-correction for this word, or null if none.
*/
- public String getAutoCorrectionOrNull() {
+ public SuggestedWordInfo getAutoCorrectionOrNull() {
return mAutoCorrection;
}
/**
- * @return the auto-correction dictionary type or null if none.
- */
- public String getAutoCorrectionDictionaryTypeOrNull() {
- return mAutoCorrectionDictionaryType;
- }
-
- /**
* @return whether we started composing this word by resuming suggestion on an existing string
*/
public boolean isResumed() {
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 07bfd0dee..07f2ed3db 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -607,25 +607,21 @@ public final class InputLogic {
// TODO: on the long term, this method should become private, but it will be difficult.
// Especially, how do we deal with InputMethodService.onDisplayCompletions?
- public void setSuggestedWords(final SuggestedWords suggestedWords,
- final SettingsValues settingsValues, final LatinIME.UIHandler handler) {
+ public void setSuggestedWords(final SuggestedWords suggestedWords) {
if (!suggestedWords.isEmpty()) {
- final String autoCorrection;
- final String dictType;
+ final SuggestedWordInfo suggestedWordInfo;
if (suggestedWords.mWillAutoCorrect) {
- SuggestedWordInfo info = suggestedWords.getInfo(
- SuggestedWords.INDEX_OF_AUTO_CORRECTION);
- autoCorrection = info.mWord;
- dictType = info.mSourceDict.mDictType;
+ suggestedWordInfo = suggestedWords.getInfo(SuggestedWords.INDEX_OF_AUTO_CORRECTION);
} else {
// We can't use suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD)
// because it may differ from mWordComposer.mTypedWord.
- autoCorrection = suggestedWords.mTypedWord;
- dictType = Dictionary.TYPE_USER_TYPED;
+ suggestedWordInfo = new SuggestedWordInfo(suggestedWords.mTypedWord,
+ SuggestedWordInfo.MAX_SCORE,
+ SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
+ SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
+ SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */);
}
- // TODO: Use the SuggestedWordInfo to set the auto correction when
- // user typed word is available via SuggestedWordInfo.
- mWordComposer.setAutoCorrection(autoCorrection, dictType);
+ mWordComposer.setAutoCorrection(suggestedWordInfo);
}
mSuggestedWords = suggestedWords;
final boolean newAutoCorrectionIndicator = suggestedWords.mWillAutoCorrect;
@@ -2092,19 +2088,19 @@ public final class InputLogic {
// INPUT_STYLE_TYPING.
performUpdateSuggestionStripSync(settingsValues, SuggestedWords.INPUT_STYLE_TYPING);
}
- final String typedAutoCorrection = mWordComposer.getAutoCorrectionOrNull();
+ final SuggestedWordInfo autoCorrectionOrNull = mWordComposer.getAutoCorrectionOrNull();
final String typedWord = mWordComposer.getTypedWord();
- final String autoCorrection = (typedAutoCorrection != null)
- ? typedAutoCorrection : typedWord;
- if (autoCorrection != null) {
+ final String stringToCommit = (autoCorrectionOrNull != null)
+ ? autoCorrectionOrNull.mWord : typedWord;
+ if (stringToCommit != null) {
if (TextUtils.isEmpty(typedWord)) {
throw new RuntimeException("We have an auto-correction but the typed word "
+ "is empty? Impossible! I must commit suicide.");
}
final boolean isBatchMode = mWordComposer.isBatchMode();
- commitChosenWord(settingsValues, autoCorrection,
+ commitChosenWord(settingsValues, stringToCommit,
LastComposedWord.COMMIT_TYPE_DECIDED_WORD, separator);
- if (!typedWord.equals(autoCorrection)) {
+ if (!typedWord.equals(stringToCommit)) {
// This will make the correction flash for a short while as a visual clue
// to the user that auto-correction happened. It has no other effect; in particular
// note that this won't affect the text inside the text field AT ALL: it only makes
@@ -2112,13 +2108,14 @@ public final class InputLogic {
// of the auto-correction flash. At this moment, the "typedWord" argument is
// ignored by TextView.
mConnection.commitCorrection(new CorrectionInfo(
- mConnection.getExpectedSelectionEnd() - autoCorrection.length(),
- typedWord, autoCorrection));
- StatsUtils.onAutoCorrection(typedWord, autoCorrection, isBatchMode,
- mWordComposer.getAutoCorrectionDictionaryTypeOrNull());
- StatsUtils.onWordCommitAutoCorrect(autoCorrection, isBatchMode);
+ mConnection.getExpectedSelectionEnd() - stringToCommit.length(),
+ typedWord, stringToCommit));
+ StatsUtils.onAutoCorrection(typedWord, stringToCommit, isBatchMode,
+ null == autoCorrectionOrNull
+ ? null : autoCorrectionOrNull.mSourceDict.mDictType);
+ StatsUtils.onWordCommitAutoCorrect(stringToCommit, isBatchMode);
} else {
- StatsUtils.onWordCommitUserTyped(autoCorrection, isBatchMode);
+ StatsUtils.onWordCommitUserTyped(stringToCommit, isBatchMode);
}
}
}
diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
index 1d29e537d..45792fe0e 100644
--- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java
@@ -28,6 +28,7 @@ import android.text.TextUtils;
import android.widget.ListView;
import android.widget.Toast;
+import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.accounts.LoginAccountUtils;
@@ -176,6 +177,7 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
*
* Package-private for testing.
*/
+ @UsedForTesting
AlertDialog createAccountPicker(final String[] accounts,
final String selectedAccount) {
if (accounts == null || accounts.length == 0) {