Fix for Android 4 soft keyboard
This commit is contained in:
parent
37e9354a5b
commit
7120ad3e61
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="75" android:versionName="1.2.34" package="org.solovyev.android.calculator">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="78" android:versionName="1.2.38" package="org.solovyev.android.calculator">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
|
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>
|
||||||
|
|
||||||
<application android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
<application android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication">
|
||||||
|
|
||||||
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
|
<activity android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<org.solovyev.android.calculator.CalculatorEditor
|
<org.solovyev.android.calculator.CalculatorEditor
|
||||||
a:id="@+id/calculatorEditor"
|
a:id="@+id/calculatorEditor"
|
||||||
style="@style/editor_style"
|
style="@style/editor_style"
|
||||||
a:editable="false"
|
a:textIsSelectable="true"
|
||||||
a:singleLine="false"
|
a:singleLine="false"
|
||||||
a:scrollbars="vertical"
|
a:scrollbars="vertical"
|
||||||
a:hint ="@string/c_calc_editor_hint"/>
|
a:hint ="@string/c_calc_editor_hint"/>
|
||||||
|
@ -10,19 +10,16 @@ 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;
|
||||||
import org.solovyev.android.calculator.model.TextProcessor;
|
import org.solovyev.android.calculator.model.TextProcessor;
|
||||||
import org.solovyev.android.calculator.view.TextHighlighter;
|
import org.solovyev.android.calculator.view.TextHighlighter;
|
||||||
|
import org.solovyev.common.utils.CollectionsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -50,7 +47,9 @@ public class CalculatorEditor extends EditText implements SharedPreferences.OnSh
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
this.setOnTouchListener(new OnTouchListener() {
|
// NOTE: in this solution cursor is missing
|
||||||
|
|
||||||
|
/*this.setOnTouchListener(new OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
final TextView textView = (TextView)v;
|
final TextView textView = (TextView)v;
|
||||||
@ -69,15 +68,29 @@ public class CalculatorEditor extends EditText implements SharedPreferences.OnSh
|
|||||||
// consume touch even
|
// consume touch even
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCheckIsTextEditor() {
|
public boolean onCheckIsTextEditor() {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
// NOTE: code below can be used carefully and should not be copied without special intention
|
||||||
|
// The main purpose of code is to disable soft input (virtual keyboard) but leave all the TextEdit functionality, like cursor, scrolling, copy/paste menu etc
|
||||||
|
|
||||||
|
if ( Build.VERSION.SDK_INT >= 11 ) {
|
||||||
// fix for missing cursor in android 3 and higher
|
// fix for missing cursor in android 3 and higher
|
||||||
|
try {
|
||||||
|
// IDEA: return false always except if method was called from TextView.isCursorVisible() method
|
||||||
|
for (StackTraceElement stackTraceElement : CollectionsUtils.asList(Thread.currentThread().getStackTrace())) {
|
||||||
|
if ( "isCursorVisible".equals(stackTraceElement.getMethodName()) ) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// just in case...
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user