Skip to content

Commit 6183cd6

Browse files
committed
Take sentence-level spell checking APIs public
Bug: 6136149 Change-Id: I772164d9c67e95876c228efcce2356a81a06be4f
1 parent 0184ce9 commit 6183cd6

File tree

4 files changed

+52
-17
lines changed

4 files changed

+52
-17
lines changed

api/current.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18916,6 +18916,7 @@ package android.service.textservice {
1891618916
method public void onCancel();
1891718917
method public void onClose();
1891818918
method public abstract void onCreate();
18919+
method public android.view.textservice.SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple(android.view.textservice.TextInfo[], int);
1891918920
method public abstract android.view.textservice.SuggestionsInfo onGetSuggestions(android.view.textservice.TextInfo, int);
1892018921
method public android.view.textservice.SuggestionsInfo[] onGetSuggestionsMultiple(android.view.textservice.TextInfo[], int, boolean);
1892118922
}
@@ -25147,6 +25148,18 @@ package android.view.inputmethod {
2514725148

2514825149
package android.view.textservice {
2514925150

25151+
public final class SentenceSuggestionsInfo implements android.os.Parcelable {
25152+
ctor public SentenceSuggestionsInfo(android.view.textservice.SuggestionsInfo[], int[], int[]);
25153+
ctor public SentenceSuggestionsInfo(android.os.Parcel);
25154+
method public int describeContents();
25155+
method public int getLengthAt(int);
25156+
method public int getOffsetAt(int);
25157+
method public int getSuggestionsCount();
25158+
method public android.view.textservice.SuggestionsInfo getSuggestionsInfoAt(int);
25159+
method public void writeToParcel(android.os.Parcel, int);
25160+
field public static final android.os.Parcelable.Creator CREATOR;
25161+
}
25162+
2515025163
public final class SpellCheckerInfo implements android.os.Parcelable {
2515125164
method public int describeContents();
2515225165
method public android.content.ComponentName getComponent();
@@ -25165,6 +25178,7 @@ package android.view.textservice {
2516525178
public class SpellCheckerSession {
2516625179
method public void cancel();
2516725180
method public void close();
25181+
method public void getSentenceSuggestions(android.view.textservice.TextInfo[], int);
2516825182
method public android.view.textservice.SpellCheckerInfo getSpellChecker();
2516925183
method public void getSuggestions(android.view.textservice.TextInfo, int);
2517025184
method public void getSuggestions(android.view.textservice.TextInfo[], int, boolean);

core/java/android/service/textservice/SpellCheckerService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public final void setInternalISpellCheckerSession(InternalISpellCheckerSession s
112112
* So, this is not called on the main thread,
113113
* but will be called in series on another thread.
114114
* @param textInfo the text metadata
115-
* @param suggestionsLimit the number of limit of suggestions returned
115+
* @param suggestionsLimit the maximum number of suggestions to be returned
116116
* @return SuggestionsInfo which contains suggestions for textInfo
117117
*/
118118
public abstract SuggestionsInfo onGetSuggestions(TextInfo textInfo, int suggestionsLimit);
@@ -123,9 +123,10 @@ public final void setInternalISpellCheckerSession(InternalISpellCheckerSession s
123123
* So, this is not called on the main thread,
124124
* but will be called in series on another thread.
125125
* @param textInfos an array of the text metadata
126-
* @param suggestionsLimit the number of limit of suggestions returned
126+
* @param suggestionsLimit the maximum number of suggestions to be returned
127127
* @param sequentialWords true if textInfos can be treated as sequential words.
128-
* @return an array of SuggestionsInfo of onGetSuggestions
128+
* @return an array of {@link SentenceSuggestionsInfo} returned by
129+
* {@link SpellCheckerService.Session#onGetSuggestions(TextInfo, int)}
129130
*/
130131
public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos,
131132
int suggestionsLimit, boolean sequentialWords) {
@@ -140,11 +141,14 @@ public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos,
140141
}
141142

142143
/**
143-
* @hide
144144
* The default implementation returns an array of SentenceSuggestionsInfo by simply calling
145145
* onGetSuggestions().
146146
* When you override this method, make sure that suggestionsLimit is applied to suggestions
147147
* that share the same start position and length.
148+
* @param textInfos an array of the text metadata
149+
* @param suggestionsLimit the maximum number of suggestions to be returned
150+
* @return an array of {@link SentenceSuggestionsInfo} returned by
151+
* {@link SpellCheckerService.Session#onGetSuggestions(TextInfo, int)}
148152
*/
149153
public SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple(TextInfo[] textInfos,
150154
int suggestionsLimit) {

core/java/android/view/textservice/SentenceSuggestionsInfo.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
import java.util.Arrays;
2323

2424
/**
25-
* @hide
26-
* This class contains a metadata of sentence level suggestions from the text service
25+
* This class contains a metadata of suggestions returned from a text service
26+
* (e.g. {@link android.service.textservice.SpellCheckerService}).
27+
* The text service uses this class to return the suggestions
28+
* for a sentence. See {@link SuggestionsInfo} which is used for suggestions for a word.
29+
* This class extends the functionality of {@link SuggestionsInfo} as far as this class enables
30+
* you to put multiple {@link SuggestionsInfo}s on a sentence with the offsets and the lengths
31+
* of all {@link SuggestionsInfo}s.
2732
*/
2833
public final class SentenceSuggestionsInfo implements Parcelable {
2934

@@ -82,14 +87,15 @@ public int describeContents() {
8287
}
8388

8489
/**
85-
* @hide
90+
* @return the count of {@link SuggestionsInfo}s this instance holds.
8691
*/
8792
public int getSuggestionsCount() {
8893
return mSuggestionsInfos.length;
8994
}
9095

9196
/**
92-
* @hide
97+
* @param i the id of {@link SuggestionsInfo}s this instance holds.
98+
* @return a {@link SuggestionsInfo} at the specified id
9399
*/
94100
public SuggestionsInfo getSuggestionsInfoAt(int i) {
95101
if (i >= 0 && i < mSuggestionsInfos.length) {
@@ -99,7 +105,8 @@ public SuggestionsInfo getSuggestionsInfoAt(int i) {
99105
}
100106

101107
/**
102-
* @hide
108+
* @param i the id of {@link SuggestionsInfo}s this instance holds
109+
* @return the offset of the specified {@link SuggestionsInfo}
103110
*/
104111
public int getOffsetAt(int i) {
105112
if (i >= 0 && i < mOffsets.length) {
@@ -109,7 +116,8 @@ public int getOffsetAt(int i) {
109116
}
110117

111118
/**
112-
* @hide
119+
* @param i the id of {@link SuggestionsInfo}s this instance holds
120+
* @return the length of the specified {@link SuggestionsInfo}
113121
*/
114122
public int getLengthAt(int i) {
115123
if (i >= 0 && i < mLengths.length) {

core/java/android/view/textservice/SpellCheckerSession.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,19 @@ public void close() {
178178
}
179179

180180
/**
181-
* @hide
181+
* Get suggestions from the specified sentences
182+
* @param textInfos an array of text metadata for a spell checker
183+
* @param suggestionsLimit the maximum number of suggestions that will be returned
182184
*/
183-
public void getSentenceSuggestions(TextInfo[] textInfo, int suggestionsLimit) {
185+
public void getSentenceSuggestions(TextInfo[] textInfos, int suggestionsLimit) {
184186
mSpellCheckerSessionListenerImpl.getSentenceSuggestionsMultiple(
185-
textInfo, suggestionsLimit);
187+
textInfos, suggestionsLimit);
186188
}
187189

188190
/**
189191
* Get candidate strings for a substring of the specified text.
190192
* @param textInfo text metadata for a spell checker
191-
* @param suggestionsLimit the number of limit of suggestions returned
193+
* @param suggestionsLimit the maximum number of suggestions that will be returned
192194
*/
193195
public void getSuggestions(TextInfo textInfo, int suggestionsLimit) {
194196
getSuggestions(new TextInfo[] {textInfo}, suggestionsLimit, false);
@@ -197,7 +199,7 @@ public void getSuggestions(TextInfo textInfo, int suggestionsLimit) {
197199
/**
198200
* A batch process of getSuggestions
199201
* @param textInfos an array of text metadata for a spell checker
200-
* @param suggestionsLimit the number of limit of suggestions returned
202+
* @param suggestionsLimit the maximum number of suggestions that will be returned
201203
* @param sequentialWords true if textInfos can be treated as sequential words.
202204
*/
203205
public void getSuggestions(
@@ -434,12 +436,19 @@ public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
434436
*/
435437
public interface SpellCheckerSessionListener {
436438
/**
437-
* Callback for "getSuggestions"
438-
* @param results an array of results of getSuggestions
439+
* Callback for {@link SpellCheckerSession#getSuggestions(TextInfo[], int, boolean)}
440+
* @param results an array of {@link SuggestionsInfo}s.
441+
* These results are suggestions for {@link TextInfo}s queried by
442+
* {@link SpellCheckerSession#getSuggestions(TextInfo[], int, boolean)}.
439443
*/
440444
public void onGetSuggestions(SuggestionsInfo[] results);
445+
// TODO: Remove @hide as soon as the sample spell checker client gets fixed.
441446
/**
442447
* @hide
448+
* Callback for {@link SpellCheckerSession#getSentenceSuggestions(TextInfo[], int)}
449+
* @param results an array of {@link SentenceSuggestionsInfo}s.
450+
* These results are suggestions for {@link TextInfo}s
451+
* queried by {@link SpellCheckerSession#getSentenceSuggestions(TextInfo[], int)}.
443452
*/
444453
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results);
445454
}

0 commit comments

Comments
 (0)