soft keyboard disabled
This commit is contained in:
parent
2c27a10540
commit
7c9a29b420
@ -10,6 +10,7 @@ import android.graphics.Color;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.ContextMenu;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
import org.solovyev.android.calculator.math.MathType;
|
||||||
@ -40,6 +41,21 @@ public class CalculatorEditor extends EditText {
|
|||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCheckIsTextEditor() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreateContextMenu(ContextMenu menu) {
|
||||||
|
super.onCreateContextMenu(menu);
|
||||||
|
|
||||||
|
menu.removeItem(android.R.id.selectAll);
|
||||||
|
menu.removeItem(android.R.id.startSelectingText);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void redraw() {
|
public void redraw() {
|
||||||
String text = getText().toString();
|
String text = getText().toString();
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import org.solovyev.android.calculator.model.CalculatorModel;
|
|||||||
import org.solovyev.android.calculator.model.ParseException;
|
import org.solovyev.android.calculator.model.ParseException;
|
||||||
import org.solovyev.android.view.CursorControl;
|
import org.solovyev.android.view.CursorControl;
|
||||||
import org.solovyev.android.view.HistoryControl;
|
import org.solovyev.android.view.HistoryControl;
|
||||||
import org.solovyev.android.view.widgets.SoftKeyboardDisabler;
|
|
||||||
import org.solovyev.common.utils.MutableObject;
|
import org.solovyev.common.utils.MutableObject;
|
||||||
import org.solovyev.common.utils.StringUtils;
|
import org.solovyev.common.utils.StringUtils;
|
||||||
import org.solovyev.common.utils.history.HistoryAction;
|
import org.solovyev.common.utils.history.HistoryAction;
|
||||||
@ -50,7 +49,6 @@ public class CalculatorView implements CursorControl, HistoryControl<CalculatorH
|
|||||||
this.calculatorModel = calculator;
|
this.calculatorModel = calculator;
|
||||||
|
|
||||||
this.editor = (CalculatorEditor) activity.findViewById(R.id.calculatorEditor);
|
this.editor = (CalculatorEditor) activity.findViewById(R.id.calculatorEditor);
|
||||||
this.editor.setOnTouchListener(new SoftKeyboardDisabler());
|
|
||||||
|
|
||||||
this.display = (CalculatorDisplay) activity.findViewById(R.id.calculatorDisplay);
|
this.display = (CalculatorDisplay) activity.findViewById(R.id.calculatorDisplay);
|
||||||
this.display.setOnClickListener(new View.OnClickListener() {
|
this.display.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
|
||||||
* For more information, please, contact se.solovyev@gmail.com
|
|
||||||
* or visit http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.view.widgets;
|
|
||||||
|
|
||||||
import android.text.InputType;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 10/9/11
|
|
||||||
* Time: 4:27 PM
|
|
||||||
*/
|
|
||||||
public class SoftKeyboardDisabler implements View.OnTouchListener {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
boolean result;
|
|
||||||
Log.d(this.getClass().getName(), "org.solovyev.android.view.widgets.SoftKeyboardDisabler.onTouch(): action=" + event.getAction() + ", event=" + event);
|
|
||||||
|
|
||||||
if (v instanceof EditText) {
|
|
||||||
final EditText editText = (EditText) v;
|
|
||||||
int inputType = editText.getInputType();
|
|
||||||
int selectionStart = editText.getSelectionStart();
|
|
||||||
int selectionEnd = editText.getSelectionEnd();
|
|
||||||
|
|
||||||
// disable soft input
|
|
||||||
editText.setInputType(InputType.TYPE_NULL);
|
|
||||||
editText.onTouchEvent(event);
|
|
||||||
|
|
||||||
// restore input type
|
|
||||||
editText.setInputType(inputType);
|
|
||||||
editText.setSelection(selectionStart, selectionEnd);
|
|
||||||
|
|
||||||
result = true;
|
|
||||||
} else {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user