Possible fix for disabling virtual keyboard
This commit is contained in:
parent
391fe95df9
commit
315a2eb604
@ -10,10 +10,14 @@ import android.content.SharedPreferences;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.text.InputType;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||||
import org.solovyev.android.calculator.model.CalculatorParseException;
|
import org.solovyev.android.calculator.model.CalculatorParseException;
|
||||||
@ -37,20 +41,40 @@ public class CalculatorEditor extends EditText implements SharedPreferences.OnSh
|
|||||||
|
|
||||||
public CalculatorEditor(Context context) {
|
public CalculatorEditor(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculatorEditor(Context context, AttributeSet attrs) {
|
public CalculatorEditor(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculatorEditor(Context context, AttributeSet attrs, int defStyle) {
|
private void init() {
|
||||||
super(context, attrs, defStyle);
|
this.setOnTouchListener(new OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
final TextView textView = (TextView)v;
|
||||||
|
// backup the input type
|
||||||
|
int inputType = textView.getInputType();
|
||||||
|
|
||||||
|
// disable soft input
|
||||||
|
textView.setInputType(InputType.TYPE_NULL);
|
||||||
|
|
||||||
|
// call native handler
|
||||||
|
textView.onTouchEvent(event);
|
||||||
|
|
||||||
|
// restore input type
|
||||||
|
textView.setInputType(inputType);
|
||||||
|
|
||||||
|
// consume touch even
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCheckIsTextEditor() {
|
public boolean onCheckIsTextEditor() {
|
||||||
// Main goal of this implementation is to hide android soft keyboard from appearing when working with text input
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
// fix for missing cursor in android 3 and higher
|
// fix for missing cursor in android 3 and higher
|
||||||
return true;
|
return true;
|
||||||
@ -59,6 +83,11 @@ public class CalculatorEditor extends EditText implements SharedPreferences.OnSh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CalculatorEditor(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreateContextMenu(ContextMenu menu) {
|
protected void onCreateContextMenu(ContextMenu menu) {
|
||||||
super.onCreateContextMenu(menu);
|
super.onCreateContextMenu(menu);
|
||||||
|
Loading…
Reference in New Issue
Block a user