diff options
Diffstat (limited to 'core/java/android/app/SearchManager.java')
-rw-r--r-- | core/java/android/app/SearchManager.java | 128 |
1 files changed, 39 insertions, 89 deletions
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index e5ba6a4..0631ad5 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -20,7 +20,6 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; -import android.content.res.Configuration; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; @@ -1189,8 +1188,6 @@ public class SearchManager /** * Intent extra data key: This key will be used for the extra populated by the * {@link #SUGGEST_COLUMN_INTENT_EXTRA_DATA} column. - * - * {@hide} */ public final static String EXTRA_DATA_KEY = "intent_extra_data_key"; @@ -1270,16 +1267,12 @@ public class SearchManager * result indicates the shortcut refers to a no longer valid sugggestion. * * @see #SUGGEST_COLUMN_SHORTCUT_ID - * - * @hide pending API council approval */ public final static String SUGGEST_URI_PATH_SHORTCUT = "search_suggest_shortcut"; /** * MIME type for shortcut validation. You'll use this in your suggestions content provider * in the getType() function. - * - * @hide pending API council approval */ public final static String SHORTCUT_MIME_TYPE = "vnd.android.cursor.item/vnd.android.search.suggest"; @@ -1390,9 +1383,7 @@ public class SearchManager * this element exists at the given row, this is the data that will be used when * forming the suggestion's intent. If not provided, the Intent's extra data field will be null. * This column allows suggestions to provide additional arbitrary data which will be included as - * an extra under the key EXTRA_DATA_KEY. - * - * @hide Pending API council approval. + * an extra under the key {@link #EXTRA_DATA_KEY}. */ public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data"; /** @@ -1426,8 +1417,6 @@ public class SearchManager * {@link #SUGGEST_NEVER_MAKE_SHORTCUT}, the result will not be stored as a shortcut. * Otherwise, the shortcut id will be used to check back for validation via * {@link #SUGGEST_URI_PATH_SHORTCUT}. - * - * @hide Pending API council approval. */ public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id"; @@ -1444,8 +1433,6 @@ public class SearchManager * Column name for suggestions cursor. <i>Optional.</i> This column is used to specify * that a spinner should be shown in lieu of an icon2 while the shortcut of this suggestion * is being refreshed. - * - * @hide Pending API council approval. */ public final static String SUGGEST_COLUMN_SPINNER_WHILE_REFRESHING = "suggest_spinner_while_refreshing"; @@ -1453,8 +1440,6 @@ public class SearchManager /** * Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion * should not be stored as a shortcut in global search. - * - * @hide Pending API council approval. */ public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1"; @@ -1501,8 +1486,6 @@ public class SearchManager * Intent action for starting a web search provider's settings activity. * Web search providers should handle this intent if they have provider-specific * settings to implement. - * - * @hide Pending API council approval. */ public final static String INTENT_ACTION_WEB_SEARCH_SETTINGS = "android.search.action.WEB_SEARCH_SETTINGS"; @@ -1511,11 +1494,17 @@ public class SearchManager * Intent action broadcasted to inform that the searchables list or default have changed. * Components should handle this intent if they cache any searchable data and wish to stay * up to date on changes. - * - * @hide Pending API council approval. */ public final static String INTENT_ACTION_SEARCHABLES_CHANGED = "android.search.action.SEARCHABLES_CHANGED"; + + /** + * Intent action broadcasted to inform that the search settings have changed in some way. + * Either searchables have been enabled or disabled, or a different web search provider + * has been chosen. + */ + public final static String INTENT_ACTION_SEARCH_SETTINGS_CHANGED + = "android.search.action.SETTINGS_CHANGED"; /** * If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION}, @@ -1532,8 +1521,9 @@ public class SearchManager private final Context mContext; + private int mIdent; + // package private since they are used by the inner class SearchManagerCallback - /* package */ boolean mIsShowing = false; /* package */ final Handler mHandler; /* package */ OnDismissListener mDismissListener = null; /* package */ OnCancelListener mCancelListener = null; @@ -1546,6 +1536,17 @@ public class SearchManager mService = ISearchManager.Stub.asInterface( ServiceManager.getService(Context.SEARCH_SERVICE)); } + + /*package*/ boolean hasIdent() { + return mIdent != 0; + } + + /*package*/ void setIdent(int ident) { + if (mIdent != 0) { + throw new IllegalStateException("mIdent already set"); + } + mIdent = ident; + } /** * Launch search UI. @@ -1592,13 +1593,12 @@ public class SearchManager ComponentName launchActivity, Bundle appSearchData, boolean globalSearch) { - if (DBG) debug("startSearch(), mIsShowing=" + mIsShowing); - if (mIsShowing) return; + if (mIdent == 0) throw new IllegalArgumentException( + "Called from outside of an Activity context"); try { - mIsShowing = true; // activate the search manager and start it up! mService.startSearch(initialQuery, selectInitialQuery, launchActivity, appSearchData, - globalSearch, mSearchManagerCallback); + globalSearch, mSearchManagerCallback, mIdent); } catch (RemoteException ex) { Log.e(TAG, "startSearch() failed: " + ex); } @@ -1616,15 +1616,10 @@ public class SearchManager * @see #startSearch */ public void stopSearch() { - if (DBG) debug("stopSearch(), mIsShowing=" + mIsShowing); - if (!mIsShowing) return; + if (DBG) debug("stopSearch()"); try { mService.stopSearch(); - // onDismiss will also clear this, but we do it here too since onDismiss() is - // called asynchronously. - mIsShowing = false; } catch (RemoteException ex) { - Log.e(TAG, "stopSearch() failed: " + ex); } } @@ -1638,8 +1633,13 @@ public class SearchManager * @hide */ public boolean isVisible() { - if (DBG) debug("isVisible(), mIsShowing=" + mIsShowing); - return mIsShowing; + if (DBG) debug("isVisible()"); + try { + return mService.isVisible(); + } catch (RemoteException e) { + Log.e(TAG, "isVisible() failed: " + e); + return false; + } } /** @@ -1691,7 +1691,6 @@ public class SearchManager private final Runnable mFireOnDismiss = new Runnable() { public void run() { if (DBG) debug("mFireOnDismiss"); - mIsShowing = false; if (mDismissListener != null) { mDismissListener.onDismiss(); } @@ -1701,7 +1700,6 @@ public class SearchManager private final Runnable mFireOnCancel = new Runnable() { public void run() { if (DBG) debug("mFireOnCancel"); - // doesn't need to clear mIsShowing since onDismiss() always gets called too if (mCancelListener != null) { mCancelListener.onCancel(); } @@ -1720,66 +1718,18 @@ public class SearchManager } - // TODO: remove the DialogInterface interfaces from SearchManager. - // This changes the public API, so I'll do it in a separate change. - public void onCancel(DialogInterface dialog) { - throw new UnsupportedOperationException(); - } - public void onDismiss(DialogInterface dialog) { - throw new UnsupportedOperationException(); - } - - /** - * Saves the state of the search UI. - * - * @return A Bundle containing the state of the search dialog, or {@code null} - * if the search UI is not visible. - * - * @hide - */ - public Bundle saveSearchDialog() { - if (DBG) debug("saveSearchDialog(), mIsShowing=" + mIsShowing); - if (!mIsShowing) return null; - try { - return mService.onSaveInstanceState(); - } catch (RemoteException ex) { - Log.e(TAG, "onSaveInstanceState() failed: " + ex); - return null; - } - } - /** - * Restores the state of the search dialog. - * - * @param searchDialogState Bundle to read the state from. - * - * @hide + * @deprecated This method is an obsolete internal implementation detail. Do not use. */ - public void restoreSearchDialog(Bundle searchDialogState) { - if (DBG) debug("restoreSearchDialog(" + searchDialogState + ")"); - if (searchDialogState == null) return; - try { - mService.onRestoreInstanceState(searchDialogState); - } catch (RemoteException ex) { - Log.e(TAG, "onRestoreInstanceState() failed: " + ex); - } + public void onCancel(DialogInterface dialog) { + throw new UnsupportedOperationException(); } /** - * Update the search dialog after a configuration change. - * - * @param newConfig The new configuration. - * - * @hide + * @deprecated This method is an obsolete internal implementation detail. Do not use. */ - public void onConfigurationChanged(Configuration newConfig) { - if (DBG) debug("onConfigurationChanged(" + newConfig + "), mIsShowing=" + mIsShowing); - if (!mIsShowing) return; - try { - mService.onConfigurationChanged(newConfig); - } catch (RemoteException ex) { - Log.e(TAG, "onConfigurationChanged() failed:" + ex); - } + public void onDismiss(DialogInterface dialog) { + throw new UnsupportedOperationException(); } /** |