Skip to content

Commit b7ad825

Browse files
satok16Android (Google) Code Review
authored andcommitted
Merge "Add documents for the spell checker framework and the input method subtype" into ics-mr0
2 parents 11116b8 + 44b7503 commit b7ad825

File tree

4 files changed

+101
-2
lines changed

4 files changed

+101
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,28 @@
3535
* SpellCheckerService provides an abstract base class for a spell checker.
3636
* This class combines a service to the system with the spell checker service interface that
3737
* spell checker must implement.
38+
*
39+
* <p>In addition to the normal Service lifecycle methods, this class
40+
* introduces a new specific callback that subclasses should override
41+
* {@link #createSession()} to provide a spell checker session that is corresponding
42+
* to requested language and so on. The spell checker session returned by this method
43+
* should extend {@link SpellCheckerService.Session}.
44+
* </p>
45+
*
46+
* <h3>Returning spell check results</h3>
47+
*
48+
* <p>{@link SpellCheckerService.Session#onGetSuggestions(TextInfo, int)}
49+
* should return spell check results.
50+
* It receives {@link android.view.textservice.TextInfo} and returns
51+
* {@link android.view.textservice.SuggestionsInfo} for the input.
52+
* You may want to override
53+
* {@link SpellCheckerService.Session#onGetSuggestionsMultiple(TextInfo[], int, boolean)} for
54+
* better performance and quality.
55+
* </p>
56+
*
57+
* <p>Please note that {@link SpellCheckerService.Session#getLocale()} does not return a valid
58+
* locale before {@link SpellCheckerService.Session#onCreate()} </p>
59+
*
3860
*/
3961
public abstract class SpellCheckerService extends Service {
4062
private static final String TAG = SpellCheckerService.class.getSimpleName();
@@ -89,7 +111,7 @@ public final void setInternalISpellCheckerSession(InternalISpellCheckerSession s
89111
* but will be called in series on another thread.
90112
* @param textInfo the text metadata
91113
* @param suggestionsLimit the number of limit of suggestions returned
92-
* @return SuggestionInfo which contains suggestions for textInfo
114+
* @return SuggestionsInfo which contains suggestions for textInfo
93115
*/
94116
public abstract SuggestionsInfo onGetSuggestions(TextInfo textInfo, int suggestionsLimit);
95117

@@ -101,7 +123,7 @@ public final void setInternalISpellCheckerSession(InternalISpellCheckerSession s
101123
* @param textInfos an array of the text metadata
102124
* @param suggestionsLimit the number of limit of suggestions returned
103125
* @param sequentialWords true if textInfos can be treated as sequential words.
104-
* @return an array of SuggestionInfo of onGetSuggestions
126+
* @return an array of SuggestionsInfo of onGetSuggestions
105127
*/
106128
public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos,
107129
int suggestionsLimit, boolean sequentialWords) {

core/java/android/view/inputmethod/InputMethodSubtype.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
* Subtype can describe locale (e.g. en_US, fr_FR...) and mode (e.g. voice, keyboard...), and is
3636
* used for IME switch and settings. The input method subtype allows the system to bring up the
3737
* specified subtype of the designated input method directly.
38+
*
39+
* <p>It should be defined in an XML resource file of the input method
40+
* with the <code>&lt;subtype></code> element.
41+
* For more information, see the guide to
42+
* <a href="{@docRoot}resources/articles/creating-input-method.html">
43+
* Creating an Input Method</a>.</p>
44+
*
3845
*/
3946
public final class InputMethodSubtype implements Parcelable {
4047
private static final String TAG = InputMethodSubtype.class.getSimpleName();

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,51 @@
3434

3535
/**
3636
* The SpellCheckerSession interface provides the per client functionality of SpellCheckerService.
37+
*
38+
*
39+
* <a name="Applications"></a>
40+
* <h3>Applications</h3>
41+
*
42+
* <p>In most cases, applications that are using the standard
43+
* {@link android.widget.TextView} or its subclasses will have little they need
44+
* to do to work well with spell checker services. The main things you need to
45+
* be aware of are:</p>
46+
*
47+
* <ul>
48+
* <li> Properly set the {@link android.R.attr#inputType} in your editable
49+
* text views, so that the spell checker will have enough context to help the
50+
* user in editing text in them.
51+
* </ul>
52+
*
53+
* <p>For the rare people amongst us writing client applications that use the spell checker service
54+
* directly, you will need to use {@link #getSuggestions(TextInfo, int)} or
55+
* {@link #getSuggestions(TextInfo[], int, boolean)} for obtaining results from the spell checker
56+
* service by yourself.</p>
57+
*
58+
* <h3>Security</h3>
59+
*
60+
* <p>There are a lot of security issues associated with spell checkers,
61+
* since they could monitor all the text being sent to them
62+
* through, for instance, {@link android.widget.TextView}.
63+
* The Android spell checker framework also allows
64+
* arbitrary third party spell checkers, so care must be taken to restrict their
65+
* selection and interactions.</p>
66+
*
67+
* <p>Here are some key points about the security architecture behind the
68+
* spell checker framework:</p>
69+
*
70+
* <ul>
71+
* <li>Only the system is allowed to directly access a spell checker framework's
72+
* {@link android.service.textservice.SpellCheckerService} interface, via the
73+
* {@link android.Manifest.permission#BIND_TEXT_SERVICE} permission. This is
74+
* enforced in the system by not binding to a spell checker service that does
75+
* not require this permission.
76+
*
77+
* <li>The user must explicitly enable a new spell checker in settings before
78+
* they can be enabled, to confirm with the system that they know about it
79+
* and want to make it available for use.
80+
* </ul>
81+
*
3782
*/
3883
public class SpellCheckerSession {
3984
private static final String TAG = SpellCheckerSession.class.getSimpleName();

core/java/android/view/textservice/TextServicesManager.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,31 @@
3535
*
3636
* The user can change the current text services in Settings. And also applications can specify
3737
* the target text services.
38+
*
39+
* <h3>Architecture Overview</h3>
40+
*
41+
* <p>There are three primary parties involved in the text services
42+
* framework (TSF) architecture:</p>
43+
*
44+
* <ul>
45+
* <li> The <strong>text services manager</strong> as expressed by this class
46+
* is the central point of the system that manages interaction between all
47+
* other parts. It is expressed as the client-side API here which exists
48+
* in each application context and communicates with a global system service
49+
* that manages the interaction across all processes.
50+
* <li> A <strong>text service</strong> implements a particular
51+
* interaction model allowing the client application to retrieve information of text.
52+
* The system binds to the current text service that is in use, causing it to be created and run.
53+
* <li> Multiple <strong>client applications</strong> arbitrate with the text service
54+
* manager for connections to text services.
55+
* </ul>
56+
*
57+
* <h3>Text services sessions</h3>
58+
* <ul>
59+
* <li>The <strong>spell checker session</strong> is one of the text services.
60+
* {@link android.view.textservice.SpellCheckerSession}</li>
61+
* </ul>
62+
*
3863
*/
3964
public final class TextServicesManager {
4065
private static final String TAG = TextServicesManager.class.getSimpleName();

0 commit comments

Comments
 (0)