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:org.wso2.cdm.agent.AuthenticationActivity.java

public void showAgreement(String message, String title) {
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.custom_terms_popup);
    dialog.setTitle(CommonUtilities.EULA_TITLE);
    dialog.setCancelable(false);/*w w  w  . jav  a  2s. c  o m*/

    WebView web = (WebView) dialog.findViewById(R.id.webview);
    String html = "<html><body>" + message + "</body></html>";
    String mime = "text/html";
    String encoding = "utf-8";
    web.loadDataWithBaseURL(null, html, mime, encoding, null);

    Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
    Button cancelButton = (Button) dialog.findViewById(R.id.dialogButtonCancel);

    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Preference.put(context, getResources().getString(R.string.shared_pref_isagreed), "1");
            dialog.dismiss();
            loadPincodeAcitvity();
        }
    });

    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            cancelEntry();
        }
    });

    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
                return true;
            } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
                return true;
            }
            return false;
        }
    });

    dialog.show();
}

From source file:com.example.android.bluepayandroidsdk.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK || KeyEvent.KEYCODE_HOME == keyCode
            || KeyEvent.KEYCODE_SEARCH == keyCode)) {
        return false;
    }/*from w  ww  .  j  a va  2  s . c  om*/
    return super.onKeyDown(keyCode, event);
}

From source file:com.example.android.bluepayandroidsdk.MainActivity.java

@Override
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK || KeyEvent.KEYCODE_HOME == keyCode
            || KeyEvent.KEYCODE_SEARCH == keyCode)) {

        return false;
    }/* w  w w .  j a v  a  2 s .c o m*/
    return super.onKeyMultiple(keyCode, repeatCount, event);
}

From source file:com.example.android.bluepayandroidsdk.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK || KeyEvent.KEYCODE_HOME == keyCode
            || KeyEvent.KEYCODE_SEARCH == keyCode)) {
        return false;
    }/*from ww w.  j  a va 2s .c om*/
    return super.onKeyUp(keyCode, event);
}

From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {

        if (MenuItemCompat.isActionViewExpanded(miSearch)) {
            MenuItemCompat.collapseActionView(miSearch);
        } else {/*www  . j  a  va  2 s  .  co  m*/
            MenuItemCompat.expandActionView(miSearch);
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.nogago.android.tracks.TrackListActivity.java

/**
 * Starts a new recording.//  ww  w.  jav a 2 s. co  m
 */

//  private void startRecording() {
//    trackRecordingServiceConnection.startAndBind();

/*
 * If the binding has happened, then invoke the callback to start a new
 * recording. If the binding hasn't happened, then invoking the callback
 * will have no effect. But when the binding occurs, the callback will get
 * invoked.
 */
//    bindChangedCallback.run();
//  }

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        if (ApiAdapterFactory.getApiAdapter().handleSearchKey(searchMenuItem)) {
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:net.olejon.spotcommander.WebViewActivity.java

@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK: {
        event.startTracking();//from w  ww . java2 s  .  c  o  m
        return true;
    }
    case KeyEvent.KEYCODE_MENU: {
        return true;
    }
    case KeyEvent.KEYCODE_SEARCH: {
        return true;
    }
    case KeyEvent.KEYCODE_VOLUME_DOWN: {
        return true;
    }
    case KeyEvent.KEYCODE_VOLUME_UP: {
        return true;
    }
    default: {
        return super.onKeyDown(keyCode, event);
    }
    }
}

From source file:net.olejon.spotcommander.WebViewActivity.java

@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MENU: {
        mWebView.loadUrl("javascript:nativeAppAction('menu')");
        return true;
    }//www  .j  a  v  a  2 s. c  o  m
    case KeyEvent.KEYCODE_SEARCH: {
        mWebView.loadUrl("javascript:nativeAppAction('search')");
        return true;
    }
    case KeyEvent.KEYCODE_BACK: {
        if (mHasLongPressedBack)
            return true;

        if (mWebView.canGoBack() && mWebView.getUrl().contains("accounts.spotify.com/")
                || mWebView.canGoBack() && mWebView.getUrl().contains("facebook.com/")) {
            mWebView.goBack();

            return true;
        } else if (mWebView.canGoBack() || mTools.getSharedPreferencesBoolean("CAN_CLOSE_COVER")) {
            mWebView.loadUrl("javascript:nativeAppAction('back')");

            return true;
        }

        mTools.showToast(getString(R.string.webview_back), 1);

        return true;
    }
    case KeyEvent.KEYCODE_VOLUME_DOWN: {
        mWebView.loadUrl("javascript:nativeAppAction('volume_down')");
        return true;
    }
    case KeyEvent.KEYCODE_VOLUME_UP: {
        mWebView.loadUrl("javascript:nativeAppAction('volume_up')");
        return true;
    }
    default: {
        return super.onKeyUp(keyCode, event);
    }
    }
}

