Skip to content

Commit

Permalink
refactor(text): optimize how to recompute tab geometry
Browse files Browse the repository at this point in the history
- fix: mistouch caused by too large response area
- fix: can not pick the last candidate item when has a long page size
- improve candidate view visually
  • Loading branch information
WhiredPlanck authored and Bambooin committed Oct 23, 2021
1 parent df9c966 commit cd018f8
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 192 deletions.
16 changes: 12 additions & 4 deletions app/src/main/java/com/osfans/trime/ime/core/Trime.java
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,7 @@ public void onCandidatePressed(int index) {
Rime.toggleOption(index);
updateComposing();
}
} else if (index == -4) onKey(KeyEvent.KEYCODE_PAGE_UP, 0);
else if (index == -5) onKey(KeyEvent.KEYCODE_PAGE_DOWN, 0);
else if (getPrefs().getOther().getClickCandidateAndCommit() || index > 9) {
} else if (getPrefs().getOther().getClickCandidateAndCommit() || index > 9) {
if (Rime.selectCandidate(index)) {
commitText();
}
Expand All @@ -1298,6 +1296,16 @@ else if (getPrefs().getOther().getClickCandidateAndCommit() || index > 9) {
}
}

@Override
public void onCandidateSymbolPressed(@NonNull String arrow) {
switch (arrow) {
case Candidate.PAGE_UP_BUTTON:
onKey(KeyEvent.KEYCODE_PAGE_UP, 0);
case Candidate.PAGE_DOWN_BUTTON:
onKey(KeyEvent.KEYCODE_PAGE_DOWN, 0);
}
}

/** 獲得當前漢字:候選字、選中字、剛上屏字/光標前字/光標前所有字、光標後所有字 */
private String getActiveText(int type) {
if (type == 2) return Rime.RimeGetInput(); // 當前編碼
Expand Down Expand Up @@ -1350,7 +1358,7 @@ public void updateComposing() {
mCandidate.setText(0);
}
// 刷新候选词后,如果候选词超出屏幕宽度,滚动候选栏
mTabRoot.move(mCandidate.getHightlightLeft(), mCandidate.getHightlightRight());
mTabRoot.move(mCandidate.getHighlightLeft(), mCandidate.getHighlightRight());
}
if (mainKeyboardView != null) mainKeyboardView.invalidateComposingKeys();
if (!onEvaluateInputViewShown()) setCandidatesViewShown(canCompose); // 實體鍵盤打字時顯示候選欄
Expand Down
Loading

0 comments on commit cd018f8

Please sign in to comment.