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.todoroo.astrid.activity.TaskListActivity.java
/** * @see android.app.Activity#onCreate(Bundle) *//* w w w.j a va 2 s . c o m*/ @Override protected void onCreate(Bundle savedInstanceState) { ThemeService.applyTheme(this); super.onCreate(savedInstanceState); DependencyInjectionService.getInstance().inject(this); int contentView = getContentView(); if (contentView == R.layout.task_list_wrapper_activity) swipeEnabled = true; setContentView(contentView); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(getHeaderView()); listsNav = actionBar.getCustomView().findViewById(R.id.lists_nav); listsNavDisclosure = (ImageView) actionBar.getCustomView().findViewById(R.id.list_disclosure_arrow); lists = (TextView) actionBar.getCustomView().findViewById(R.id.list_title); mainMenu = (ImageView) actionBar.getCustomView().findViewById(R.id.main_menu); personStatus = (TextView) actionBar.getCustomView().findViewById(R.id.person_image); commentsButton = (Button) actionBar.getCustomView().findViewById(R.id.comments); if (ThemeService.getTheme() == R.style.Theme_White_Alt) commentsButton.setTextColor(getResources().getColor(R.color.blue_theme_color)); initializeFragments(actionBar); createMainMenuPopover(); mainMenu.setOnClickListener(mainMenuClickListener); commentsButton.setOnClickListener(commentsButtonClickListener); personStatus.setOnClickListener(friendStatusClickListener); Bundle extras = getIntent().getExtras(); if (extras != null) extras = (Bundle) extras.clone(); if (extras == null) extras = new Bundle(); Filter savedFilter = getIntent().getParcelableExtra(TaskListFragment.TOKEN_FILTER); if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { String query = getIntent().getStringExtra(SearchManager.QUERY).trim(); String title = getString(R.string.FLA_search_filter, query); savedFilter = new Filter(title, title, new QueryTemplate().where(Task.TITLE.like("%" + //$NON-NLS-1$ query + "%")), //$NON-NLS-1$ null); } if (savedFilter == null) { savedFilter = getDefaultFilter(); extras.putAll(configureIntentAndExtrasWithFilter(getIntent(), savedFilter)); } extras.putParcelable(TaskListFragment.TOKEN_FILTER, savedFilter); if (swipeIsEnabled()) { setupPagerAdapter(); } setupTasklistFragmentWithFilter(savedFilter, extras); if (savedFilter != null) setListsTitle(savedFilter.title); if (getIntent().hasExtra(TOKEN_SOURCE)) { trackActivitySource(); } // Have to call this here because sometimes StartupService // isn't called (i.e. if the app was silently alive in the background) abTestEventReportingService.trackUserRetention(this); }
From source file:com.dictionary.activity.ArticleCollectionActivity.java
private ArticleCollectionPagerAdapter createFromIntent(Application app, Intent intent) { String lookupKey = intent.getStringExtra(Intent.EXTRA_TEXT); if (lookupKey == null) { lookupKey = intent.getStringExtra(SearchManager.QUERY); }//from www .j ava 2s . c om BlobListAdapter data = new BlobListAdapter(this, 3, 1); if (lookupKey == null || lookupKey.length() == 0) { Toast.makeText(this, R.string.article_collection_nothing_to_lookup, Toast.LENGTH_SHORT).show(); } else { Iterator<Slob.Blob> result; do { result = app.find(lookupKey, null, true); if (result.hasNext()) { break; } lookupKey = lookupKey.substring(0, lookupKey.length() - 1); } while (lookupKey.length() > 0); data.setData(result); } return new ArticleCollectionPagerAdapter(app, data, blobToBlob, getSupportFragmentManager()); }
From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java
private void setupRecyclerViewAsync(@NonNull final ViewGroup viewGroup) { final ProgressDialog progressDialog = ProgressDialog.show(this, getResources().getString(R.string.progress_loading_posts), getResources().getString(R.string.progress_please_wait), true, false); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); DatabaseLink.DatabaseListener listener = new DatabaseLink.DatabaseListener() { @Override/*w w w . j a va 2s . c om*/ void onGetResponse(String str) { final Post[] posts; try { JSONObject json = new JSONObject(str); posts = DatabaseLink.parseJson(json); } catch (JSONException e) { onError("JSON is invalid. Error: " + e.getMessage() + ", JSON: " + str); return; } if (progressDialog.isShowing()) progressDialog.dismiss(); final Post[] sortedPosts = sortPosts(posts); runOnUiThread(new Runnable() { @Override public void run() { // Inflate layout post_list View rootView = View.inflate(PostListActivity.this, R.layout.post_list, null); RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.post_list); // Setup refresh action SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) rootView .findViewById(R.id.swipe_refresh); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { recreate(); } }); // Set adapter with posts recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(sortedPosts)); // Add to ViewGroup viewGroup.addView(rootView); } }); } @Override void onError(String error) { if (progressDialog.isShowing()) progressDialog.dismiss(); new AlertDialog.Builder(progressDialog.getContext()).setTitle("Error").setMessage(error).show(); } }; Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) DatabaseLink.instance.getPostsWithTag(listener, intent.getStringExtra(SearchManager.QUERY)); else DatabaseLink.instance.getAllPosts(listener); Log.v("TrafficTimeWaste", "Querying db..."); }
From source file:org.yammp.app.ArtistFragment.java
private void doSearch() { CharSequence title = null;/*from ww w. j ava 2s . com*/ String query = null; if (mCurrentGroupArtistName == null || MediaStore.UNKNOWN_STRING.equals(mCurrentGroupArtistName)) return; Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); title = mCurrentGroupArtistName; query = mCurrentGroupArtistName; i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentGroupArtistName); i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "audio/*"); title = getString(R.string.mediasearch, title); i.putExtra(SearchManager.QUERY, query); startActivity(Intent.createChooser(i, title)); }
From source file:com.dsdar.thosearoundme.util.MemberAddContactsListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check if this fragment is part of a two-pane set up or a single pane // by reading a // boolean from the application resource directories. This lets allows // us to easily specify // which screen sizes should use a two-pane layout by setting this // boolean in the // corresponding resource size-qualified directory. // mIsTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes); // Let this fragment contribute menu items setHasOptionsMenu(true);/*from ww w. jav a2 s. c om*/ // Create the main contacts adapter mAdapter = new ContactsAdapter(getActivity()); itsContext = this.getActivity(); itsContactListActivity = new TeamMemberAddActivity(); itsSharedPreference = itsContext.getApplicationContext().getSharedPreferences(MyAppConstants.APP_PREFERENCE, itsContactListActivity.MODE_PRIVATE); itsContactsList = new ArrayList<Contact>(); if (savedInstanceState != null) { // If we're restoring state after this fragment was recreated then // retrieve previous search term and previously selected search // result. mSearchTerm = savedInstanceState.getString(SearchManager.QUERY); mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0); } /* * An ImageLoader object loads and resizes an image in the background * and binds it to the QuickContactBadge in each item layout of the * ListView. ImageLoader implements memory caching for each image, which * substantially improves refreshes of the ListView as the user scrolls * through it. * * To learn more about downloading images asynchronously and caching the * results, read the Android training class Displaying Bitmaps * Efficiently. * * http://developer.android.com/training/displaying-bitmaps/ */ mImageLoader = new ImageLoader(getActivity(), getListPreferredItemHeight()) { @Override protected Bitmap processBitmap(Object data) { // This gets called in a background thread and passed the data // from // ImageLoader.loadImage(). return loadContactPhotoThumbnail((String) data, getImageSize()); } }; // Set a placeholder loading image for the image loader mImageLoader.setLoadingImage(R.drawable.ic_contact_picture_holo_light); // Add a cache to the image loader mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f); }
From source file:org.transdroid.core.gui.search.SearchActivity.java
/** * Extracts the query string from the search {@link Intent} * @return The query string that was entered by the user */// www . j ava2 s.co m private String parseQuery(Intent intent) { String query = null; if (intent.getAction().equals(Intent.ACTION_SEARCH)) { query = intent.getStringExtra(SearchManager.QUERY).trim(); } else if (intent.getAction().equals(Intent.ACTION_SEND)) { query = SendIntentHelper.cleanUpText(intent).trim(); } if (query != null && query.length() > 0) { // Remember this search query to later show as a suggestion suggestions.saveRecentQuery(query, null); return query; } return null; }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // This needs to be before super.onCreate, otherwise ActionbarSherlock // doesn't makes the background of the actionbar white when you're // in the dark theme. setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId); Log.d(LOG, "onCreate:" + this); super.onCreate(savedInstanceState); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Don't auto-launch if this fails. prefs.edit().remove(C.DICT_FILE).commit(); setContentView(R.layout.dictionary_activity); application = (DictionaryApplication) getApplication(); theme = application.getSelectedTheme(); textColorFg = getResources().getColor(theme.tokenRowFgColor); final Intent intent = getIntent(); String intentAction = intent.getAction(); /**//ww w . j a v a 2 s .c o m * @author Dominik Kppl Querying the Intent * com.hughes.action.ACTION_SEARCH_DICT is the advanced query * Arguments: SearchManager.QUERY -> the phrase to search from * -> language in which the phrase is written to -> to which * language shall be translated */ if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) { String query = intent.getStringExtra(SearchManager.QUERY); String from = intent.getStringExtra("from"); if (from != null) from = from.toLowerCase(Locale.US); String to = intent.getStringExtra("to"); if (to != null) to = to.toLowerCase(Locale.US); if (query != null) { getIntent().putExtra(C.SEARCH_TOKEN, query); } if (intent.getStringExtra(C.DICT_FILE) == null && (from != null || to != null)) { Log.d(LOG, "DictSearch: from: " + from + " to " + to); List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null); for (DictionaryInfo info : dicts) { boolean hasFrom = from == null; boolean hasTo = to == null; for (IndexInfo index : info.indexInfos) { if (!hasFrom && index.shortName.toLowerCase(Locale.US).equals(from)) hasFrom = true; if (!hasTo && index.shortName.toLowerCase(Locale.US).equals(to)) hasTo = true; } if (hasFrom && hasTo) { if (from != null) { int which_index = 0; for (; which_index < info.indexInfos.size(); ++which_index) { if (info.indexInfos.get(which_index).shortName.toLowerCase(Locale.US).equals(from)) break; } intent.putExtra(C.INDEX_SHORT_NAME, info.indexInfos.get(which_index).shortName); } intent.putExtra(C.DICT_FILE, application.getPath(info.uncompressedFilename).toString()); break; } } } } /** * @author Dominik Kppl Querying the Intent Intent.ACTION_SEARCH is a * simple query Arguments follow from android standard (see * documentation) */ if (intentAction != null && intentAction.equals(Intent.ACTION_SEARCH)) { String query = intent.getStringExtra(SearchManager.QUERY); if (query != null) getIntent().putExtra(C.SEARCH_TOKEN, query); } /** * @author Dominik Kppl If no dictionary is chosen, use the default * dictionary specified in the preferences If this step does * fail (no default directory specified), show a toast and * abort. */ if (intent.getStringExtra(C.DICT_FILE) == null) { String dictfile = prefs.getString(getString(R.string.defaultDicKey), null); if (dictfile != null) intent.putExtra(C.DICT_FILE, application.getPath(dictfile).toString()); } String dictFilename = intent.getStringExtra(C.DICT_FILE); if (dictFilename == null) { Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show(); startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return; } if (dictFilename != null) dictFile = new File(dictFilename); ttsReady = false; textToSpeech = new TextToSpeech(getApplicationContext(), new OnInitListener() { @Override public void onInit(int status) { ttsReady = true; updateTTSLanguage(indexIndex); } }); try { final String name = application.getDictionaryName(dictFile.getName()); this.setTitle("QuickDic: " + name); dictRaf = new RandomAccessFile(dictFile, "r"); dictionary = new Dictionary(dictRaf); } catch (Exception e) { Log.e(LOG, "Unable to load dictionary.", e); if (dictRaf != null) { try { dictRaf.close(); } catch (IOException e1) { Log.e(LOG, "Unable to close dictRaf.", e1); } dictRaf = null; } Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG) .show(); startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return; } String targetIndex = intent.getStringExtra(C.INDEX_SHORT_NAME); if (savedInstanceState != null && savedInstanceState.getString(C.INDEX_SHORT_NAME) != null) { targetIndex = savedInstanceState.getString(C.INDEX_SHORT_NAME); } indexIndex = 0; for (int i = 0; i < dictionary.indices.size(); ++i) { if (dictionary.indices.get(i).shortName.equals(targetIndex)) { indexIndex = i; break; } } Log.d(LOG, "Loading index " + indexIndex); index = dictionary.indices.get(indexIndex); setListAdapter(new IndexAdapter(index)); // Pre-load the collators. new Thread(new Runnable() { public void run() { android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); final long startMillis = System.currentTimeMillis(); try { TransliteratorManager.init(new TransliteratorManager.Callback() { @Override public void onTransliteratorReady() { uiHandler.post(new Runnable() { @Override public void run() { onSearchTextChange(searchView.getQuery().toString()); } }); } }); for (final Index index : dictionary.indices) { final String searchToken = index.sortedIndexEntries.get(0).token; final IndexEntry entry = index.findExact(searchToken); if (entry == null || !searchToken.equals(entry.token)) { Log.e(LOG, "Couldn't find token: " + searchToken + ", " + (entry == null ? "null" : entry.token)); } } indexPrepFinished = true; } catch (Exception e) { Log.w(LOG, "Exception while prepping. This can happen if dictionary is closed while search is happening."); } Log.d(LOG, "Prepping indices took:" + (System.currentTimeMillis() - startMillis)); } }).start(); String fontName = prefs.getString(getString(R.string.fontKey), "FreeSerif.otf.jpg"); if ("SYSTEM".equals(fontName)) { typeface = Typeface.DEFAULT; } else if ("SERIF".equals(fontName)) { typeface = Typeface.SERIF; } else if ("SANS_SERIF".equals(fontName)) { typeface = Typeface.SANS_SERIF; } else if ("MONOSPACE".equals(fontName)) { typeface = Typeface.MONOSPACE; } else { if ("FreeSerif.ttf.jpg".equals(fontName)) { fontName = "FreeSerif.otf.jpg"; } try { typeface = Typeface.createFromAsset(getAssets(), fontName); } catch (Exception e) { Log.w(LOG, "Exception trying to use typeface, using default.", e); Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()), Toast.LENGTH_LONG) .show(); } } if (typeface == null) { Log.w(LOG, "Unable to create typeface, using default."); typeface = Typeface.DEFAULT; } final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14"); try { fontSizeSp = Integer.parseInt(fontSize.trim()); } catch (NumberFormatException e) { fontSizeSp = 14; } // ContextMenu. registerForContextMenu(getListView()); // Cache some prefs. wordList = application.getWordListFile(); saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey), false); clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey), false); Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry); onCreateSetupActionBarAndSearchView(); // Set the search text from the intent, then the saved state. String text = getIntent().getStringExtra(C.SEARCH_TOKEN); if (savedInstanceState != null) { text = savedInstanceState.getString(C.SEARCH_TOKEN); } if (text == null) { text = ""; } setSearchText(text, true); Log.d(LOG, "Trying to restore searchText=" + text); setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString()); updateLangButton(); searchView.requestFocus(); // http://stackoverflow.com/questions/2833057/background-listview-becomes-black-when-scrolling // getListView().setCacheColorHint(0); }
From source file:com.example.android.navigationdrawerexample.Controller.PilihanController.java
/** @Override//w ww . ja v a 2 s. com public boolean onPrepareOptionsMenu(Menu menu) { // If the nav drawer is open, hide action items related to the content view boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); menu.findItem(R.id.action_websearch).setVisible(!drawerOpen); return super.onPrepareOptionsMenu(menu); } */ @Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; } // Handle action buttons switch (item.getItemId()) { case R.id.action_websearch: // create intent to perform web search for this planet Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getActionBar().getTitle()); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.hannesdorfmann.search.SearchActivity.java
@Override protected void onNewIntent(Intent intent) { if (intent.hasExtra(SearchManager.QUERY)) { String query = intent.getStringExtra(SearchManager.QUERY); if (!TextUtils.isEmpty(query)) { searchView.setQuery(query, false); searchFor(query);/* ww w.j a v a 2s . co m*/ } } }
From source file:info.staticfree.android.units.Units.java
private void handleIntent(Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { final Intent pickUnit = new Intent(Intent.ACTION_PICK, UsageEntry.CONTENT_URI); final String query = intent.getExtras().getString(SearchManager.QUERY); pickUnit.putExtra(UnitList.EXTRA_UNIT_QUERY, query); startActivityForResult(pickUnit, REQUEST_PICK_UNIT); } else if (ACTION_USE_UNIT.equals(action)) { sendUnitAsSoftKeyboard(intent.getData()); }/* www. j av a 2 s . c o m*/ }