aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-02-18 17:07:46 +0900
committerJean Chalard <jchalard@google.com>2014-02-18 17:07:46 +0900
commit63be066544f19928d6a29c58c028cce7c95fa457 (patch)
tree8281b076c407bfd70edc5295e7358003c3a7eab6
parentdb21fad18f70eb4abaf60a8c0ae7f285682acf20 (diff)
downloadlatinime-63be066544f19928d6a29c58c028cce7c95fa457.tar.gz
latinime-63be066544f19928d6a29c58c028cce7c95fa457.tar.xz
latinime-63be066544f19928d6a29c58c028cce7c95fa457.zip
Cleanup.
Less code, less chance of stuff escaping, and a bit of a clarification. Yay. Change-Id: I3193fd8ad7ac28195260cbc231c4e498a63a460c
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java8
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java13
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java6
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTestsLanguageWithoutSpaces.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/PunctuationTests.java6
6 files changed, 12 insertions, 27 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d922ef6eb..4bee987cf 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1310,12 +1310,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Nothing to do so far.
}
- // TODO: remove this, read this directly from mInputLogic or something in the tests
- @UsedForTesting
- public boolean isShowingPunctuationList() {
- return mInputLogic.isShowingPunctuationList(mSettings.getCurrent());
- }
-
// TODO[IL]: Define a clear interface for this
public boolean isSuggestionStripVisible() {
final SettingsValues currentSettings = mSettings.getCurrent();
@@ -1692,7 +1686,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: can this be removed somehow without breaking the tests?
@UsedForTesting
- /* package for test */ SuggestedWords getSuggestedWords() {
+ /* package for test */ SuggestedWords getSuggestedWordsForTest() {
// You may not use this method for anything else than debug
return DEBUG ? mInputLogic.mSuggestedWords : null;
}
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 9bf9d1f45..3fc2cf8fd 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -198,7 +198,7 @@ public final class InputLogic {
final SuggestedWords suggestedWords = mSuggestedWords;
final String suggestion = suggestionInfo.mWord;
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
- if (suggestion.length() == 1 && isShowingPunctuationList(settingsValues)) {
+ if (suggestion.length() == 1 && suggestedWords.isPunctuationSuggestions()) {
// Word separators are suggested before the user inputs something.
// So, LatinImeLogger logs "" as a user's input.
LatinImeLogger.logOnManualSuggestion("", suggestion, index, suggestedWords);
@@ -821,7 +821,7 @@ public final class InputLogic {
if (maybeDoubleSpacePeriod(settingsValues, handler)) {
keyboardSwitcher.updateShiftState();
mSpaceState = SpaceState.DOUBLE;
- } else if (!isShowingPunctuationList(settingsValues)) {
+ } else if (!mSuggestedWords.isPunctuationSuggestions()) {
mSpaceState = SpaceState.WEAK;
}
}
@@ -1456,15 +1456,6 @@ public final class InputLogic {
}
/**
- * Find out if the punctuation list is shown in the suggestion strip.
- * @return whether the current suggestions are the punctuation list.
- */
- // TODO: make this private. It's used through LatinIME for tests.
- public boolean isShowingPunctuationList(final SettingsValues settingsValues) {
- return settingsValues.mSpacingAndPunctuations.mSuggestPuncList == mSuggestedWords;
- }
-
- /**
* Factor in auto-caps and manual caps and compute the current caps mode.
* @param settingsValues the current settings values.
* @param keyboardShiftMode the current shift mode of the keyboard. See
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 2c23d743f..4222c66c8 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -357,7 +357,7 @@ public class InputLogicTests extends InputTestsBase {
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
// Test the first prediction is displayed
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
+ final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("predictions after space", "Obama",
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
@@ -371,7 +371,7 @@ public class InputLogicTests extends InputTestsBase {
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
// Test the first prediction is displayed
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
+ final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("predictions after manual pick", "Obama",
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
@@ -382,7 +382,7 @@ public class InputLogicTests extends InputTestsBase {
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
// Test the first prediction is not displayed
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
+ final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("no prediction after period", 0, suggestedWords.size());
}
}
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsLanguageWithoutSpaces.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsLanguageWithoutSpaces.java
index 89021b4e5..e38ba721e 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsLanguageWithoutSpaces.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsLanguageWithoutSpaces.java
@@ -99,7 +99,7 @@ public class InputLogicTestsLanguageWithoutSpaces extends InputTestsBase {
assertEquals("predictions in lang without spaces", "Barack",
mEditText.getText().toString());
// Test the first prediction is displayed
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
+ final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("predictions in lang without spaces", "Obama",
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
index a474c6a8d..1257ae297 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
@@ -60,7 +60,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
runMessages();
assertTrue("type word then type space should display punctuation strip",
- mLatinIME.isShowingPunctuationList());
+ mLatinIME.getSuggestedWordsForTest().isPunctuationSuggestions());
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
assertEquals("type word then type space then punctuation from strip twice for French",
@@ -84,7 +84,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
type(WORD_TO_TYPE);
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
runMessages();
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
+ final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("type word then type space yields predictions for French",
EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
} finally {
diff --git a/tests/src/com/android/inputmethod/latin/PunctuationTests.java b/tests/src/com/android/inputmethod/latin/PunctuationTests.java
index 556af0906..c253e6488 100644
--- a/tests/src/com/android/inputmethod/latin/PunctuationTests.java
+++ b/tests/src/com/android/inputmethod/latin/PunctuationTests.java
@@ -41,7 +41,7 @@ public class PunctuationTests extends InputTestsBase {
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
runMessages();
assertTrue("type word then type space should display punctuation strip",
- mLatinIME.isShowingPunctuationList());
+ mLatinIME.getSuggestedWordsForTest().isPunctuationSuggestions());
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
assertEquals("type word then type space then punctuation from strip twice",
@@ -156,7 +156,7 @@ public class PunctuationTests extends InputTestsBase {
type(WORD_TO_TYPE);
assertEquals("auto-correction with single quote inside. ID = "
+ Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID)
- + " ; Suggestions = " + mLatinIME.getSuggestedWords(),
+ + " ; Suggestions = " + mLatinIME.getSuggestedWordsForTest(),
EXPECTED_RESULT, mEditText.getText().toString());
}
@@ -166,7 +166,7 @@ public class PunctuationTests extends InputTestsBase {
type(WORD_TO_TYPE);
assertEquals("auto-correction with single quotes around. ID = "
+ Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID)
- + " ; Suggestions = " + mLatinIME.getSuggestedWords(),
+ + " ; Suggestions = " + mLatinIME.getSuggestedWordsForTest(),
EXPECTED_RESULT, mEditText.getText().toString());
}