List of usage examples for android.view KeyEvent KEYCODE_SEARCH
int KEYCODE_SEARCH
To view the source code for android.view KeyEvent KEYCODE_SEARCH.
Click Source Link
From source file:org.apache.cordova.AndroidWebView.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { // A custom view is currently displayed (e.g. playing a video) if (mCustomView != null) { this.hideCustomView(); } else {//from ww w . j a v a2 s . co m // The webview is currently displayed // If back key is bound, then send event to JavaScript if (this.bound) { this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');"); return true; } else { // 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 behavior else { //this.activityState = ACTIVITY_EXITING; //return false; // If they hit back button when app is initializing, app should exit instead of hang until initialization (CB2-458) this.cordova.getActivity().finish(); } } } } // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { if (this.lastMenuEventTime < event.getEventTime()) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); } this.lastMenuEventTime = event.getEventTime(); 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 behavior? return super.onKeyUp(keyCode, event); }
From source file:com.google.android.apps.mytracks.TrackListActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { // T,B, Space are already mapped by BB on Q10! Intent intent;/*from w w w . j ava2s .c o m*/ boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT; switch (keyCode) { case KeyEvent.KEYCODE_SEARCH: if (ApiAdapterFactory.getApiAdapter().handleSearchKey(searchMenuItem)) { return true; } break; case KeyEvent.KEYCODE_H: // Help intent = IntentUtils.newIntent(TrackListActivity.this, HelpActivity.class); startActivity(intent); break; case KeyEvent.KEYCODE_N: if (!isRecording) { // Not recording -> Recording AnalyticsUtils.sendPageViews(TrackListActivity.this, "/action/record_track"); startGps = false; handleStartGps(); updateMenuItems(true); startRecording(); } break; case KeyEvent.KEYCODE_P: if (isRecording) { if (recordingTrackPaused) { // Paused -> Resume AnalyticsUtils.sendPageViews(TrackListActivity.this, "/action/resume_track"); updateMenuItems(true); TrackRecordingServiceConnectionUtils.resumeTrack(trackRecordingServiceConnection); trackController.update(true, false); } else { // Recording -> Paused AnalyticsUtils.sendPageViews(TrackListActivity.this, "/action/pause_track"); updateMenuItems(true); TrackRecordingServiceConnectionUtils.pauseTrack(trackRecordingServiceConnection); trackController.update(true, true); } } else { Toast.makeText(getApplicationContext(), "Cannot pause track that is not recorded.", Toast.LENGTH_LONG).show(); } break; case KeyEvent.KEYCODE_S: if (isRecording) { // Stop Recording updateMenuItems(false); TrackRecordingServiceConnectionUtils.stopRecording(TrackListActivity.this, trackRecordingServiceConnection, true); } else { // Search ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this); } break; case KeyEvent.KEYCODE_A: intent = IntentUtils.newIntent(this, SettingsActivity.class); startActivity(intent); break; } return super.onKeyUp(keyCode, event); }
From source file:com.csipsimple.ui.incall.CallActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.d(TAG, "Key down : " + keyCode); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: ///*from w w w .j a v a2 s. c om*/ // Volume has been adjusted by the user. // Log.d(TAG, "onKeyDown: Volume button pressed"); int action = AudioManager.ADJUST_RAISE; if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { action = AudioManager.ADJUST_LOWER; } // Detect if ringing SipCallSession currentCallInfo = getActiveCallInfo(); // If not any active call active if (currentCallInfo == null && serviceConnected) { break; } //TODO: adjust volume here if (service != null) { try { service.adjustVolume(currentCallInfo, action, AudioManager.FLAG_SHOW_UI); } catch (RemoteException e) { Log.e(TAG, "Can't adjust volume", e); } } return true; case KeyEvent.KEYCODE_CALL: case KeyEvent.KEYCODE_ENDCALL: return inCallAnswerControls.onKeyDown(keyCode, event); case KeyEvent.KEYCODE_SEARCH: // Prevent search return true; default: // Nothing to do } return super.onKeyDown(keyCode, event); }
From source file:com.gelakinetic.mtgfam.activities.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH) { // Send the search key to the leftmost fragment Fragment f = mFragmentManager.findFragmentById(R.id.left_container); if (((FamiliarFragment) f).onInterceptSearchKey() == false) { return super.onKeyDown(keyCode, event); } else {/* w ww .j ava 2 s . com*/ return true; } } else if (keyCode == KeyEvent.KEYCODE_BACK) { // If we're not at the root of a hierarchy, the back button should do as it pleases if (getSupportFragmentManager().getBackStackEntryCount() > 0 || !this.isTaskRoot()) { return super.onKeyDown(keyCode, event); } // Else if were at the root, and the SlidingMenu is closed, it should open the menu else if (!this.getSlidingMenu().isMenuShowing()) { this.getSlidingMenu().showMenu(); return true; } // If the SlidingMenu is open, it should close the app else { return super.onKeyDown(keyCode, event); } } return super.onKeyDown(keyCode, event); }
From source file:com.csipsimple.ui.incall.CallActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { Log.d(TAG, "Key up : " + keyCode); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_CALL: case KeyEvent.KEYCODE_SEARCH: return true; case KeyEvent.KEYCODE_ENDCALL: return inCallAnswerControls.onKeyDown(keyCode, event); }/*ww w .j a va 2s . c o m*/ return super.onKeyUp(keyCode, event); }
From source file:org.wso2.emm.agent.AuthenticationActivity.java
/** * Show the license text retrieved from the server. * * @param message Message text to be shown as the license. * @param title Title of the license./*w w w . ja va 2s . c o m*/ */ private void showAgreement(final String message, String title) { AuthenticationActivity.this.runOnUiThread(new Runnable() { @Override public void run() { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom_terms_popup); dialog.setTitle(Constants.EULA_TITLE); dialog.setCancelable(false); WebView webView = (WebView) dialog.findViewById(R.id.webview); webView.loadDataWithBaseURL(null, message, Constants.MIME_TYPE, Constants.ENCODING_METHOD, 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.putBoolean(context, Constants.PreferenceFlag.IS_AGREED, true); dialog.dismiss(); //load the next intent based on ownership type checkManifestPermissions(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); CommonUtils.clearClientCredentials(context); cancelEntry(); } }); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == Constants.DEFAILT_REPEAT_COUNT) { return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == Constants.DEFAILT_REPEAT_COUNT) { return true; } return false; } }); dialog.show(); } }); }
From source file:io.github.vomitcuddle.SearchViewAllowEmpty.SearchView.java
/** * React to the user typing while in the suggestions list. First, check for * action keys. If not handled, try refocusing regular characters into the * EditText./*from ww w . j a va 2s .c o m*/ */ private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) { // guard against possible race conditions (late arrival after dismiss) if (mSearchable == null) { return false; } if (mSuggestionsAdapter == null) { return false; } if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) { // First, check for enter or search (both of which we'll treat as a // "click") if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_TAB) { int position = mQueryTextView.getListSelection(); return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null); } // Next, check for left/right moves, which we use to "return" the // user to the edit view if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { // give "focus" to text editor, with cursor at the beginning if // left key, at end if right key int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView.length(); mQueryTextView.setSelection(selPoint); mQueryTextView.setListSelection(0); mQueryTextView.clearListSelection(); HIDDEN_METHOD_INVOKER.ensureImeVisible(mQueryTextView, true); return true; } // Next, check for an "up and out" move if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) { // TODO: restoreUserQuery(); // let ACTV complete the move return false; } } return false; }
From source file:com.phonegap.DroidGap.java
/** * Called when a key is pressed./*ww w. j a v a 2s . c om*/ * * @param keyCode * @param event */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // If back key if (keyCode == KeyEvent.KEYCODE_BACK) { // If back key is bound, then send event to JavaScript if (mKey.isBound()) { this.appView.loadUrl("javascript:document.keyEvent.backTrigger()"); } // If not bound else { // Go to previous page in webview if it is possible to go back if (this.appView.canGoBack()) { this.appView.goBack(); } // If not, then invoke behavior of super class else { return super.onKeyDown(keyCode, event); } } } // If menu key else if (keyCode == KeyEvent.KEYCODE_MENU) { appView.loadUrl("javascript:keyEvent.menuTrigger()"); } // If search key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { appView.loadUrl("javascript:keyEvent.searchTrigger()"); } return false; }
From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java
/** * React to the user typing while in the suggestions list. First, check for * action keys. If not handled, try refocusing regular characters into the * EditText./*w w w . java 2 s. c o m*/ */ private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) { // guard against possible race conditions (late arrival after dismiss) if (mSearchable == null) { return false; } if (mSuggestionsAdapter == null) { return false; } if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) { // First, check for enter or search (both of which we'll treat as a // "click") if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_TAB) { int position = mQueryTextView.getListSelection(); return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null); } // Next, check for left/right moves, which we use to "return" the // user to the edit view if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { // give "focus" to text editor, with cursor at the beginning if // left key, at end if right key // TODO: Reverse left/right for right-to-left languages, e.g. // Arabic int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView.length(); mQueryTextView.setSelection(selPoint); mQueryTextView.setListSelection(0); mQueryTextView.clearListSelection(); ensureImeVisible(mQueryTextView, true); return true; } // Next, check for an "up and out" move if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) { // TODO: restoreUserQuery(); // let ACTV complete the move return false; } // Next, check for an "action key" // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode); // TODO if ((actionKey != null) // TODO && ((actionKey.getSuggestActionMsg() != null) || (actionKey // TODO .getSuggestActionMsgColumn() != null))) { // TODO // launch suggestion using action key column // TODO int position = mQueryTextView.getListSelection(); // TODO if (position != ListView.INVALID_POSITION) { // TODO Cursor c = mSuggestionsAdapter.getCursor(); // TODO if (c.moveToPosition(position)) { // TODO final String actionMsg = getActionKeyMessage(c, actionKey); // TODO if (actionMsg != null && (actionMsg.length() > 0)) { // TODO return onItemClicked(position, keyCode, actionMsg); // TODO } // TODO } // TODO } // TODO } } return false; }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void LaunchMsimDialog(final boolean bCheckEcmMode) { AlertDialog.Builder builder = new AlertDialog.Builder(ComposeMessageActivity.this); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.multi_sim_sms_sender, (ViewGroup) findViewById(R.id.layout_root)); builder.setView(layout);//from w ww . ja v a2 s. c o m builder.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: { dismissMsimDialog(); return true; } case KeyEvent.KEYCODE_SEARCH: { return true; } } return false; } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dismissMsimDialog(); } }); ContactList recipients = isRecipientsEditorVisible() ? mRecipientsEditor.constructContactsFromInput(false) : getRecipients(); builder.setTitle( getResources().getString(R.string.to_address_label) + recipients.formatNamesAndNumbers(",")); mMsimDialog = builder.create(); mMsimDialog.setCanceledOnTouchOutside(true); int[] smsBtnIds = { R.id.BtnSubOne, R.id.BtnSubTwo, R.id.BtnSubThree }; int phoneCount = MSimTelephonyManager.getDefault().getPhoneCount(); Button[] smsBtns = new Button[phoneCount]; for (int i = 0; i < phoneCount; i++) { final int subscription = i; int subID = i + 1; smsBtns[i] = (Button) layout.findViewById(smsBtnIds[i]); smsBtns[i].setVisibility(View.VISIBLE); smsBtns[i].setText(MSimTelephonyManager.getDefault().getSimOperatorName(i) + "-" + subID); smsBtns[i].setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.d(TAG, "Sub slected " + subscription); processMsimSendMessage(subscription, bCheckEcmMode); } }); } mMsimDialog.show(); }