diff options
| author | Amith Yamasani <yamasani@google.com> | 2010-01-25 09:15:50 -0800 |
|---|---|---|
| committer | Amith Yamasani <yamasani@google.com> | 2010-01-27 12:16:45 -0800 |
| commit | e9ce3f01d42769f03f10e70c3244500e92d7eee1 (patch) | |
| tree | 6b476470fcbb3da64b2bd81f04378f5171e72620 /core/java/android/app | |
| parent | ec3cad8ec6b18da75b179d0fd279d652ae8fc1aa (diff) | |
Move Search dialog out of system process into current activity.
SearchManager now manages the SearchDialog, in-process.
Nuked SearchDialogWrapper
SearchManagerService now just holds the Searchables information.
Hitting Search when in the local Search dialog will launch the QSB.
Diffstat (limited to 'core/java/android/app')
| -rw-r--r-- | core/java/android/app/Activity.java | 13 | ||||
| -rw-r--r-- | core/java/android/app/ISearchManager.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/app/SearchDialog.java | 18 | ||||
| -rw-r--r-- | core/java/android/app/SearchManager.java | 92 |
4 files changed, 36 insertions, 106 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 1c3414d14438..ca15a99f182a 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -39,6 +39,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; +import android.os.Looper; import android.os.RemoteException; import android.text.Selection; import android.text.SpannableStringBuilder; @@ -3449,17 +3450,7 @@ public class Activity extends ContextThemeWrapper return; } - // uses super.getSystemService() since this.getSystemService() looks at the - // mSearchManager field. - mSearchManager = (SearchManager) super.getSystemService(Context.SEARCH_SERVICE); - int ident = mIdent; - if (ident == 0) { - if (mParent != null) ident = mParent.mIdent; - if (ident == 0) { - throw new IllegalArgumentException("no ident"); - } - } - mSearchManager.setIdent(ident, getComponentName()); + mSearchManager = new SearchManager(this, null); } @Override diff --git a/core/java/android/app/ISearchManager.aidl b/core/java/android/app/ISearchManager.aidl index 0920467d8b89..9ba7863b4d3b 100644 --- a/core/java/android/app/ISearchManager.aidl +++ b/core/java/android/app/ISearchManager.aidl @@ -29,23 +29,4 @@ interface ISearchManager { List<SearchableInfo> getSearchablesForWebSearch(); SearchableInfo getDefaultSearchableForWebSearch(); void setDefaultWebSearch(in ComponentName component); - void startSearch(in String initialQuery, - boolean selectInitialQuery, - in ComponentName launchActivity, - in Bundle appSearchData, - boolean globalSearch, - ISearchManagerCallback searchManagerCallback, - int ident); - - void triggerSearch(in String query, - in ComponentName launchActivity, - in Bundle appSearchData, - ISearchManagerCallback searchManagerCallback, - int ident); - - void stopSearch(); - - - boolean isVisible(); - } diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index b3963968b09a..3dfbe7184f90 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -73,8 +73,8 @@ import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicLong; /** - * System search dialog. This is controlled by the - * SearchManagerService and runs in the system process. + * Search dialog. This is controlled by the + * SearchManager and runs in the current foreground process. * * @hide */ @@ -118,6 +118,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS private Bundle mAppSearchData; private boolean mGlobalSearchMode; private Context mActivityContext; + private SearchManager mSearchManager; // Values we store to allow user to toggle between in-app search and global search. private ComponentName mStoredComponentName; @@ -157,7 +158,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS * * @param context Application Context we can use for system acess */ - public SearchDialog(Context context) { + public SearchDialog(Context context, SearchManager searchManager) { super(context, com.android.internal.R.style.Theme_GlobalSearchBar); // Save voice intent for later queries/launching @@ -168,6 +169,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mSearchManager = searchManager; } /** @@ -180,7 +182,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS Window theWindow = getWindow(); WindowManager.LayoutParams lp = theWindow.getAttributes(); - lp.type = WindowManager.LayoutParams.TYPE_SEARCH_BAR; lp.width = ViewGroup.LayoutParams.MATCH_PARENT; // taking up the whole window (even when transparent) is less than ideal, // but necessary to show the popup window until the window manager supports @@ -291,8 +292,10 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // // TODO: When the browser icon issue is reconciled in Eclair, remove this special case. if (isBrowserSearch()) currentSearchText = ""; - - return doShow(currentSearchText, false, null, mAppSearchData, true); + + cancel(); + mSearchManager.startGlobalSearch(currentSearchText, false, mStoredAppSearchData); + return true; } else { if (mStoredComponentName != null) { // This means we should toggle *back* to an in-app search context from @@ -1314,8 +1317,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS } /** - * Launches an intent, including any special intent handling. Doesn't dismiss the dialog - * since that will be handled in {@link SearchDialogWrapper#performActivityResuming} + * Launches an intent, including any special intent handling. */ private void launchIntent(Intent intent) { if (intent == null) { diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index d25d6702c703..12a434784620 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -1709,7 +1709,7 @@ public class SearchManager /* package */ OnDismissListener mDismissListener = null; /* package */ OnCancelListener mCancelListener = null; - private final SearchManagerCallback mSearchManagerCallback = new SearchManagerCallback(); + private SearchDialog mSearchDialog; /*package*/ SearchManager(Context context, Handler handler) { mContext = context; @@ -1778,31 +1778,29 @@ public class SearchManager ComponentName launchActivity, Bundle appSearchData, boolean globalSearch) { - if (mIdent == 0) throw new IllegalArgumentException( - "Called from outside of an Activity context"); + ensureSearchDialog(); if (globalSearch) { startGlobalSearch(initialQuery, selectInitialQuery, appSearchData); return; } - if (!mAssociatedPackage.equals(launchActivity.getPackageName())) { - Log.w(TAG, "invoking app search on a different package " + - "not associated with this search manager"); - } - try { - // activate the search manager and start it up! - mService.startSearch(initialQuery, selectInitialQuery, launchActivity, appSearchData, - globalSearch, mSearchManagerCallback, mIdent); - } catch (RemoteException ex) { - Log.e(TAG, "startSearch() failed.", ex); + mSearchDialog.show(initialQuery, selectInitialQuery, launchActivity, appSearchData, + globalSearch); + } + + private void ensureSearchDialog() { + if (mSearchDialog == null) { + mSearchDialog = new SearchDialog(mContext, this); + mSearchDialog.setOnCancelListener(this); + mSearchDialog.setOnDismissListener(this); } } /** * Starts the global search activity. */ - private void startGlobalSearch(String initialQuery, boolean selectInitialQuery, + /* package */ void startGlobalSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData) { ComponentName globalSearchActivity = getGlobalSearchActivity(); if (globalSearchActivity == null) { @@ -1876,8 +1874,6 @@ public class SearchManager public void triggerSearch(String query, ComponentName launchActivity, Bundle appSearchData) { - if (mIdent == 0) throw new IllegalArgumentException( - "Called from outside of an Activity context"); if (!mAssociatedPackage.equals(launchActivity.getPackageName())) { throw new IllegalArgumentException("invoking app search on a different package " + "not associated with this search manager"); @@ -1886,12 +1882,8 @@ public class SearchManager Log.w(TAG, "triggerSearch called with empty query, ignoring."); return; } - try { - mService.triggerSearch(query, launchActivity, appSearchData, mSearchManagerCallback, - mIdent); - } catch (RemoteException ex) { - Log.e(TAG, "triggerSearch() failed.", ex); - } + startSearch(query, false, launchActivity, appSearchData, false); + mSearchDialog.launchQuerySearch(); } /** @@ -1906,10 +1898,8 @@ public class SearchManager * @see #startSearch */ public void stopSearch() { - if (DBG) debug("stopSearch()"); - try { - mService.stopSearch(); - } catch (RemoteException ex) { + if (mSearchDialog != null) { + mSearchDialog.cancel(); } } @@ -1923,13 +1913,7 @@ public class SearchManager * @hide */ public boolean isVisible() { - if (DBG) debug("isVisible()"); - try { - return mService.isVisible(); - } catch (RemoteException e) { - Log.e(TAG, "isVisible() failed: " + e); - return false; - } + return mSearchDialog == null? false : mSearchDialog.isShowing(); } /** @@ -1976,44 +1960,14 @@ public class SearchManager mCancelListener = listener; } - private class SearchManagerCallback extends ISearchManagerCallback.Stub { - - private final Runnable mFireOnDismiss = new Runnable() { - public void run() { - if (DBG) debug("mFireOnDismiss"); - if (mDismissListener != null) { - mDismissListener.onDismiss(); - } - } - }; - - private final Runnable mFireOnCancel = new Runnable() { - public void run() { - if (DBG) debug("mFireOnCancel"); - if (mCancelListener != null) { - mCancelListener.onCancel(); - } - } - }; - - public void onDismiss() { - if (DBG) debug("onDismiss()"); - mHandler.post(mFireOnDismiss); - } - - public void onCancel() { - if (DBG) debug("onCancel()"); - mHandler.post(mFireOnCancel); - } - - } - /** * @deprecated This method is an obsolete internal implementation detail. Do not use. */ @Deprecated public void onCancel(DialogInterface dialog) { - throw new UnsupportedOperationException(); + if (mCancelListener != null) { + mCancelListener.onCancel(); + } } /** @@ -2021,7 +1975,9 @@ public class SearchManager */ @Deprecated public void onDismiss(DialogInterface dialog) { - throw new UnsupportedOperationException(); + if (mDismissListener != null) { + mDismissListener.onDismiss(); + } } /** @@ -2208,4 +2164,4 @@ public class SearchManager Thread thread = Thread.currentThread(); Log.d(TAG, msg + " (" + thread.getName() + "-" + thread.getId() + ")"); } -}
\ No newline at end of file +} |
