Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make carriage returns behave normally #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/io/appium/android/ime/UnicodeIME.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class UnicodeIME extends InputMethodService {
// markers of UTF-7 content
private static final char M_UTF7_SHIFT = '&';
private static final char M_UTF7_UNSHIFT = '-';


private static String strInputString = "";
// local state
private boolean isShifted;
private long metaState;
Expand All @@ -53,7 +54,7 @@ public class UnicodeIME extends InputMethodService {
public void onStartInput(EditorInfo attribute, boolean restarting) {
Log.i(TAG, "onStartInput");
super.onStartInput(attribute, restarting);

strInputString = "";
if (!restarting) {
metaState = 0;
isShifted = false;
Expand All @@ -63,7 +64,7 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {

@Override
public void onFinishInput() {
Log.i(TAG, "onFinishInput");
Log.i(TAG, "onFinishInput: string" + strInputString );
super.onFinishInput();
unicodeString = null;
}
Expand All @@ -80,14 +81,12 @@ public boolean onEvaluateInputViewShown() {

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.i(TAG, "onKeyDown (keyCode='" + keyCode + "', event.keyCode='" + event.getKeyCode() + "', metaState='" + event.getMetaState() + "')");
int c = getUnicodeChar(keyCode, event);

if (c == 0) {
return super.onKeyDown(keyCode, event);
}

if (!isShifted) {
if (!isShifted) {
if (c == M_UTF7_SHIFT) {
shift();
return true;
Expand All @@ -109,7 +108,6 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
Log.i(TAG, "onKeyUp (keyCode='" + keyCode + "', event.keyCode='" + event.getKeyCode() + "', metaState='" + event.getMetaState() + "')");
metaState = MetaKeyKeyListener.handleKeyUp(metaState, keyCode, event);
return super.onKeyUp(keyCode, event);
}
Expand Down Expand Up @@ -137,6 +135,7 @@ private int getUnicodeChar(int keyCode, KeyEvent event) {

private void commitChar(int c) {
getCurrentInputConnection().commitText(String.valueOf((char) c), 1);
strInputString = strInputString + String.valueOf((char) c);
}

private void appendChar(int c) {
Expand All @@ -156,6 +155,8 @@ private String decodeUtf7(String encStr) {
}

private boolean isAsciiPrintable(int c) {
if (c == 10)
return true;
return c >= 0x20 && c <= 0x7E;
}
}