List of usage examples for android.view KeyEvent ACTION_DOWN
int ACTION_DOWN
To view the source code for android.view KeyEvent ACTION_DOWN.
Click Source Link
From source file:org.telegram.ui.Components.ChatActivityEnterView.java
private void createEmojiView() { if (emojiView != null) { return;//from w w w . j a v a 2 s . c o m } emojiView = new EmojiView(allowStickers, allowGifs, parentActivity); emojiView.setVisibility(GONE); emojiView.setListener(new EmojiView.Listener() { public boolean onBackspace() { if (messageEditText.length() == 0) { return false; } messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); return true; } public void onEmojiSelected(String symbol) { int i = messageEditText.getSelectionEnd(); if (i < 0) { i = 0; } try { innerTextChange = 2; CharSequence localCharSequence = Emoji.replaceEmoji(symbol, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); messageEditText.setText(messageEditText.getText().insert(i, localCharSequence)); int j = i + localCharSequence.length(); messageEditText.setSelection(j, j); } catch (Exception e) { FileLog.e(e); } finally { innerTextChange = 0; } } public void onStickerSelected(TLRPC.Document sticker) { ChatActivityEnterView.this.onStickerSelected(sticker); StickersQuery.addRecentSticker(StickersQuery.TYPE_IMAGE, sticker, (int) (System.currentTimeMillis() / 1000)); if ((int) dialog_id == 0) { MessagesController.getInstance().saveGif(sticker); } } @Override public void onStickersSettingsClick() { if (parentFragment != null) { parentFragment.presentFragment(new StickersActivity(StickersQuery.TYPE_IMAGE)); } } @Override public void onGifSelected(TLRPC.Document gif) { SendMessagesHelper.getInstance().sendSticker(gif, dialog_id, replyingMessageObject); StickersQuery.addRecentGif(gif, (int) (System.currentTimeMillis() / 1000)); if ((int) dialog_id == 0) { MessagesController.getInstance().saveGif(gif); } if (delegate != null) { delegate.onMessageSend(null); } } @Override public void onGifTab(boolean opened) { if (!AndroidUtilities.usingHardwareInput) { if (opened) { if (messageEditText.length() == 0) { messageEditText.setText("@gif "); messageEditText.setSelection(messageEditText.length()); } } else if (messageEditText.getText().toString().equals("@gif ")) { messageEditText.setText(""); } } } @Override public void onStickersTab(boolean opened) { delegate.onStickersTab(opened); } @Override public void onClearEmojiRecent() { if (parentFragment == null || parentActivity == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("ClearRecentEmoji", R.string.ClearRecentEmoji)); builder.setPositiveButton( LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { emojiView.clearRecentEmoji(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); parentFragment.showDialog(builder.create()); } @Override public void onShowStickerSet(TLRPC.StickerSet stickerSet, TLRPC.InputStickerSet inputStickerSet) { if (parentFragment == null || parentActivity == null) { return; } if (stickerSet != null) { inputStickerSet = new TLRPC.TL_inputStickerSetID(); inputStickerSet.access_hash = stickerSet.access_hash; inputStickerSet.id = stickerSet.id; } parentFragment.showDialog(new StickersAlert(parentActivity, parentFragment, inputStickerSet, null, ChatActivityEnterView.this)); } @Override public void onStickerSetAdd(TLRPC.StickerSetCovered stickerSet) { StickersQuery.removeStickersSet(parentActivity, stickerSet.set, 2, parentFragment, false); } @Override public void onStickerSetRemove(TLRPC.StickerSetCovered stickerSet) { StickersQuery.removeStickersSet(parentActivity, stickerSet.set, 0, parentFragment, false); } }); emojiView.setVisibility(GONE); sizeNotifierLayout.addView(emojiView); }
From source file:org.mdc.chess.MDChess.java
private void newNetworkEngineDialog() { View content = View.inflate(this, R.layout.create_network_engine, null); final EditText engineNameView = (EditText) content.findViewById(R.id.create_network_engine); final TextInputLayout engineNameWrapper = (TextInputLayout) content .findViewById(R.id.create_network_engine_wrapper); engineNameWrapper.setHint(content.getResources().getString(R.string.engine_name)); engineNameView.setText(""); final Runnable createEngine = new Runnable() { public void run() { String engineName = engineNameView.getText().toString(); String sep = File.separator; String pathName = Environment.getExternalStorageDirectory() + sep + engineDir + sep + engineName; File file = new File(pathName); boolean nameOk = true; int errMsg = -1; if (engineName.contains("/")) { nameOk = false;//ww w .j ava2 s . co m errMsg = R.string.slash_not_allowed; } else if (reservedEngineName(engineName) || file.exists()) { nameOk = false; errMsg = R.string.engine_name_in_use; } if (!nameOk) { Toast.makeText(getApplicationContext(), errMsg, Toast.LENGTH_LONG).show(); networkEngineDialog(); return; } networkEngineToConfig = pathName; networkEngineConfigDialog(); } }; new MaterialDialog.Builder(this).title(R.string.create_network_engine).customView(content, true) .positiveText(android.R.string.ok).negativeText(R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { createEngine.run(); } }).onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { networkEngineDialog(); } }).show(); engineNameView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { createEngine.run(); return true; } return false; } }); }
From source file:org.mdc.chess.MDChess.java
private void networkEngineConfigDialog() { View content = View.inflate(this, R.layout.network_engine_config, null); final EditText hostNameView = (EditText) content.findViewById(R.id.network_engine_host); final EditText portView = (EditText) content.findViewById(R.id.network_engine_port); String hostName = ""; String port = "0"; try {/* w w w. j a v a 2 s . com*/ if (EngineUtil.isNetEngine(networkEngineToConfig)) { String[] lines = Util.readFile(networkEngineToConfig); if (lines.length > 1) { hostName = lines[1]; } if (lines.length > 2) { port = lines[2]; } } } catch (IOException e1) { Log.d("Exception", e1.toString()); } hostNameView.setText(hostName); portView.setText(port); final Runnable writeConfig = new Runnable() { public void run() { String hostName = hostNameView.getText().toString(); String port = portView.getText().toString(); try { FileWriter fw = new FileWriter(new File(networkEngineToConfig), false); fw.write("NETE\n"); fw.write(hostName); fw.write("\n"); fw.write(port); fw.write("\n"); fw.close(); setEngineOptions(true); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }; new MaterialDialog.Builder(this).title(R.string.configure_network_engine).customView(content, true) .positiveText(android.R.string.ok).negativeText(R.string.cancel).neutralText(R.string.delete) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { writeConfig.run(); networkEngineDialog(); } }).onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { deleteNetworkEngineDialog(); } }).onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { networkEngineDialog(); } }); portView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { writeConfig.run(); networkEngineDialog(); return true; } return false; } }); }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { // Dispatch in the normal way boolean handled = super.dispatchKeyEvent(event); if (!handled) { // If we didn't handle it... final View focused = getFocusedChild(); if (focused != null && event.getAction() == KeyEvent.ACTION_DOWN) { // ... and our focused child didn't handle it // ... give it to ourselves so we can scroll if necessary handled = onKeyDown(event.getKeyCode(), event); }/* w w w. j a v a 2 s. c o m*/ } return handled; }
From source file:org.petero.droidfish.DroidFish.java
private final Dialog newNetworkEngineDialog() { View content = View.inflate(this, R.layout.create_network_engine, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content);//from w w w .ja v a 2 s.c o m builder.setTitle(R.string.create_network_engine); final EditText engineNameView = (EditText) content.findViewById(R.id.create_network_engine); engineNameView.setText(""); final Runnable createEngine = new Runnable() { public void run() { String engineName = engineNameView.getText().toString(); String sep = File.separator; String pathName = Environment.getExternalStorageDirectory() + sep + engineDir + sep + engineName; File file = new File(pathName); boolean nameOk = true; int errMsg = -1; if (engineName.contains("/")) { nameOk = false; errMsg = R.string.slash_not_allowed; } else if (reservedEngineName(engineName) || file.exists()) { nameOk = false; errMsg = R.string.engine_name_in_use; } if (!nameOk) { Toast.makeText(getApplicationContext(), errMsg, Toast.LENGTH_LONG).show(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); return; } networkEngineToConfig = pathName; removeDialog(NETWORK_ENGINE_CONFIG_DIALOG); showDialog(NETWORK_ENGINE_CONFIG_DIALOG); } }; builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { createEngine.run(); } }); builder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); final Dialog dialog = builder.create(); engineNameView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { createEngine.run(); dialog.cancel(); return true; } return false; } }); return dialog; }
From source file:org.petero.droidfish.DroidFish.java
private final Dialog networkEngineConfigDialog() { View content = View.inflate(this, R.layout.network_engine_config, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content);// w w w .j a va 2 s . c o m builder.setTitle(R.string.configure_network_engine); final EditText hostNameView = (EditText) content.findViewById(R.id.network_engine_host); final EditText portView = (EditText) content.findViewById(R.id.network_engine_port); String hostName = ""; String port = "0"; try { if (EngineUtil.isNetEngine(networkEngineToConfig)) { String[] lines = Util.readFile(networkEngineToConfig); if (lines.length > 1) hostName = lines[1]; if (lines.length > 2) port = lines[2]; } } catch (IOException e1) { } hostNameView.setText(hostName); portView.setText(port); final Runnable writeConfig = new Runnable() { public void run() { String hostName = hostNameView.getText().toString(); String port = portView.getText().toString(); try { FileWriter fw = new FileWriter(new File(networkEngineToConfig), false); fw.write("NETE\n"); fw.write(hostName); fw.write("\n"); fw.write(port); fw.write("\n"); fw.close(); setEngineOptions(true); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }; builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { writeConfig.run(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setNeutralButton(R.string.delete, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(DELETE_NETWORK_ENGINE_DIALOG); showDialog(DELETE_NETWORK_ENGINE_DIALOG); } }); final Dialog dialog = builder.create(); portView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { writeConfig.run(); dialog.cancel(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); return true; } return false; } }); return dialog; }
From source file:edu.mit.viral.shen.DroidFish.java
private final Dialog newNetworkEngineDialog() { View content = View.inflate(this, R.layout.create_network_engine, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content);// www . j a va 2s. c o m builder.setTitle(R.string.create_network_engine); final EditText engineNameView = (EditText) content.findViewById(R.id.create_network_engine); engineNameView.setText(""); final Runnable createEngine = new Runnable() { public void run() { String engineName = engineNameView.getText().toString(); String sep = File.separator; String pathName = Environment.getExternalStorageDirectory() + sep + engineDir + sep + engineName; File file = new File(pathName); boolean nameOk = true; int errMsg = -1; if (engineName.contains("/")) { nameOk = false; errMsg = R.string.slash_not_allowed; } else if (internalEngine(engineName) || file.exists()) { nameOk = false; errMsg = R.string.engine_name_in_use; } if (!nameOk) { Toast.makeText(getApplicationContext(), errMsg, Toast.LENGTH_LONG).show(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); return; } networkEngineToConfig = pathName; removeDialog(NETWORK_ENGINE_CONFIG_DIALOG); showDialog(NETWORK_ENGINE_CONFIG_DIALOG); } }; builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { createEngine.run(); } }); builder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); final Dialog dialog = builder.create(); engineNameView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { createEngine.run(); dialog.cancel(); return true; } return false; } }); return dialog; }
From source file:edu.mit.viral.shen.DroidFish.java
private final Dialog networkEngineConfigDialog() { View content = View.inflate(this, R.layout.network_engine_config, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content);/*from www . ja v a2 s .co m*/ builder.setTitle(R.string.configure_network_engine); final EditText hostNameView = (EditText) content.findViewById(R.id.network_engine_host); final EditText portView = (EditText) content.findViewById(R.id.network_engine_port); String hostName = ""; String port = "0"; try { String[] lines = Util.readFile(networkEngineToConfig); if ((lines.length >= 1) && lines[0].equals("NETE")) { if (lines.length > 1) hostName = lines[1]; if (lines.length > 2) port = lines[2]; } } catch (IOException e1) { } hostNameView.setText(hostName); portView.setText(port); final Runnable writeConfig = new Runnable() { public void run() { String hostName = hostNameView.getText().toString(); String port = portView.getText().toString(); try { FileWriter fw = new FileWriter(new File(networkEngineToConfig), false); fw.write("NETE\n"); fw.write(hostName); fw.write("\n"); fw.write(port); fw.write("\n"); fw.close(); setEngineOptions(true); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }; builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { writeConfig.run(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setNeutralButton(R.string.delete, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(DELETE_NETWORK_ENGINE_DIALOG); showDialog(DELETE_NETWORK_ENGINE_DIALOG); } }); final Dialog dialog = builder.create(); portView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { writeConfig.run(); dialog.cancel(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); return true; } return false; } }); return dialog; }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
private void initSearchBar() { if (searchBarInitialized) return;//from w w w . j a va2 s .c o m final EditText field = (EditText) searchBarView.findViewById(R.id.board_search_field); final TextView results = (TextView) searchBarView.findViewById(R.id.board_search_result); if (pageType == TYPE_POSTSLIST) { field.setHint(R.string.search_bar_in_thread_hint); } final View.OnClickListener searchOnClickListener = new View.OnClickListener() { private int lastFound = -1; @Override public void onClick(View v) { if (v != null && v.getId() == R.id.board_search_close) { searchHighlightActive = false; adapter.notifyDataSetChanged(); searchBarView.setVisibility(View.GONE); } else if (listView != null && listView.getChildCount() > 0 && adapter != null && cachedSearchResults != null) { boolean atEnd = listView.getChildAt(listView.getChildCount() - 1).getTop() + listView.getChildAt(listView.getChildCount() - 1).getHeight() == listView.getHeight(); View topView = listView.getChildAt(0); if ((v == null || v.getId() == R.id.board_search_previous) && topView.getTop() < 0 && listView.getChildCount() > 1) topView = listView.getChildAt(1); int currentListPosition = listView.getPositionForView(topView); int newResultIndex = Collections.binarySearch(cachedSearchResults, currentListPosition); if (newResultIndex >= 0) { if (v != null) { if (v.getId() == R.id.board_search_next) ++newResultIndex; else if (v.getId() == R.id.board_search_previous) --newResultIndex; } } else { newResultIndex = -newResultIndex - 1; if (v != null && v.getId() == R.id.board_search_previous) --newResultIndex; } while (newResultIndex < 0) newResultIndex += cachedSearchResults.size(); newResultIndex %= cachedSearchResults.size(); if (v != null && v.getId() == R.id.board_search_next && lastFound == newResultIndex && atEnd) newResultIndex = 0; lastFound = newResultIndex; listView.setSelection(cachedSearchResults.get(newResultIndex)); results.setText((newResultIndex + 1) + "/" + cachedSearchResults.size()); } } }; for (int id : new int[] { R.id.board_search_close, R.id.board_search_previous, R.id.board_search_next }) { searchBarView.findViewById(id).setOnClickListener(searchOnClickListener); } field.setOnKeyListener(new View.OnKeyListener() { private boolean searchUsingChan() { if (pageType != TYPE_THREADSLIST) return false; if (presentationModel != null) if (presentationModel.source != null) if (presentationModel.source.boardModel != null) if (!presentationModel.source.boardModel.searchAllowed) return false; return true; } @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { if (searchUsingChan()) { UrlPageModel model = new UrlPageModel(); model.chanName = chan.getChanName(); model.type = UrlPageModel.TYPE_SEARCHPAGE; model.boardName = tabModel.pageModel.boardName; model.searchRequest = field.getText().toString(); UrlHandler.open(model, activity); } else { int highlightColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.searchHighlightBackground, Color.RED); String request = field.getText().toString().toLowerCase(Locale.US); if (cachedSearchRequest == null || !request.equals(cachedSearchRequest)) { cachedSearchRequest = request; cachedSearchResults = new ArrayList<Integer>(); cachedSearchHighlightedSpanables = new SparseArray<Spanned>(); List<PresentationItemModel> safePresentationList = presentationModel .getSafePresentationList(); if (safePresentationList != null) { for (int i = 0; i < safePresentationList.size(); ++i) { PresentationItemModel model = safePresentationList.get(i); if (model.hidden && !staticSettings.showHiddenItems) continue; String comment = model.spannedComment.toString().toLowerCase(Locale.US) .replace('\n', ' '); List<Integer> altFoundPositions = null; if (model.floating) { int floatingpos = FlowTextHelper.getFloatingPosition(model.spannedComment); if (floatingpos != -1 && floatingpos < model.spannedComment.length() && model.spannedComment.charAt(floatingpos) == '\n') { String altcomment = comment.substring(0, floatingpos) + comment.substring(floatingpos + 1, Math.min(model.spannedComment.length(), floatingpos + request.length())); int start = 0; int curpos; while (start < altcomment.length() && (curpos = altcomment.indexOf(request, start)) != -1) { if (altFoundPositions == null) altFoundPositions = new ArrayList<Integer>(); altFoundPositions.add(curpos); start = curpos + request.length(); } } } if (comment.contains(request) || altFoundPositions != null) { cachedSearchResults.add(Integer.valueOf(i)); SpannableStringBuilder spannedHighlited = new SpannableStringBuilder( safePresentationList.get(i).spannedComment); int start = 0; int curpos; while (start < comment.length() && (curpos = comment.indexOf(request, start)) != -1) { start = curpos + request.length(); if (altFoundPositions != null && Collections.binarySearch(altFoundPositions, curpos) >= 0) continue; spannedHighlited.setSpan(new BackgroundColorSpan(highlightColor), curpos, curpos + request.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (altFoundPositions != null) { for (Integer pos : altFoundPositions) { spannedHighlited.setSpan(new BackgroundColorSpan(highlightColor), pos, pos + request.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } cachedSearchHighlightedSpanables.put(i, spannedHighlited); } } } } if (cachedSearchResults.size() == 0) { Toast.makeText(activity, R.string.notification_not_found, Toast.LENGTH_LONG).show(); } else { boolean firstTime = !searchHighlightActive; searchHighlightActive = true; adapter.notifyDataSetChanged(); searchBarView.findViewById(R.id.board_search_next).setVisibility(View.VISIBLE); searchBarView.findViewById(R.id.board_search_previous).setVisibility(View.VISIBLE); searchBarView.findViewById(R.id.board_search_result).setVisibility(View.VISIBLE); searchOnClickListener .onClick(firstTime ? null : searchBarView.findViewById(R.id.board_search_next)); } } try { InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(field.getWindowToken(), 0); } catch (Exception e) { Logger.e(TAG, e); } return true; } return false; } }); field.addTextChangedListener(new OnSearchTextChangedListener(this)); field.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); if (resources.getDimensionPixelSize(R.dimen.panel_height) < field.getMeasuredHeight()) searchBarView.getLayoutParams().height = field.getMeasuredHeight(); searchBarInitialized = true; }
From source file:com.android.mms.ui.ComposeMessageActivity.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null) { // if shift key is down, then we want to insert the '\n' char in the TextView; // otherwise, the default action is to send the message. if (!event.isShiftPressed() && event.getAction() == KeyEvent.ACTION_DOWN) { if (isPreparedForSending()) { confirmSendMessageIfNeeded(); }//from w w w . j a va 2 s . co m return true; } return false; } if (isPreparedForSending()) { confirmSendMessageIfNeeded(); } return true; }