summaryrefslogtreecommitdiffstats
path: root/samples/SpellChecker
diff options
context:
space:
mode:
authorsatok <satok@google.com>2012-04-12 16:36:46 +0900
committersatok <satok@google.com>2012-04-16 19:50:46 +0900
commit32d906962a0264a08448c0771de5ea30054be0d3 (patch)
treea5f8e3e52a0cb310d25b98b245331316c24cd158 /samples/SpellChecker
parent31446e98dd8cda999d17c9cc3f9c42032e02a4d9 (diff)
downloadandroid_development-32d906962a0264a08448c0771de5ea30054be0d3.tar.gz
android_development-32d906962a0264a08448c0771de5ea30054be0d3.tar.bz2
android_development-32d906962a0264a08448c0771de5ea30054be0d3.zip
Get rid of isSentenceSpellCheckSupported corresponding to I0e931b7248f8c65268b60af599c07
Bug: 6320351 Change-Id: I6dae866d19bc6a22a3e2dc7631f00a0490477239
Diffstat (limited to 'samples/SpellChecker')
-rw-r--r--samples/SpellChecker/HelloSpellChecker/src/com/example/android/hellospellchecker/HelloSpellCheckerActivity.java9
-rw-r--r--samples/SpellChecker/SampleSpellCheckerService/res/xml/spellchecker.xml3
-rw-r--r--samples/SpellChecker/SampleSpellCheckerService/src/com/example/android/samplespellcheckerservice/SampleSpellCheckerService.java25
3 files changed, 27 insertions, 10 deletions
diff --git a/samples/SpellChecker/HelloSpellChecker/src/com/example/android/hellospellchecker/HelloSpellCheckerActivity.java b/samples/SpellChecker/HelloSpellChecker/src/com/example/android/hellospellchecker/HelloSpellCheckerActivity.java
index f88b0232d..9a18a22dc 100644
--- a/samples/SpellChecker/HelloSpellChecker/src/com/example/android/hellospellchecker/HelloSpellCheckerActivity.java
+++ b/samples/SpellChecker/HelloSpellChecker/src/com/example/android/hellospellchecker/HelloSpellCheckerActivity.java
@@ -45,11 +45,7 @@ public class HelloSpellCheckerActivity extends Activity implements SpellCheckerS
}
private boolean isSentenceSpellCheckSupported() {
- if (mScs == null || Build.VERSION.SDK_INT < 16) {
- return false;
- }
- // Note that isSentenceSpellCheckSupported works on JB or later.
- return mScs.isSentenceSpellCheckSupported();
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}
@Override
@@ -70,6 +66,9 @@ public class HelloSpellCheckerActivity extends Activity implements SpellCheckerS
"I wold like to here form you")}, 3);
mScs.getSentenceSuggestions(new TextInfo[] {new TextInfo("hell othere")}, 3);
} else {
+ // Note that getSuggestions() is a deprecated API.
+ // It is recommended for an application running on Jelly Bean or later
+ // to call getSentenceSuggestions() only.
mScs.getSuggestions(new TextInfo("tgis"), 3);
mScs.getSuggestions(new TextInfo("hllo"), 3);
mScs.getSuggestions(new TextInfo("helloworld"), 3);
diff --git a/samples/SpellChecker/SampleSpellCheckerService/res/xml/spellchecker.xml b/samples/SpellChecker/SampleSpellCheckerService/res/xml/spellchecker.xml
index b3a078a29..f4601d2da 100644
--- a/samples/SpellChecker/SampleSpellCheckerService/res/xml/spellchecker.xml
+++ b/samples/SpellChecker/SampleSpellCheckerService/res/xml/spellchecker.xml
@@ -22,8 +22,7 @@
<spell-checker xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/spellchecker_name"
- android:settingsActivity="com.example.android.samplespellcheckerservice.SpellCheckerSettingsActivity"
- android:supportsSentenceSpellCheck="true">
+ android:settingsActivity="com.example.android.samplespellcheckerservice.SpellCheckerSettingsActivity">
<subtype
android:label="@string/subtype_generic"
android:subtypeLocale="en"
diff --git a/samples/SpellChecker/SampleSpellCheckerService/src/com/example/android/samplespellcheckerservice/SampleSpellCheckerService.java b/samples/SpellChecker/SampleSpellCheckerService/src/com/example/android/samplespellcheckerservice/SampleSpellCheckerService.java
index 8778cc0cc..e0abb4cc0 100644
--- a/samples/SpellChecker/SampleSpellCheckerService/src/com/example/android/samplespellcheckerservice/SampleSpellCheckerService.java
+++ b/samples/SpellChecker/SampleSpellCheckerService/src/com/example/android/samplespellcheckerservice/SampleSpellCheckerService.java
@@ -37,8 +37,8 @@ public class SampleSpellCheckerService extends SpellCheckerService {
private static class AndroidSpellCheckerSession extends Session {
private boolean isSentenceSpellCheckApiSupported() {
- // Note that the sentence level spell check APIs work on JB or later.
- return Build.VERSION.SDK_INT >= 16;
+ // Note that the sentence level spell check APIs work on Jelly Bean or later.
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}
private String mLocale;
@@ -47,6 +47,15 @@ public class SampleSpellCheckerService extends SpellCheckerService {
mLocale = getLocale();
}
+ /**
+ * This method should have a concrete implementation in all spell checker services.
+ * Please note that the default implementation of
+ * {@link SpellCheckerService.Session#onGetSuggestionsMultiple(TextInfo[], int, boolean)}
+ * calls up this method. You may want to override
+ * {@link SpellCheckerService.Session#onGetSuggestionsMultiple(TextInfo[], int, boolean)}
+ * by your own implementation if you'd like to provide an optimized implementation for
+ * {@link SpellCheckerService.Session#onGetSuggestionsMultiple(TextInfo[], int, boolean)}.
+ */
@Override
public SuggestionsInfo onGetSuggestions(TextInfo textInfo, int suggestionsLimit) {
if (DBG) {
@@ -63,6 +72,16 @@ public class SampleSpellCheckerService extends SpellCheckerService {
new String[] {"aaa", "bbb", "Candidate for " + input, mLocale});
}
+ /**
+ * Please consider providing your own implementation of sentence level spell checking.
+ * Please note that this sample implementation is just a mock to demonstrate how a sentence
+ * level spell checker returns the result.
+ * If you don't override this method, the framework converts queries of
+ * {@link SpellCheckerService.Session#onGetSentenceSuggestionsMultiple(TextInfo[], int)}
+ * to queries of
+ * {@link SpellCheckerService.Session#onGetSuggestionsMultiple(TextInfo[], int, boolean)}
+ * by the default implementation.
+ */
@Override
public SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple(
TextInfo[] textInfos, int suggestionsLimit) {
@@ -99,7 +118,7 @@ public class SampleSpellCheckerService extends SpellCheckerService {
offsets = new int[] { 2, 15, 20 };
lengths = new int[] { 4, 4, 4 };
} else {
- // Just a fake logic:
+ // Just a mock logic:
// length <= 3 for short words that we assume are in the fake dictionary
// length > 20 for too long words that we assume can't be recognized
// (such as CJK words)