From source file:org.appcelerator.titanium.TiBaseActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    boolean handled = false;

    TiViewProxy window;//from  w w  w.  ja  v  a  2  s.c om
    if (this.window != null) {
        window = this.window;
    } else {
        window = this.view;
    }

    if (window == null) {
        return super.dispatchKeyEvent(event);
    }

    switch (event.getKeyCode()) {
    case KeyEvent.KEYCODE_BACK: {

        if (event.getAction() == KeyEvent.ACTION_UP) {
            String backEvent = "android:back";
            KrollProxy proxy = null;
            //android:back could be fired from a tabGroup window (activityProxy)
            //or hw window (window).This event is added specifically to the activity
            //proxy of a tab group in window.js
            if (activityProxy.hasListeners(backEvent)) {
                proxy = activityProxy;
            } else if (window.hasListeners(backEvent)) {
                proxy = window;
            }

            if (proxy != null) {
                proxy.fireEvent(backEvent, null);
                handled = true;
            }

        }
        break;
    }
    case KeyEvent.KEYCODE_CAMERA: {
        if (window.hasListeners(TiC.EVENT_ANDROID_CAMERA)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent(TiC.EVENT_ANDROID_CAMERA, null);
            }
            handled = true;
        }
        // TODO: Deprecate old event
        if (window.hasListeners("android:camera")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent("android:camera", null);
            }
            handled = true;
        }

        break;
    }
    case KeyEvent.KEYCODE_FOCUS: {
        if (window.hasListeners(TiC.EVENT_ANDROID_FOCUS)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent(TiC.EVENT_ANDROID_FOCUS, null);
            }
            handled = true;
        }
        // TODO: Deprecate old event
        if (window.hasListeners("android:focus")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent("android:focus", null);
            }
            handled = true;
        }

        break;
    }
    case KeyEvent.KEYCODE_SEARCH: {
        if (window.hasListeners(TiC.EVENT_ANDROID_SEARCH)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent(TiC.EVENT_ANDROID_SEARCH, null);
            }
            handled = true;
        }
        // TODO: Deprecate old event
        if (window.hasListeners("android:search")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent("android:search", null);
            }
            handled = true;
        }

        break;
    }
    case KeyEvent.KEYCODE_VOLUME_UP: {
        if (window.hasListeners(TiC.EVENT_ANDROID_VOLUP)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent(TiC.EVENT_ANDROID_VOLUP, null);
            }
            handled = true;
        }
        // TODO: Deprecate old event
        if (window.hasListeners("android:volup")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent("android:volup", null);
            }
            handled = true;
        }

        break;
    }
    case KeyEvent.KEYCODE_VOLUME_DOWN: {
        if (window.hasListeners(TiC.EVENT_ANDROID_VOLDOWN)) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent(TiC.EVENT_ANDROID_VOLDOWN, null);
            }
            handled = true;
        }
        // TODO: Deprecate old event
        if (window.hasListeners("android:voldown")) {
            if (event.getAction() == KeyEvent.ACTION_UP) {
                window.fireEvent("android:voldown", null);
            }
            handled = true;
        }

        break;
    }
    }

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

    return handled;
}

From source file:org.apache.cordova.CordovaWebView.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // If back key
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // If back key is bound, then send event to JavaScript
        if (this.bound) {
            this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
            return true;
        } else {//from  w ww .  j a  v  a2 s  .c om
            // If not bound
            // Go to previous page in webview if it is possible to go back
            if (this.backHistory()) {
                return true;
            }
            // If not, then invoke default behaviour
            else {
                //this.activityState = ACTIVITY_EXITING;
                return false;
            }
        }
    }
    // Legacy
    else if (keyCode == KeyEvent.KEYCODE_MENU) {
        this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');");
        return super.onKeyUp(keyCode, event);
    }
    // If search key
    else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        this.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');");
        return true;
    } else if (keyUpCodes.contains(keyCode)) {
        //What the hell should this do?
        return super.onKeyUp(keyCode, event);
    }

    //Does webkit change this behaviour?
    return super.onKeyUp(keyCode, event);
}