List of usage examples for android.view KeyEvent KEYCODE_ENTER
int KEYCODE_ENTER
To view the source code for android.view KeyEvent KEYCODE_ENTER.
Click Source Link
From source file:com.mozilla.simplepush.simplepushdemoapp.MainActivity.java
/** Initialize the app from the saved state * * @param savedInstanceState The previously stored instance */// w ww .j a v a2 s .c om @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Properties config; try { config = loadProperties(); SENDER_ID = config.getProperty("sender_id"); if (SENDER_ID == null) { Log.e(TAG, "sender_id not definied in configuration file. Aborting"); return; } } catch (IOException x) { Log.e(TAG, "Could not load properties"); return; } setContentView(R.layout.activity_main); // Set the convenience globals. mDisplay = (TextView) findViewById(R.id.display); hostUrl = (EditText) findViewById(R.id.host_edit); pingData = (EditText) findViewById(R.id.message); sendButton = (Button) findViewById(R.id.send); connectButton = (Button) findViewById(R.id.connect); context = getApplicationContext(); // Check that GCM is available on this device. if (checkPlayServices()) { gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(context); } else { Log.i(TAG, "No valid Google Play Services APK found"); } // detect the "enter/submit" key for the editor views. hostUrl.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; // yes, be very careful about this, else you can send multiple actions. if (actionId == EditorInfo.IME_ACTION_SEND || (actionId == EditorInfo.IME_ACTION_UNSPECIFIED && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { registerInBackground(); handled = true; } return handled; } }); pingData.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_SEND || (actionId == EditorInfo.IME_ACTION_UNSPECIFIED && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { SendNotification(getMessage()); handled = true; } return handled; } }); }
From source file:com.letsgood.sampleapp.ChatActivity.java
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (Synergykit.getLoggedUser() != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { sendMessage(v);//from www . j av a2 s .com } return false; }
From source file:com.cse3310.phms.ui.activities.BaseActivity.java
private void setUpAutoCompleteTextView() { mAutoCompTextView.setAdapter(mSuggestionAdapter); // listener for close/open of search field mAutoCompTextView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override/*from ww w.j a va 2 s .c om*/ public void onViewAttachedToWindow(View v) { v.requestFocus(); Keyboard.show(mInputManager, mAutoCompTextView); } @Override public void onViewDetachedFromWindow(View v) { Keyboard.hide(mInputManager, mAutoCompTextView); } }); // listener for when a suggestion is click mAutoCompTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Keyboard.hide(mInputManager, mAutoCompTextView); doSearch(); } }); // listener for when the search key on the keyboard is pressed mAutoCompTextView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { Keyboard.hide(mInputManager, mAutoCompTextView); mAutoCompTextView.dismissDropDown(); // hide suggestion doSearch(); return true; } return false; } }); // handler for the clear input button to the right of the search text view. mAutoCompTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; if (event.getAction() == MotionEvent.ACTION_UP) { // some magic... :| to get the delete text icon to work if (event.getX() >= (mAutoCompTextView.getRight() - mAutoCompTextView.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { mAutoCompTextView.setText(""); // set search text view to empty string. return true; } } return false; } }); }
From source file:com.markupartist.sthlmtraveling.PlaceSearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.place_search_layout); registerScreen("Place Search"); Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(ARG_ONLY_STOPS)) { mSearchOnlyStops = extras.getBoolean(ARG_ONLY_STOPS); }/* w ww. ja v a 2 s.com*/ } initGoogleApiClient(false); createSearchHandler(); if (savedInstanceState != null) { if (savedInstanceState.containsKey(STATE_SEARCH_FILTER)) { mCurrentSearchFilterType = savedInstanceState.getInt(STATE_SEARCH_FILTER); } } mHistoryDbAdapter = new HistoryDbAdapter(this).open(); ImageButton backButton = (ImageButton) findViewById(R.id.search_back); ViewHelper.tint(backButton, ContextCompat.getColor(this, R.color.primary_dark)); ViewHelper.flipIfRtl(backButton); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); mSearchEdit = (EditText) findViewById(R.id.search_edit); mSearchEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { mSearchResultAdapter.getFilter().filter(mSearchEdit.getText()); } return false; } }); mSearchEdit.requestFocus(); mClearButton = (ImageButton) findViewById(R.id.search_clear); ViewHelper.tintIcon(mClearButton.getDrawable(), Color.GRAY); mClearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSearchEdit.setText(""); mSearchResultAdapter.clear(); } }); mSearchFailed = findViewById(R.id.search_result_error); mProgressBar = (ContentLoadingProgressBar) findViewById(R.id.search_progress_bar); setupHistoryViews(); if (!mSearchOnlyStops) { getSupportLoaderManager().initLoader(LOADER_HISTORY, null, this); } setupSearchResultViews(); if (!shouldSearchGooglePlaces()) { setSearchFilter(FILTER_TYPE_STHLM_TRAVELING); } mMyLocationManager = new LocationManager(this, getGoogleApiClient()); mMyLocationManager.setLocationListener(this); mMyLocationManager.setAccuracy(false); registerPlayService(mMyLocationManager); if (!mSearchOnlyStops) { verifyLocationPermission(); mMyLocationManager.requestLocation(); } }
From source file:org.alfresco.mobile.android.application.fragments.site.search.SearchSitesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; }//from w ww . j a v a2s . c om setRootView(inflater.inflate(R.layout.fr_site_search, container, false)); init(getRootView(), emptyListMessageId); searchText = (MaterialAutoCompleteTextView) viewById(R.id.search_query); searchAdapter = new HistorySearchInlineCursorAdapter(this, null, R.layout.row_two_lines_search); getLoaderManager().initLoader(0, null, this); searchText.setAdapter(searchAdapter); searchText.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TwoLinesViewHolder vh = (TwoLinesViewHolder) view.getTag(); HistorySearch tmphistorySearchItem = HistorySearchManager.retrieveHistorySearch(getActivity(), (Long) vh.choose.getTag()); searchText.setText(tmphistorySearchItem.getQuery()); historySearchItem = tmphistorySearchItem; search(); } }); bAdd = (ImageButton) viewById(R.id.search_action); bAdd.setEnabled(false); activateSend(); bAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { search(); } }); searchText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { historySearchItem = null; activateSend(); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); searchText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null && (event.getAction() == KeyEvent.ACTION_DOWN) && ((actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) { search(); return true; } return false; } }); return getRootView(); }
From source file:com.groundupworks.partyphotobooth.fragments.CaptureFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final KioskActivity activity = (KioskActivity) getActivity(); final Context appContext = activity.getApplicationContext(); final Bundle args = getArguments(); final int totalFrames = args.getInt(FRAGMENT_BUNDLE_KEY_TOTAL_FRAMES); final int currentFrame = args.getInt(FRAGMENT_BUNDLE_KEY_CURRENT_FRAME); /*//w w w .j a v a 2 s. c o m * Select camera from preference. */ // Get from preference. PreferencesHelper preferencesHelper = new PreferencesHelper(); PhotoBoothMode mode = preferencesHelper.getPhotoBoothMode(appContext); int cameraPreference = CameraInfo.CAMERA_FACING_FRONT; if (PhotoBoothMode.PHOTOGRAPHER.equals(mode)) { cameraPreference = CameraInfo.CAMERA_FACING_BACK; } // Default to first camera available. final int numCameras = Camera.getNumberOfCameras(); if (numCameras > 0) { mCameraId = 0; } // Select preferred camera. CameraInfo cameraInfo = new CameraInfo(); for (int cameraId = 0; cameraId < numCameras; cameraId++) { Camera.getCameraInfo(cameraId, cameraInfo); // Break on finding the preferred camera. if (cameraInfo.facing == cameraPreference) { mCameraId = cameraId; break; } } /* * Initialize and set key event handlers. */ mKeyEventHandler = new KioskActivity.KeyEventHandler() { @Override public boolean onKeyEvent(KeyEvent event) { final int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { mStartButton.dispatchKeyEvent(event); return true; } return false; } }; activity.setKeyEventHandler(mKeyEventHandler); /* * Functionalize views. */ // Configure start button and trigger behaviour. switch (mode) { case PHOTOGRAPHER: mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCapture(); } }); mStartButton.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { initiateCapture(); return true; } }); linkStartButton(); break; case AUTOMATIC: if (currentFrame > 1) { // Auto-trigger when camera is ready and preview has started. mPreview.setOnPreviewListener(new CenteredPreview.OnPreviewListener() { @Override public void onStarted() { if (isActivityAlive()) { mPreview.post(new Runnable() { @Override public void run() { if (isActivityAlive()) { initiateCountdownCapture(); } } }); } } @Override public void onStopped() { // Do nothing. } }); break; } else { // Fall through to self-serve behaviour. Do not break. } case SELF_SERVE: default: mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCountdownCapture(); } }); mStartButton.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { initiateCountdownCapture(); return true; } }); linkStartButton(); } // Show frame count only if more than one frame is to be captured. if (totalFrames > 1) { String frameCountText = getString(R.string.capture__frame_count, currentFrame, totalFrames); mFrameCount.setTypeface( Theme.from(appContext, preferencesHelper.getPhotoBoothTheme(appContext)).getFont()); mFrameCount.setText(frameCountText); mFrameCount.setVisibility(View.VISIBLE); } }
From source file:org.catrobat.catroid.ui.dialogs.OverwriteRenameMediaDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_overwrite_media, null); replaceButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_media_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_media_radio_rename); renameButton.setOnClickListener(this); mediaText = (EditText) dialogView.findViewById(R.id.dialog_overwrite_media_edit); mediaText.setText(mediaName);// w w w . j ava 2s . c o m mediaTextView = (TextView) dialogView.findViewById(R.id.dialog_overwrite_media_edit_text); mediaTextLine = dialogView.findViewById(R.id.dialog_overwrite_media_edit_line); final int header; final int replaceText; final int renameText; final int renameHeaderText; switch (mediaType) { case Constants.MEDIA_TYPE_LOOK: header = R.string.look_rename_overwrite; replaceText = R.string.overwrite_replace_look; renameText = R.string.overwrite_rename_look; renameHeaderText = R.string.new_look_name; break; case Constants.MEDIA_TYPE_SOUND: header = R.string.rename_sound_overwrite; replaceText = R.string.overwrite_replace_sound; renameText = R.string.overwrite_rename_sound; renameHeaderText = R.string.new_sound_name; break; default: header = R.string.rename_sprite_dialog; replaceText = R.string.overwrite_replace_default; renameText = R.string.overwrite_rename_default; renameHeaderText = R.string.new_sound_name; } replaceButton.setText(replaceText); renameButton.setText(renameText); mediaTextView.setText(renameHeaderText); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(header) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (!okButtonResult) { return false; } else { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } return false; } }); return dialog; }
From source file:com.fatelon.partyphotobooth.fragments.CaptureFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final KioskActivity activity = (KioskActivity) getActivity(); final Context appContext = activity.getApplicationContext(); final Bundle args = getArguments(); final int totalFrames = args.getInt(FRAGMENT_BUNDLE_KEY_TOTAL_FRAMES); final int currentFrame = args.getInt(FRAGMENT_BUNDLE_KEY_CURRENT_FRAME); /*//from www.j a v a2s. c om * Select camera from preference. */ // Get from preference. PreferencesHelper preferencesHelper = new PreferencesHelper(); mPhotoBoothMode = preferencesHelper.getPhotoBoothMode(appContext); int cameraPreference = CameraInfo.CAMERA_FACING_FRONT; if (PreferencesHelper.PhotoBoothMode.PHOTOGRAPHER.equals(mPhotoBoothMode)) { cameraPreference = CameraInfo.CAMERA_FACING_BACK; } // Default to first camera available. final int numCameras = Camera.getNumberOfCameras(); if (numCameras > 0) { mCameraId = 0; } // Select preferred camera. CameraInfo cameraInfo = new CameraInfo(); for (int cameraId = 0; cameraId < numCameras; cameraId++) { Camera.getCameraInfo(cameraId, cameraInfo); // Break on finding the preferred camera. if (cameraInfo.facing == cameraPreference) { mCameraId = cameraId; break; } } /* * Initialize and set key event handlers. */ mKeyEventHandler = new KioskActivity.KeyEventHandler() { @Override public boolean onKeyEvent(KeyEvent event) { final int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { mStartButton.dispatchKeyEvent(event); return true; } return false; } }; activity.setKeyEventHandler(mKeyEventHandler); /* * Functionalize views. */ // Configure start button and trigger behaviour. switch (mPhotoBoothMode) { case PHOTOGRAPHER: mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCapture(); } }); mStartButton.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { initiateCapture(); return true; } }); linkStartButton(); break; case AUTOMATIC: mStartButtonLong.setVisibility(View.VISIBLE); mStartButton.setVisibility(View.GONE); mStartButton = mStartButtonLong; if (currentFrame > 1) { // Auto-trigger when camera is ready and preview has started. mPreview.setOnPreviewListener(new CenteredPreview.OnPreviewListener() { @Override public void onStarted() { if (isActivityAlive()) { mPreview.post(new Runnable() { @Override public void run() { if (isActivityAlive()) { initiateCountdownCapture(); } } }); } } @Override public void onStopped() { // Do nothing. } }); break; } else { // Fall through to self-serve behaviour. Do not break. } case SELF_SERVE: default: mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { initiateCountdownCapture(); } }); mStartButton.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { initiateCountdownCapture(); return true; } }); linkStartButton(); } // Show frame count only if more than one frame is to be captured. if (totalFrames > 1) { String frameCountText = getString(R.string.capture__frame_count, currentFrame, totalFrames); mFrameCount.setTypeface( Theme.from(appContext, preferencesHelper.getPhotoBoothTheme(appContext)).getFont()); mFrameCount.setText(frameCountText); mFrameCount.setVisibility(View.VISIBLE); } }
From source file:org.mdc.chess.SeekBarPreference.java
@Override protected View onCreateView(ViewGroup parent) { TextView name = new TextView(getContext()); name.setText(getTitle());//from ww w .java 2 s.c o m //name.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); TextViewCompat.setTextAppearance(name, android.R.style.TextAppearance_Large); name.setGravity(Gravity.START); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.START; lp.weight = 1.0f; name.setLayoutParams(lp); currValBox = new TextView(getContext()); currValBox.setTextSize(12); currValBox.setTypeface(Typeface.MONOSPACE, Typeface.ITALIC); currValBox.setPadding(2, 5, 0, 0); currValBox.setText(valToString()); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER; currValBox.setLayoutParams(lp); LinearLayout row1 = new LinearLayout(getContext()); row1.setOrientation(LinearLayout.HORIZONTAL); row1.addView(name); row1.addView(currValBox); final SeekBar bar = new SeekBar(getContext()); bar.setMax(maxValue); bar.setProgress(currVal); bar.setOnSeekBarChangeListener(this); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.END; bar.setLayoutParams(lp); CharSequence summaryCharSeq = getSummary(); boolean haveSummary = (summaryCharSeq != null) && (summaryCharSeq.length() > 0); TextView summary = null; if (haveSummary) { summary = new TextView(getContext()); summary.setText(getSummary()); // summary.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); summary.setGravity(Gravity.START); lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.START; lp.weight = 1.0f; summary.setLayoutParams(lp); } LinearLayout layout = new LinearLayout(getContext()); layout.setPadding(25, 5, 25, 5); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(row1); layout.addView(bar); if (summary != null) { layout.addView(summary); } layout.setId(android.R.id.widget_frame); currValBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View content = View.inflate(SeekBarPreference.this.getContext(), R.layout.select_percentage, null); final AlertDialog.Builder builder = new AlertDialog.Builder(SeekBarPreference.this.getContext()); builder.setView(content); String title = ""; String key = getKey(); if (key.equals("strength")) { title = getContext().getString(R.string.edit_strength); } else if (key.equals("bookRandom")) { title = getContext().getString(R.string.edit_randomization); } builder.setTitle(title); final EditText valueView = (EditText) content.findViewById(R.id.selpercentage_number); valueView.setText(currValBox.getText().toString().replaceAll("%", "").replaceAll(",", ".")); final Runnable selectValue = new Runnable() { public void run() { try { String txt = valueView.getText().toString(); int value = (int) (Double.parseDouble(txt) * 10 + 0.5); if (value < 0) value = 0; if (value > maxValue) value = maxValue; onProgressChanged(bar, value, false); } catch (NumberFormatException ignored) { } } }; valueView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { selectValue.run(); return true; } return false; } }); builder.setPositiveButton("Ok", new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { selectValue.run(); } }); builder.setNegativeButton("Cancel", null); builder.create().show(); } }); return layout; }
From source file:com.googlecode.eyesfree.brailleback.IMENavigationMode.java
@Override public boolean onMappedInputEvent(BrailleInputEvent event, DisplayManager.Content content) { BrailleIME ime = getIME();/*from w ww .j ava 2 s. co m*/ // These commands are handled by the IME whenever it is accepting // input, even if it has not taken control of the display. if (ime != null && mState.acceptsText()) { switch (event.getCommand()) { case BrailleInputEvent.CMD_KEY_DEL: return ime.sendAndroidKey(KeyEvent.KEYCODE_DEL); case BrailleInputEvent.CMD_KEY_ENTER: return ime.sendAndroidKey(KeyEvent.KEYCODE_ENTER); case BrailleInputEvent.CMD_KEY_FORWARD_DEL: return ime.sendAndroidKey(KeyEvent.KEYCODE_FORWARD_DEL); case BrailleInputEvent.CMD_BRAILLE_KEY: return ime.handleBrailleKey(event.getArgument()); } } // If navigation commands are handled by the IME in this state, then // move the cursor by the appropriate granularity. if (ime != null && mState.navigatesViaIME()) { switch (event.getCommand()) { case BrailleInputEvent.CMD_NAV_ITEM_PREVIOUS: return ime.moveCursor(BrailleIME.DIRECTION_BACKWARD, AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER); case BrailleInputEvent.CMD_NAV_ITEM_NEXT: return ime.moveCursor(BrailleIME.DIRECTION_FORWARD, AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER); case BrailleInputEvent.CMD_NAV_LINE_PREVIOUS: // Line navigation moves by paragraph since there's no way // of knowing the line extents in the edit text. return ime.moveCursor(BrailleIME.DIRECTION_BACKWARD, AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_PARAGRAPH); case BrailleInputEvent.CMD_NAV_LINE_NEXT: return ime.moveCursor(BrailleIME.DIRECTION_FORWARD, AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_PARAGRAPH); } } // Alternatively, we may handle these navigation commands by sending // "move by granularity" through the accessibility system. if (ime != null && mState.navigatesByTextGranularity()) { AccessibilityNodeInfoCompat focusedNode = getFocusedNode(); switch (event.getCommand()) { case BrailleInputEvent.CMD_NAV_ITEM_PREVIOUS: return previousAtMovementGranularity(AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER); case BrailleInputEvent.CMD_NAV_ITEM_NEXT: return nextAtMovementGranularity(AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_CHARACTER); case BrailleInputEvent.CMD_NAV_LINE_PREVIOUS: return previousAtMovementGranularity(AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE); case BrailleInputEvent.CMD_NAV_LINE_NEXT: return nextAtMovementGranularity(AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE); } } // These commands are handled by the IME only when it has taken // control of the display. Otherwise, they are delegated. if (ime != null && mState.controlsDisplay()) { switch (event.getCommand()) { case BrailleInputEvent.CMD_ACTIVATE_CURRENT: return ime.sendDefaultAction(); case BrailleInputEvent.CMD_ROUTE: return ime.route(event.getArgument(), content); } } // If all else fails, delegate the event. return mNext.onMappedInputEvent(event, content); }