List of usage examples for android.app SearchManager QUERY
String QUERY
To view the source code for android.app SearchManager QUERY.
Click Source Link
From source file:com.tandong.sa.sherlock.widget.SearchView.java
/** * Constructs an intent from the given information and the search dialog * state.//ww w . j a va 2 s . com * * @param action * Intent action. * @param data * Intent data, or <code>null</code>. * @param extraData * Data for {@link SearchManager#EXTRA_DATA_KEY} or * <code>null</code>. * @param query * Intent query, or <code>null</code>. * @param actionKey * The key code of the action key that was pressed, or * {@link KeyEvent#KEYCODE_UNKNOWN} if none. * @param actionMsg * The message for the action key that was pressed, or * <code>null</code> if none. * @return The intent. */ private Intent createIntent(String action, Uri data, String extraData, String query, int actionKey, String actionMsg) { // Now build the Intent Intent intent = new Intent(action); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // We need CLEAR_TOP to avoid reusing an old task that has other // activities // on top of the one we want. We don't want to do this in in-app search // though, // as it can be destructive to the activity stack. if (data != null) { intent.setData(data); } intent.putExtra(SearchManager.USER_QUERY, mUserQuery); if (query != null) { intent.putExtra(SearchManager.QUERY, query); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } if (mAppSearchData != null) { intent.putExtra(SearchManager.APP_DATA, mAppSearchData); } if (actionKey != KeyEvent.KEYCODE_UNKNOWN) { intent.putExtra(SearchManager.ACTION_KEY, actionKey); intent.putExtra(SearchManager.ACTION_MSG, actionMsg); } intent.setComponent(mSearchable.getSearchActivity()); return intent; }
From source file:com.bernard.beaconportal.activities.activity.MessageList.java
private boolean decodeExtras(Intent intent) { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null) { Uri uri = intent.getData();/*from www . j a v a2 s . co m*/ List<String> segmentList = uri.getPathSegments(); String accountId = segmentList.get(0); Collection<Account> accounts = Preferences.getPreferences(this).getAvailableAccounts(); for (Account account : accounts) { if (String.valueOf(account.getAccountNumber()).equals(accountId)) { mMessageReference = new MessageReference(); mMessageReference.accountUuid = account.getUuid(); mMessageReference.folderName = segmentList.get(1); mMessageReference.uid = segmentList.get(2); break; } } } else if (ACTION_SHORTCUT.equals(action)) { // Handle shortcut intents String specialFolder = intent.getStringExtra(EXTRA_SPECIAL_FOLDER); if (SearchAccount.UNIFIED_INBOX.equals(specialFolder)) { mSearch = SearchAccount.createUnifiedInboxAccount(this).getRelatedSearch(); } else if (SearchAccount.ALL_MESSAGES.equals(specialFolder)) { mSearch = SearchAccount.createAllMessagesAccount(this).getRelatedSearch(); } } else if (intent.getStringExtra(SearchManager.QUERY) != null) { // check if this intent comes from the system search ( remote ) if (Intent.ACTION_SEARCH.equals(intent.getAction())) { // Query was received from Search Dialog String query = intent.getStringExtra(SearchManager.QUERY); mSearch = new LocalSearch(getString(R.string.search_results)); mSearch.setManualSearch(true); mNoThreading = true; mSearch.or(new SearchCondition(Searchfield.SENDER, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(Searchfield.SUBJECT, Attribute.CONTAINS, query)); mSearch.or(new SearchCondition(Searchfield.MESSAGE_CONTENTS, Attribute.CONTAINS, query)); Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA); if (appData != null) { mSearch.addAccountUuid(appData.getString(EXTRA_SEARCH_ACCOUNT)); // searches started from a folder list activity will provide // an account, but no folder if (appData.getString(EXTRA_SEARCH_FOLDER) != null) { mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER)); } } else { mSearch.addAccountUuid(SearchSpecification.ALL_ACCOUNTS); } } } else { // regular LocalSearch object was passed mSearch = intent.getParcelableExtra(EXTRA_SEARCH); mNoThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false); } if (mMessageReference == null) { mMessageReference = intent.getParcelableExtra(EXTRA_MESSAGE_REFERENCE); } if (mMessageReference != null) { mSearch = new LocalSearch(); mSearch.addAccountUuid(mMessageReference.accountUuid); mSearch.addAllowedFolder(mMessageReference.folderName); } if (mSearch == null) { // We've most likely been started by an old unread widget String accountUuid = intent.getStringExtra("account"); String folderName = intent.getStringExtra("folder"); mSearch = new LocalSearch(folderName); mSearch.addAccountUuid((accountUuid == null) ? "invalid" : accountUuid); if (folderName != null) { mSearch.addAllowedFolder(folderName); } } Preferences prefs = Preferences.getPreferences(getApplicationContext()); String[] accountUuids = mSearch.getAccountUuids(); if (mSearch.searchAllAccounts()) { Account[] accounts = prefs.getAccounts(); mSingleAccountMode = (accounts.length == 1); if (mSingleAccountMode) { mAccount = accounts[0]; } } else { mSingleAccountMode = (accountUuids.length == 1); if (mSingleAccountMode) { mAccount = prefs.getAccount(accountUuids[0]); } } mSingleFolderMode = mSingleAccountMode && (mSearch.getFolderNames().size() == 1); if (mSingleAccountMode && (mAccount == null || !mAccount.isAvailable(this))) { Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account"); onAccountUnavailable(); return false; } if (mSingleFolderMode) { mFolderName = mSearch.getFolderNames().get(0); } // now we know if we are in single account mode and need a subtitle mActionBarSubTitle.setVisibility((!mSingleFolderMode) ? View.GONE : View.VISIBLE); return true; }
From source file:com.chen.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *///from w w w .j a va 2 s . c o m private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newinstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(mAccount.getEmailAddress())); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = (Uri) intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; // Save this search query for future suggestions. final String query = intent.getStringExtra(SearchManager.QUERY); final String authority = mContext.getString(R.string.suggestions_authority); final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(mContext, authority, SuggestionsProvider.MODE); suggestions.saveRecentQuery(query, null); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } } else { LogUtils.e(LOG_TAG, "Missing account extra from search intent. Finishing"); mActivity.finish(); } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); //Logger.LogVerbose("OpenExplorer.onPrepareOptionsMenu"); if (getClipboard() != null) { MenuUtils.setMenuChecked(menu, getClipboard().isMultiselect(), R.id.menu_multi); MenuUtils.setMenuVisible(menu, getClipboard().size() > 0, R.id.content_paste); } else/* w w w .j ava 2s. com*/ MenuUtils.setMenuVisible(menu, false, R.id.content_paste); MenuUtils.setMenuVisible(menu, IS_DEBUG_BUILD && !isBlackBerry(), R.id.menu_debug); if (!BEFORE_HONEYCOMB && USE_ACTION_BAR) { //MenuUtils.setMenuVisible(menu, false, R.id.title_menu); if (menu.findItem(R.id.menu_search) != null) { if (mSearchView == null) mSearchView = SearchViewCompat.newSearchView(this); MenuItem item = menu.findItem(R.id.menu_search); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); MenuItemCompat.setActionView(item, mSearchView); if (mSearchView != null) SearchViewCompat.setOnQueryTextListener(mSearchView, new SearchViewCompat.OnQueryTextListenerCompat() { public boolean onQueryTextSubmit(String query) { mSearchView.clearFocus(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEARCH); Bundle appData = new Bundle(); appData.putString("path", getDirContentFragment(false).getPath().getPath()); intent.putExtra(SearchManager.APP_DATA, appData); intent.putExtra(SearchManager.QUERY, query); handleIntent(intent); return true; } public boolean onQueryTextChange(String newText) { return false; } }); } } MenuUtils.setMenuChecked(menu, USE_SPLIT_ACTION_BAR, R.id.menu_view_split); //MenuUtils.setMenuChecked(menu, mLogFragment != null && mLogFragment.isVisible(), R.id.menu_view_logview); MenuUtils.setMenuChecked(menu, getPreferences().getBoolean("global", "pref_fullscreen", false), R.id.menu_view_fullscreen); if (!getResources().getBoolean(R.bool.allow_fullscreen)) MenuUtils.setMenuVisible(menu, false, R.id.menu_view_fullscreen); else MenuUtils.setMenuChecked(menu, IS_FULL_SCREEN, R.id.menu_view_fullscreen); if (getWindowWidth() < 500 && Build.VERSION.SDK_INT < 14) // ICS can split the actionbar { MenuUtils.setMenuShowAsAction(menu, 0 // Never , R.id.menu_sort, R.id.menu_view, R.id.menu_new_folder); MenuUtils.setMenuVisible(menu, true, R.id.menu_more); } //if(BEFORE_HONEYCOMB) { OpenFragment f = getSelectedFragment(); if (f != null && f.hasOptionsMenu() && !f.isDetached() && f.isVisible()) f.onPrepareOptionsMenu(menu); } if (menu != null && menu.findItem(R.id.content_paste) != null && getClipboard() != null && getClipboard().size() > 0) { SubMenu sub = menu.findItem(R.id.content_paste).getSubMenu(); if (sub != null) { int i = 0; for (final OpenPath item : getClipboard().getAll()) { sub.add(Menu.CATEGORY_CONTAINER, i++, i, item.getName()).setCheckable(true).setChecked(true) .setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuitem) { getClipboard().remove(item); return true; } }).setIcon(ThumbnailCreator.getDefaultResourceId(item, 32, 32)); } } } if (!CAN_DO_CAROUSEL) MenuUtils.setMenuVisible(menu, false, R.id.menu_view_carousel); //if(BEFORE_HONEYCOMB) // setupBaseBarButtons(menu, false); return true; }
From source file:com.android.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *///w w w . j a va 2 s.com private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newInstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setEmail(mAccount.getEmailAddress(), mAccount.getType()); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } // Check if we should load all conversations instead of using // the default behavior which loads an initial subset. mIgnoreInitialConversationLimit = intent.getBooleanExtra(Utils.EXTRA_IGNORE_INITIAL_CONVERSATION_LIMIT, false); args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; // Save this search query for future suggestions final String query = intent.getStringExtra(SearchManager.QUERY); mSearchViewController.saveRecentQuery(query); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } } else { LogUtils.e(LOG_TAG, "Missing account extra from search intent. Finishing"); mActivity.finish(); } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *//* w w w . j a v a 2s.c o m*/ private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newInstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(mAccount.getEmailAddress())); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; //TS: junwei-xu 2014-1-5 EMAIL BUGFIX_879468 ADD_S } else if (intent.getData() != null) { folderUri = intent.getData(); //TS: junwei-xu 2014-1-5 EMAIL BUGFIX_879468 ADD_E } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } // Check if we should load all conversations instead of using // the default behavior which loads an initial subset. mIgnoreInitialConversationLimit = intent.getBooleanExtra(Utils.EXTRA_IGNORE_INITIAL_CONVERSATION_LIMIT, false); args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; //TS: zheng.zou 2015-03-18 EMAIL BUGFIX_744708 ADD_S mToastBar.hide(false, false); //TS: zheng.zou 2015-03-18 EMAIL BUGFIX_744708 ADD_E // Save this search query for future suggestions. final String query = intent.getStringExtra(SearchManager.QUERY); final String authority = mContext.getString(R.string.suggestions_authority); final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(mContext, authority, SuggestionsProvider.MODE); suggestions.saveRecentQuery(query, null); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } /** TCT: init the list context for remote search, except folder. @{ */ // use a UNINITIALIZED folder temporarily. need update when finish search load. Folder folder = Folder.newUnsafeInstance(); mConvListContext = ConversationListContext.forSearchQuery(mAccount, folder, query); mConvListContext .setSearchField(mActivity.getIntent().getStringExtra(SearchParams.BUNDLE_QUERY_FIELD)); /** @} */ } else { /** TCT: The action is search but no extra account means it's a global search. @{ */ mGlobalSearch = true; LogUtils.logFeature(LogTag.SEARCH_TAG, "Handle ACTION_SEARCH , is mGlobalSearch [%s]", mGlobalSearch); // reload conbined inbox folder if needed. if (mAccount != null && (mFolder == null || !mFolder.isInitialized())) { Bundle args = new Bundle(); LogUtils.logFeature(LogTag.SEARCH_TAG, " GlobalSearch but without Folder, reload inbox again."); args.putParcelable(Utils.EXTRA_FOLDER_URI, mAccount.settings.defaultInbox); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } /** @} */ } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }