diff options
| author | Bjorn Bringert <bringert@android.com> | 2009-04-27 17:08:11 +0100 |
|---|---|---|
| committer | Bjorn Bringert <bringert@android.com> | 2009-04-29 13:02:54 +0100 |
| commit | 203464af9638e4d5aecd811452af67fff9aa3087 (patch) | |
| tree | 08716c64a117bf7ee05efe7f2eeeedc0151ad558 /core/java/android/server | |
| parent | 493b00afbfd4f603939ee98540a4d8df084107fd (diff) | |
| download | frameworks_base-203464af9638e4d5aecd811452af67fff9aa3087.zip frameworks_base-203464af9638e4d5aecd811452af67fff9aa3087.tar.gz frameworks_base-203464af9638e4d5aecd811452af67fff9aa3087.tar.bz2 | |
Add searchSuggestThreshold to searchable meta-data.
This lets the searchable activity specify the number of
characters needed to trigger suggestions. Before, this was
hard-coded at 0. This caused unnecessary querying of the
suggestion provider in cases where the provider does not
return suggestions for empty or short queries.
The attribute is not yet public, pending API council approval.
Diffstat (limited to 'core/java/android/server')
| -rw-r--r-- | core/java/android/server/search/SearchableInfo.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/server/search/SearchableInfo.java b/core/java/android/server/search/SearchableInfo.java index 22abd1b..a4a7827 100644 --- a/core/java/android/server/search/SearchableInfo.java +++ b/core/java/android/server/search/SearchableInfo.java @@ -71,6 +71,7 @@ public final class SearchableInfo implements Parcelable { private String mSuggestSelection = null; private String mSuggestIntentAction = null; private String mSuggestIntentData = null; + private int mSuggestThreshold = 0; private ActionKeyInfo mActionKeyList = null; private String mSuggestProviderPackage = null; @@ -140,6 +141,16 @@ public final class SearchableInfo implements Parcelable { } /** + * Gets the suggestion threshold for use with these suggestions. + * + * @return The value of the <code>searchSuggestThreshold</code> attribute, + * or 0 if the attribute is not set. + */ + public int getSuggestThreshold() { + return mSuggestThreshold; + } + + /** * Get the context for the searchable activity. * * This is fairly expensive so do it on the original scan, or when an app is @@ -238,6 +249,8 @@ public final class SearchableInfo implements Parcelable { com.android.internal.R.styleable.Searchable_searchSuggestIntentAction); mSuggestIntentData = a.getString( com.android.internal.R.styleable.Searchable_searchSuggestIntentData); + mSuggestThreshold = a.getInt( + com.android.internal.R.styleable.Searchable_searchSuggestThreshold, 0); } mVoiceSearchMode = a.getInt(com.android.internal.R.styleable.Searchable_voiceSearchMode, 0); @@ -600,6 +613,7 @@ public final class SearchableInfo implements Parcelable { mSuggestSelection = in.readString(); mSuggestIntentAction = in.readString(); mSuggestIntentData = in.readString(); + mSuggestThreshold = in.readInt(); mActionKeyList = null; int count = in.readInt(); @@ -636,6 +650,7 @@ public final class SearchableInfo implements Parcelable { dest.writeString(mSuggestSelection); dest.writeString(mSuggestIntentAction); dest.writeString(mSuggestIntentData); + dest.writeInt(mSuggestThreshold); // This is usually a very short linked list so we'll just pre-count it ActionKeyInfo nextKeyInfo = mActionKeyList; |
