List of usage examples for android.content Context SEARCH_SERVICE
String SEARCH_SERVICE
To view the source code for android.content Context SEARCH_SERVICE.
Click Source Link
From source file:gov.cdc.epiinfo.RecordList.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = new SearchView(this); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from w w w. j av a 2s . c om*/ public boolean onQueryTextSubmit(String searchTerm) { try { mDbHelper.fetchTopOne(); String query = BuildQuery(searchTerm); String fieldName1; String fieldName2; String fieldName3; String[] from = new String[1]; int[] to = new int[1]; if (formMetadata.DataFields.size() > 2) { fieldName1 = formMetadata.DataFields.get(0).getName(); fieldName2 = formMetadata.DataFields.get(1).getName(); fieldName3 = formMetadata.DataFields.get(2).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, fieldName3, query); from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2, "columnName3", fieldName3, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3, R.id.header4, R.id.text4, R.id.hiddenText }; } else if (formMetadata.DataFields.size() == 2) { fieldName1 = formMetadata.DataFields.get(0).getName(); fieldName2 = formMetadata.DataFields.get(1).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, query); from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3, R.id.hiddenText }; } else if (formMetadata.DataFields.size() == 1) { fieldName1 = formMetadata.DataFields.get(0).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, query); from = new String[] { "_id", "columnName1", fieldName1, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.hiddenText }; } startManagingCursor(mNotesCursor); CustomListAdapter notes = new CustomListAdapter(self, R.layout.line_list_row, mNotesCursor, from, to); lineListFragment.setListAdapter(notes); } catch (Exception ex) { fillData(); } return false; } @Override public boolean onQueryTextChange(String newText) { if (newText.equals("")) { fillData(); } return false; } }); mnuSearch = menu.add(0, SEARCH_ID, 0, R.string.menu_search); mnuSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); mnuSearch.setActionView(searchView); mnuSearch.setIcon(gov.cdc.epiinfo.R.drawable.action_search); MenuItem mnuQR = menu.add(0, QR_ID, 1, R.string.menu_barcode); mnuQR.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mnuQR.setIcon(gov.cdc.epiinfo.R.drawable.qrcode_scan); MenuItem mnuCloud = menu.add(0, CLOUD_ID, 2, R.string.menu_cloud_sync); mnuCloud.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem mnuSync = menu.add(0, SYNC_ID, 3, R.string.menu_sync_file); mnuSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem mnuDeleteAll = menu.add(0, DELETE_ALL_ID, 4, R.string.menu_delete_all); mnuDeleteAll.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (fkeyGuid == null || fkeyGuid.length() == 0) { mnuSetDefault = menu.add(0, SET_DEFAULT_ID, 5, R.string.set_default_form); mnuSetDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mnuExitDefault = menu.add(0, EXIT_DEFAULT_MODE_ID, 5, R.string.exit_default_form); mnuExitDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (AppManager.getDefaultForm().equals("")) { mnuSetDefault.setVisible(true); mnuExitDefault.setVisible(false); } else { mnuSetDefault.setVisible(false); mnuExitDefault.setVisible(true); } } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPref.getString("cloud_service", "").equals("Box")) { mnuBoxSignin = menu.add(0, BOX_SIGNIN_ID, 6, R.string.box_signin); mnuBoxSignin.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mnuBoxSignout = menu.add(0, BOX_SIGNOUT_ID, 6, R.string.box_signout); mnuBoxSignout.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (BoxClient.isAuthenticated(this)) { mnuBoxSignout.setVisible(true); mnuBoxSignin.setVisible(false); } else { mnuBoxSignout.setVisible(false); mnuBoxSignin.setVisible(true); } } MenuItem mnuHelp = menu.add(1, HELP_ID, 7, R.string.menu_help); mnuHelp.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; }
From source file:com.jtechme.apphub.FDroid.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); if (fdroidApp.bluetoothAdapter == null) { // ignore on devices without Bluetooth MenuItem btItem = menu.findItem(R.id.action_bluetooth_apk); btItem.setVisible(false);/*from w w w . java 2s.c om*/ } SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchMenuItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // LayoutParams.MATCH_PARENT does not work, use a big value instead searchView.setMaxWidth(1000000); searchView.setOnQueryTextListener(this); // If we were asked to execute a search before getting around to building the options // menu, then we should deal with that now that the options menu is all sorted out. if (pendingSearchQuery != null) { performSearch(pendingSearchQuery); pendingSearchQuery = null; } return super.onCreateOptionsMenu(menu); }
From source file:httbdd.cse.nghiatran.halofind.screen.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.sample_actions, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override// www . j a v a 2 s . c o m public boolean onQueryTextSubmit(String query) { handleSearch(query); return true; } @Override public boolean onQueryTextChange(String newText) { if (TextUtils.isEmpty(newText)) { } else { } return true; } }); return true; }
From source file:org.fdroid.fdroid.FDroid.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); if (fdroidApp.bluetoothAdapter == null) { // ignore on devices without Bluetooth MenuItem btItem = menu.findItem(R.id.action_bluetooth_apk); btItem.setVisible(false);/*w w w .j av a 2s .c om*/ } if (Build.VERSION.SDK_INT < 10) { MenuItem menuItem = menu.findItem(R.id.action_swap); menuItem.setVisible(false); } SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchMenuItem = menu.findItem(R.id.action_search); searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // LayoutParams.MATCH_PARENT does not work, use a big value instead searchView.setMaxWidth(1000000); searchView.setOnQueryTextListener(this); // If we were asked to execute a search before getting around to building the options // menu, then we should deal with that now that the options menu is all sorted out. if (pendingSearchQuery != null) { performSearch(pendingSearchQuery); pendingSearchQuery = null; } return super.onCreateOptionsMenu(menu); }
From source file:com.smedic.tubtub.Pane.java
/** * Options menu in action bar/* w w w .ja v a 2 s . co m*/ * * @param menu * @return */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); } //suggestions final CursorAdapter suggestionAdapter = new SimpleCursorAdapter(this, suggestions, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 }, new int[] { android.R.id.text1 }, 0); final List<String> suggestions = new ArrayList<>(); searchView.setSuggestionsAdapter(suggestionAdapter); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { searchView.setQuery(suggestions.get(position), false); searchView.clearFocus(); Intent suggestionIntent = new Intent(Intent.ACTION_SEARCH); suggestionIntent.putExtra(SearchManager.QUERY, suggestions.get(position)); handleIntent(suggestionIntent); return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { return false; //if true, no new intent is started } @Override public boolean onQueryTextChange(final String query) { // check network connection. If not available, do not query. // this also disables onSuggestionClick triggering if (query.length() > 2) { //make suggestions after 3rd letter if (networkConf.isNetworkAvailable()) { suggestionLoader(suggestions, suggestionAdapter, query).forceLoad(); return true; } } return false; } }); return true; }
From source file:fr.cph.chicago.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { this.mMenu = menu; getMenuInflater().inflate(R.menu.main, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return super.onCreateOptionsMenu(menu); }
From source file:org.gnucash.android.ui.account.AccountsListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (mParentAccountId > 0) inflater.inflate(R.menu.sub_account_actions, menu); else {// www . java 2 s .c o m inflater.inflate(R.menu.account_actions, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); mSearchView = (com.actionbarsherlock.widget.SearchView) menu.findItem(R.id.menu_search).getActionView(); if (mSearchView == null) return; mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); mSearchView.setOnQueryTextListener(this); mSearchView.setOnCloseListener(this); } }
From source file:com.jefftharris.passwdsafe.PasswdSafe.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (itsNavDrawerFrag.isDrawerOpen()) { return super.onCreateOptionsMenu(menu); }/*from www .java 2 s . c om*/ // Only show items in the action bar relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bar. getMenuInflater().inflate(R.menu.activity_passwdsafe, menu); restoreActionBar(); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); itsSearchItem = menu.findItem(R.id.menu_search); MenuItemCompat.collapseActionView(itsSearchItem); SearchView searchView = (SearchView) MenuItemCompat.getActionView(itsSearchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); return true; }
From source file:org.voidsink.anewjkuapp.fragment.MapFragment.java
private void setupSearchView(SearchView searchView) { // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); // Assumes current activity is the searchable activity if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setOnQueryTextListener(this); }//from www .j av a 2 s .com }
From source file:com.itude.mobile.mobbl.core.controller.MBDialogController.java
public boolean onSearchRequested() { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchableInfo searchableInfo = searchManager .getSearchableInfo(MBViewManager.getInstance().getComponentName()); if (searchableInfo == null) { return false; }// w ww. ja v a 2 s .c o m MBViewManager.getInstance().runOnUiThread(new MBThread() { @Override public void runMethod() { MBViewManager.getInstance().startSearch(null, false, null, false); } }); return true; }