[SD5(2)] Remove useless args

Bug: 15840116
Change-Id: I1123426fbd9d420c1be64ccc917a5f870e70e6fa
This commit is contained in:
Jean Chalard 2014-06-27 21:57:57 +09:00
parent 87d907bda9
commit 20c89b1cf5
3 changed files with 13 additions and 54 deletions

View File

@ -619,28 +619,14 @@ public final class RichInputConnection {
return new PrevWordsInfo(prevWordsInfo); return new PrevWordsInfo(prevWordsInfo);
} }
/**
* @param sortedSeparators a sorted array of code points which may separate words
* @return the word that surrounds the cursor, including up to one trailing
* separator. For example, if the field contains "he|llo world", where |
* represents the cursor, then "hello " will be returned.
*/
public CharSequence getWordAtCursor(final int[] sortedSeparators) {
// getWordRangeAtCursor returns null if the connection is null
final TextRange r = getWordRangeAtCursor(sortedSeparators, 0);
return (r == null) ? null : r.mWord;
}
/** /**
* Returns the text surrounding the cursor. * Returns the text surrounding the cursor.
* *
* @param sortedSeparators a sorted array of code points that split words. * @param sortedSeparators a sorted array of code points that split words.
* @param additionalPrecedingWordsCount the number of words before the current word that should
* be included in the returned range
* @return a range containing the text surrounding the cursor * @return a range containing the text surrounding the cursor
*/ */
public TextRange getWordRangeAtCursor(final int[] sortedSeparators, public TextRange getWordRangeAtCursor(final int[] sortedSeparators) {
final int additionalPrecedingWordsCount) { final int additionalPrecedingWordsCount = 0;
mIC = mParent.getCurrentInputConnection(); mIC = mParent.getCurrentInputConnection();
if (mIC == null) { if (mIC == null) {
return null; return null;

View File

@ -1288,8 +1288,7 @@ public final class InputLogic {
return; return;
} }
final TextRange range = mConnection.getWordRangeAtCursor( final TextRange range = mConnection.getWordRangeAtCursor(
settingsValues.mSpacingAndPunctuations.mSortedWordSeparators, settingsValues.mSpacingAndPunctuations.mSortedWordSeparators);
0 /* additionalPrecedingWordsCount */);
if (null == range) return; // Happens if we don't have an input connection at all if (null == range) return; // Happens if we don't have an input connection at all
if (range.length() <= 0) return; // Race condition. No text to resume on, so bail out. if (range.length() <= 0) return; // Race condition. No text to resume on, so bail out.
// If for some strange reason (editor bug or so) we measure the text before the cursor as // If for some strange reason (editor bug or so) we measure the text before the cursor as

View File

@ -233,47 +233,21 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
ic.beginBatchEdit(); ic.beginBatchEdit();
// basic case // basic case
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
assertTrue(TextUtils.equals("word", r.mWord)); assertTrue(TextUtils.equals("word", r.mWord));
// more than one word
r = ic.getWordRangeAtCursor(SPACE, 1);
assertTrue(TextUtils.equals("word word", r.mWord));
ic.endBatchEdit();
// tab character instead of space // tab character instead of space
mockInputMethodService.setInputConnection(new MockConnection("one\tword\two", "rd", et)); mockInputMethodService.setInputConnection(new MockConnection("one\tword\two", "rd", et));
ic.beginBatchEdit(); ic.beginBatchEdit();
r = ic.getWordRangeAtCursor(TAB, 1); r = ic.getWordRangeAtCursor(TAB);
ic.endBatchEdit(); ic.endBatchEdit();
assertTrue(TextUtils.equals("word\tword", r.mWord)); assertTrue(TextUtils.equals("word", r.mWord));
// only one word doesn't go too far
mockInputMethodService.setInputConnection(new MockConnection("one\tword\two", "rd", et));
ic.beginBatchEdit();
r = ic.getWordRangeAtCursor(TAB, 1);
ic.endBatchEdit();
assertTrue(TextUtils.equals("word\tword", r.mWord));
// tab or space
mockInputMethodService.setInputConnection(new MockConnection("one word\two", "rd", et));
ic.beginBatchEdit();
r = ic.getWordRangeAtCursor(SPACE_TAB, 1);
ic.endBatchEdit();
assertTrue(TextUtils.equals("word\tword", r.mWord));
// tab or space multiword
mockInputMethodService.setInputConnection(new MockConnection("one word\two", "rd", et));
ic.beginBatchEdit();
r = ic.getWordRangeAtCursor(SPACE_TAB, 2);
ic.endBatchEdit();
assertTrue(TextUtils.equals("one word\tword", r.mWord));
// splitting on supplementary character // splitting on supplementary character
mockInputMethodService.setInputConnection( mockInputMethodService.setInputConnection(
new MockConnection("one word" + SUPPLEMENTARY_CHAR + "wo", "rd", et)); new MockConnection("one word" + SUPPLEMENTARY_CHAR + "wo", "rd", et));
ic.beginBatchEdit(); ic.beginBatchEdit();
r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), 0); r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR));
ic.endBatchEdit(); ic.endBatchEdit();
assertTrue(TextUtils.equals("word", r.mWord)); assertTrue(TextUtils.equals("word", r.mWord));
} }
@ -303,7 +277,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
TextRange r; TextRange r;
SuggestionSpan[] suggestions; SuggestionSpan[] suggestions;
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
suggestions = r.getSuggestionSpansAtWord(); suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1); assertEquals(suggestions.length, 1);
MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1); MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
@ -315,7 +289,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */), text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */),
10 /* start */, 16 /* end */, 0 /* flags */); 10 /* start */, 16 /* end */, 0 /* flags */);
mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos)); mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos));
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
suggestions = r.getSuggestionSpansAtWord(); suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 2); assertEquals(suggestions.length, 2);
MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1); MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
@ -328,7 +302,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */), text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */),
5 /* start */, 16 /* end */, 0 /* flags */); 5 /* start */, 16 /* end */, 0 /* flags */);
mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos)); mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos));
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
suggestions = r.getSuggestionSpansAtWord(); suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1); assertEquals(suggestions.length, 1);
MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1); MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
@ -340,7 +314,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */), text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */),
10 /* start */, 20 /* end */, 0 /* flags */); 10 /* start */, 20 /* end */, 0 /* flags */);
mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos)); mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos));
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
suggestions = r.getSuggestionSpansAtWord(); suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1); assertEquals(suggestions.length, 1);
MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1); MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
@ -352,7 +326,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */), text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */),
5 /* start */, 20 /* end */, 0 /* flags */); 5 /* start */, 20 /* end */, 0 /* flags */);
mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos)); mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos));
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
suggestions = r.getSuggestionSpansAtWord(); suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1); assertEquals(suggestions.length, 1);
MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1); MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
@ -364,7 +338,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */), text.setSpan(new SuggestionSpan(Locale.ENGLISH, SUGGESTIONS2, 0 /* flags */),
5 /* start */, 20 /* end */, 0 /* flags */); 5 /* start */, 20 /* end */, 0 /* flags */);
mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos)); mockInputMethodService.setInputConnection(new MockConnection(text, cursorPos));
r = ic.getWordRangeAtCursor(SPACE, 0); r = ic.getWordRangeAtCursor(SPACE);
suggestions = r.getSuggestionSpansAtWord(); suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 0); assertEquals(suggestions.length, 0);
} }