mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-06-19 17:31:30 +02:00
Fix crash when no current input binding
Broken recently. Restore previous code
This commit is contained in:
parent
81803c406a
commit
2f8eae628f
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.IBinder;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
@ -100,7 +101,7 @@ public class Keyboard2 extends InputMethodService
|
|||||||
public void onStartInputView(EditorInfo info, boolean restarting)
|
public void onStartInputView(EditorInfo info, boolean restarting)
|
||||||
{
|
{
|
||||||
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
_config.shouldOfferSwitchingToNextInputMethod = imm.shouldOfferSwitchingToNextInputMethod(getCurrentInputBinding().getConnectionToken());
|
_config.shouldOfferSwitchingToNextInputMethod = imm.shouldOfferSwitchingToNextInputMethod(getConnectionToken());
|
||||||
refreshSubtype(imm.getCurrentInputMethodSubtype());
|
refreshSubtype(imm.getCurrentInputMethodSubtype());
|
||||||
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
|
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
|
||||||
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
||||||
@ -154,8 +155,7 @@ public class Keyboard2 extends InputMethodService
|
|||||||
else if (key.eventCode == KeyValue.EVENT_CHANGE_METHOD)
|
else if (key.eventCode == KeyValue.EVENT_CHANGE_METHOD)
|
||||||
{
|
{
|
||||||
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
|
||||||
|
imm.switchToNextInputMethod(getConnectionToken(), false);
|
||||||
imm.switchToNextInputMethod(getCurrentInputBinding().getConnectionToken(), false);
|
|
||||||
}
|
}
|
||||||
else if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0)
|
else if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0)
|
||||||
handleMetaKeyUp(key, flags);
|
handleMetaKeyUp(key, flags);
|
||||||
@ -201,4 +201,9 @@ public class Keyboard2 extends InputMethodService
|
|||||||
getCurrentInputConnection().sendKeyEvent(event);
|
getCurrentInputConnection().sendKeyEvent(event);
|
||||||
getCurrentInputConnection().sendKeyEvent(KeyEvent.changeAction(event, KeyEvent.ACTION_UP));
|
getCurrentInputConnection().sendKeyEvent(KeyEvent.changeAction(event, KeyEvent.ACTION_UP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBinder getConnectionToken()
|
||||||
|
{
|
||||||
|
return getWindow().getWindow().getAttributes().token;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user