Example usage for android.view KeyEvent KEYCODE_SEARCH

List of usage examples for android.view KeyEvent KEYCODE_SEARCH

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_SEARCH.

Prototype

int KEYCODE_SEARCH

To view the source code for android.view KeyEvent KEYCODE_SEARCH.

Click Source Link

Document

Key code constant: Search key.

Usage

From source file:com.agiro.scanner.android.CaptureActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        handler.sendEmptyMessage(R.id.restart_preview);
    }/*  w w  w . ja  v a  2  s  .c  o m*/
    return super.onKeyDown(keyCode, event);
}

From source file:net.patchingzone.ru4real.nuevo.TorchActivityPlugin.java

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    // When the search button is long pressed, quit
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        finish();/*from  www  . j  a  v a 2 s.  c om*/
        return true;
    }
    return false;
}

From source file:com.docd.purefm.ui.activities.BrowserPagerActivity.java

@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
        final Intent searchIntent = new Intent(this, SearchActivity.class);
        searchIntent.putExtra(Extras.EXTRA_PATH, currentPath.getAbsolutePath());
        startActivity(searchIntent);//  ww  w  .  j  ava  2  s.c  o m
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.keylesspalace.tusky.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU: {
        if (drawer.isDrawerOpen()) {
            drawer.closeDrawer();/*from   w ww  . j  a  va2  s .c  o  m*/
        } else {
            drawer.openDrawer();
        }
        return true;
    }
    case KeyEvent.KEYCODE_SEARCH: {
        startActivityWithSlideInAnimation(new Intent(this, SearchActivity.class));
        return true;
    }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
* @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
*///from   w ww.j a  va  2 s  .c o m
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        Limiter limiter = mPagerAdapter.getCurrentLimiter();

        if (mSlidingView.isShrinkable()) {
            mSlidingView.hideSlide();//w w  w.  j a  v a2  s .  co  m
            break;
        }

        if (mBottomBarControls.showSearch(false)) {
            break;
        }

        if (limiter != null) {
            int pos = -1;
            switch (limiter.type) {
            case MediaUtils.TYPE_ALBUM:
                setLimiter(MediaUtils.TYPE_ARTIST, limiter.data.toString());
                pos = mPagerAdapter.getMediaTypePosition(limiter.type);
                break;
            case MediaUtils.TYPE_ARTIST:
            case MediaUtils.TYPE_ALBARTIST:
            case MediaUtils.TYPE_COMPOSER:
            case MediaUtils.TYPE_GENRE:
                mPagerAdapter.clearLimiter(limiter.type);
                pos = mPagerAdapter.getMediaTypePosition(limiter.type);
                break;
            case MediaUtils.TYPE_FILE:
                File parentFile = ((File) limiter.data).getParentFile();
                mPagerAdapter.setLimiter(FileSystemAdapter.buildLimiter(parentFile));
                break;
            }
            if (pos == -1) {
                updateLimiterViews();
            } else {
                mViewPager.setCurrentItem(pos);
            }
        } else {
            finish();
        }
        break;
    case KeyEvent.KEYCODE_MENU:
        // We intercept these to avoid showing the activity-default menu
        mBottomBarControls.openMenu();
        break;
    case KeyEvent.KEYCODE_SEARCH:
        mBottomBarControls.showSearch(true);
        break;
    default:
        return false;
    }

    return true;
}

From source file:com.bellman.bible.android.view.activity.page.MainBibleActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    Log.d(TAG, "Keycode:" + keyCode);
    // common key handling i.e. KEYCODE_DPAD_RIGHT & KEYCODE_DPAD_LEFT
    if (BibleKeyHandler.getInstance().onKeyUp(keyCode, event)) {
        return true;
    } else if ((keyCode == KeyEvent.KEYCODE_SEARCH
            && ControlFactory.getInstance().getCurrentPageControl().getCurrentPage().isSearchable())) {
        Intent intent = ControlFactory.getInstance().getSearchControl().getSearchIntent(
                ControlFactory.getInstance().getCurrentPageControl().getCurrentPage().getCurrentDocument());
        if (intent != null) {
            startActivityForResult(intent, STD_REQUEST_CODE);
        }/*from w w w .j ava 2s. co  m*/
        return true;
    }

    return super.onKeyUp(keyCode, event);
}

From source file:com.google.android.apps.mytracks.MarkerListActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        if (ApiAdapterFactory.getApiAdapter().handleSearchKey(searchMenuItem)) {
            return true;
        }//  w ww . ja  v a2  s .co  m
    }
    return super.onKeyUp(keyCode, event);
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {

    if (mMapFragment != null) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            mMapFragment.searchToggle(false);
        } else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
            mMapFragment.searchToggle(true);
        }//w  ww . j ava2s.c  o  m
    }

    return super.onKeyUp(keyCode, event);
}

From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();

    boolean handled = false;

    if (!mIsFiltering) {
        handled = mFilterView.dispatchKeyEvent(event);
        if (!handled && (KeyEvent.KEYCODE_BACK == keyCode) && (KeyEvent.ACTION_DOWN == event.getAction())) {
            showFilterView();/*from   ww  w  . jav  a  2  s . co  m*/
            handled = true;
        }
    } else {

        handled = mContactListView.dispatchKeyEvent(event);

        if (!handled && KeyEvent.KEYCODE_SEARCH == keyCode && (KeyEvent.ACTION_DOWN == event.getAction())) {
            InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMgr.toggleSoftInput(0, 0);

            if (!mIsFiltering)
                showFilterView();

            onSearchRequested();
        } else if (!handled && isReadable(keyCode, event) && (KeyEvent.ACTION_DOWN == event.getAction())) {

            if (!mIsFiltering)
                showFilterView();

            handled = mFilterView.dispatchKeyEvent(event);
        }

    }

    if (!handled) {
        handled = super.dispatchKeyEvent(event);
    }

    return handled;
}