Search in sources :

Example 56 with SearchManager

use of android.app.SearchManager in project chefly_android by chef-ly.

the class RecipeListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(false);
    ImageView closeButton = (ImageView) searchView.findViewById(R.id.search_close_btn);
    closeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.d(TAG, "SearchView -> OnClose --> " + queryString);
            menu.findItem(searchView.getId()).collapseActionView();
            queryString = "";
            server.updateSearch("");
            server.setList(serverRecipes, true);
        }
    });
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            queryString = query;
            server.updateSearch(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) ImageView(android.widget.ImageView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 57 with SearchManager

use of android.app.SearchManager in project Talon-for-Twitter by klinker24.

the class SearchedTrendsActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search_activity, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    // Do not iconify the widget; expand it by default
    searchView.setIconifiedByDefault(true);
    int searchImgId = getResources().getIdentifier("android:id/search_button", null, null);
    ImageView view = (ImageView) searchView.findViewById(searchImgId);
    view.setImageResource(settings.theme == AppSettings.THEME_LIGHT ? R.drawable.ic_action_search_light : R.drawable.ic_action_search_dark);
    return true;
}
Also used : MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager) ImageView(android.widget.ImageView) Point(android.graphics.Point)

Example 58 with SearchManager

use of android.app.SearchManager in project glimmr by brk3.

the class BaseFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.fragment_main_menu, menu);
    SearchManager searchManager = (SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(mActivity.getComponentName()));
    if (mOAuth == null || mOAuth.getUser() == null) {
        menu.findItem(R.id.menu_login).setVisible(true);
        menu.findItem(R.id.menu_logout).setVisible(false);
    } else {
        menu.findItem(R.id.menu_login).setVisible(false);
        menu.findItem(R.id.menu_logout).setVisible(true);
    }
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager)

Example 59 with SearchManager

use of android.app.SearchManager in project AndroidPractice by lguipeng.

the class SearchActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    searchItem.expandActionView();
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    ComponentName componentName = getComponentName();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(componentName));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem) ComponentName(android.content.ComponentName)

Example 60 with SearchManager

use of android.app.SearchManager in project FlexibleAdapter by davideas.

the class MainActivity method initSearchView.

/* ===========
	 * SEARCH VIEW
	 * =========== */
@Override
public void initSearchView(final Menu menu) {
    // Associate searchable configuration with the SearchView
    Log.d(TAG, "onCreateOptionsMenu setup SearchView!");
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    if (searchItem != null) {
        MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {

            @Override
            public boolean onMenuItemActionExpand(MenuItem item) {
                MenuItem listTypeItem = menu.findItem(R.id.action_list_type);
                if (listTypeItem != null)
                    listTypeItem.setVisible(false);
                //hideFab();
                return true;
            }

            @Override
            public boolean onMenuItemActionCollapse(MenuItem item) {
                MenuItem listTypeItem = menu.findItem(R.id.action_list_type);
                if (listTypeItem != null)
                    listTypeItem.setVisible(true);
                //showFab();
                return true;
            }
        });
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
        mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN);
        mSearchView.setQueryHint(getString(R.string.action_search));
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setOnQueryTextListener(this);
    }
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem)

Aggregations

SearchManager (android.app.SearchManager)101 Intent (android.content.Intent)31 ISearchManager (android.app.ISearchManager)26 ActivityNotFoundException (android.content.ActivityNotFoundException)20 ComponentName (android.content.ComponentName)20 Bundle (android.os.Bundle)14 SearchView (android.support.v7.widget.SearchView)14 MenuItem (android.view.MenuItem)14 RecognizerIntent (android.speech.RecognizerIntent)12 UserHandle (android.os.UserHandle)10 View (android.view.View)9 ImageView (android.widget.ImageView)8 SearchView (android.widget.SearchView)8 TextView (android.widget.TextView)8 ActivityOptions (android.app.ActivityOptions)7 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 MenuInflater (android.view.MenuInflater)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5