Example usage for android.app SearchManager getSearchableInfo

List of usage examples for android.app SearchManager getSearchableInfo

Introduction

In this page you can find the example usage for android.app SearchManager getSearchableInfo.

Prototype

public SearchableInfo getSearchableInfo(ComponentName componentName) 

Source Link

Document

Gets information about a searchable activity.

Usage

From source file:it.gulch.linuxday.android.activities.MainActivity.java

@SuppressLint("NewApi")
@Override//from w  w w  .j a va 2 s  .co m
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    MenuItem searchMenuItem = menu.findItem(R.id.search);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        this.searchMenuItem = searchMenuItem;
        // Associate searchable configuration with the SearchView
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    } else {
        // Legacy search mode for Eclair
        MenuItemCompat.setActionView(searchMenuItem, null);
        MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    }

    return true;
}

From source file:net.mypapit.mobile.callsignview.MainActivity.java

@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);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    if (!mSearchHandle) {
        searchView.setQueryHint("Search Callsign");
    } else {//from w w w  .jav  a  2 s  .c  o  m
        searchView.setQueryHint("Search Handle/Name");
    }
    searchView.setOnQueryTextListener(this);

    return true;
}

From source file:de.kuschku.quasseldroid_ng.ui.chat.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.chat, menu);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    RxSearchView.queryTextChanges(searchView).debounce(400, TimeUnit.MILLISECONDS)
            .observeOn(AndroidSchedulers.mainThread()).subscribe(charSequence -> {
                if (context.client() != null
                        && context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED)
                    context.client().backlogStorage().getFilter(context.client().backlogManager().open())
                            .setQuery(charSequence);
            });/*from w w w .  j  a  va 2 s . c  o m*/
    return super.onCreateOptionsMenu(menu);
}

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);//from ww  w .  j  a v  a2  s  .  c o m
    }
    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:ufms.br.com.ufmsapp.fragment.EventosFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    getActivity().getMenuInflater().inflate(R.menu.eventos_list_menu, menu);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setOnQueryTextListener(this);
    searchView.setQueryHint(getString(R.string.txt_busca));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
}

From source file:com.zotfeed2.CardContentFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_anteater_tv, menu);
    //        MenuItem item = menu.findItem(R.id.action_search);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
    if (sv != null) {
        sv.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
        sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override//from w ww. j a  va 2s .c o  m
            public boolean onQueryTextSubmit(String query) {
                System.out.print("QUERY:" + query);
                ArrayList<VideoItem> results = new ArrayList<VideoItem>();
                if (!videoBeans.isEmpty() || videoBeans != null) {
                    for (VideoItem videoItem : videoBeans) {
                        //System.out.println("Title: " + article.getTitle());
                        if (videoItem.getTitle().toLowerCase().contains(query.toLowerCase())) {
                            results.add(videoItem);
                        }
                    }
                    System.out.println("Size: " + results.size());
                    search = true;
                    recyclerView.setAdapter(new ContentAdapter(results));
                    recyclerView.setHasFixedSize(true);
                    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                if (newText.isEmpty() || newText.equals(" ")) {
                    if (videoBeans != null) {
                        recyclerView.setAdapter(new ContentAdapter(videoBeans));
                        recyclerView.setHasFixedSize(true);
                        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
                    }
                }
                return false;
            }
        });
    }
    super.onCreateOptionsMenu(menu, inflater);

}

From source file:robert843.o2.pl.player.ui.PlaceholderActivity.java

private void setupNewSearchView(final MenuItem searchItem, SearchManager searchManager) {
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*from w w w  . j  a va 2 s.  co m*/
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
    // Null at line below
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    System.out.println(searchManager.getSearchableInfo(getComponentName()));
    // Everything else below edited out
}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 *
 * @param menu Menu/*from w w  w .  java 2 s  .  c  o  m*/
 * @return boolean
 */
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu, menu);
    // Retrieve the SearchView and plug it into SearchManager
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    searchView.setQueryHint(getString(R.string.query_hint));
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(final String query) {
            mMapPresenter.geocodeAddress(query);
            searchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            return false;
        }
    });
    return true;
}

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;
    }/*from   w w  w .  ja v a2s .com*/

    MBViewManager.getInstance().runOnUiThread(new MBThread() {
        @Override
        public void runMethod() {
            MBViewManager.getInstance().startSearch(null, false, null, false);
        }
    });
    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);
    }//w w w.  j  av  a2 s  .  com
}