Skip to content

Commit a3e27a5

Browse files
wxyzhBambooin
wxyzh
authored andcommitted
fix: fix some issues
1. app crash when switch IME 2. popwindow not display after use liquid_keyboard 3. Can't get keycode when use scrcpy or Physical keyboard
1 parent 887651c commit a3e27a5

File tree

1 file changed

+12
-8
lines changed
  • app/src/main/java/com/osfans/trime/ime/core

1 file changed

+12
-8
lines changed

app/src/main/java/com/osfans/trime/ime/core/Trime.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,9 @@ public void onFinishInputView(boolean finishingInput) {
869869
// Dismiss any pop-ups when the input-view is being finished and hidden.
870870
mainKeyboardView.closing();
871871
performEscape();
872-
inputFeedbackManager.releaseSoundPool();
872+
if (inputFeedbackManager != null) {
873+
inputFeedbackManager.releaseSoundPool();
874+
}
873875
try {
874876
hideCompositionView();
875877
} catch (Exception e) {
@@ -1003,9 +1005,13 @@ private boolean onKeyEvent(@NonNull KeyEvent event) {
10031005
}
10041006

10051007
final int unicodeChar = event.getUnicodeChar();
1006-
int mask = event.getMetaState();
1007-
if (unicodeChar > 0) {
1008-
keyCode = unicodeChar;
1008+
final String s = String.valueOf((char) unicodeChar);
1009+
final int i = Event.getClickCode(s);
1010+
int mask = 0;
1011+
if (i > 0) {
1012+
keyCode = i;
1013+
} else { // 空格、回車等
1014+
mask = event.getMetaState();
10091015
}
10101016
final boolean ret = handleKey(keyCode, mask);
10111017
if (isComposing()) setCandidatesViewShown(textInputManager.isComposable()); // 藍牙鍵盤打字時顯示候選欄
@@ -1205,11 +1211,9 @@ public int updateComposing() {
12051211
Timber.d("updateComposing() SymbolKeyboardType=%s", symbolKeyboardType.toString());
12061212
if (symbolKeyboardType != SymbolKeyboardType.NO_KEY
12071213
&& symbolKeyboardType != SymbolKeyboardType.CANDIDATE) {
1208-
mComposition.setWindow();
1209-
showCompositionView(false);
1210-
return 0;
1214+
mComposition.getRootView().setVisibility(View.GONE);
12111215
} else {
1212-
mComposition.setVisibility(View.VISIBLE);
1216+
mComposition.getRootView().setVisibility(View.VISIBLE);
12131217
startNum = mComposition.setWindow(minPopupSize, minPopupCheckSize, Integer.MAX_VALUE);
12141218
mCandidate.setText(startNum);
12151219
// if isCursorUpdated, showCompositionView will be called in onUpdateCursorAnchorInfo

0 commit comments

Comments
 (0)