@Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN){ //once the user clicks on part of the expression, don't want # to delete it mCalc.setSolved(false); mDisplay.setCursorVisible(true); mDisplay.clearHighlighted(); } // else if(event.getAction()==MotionEvent.ACTION_UP){ // ViewUtils.toast("Action Up",mAppContext); // InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // imm.hideSoftInputFromWindow(mDisplay.getWindowToken(), 0); // return true; // } return false; }
/** * Try to cut the current clipboard text */ private void onTextCut() { int selStart = getSelectionStart(); int selEnd = getSelectionEnd(); CharSequence copiedText = getText().subSequence(selStart, selEnd); ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText(null, copiedText)); //cut deletes the selected text mCalc.parseKeyPressed("b"); //this was in the original function, keep for now LAST_CUT_OR_COPY_TIME = SystemClock.uptimeMillis(); Toast.makeText(mContext, "Cut: \"" + copiedText + "\"", Toast.LENGTH_SHORT).show(); }
/** * Helper method to size text */ private void layoutText() { Paint paint = getPaint(); if (mTextSize != 0f) paint.setTextSize(mTextSize); //if min text size is the same as normal size, just leave if (mMinTextSize == getTextSize()) return; float textWidth = paint.measureText(getText().toString()); float boxWidth = getWidth() - getPaddingLeft() - getPaddingRight(); float textSize = getTextSize(); if (textWidth > boxWidth){ float scaled = textSize * boxWidth / textWidth; if (scaled < mMinTextSize) scaled = mMinTextSize; paint.setTextSize(scaled); mTextSize = textSize; } }
mExpressionText = getSepDispText(); mTextSuffix = ""; mTextPrefix = getResources().getString(R.string.word_Convert) + " "; mTextSuffix = mTextSuffix + " " + getResources().getString(R.string.word_to) + ":"; setTextHtml(mExpressionText); setupHighlighting(); setSelection(mSelStart, mSelEnd); setCursorVisible(!mCalc.isSolved());
mDisplay.setCalc(mCalc); mDisplay.disableSoftInputFromAppearing(); mDisplay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDisplay.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { mDisplay.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) {
@Override public void onAnimationEnd(Animator animation) { clearHighlighted(); } });
/** * Try to paste the current clipboard text into this EditText */ private void onTextPaste() { String textToPaste; ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = clipboard.getPrimaryClip(); textToPaste = clip.getItemAt(0).coerceToText(getContext()).toString(); Toast.makeText(mContext, "Pasted: \"" + textToPaste + "\"", Toast.LENGTH_SHORT).show(); mCalc.pasteIntoExpression(textToPaste); }