@@ -227,14 +227,14 @@ public static Trime getServiceOrNull() {
227
227
}
228
228
229
229
private static final Handler syncBackgroundHandler =
230
- new Handler (
231
- msg -> {
232
- if (!((Trime ) msg .obj ).isShowInputRequested ()) { // 若当前没有输入面板,则后台同步。防止面板关闭后5秒内再次打开
233
- ShortcutUtils .INSTANCE .syncInBackground ((Trime ) msg .obj );
234
- ((Trime ) msg .obj ).loadConfig ();
235
- }
236
- return false ;
237
- });
230
+ new Handler (
231
+ msg -> {
232
+ if (!((Trime ) msg .obj ).isShowInputRequested ()) { // 若当前没有输入面板,则后台同步。防止面板关闭后5秒内再次打开
233
+ ShortcutUtils .INSTANCE .syncInBackground ((Trime ) msg .obj );
234
+ ((Trime ) msg .obj ).loadConfig ();
235
+ }
236
+ return false ;
237
+ });
238
238
239
239
public Trime () {
240
240
try {
@@ -258,7 +258,7 @@ public void onWindowShown() {
258
258
259
259
updateComposing ();
260
260
261
- for (EventListener listener : ( List < EventListener >) eventListeners ) {
261
+ for (EventListener listener : eventListeners ) {
262
262
if (listener != null ) listener .onWindowShown ();
263
263
}
264
264
}
@@ -280,7 +280,7 @@ public void onWindowHidden() {
280
280
syncBackgroundHandler .sendMessageDelayed (msg , 5000 ); // 输入面板隐藏5秒后,开始后台同步
281
281
}
282
282
283
- for (EventListener listener : ( List < EventListener >) eventListeners ) {
283
+ for (EventListener listener : eventListeners ) {
284
284
if (listener != null ) listener .onWindowHidden ();
285
285
}
286
286
}
@@ -380,7 +380,7 @@ public void selectLiquidKeyboard(final int tabIndex) {
380
380
liquidKeyboard .calcPadding (mainInputView .getWidth ());
381
381
liquidKeyboard .select (tabIndex );
382
382
383
- tabView .updateCandidateWidth ();
383
+ tabView .updateTabWidth ();
384
384
if (inputRootBinding != null ) {
385
385
mTabRoot .setBackground (mCandidateRoot .getBackground ());
386
386
mTabRoot .move (tabView .getHightlightLeft (), tabView .getHightlightRight ());
@@ -408,6 +408,7 @@ private void hideCompositionView() {
408
408
if (isPopupWindowMovable .equals ("once" )) {
409
409
popupWindowPos = getImeConfig ().getWinPos ();
410
410
}
411
+
411
412
if (mPopupWindow != null && mPopupWindow .isShowing ()) {
412
413
mPopupWindow .dismiss ();
413
414
mPopupHandler .removeCallbacks (mPopupTimer );
@@ -420,13 +421,13 @@ private void showCompositionView() {
420
421
return ;
421
422
}
422
423
compositionRootBinding .compositionRoot .measure (
423
- LayoutParams .WRAP_CONTENT , LayoutParams .WRAP_CONTENT );
424
+ ViewGroup . LayoutParams .WRAP_CONTENT , ViewGroup . LayoutParams .WRAP_CONTENT );
424
425
mPopupWindow .setWidth (compositionRootBinding .compositionRoot .getMeasuredWidth ());
425
426
mPopupWindow .setHeight (compositionRootBinding .compositionRoot .getMeasuredHeight ());
426
427
mPopupHandler .post (mPopupTimer );
427
428
}
428
429
429
- private void loadBackground () {
430
+ public void loadBackground () {
430
431
final Config mConfig = getImeConfig ();
431
432
final int orientation = getResources ().getConfiguration ().orientation ;
432
433
@@ -533,7 +534,7 @@ public void onDestroy() {
533
534
getImeConfig ().destroy ();
534
535
System .exit (0 ); // 清理內存
535
536
}
536
- for (EventListener listener : ( List < EventListener >) eventListeners ) {
537
+ for (EventListener listener : eventListeners ) {
537
538
if (listener != null ) listener .onDestroy ();
538
539
}
539
540
eventListeners .clear ();
@@ -603,7 +604,7 @@ public void onUpdateSelection(
603
604
performEscape ();
604
605
}
605
606
// Update the caps-lock status for the current cursor position.
606
- updateCursorCapsToInputView ();
607
+ dispatchCapsStateToInputView ();
607
608
}
608
609
609
610
@ Override
@@ -648,15 +649,15 @@ public View onCreateInputView() {
648
649
return inputRootBinding .inputRoot ;
649
650
}
650
651
651
- void setShowComment (boolean show_comment ) {
652
+ public void setShowComment (boolean show_comment ) {
652
653
// if (mCandidateRoot != null) mCandidate.setShowComment(show_comment);
653
654
mComposition .setShowComment (show_comment );
654
655
}
655
656
656
657
@ Override
657
658
public void onStartInputView (EditorInfo attribute , boolean restarting ) {
658
659
super .onStartInputView (attribute , restarting );
659
- for (EventListener listener : ( List < EventListener >) eventListeners ) {
660
+ for (EventListener listener : eventListeners ) {
660
661
if (listener != null ) listener .onStartInputView (activeEditorInstance , restarting );
661
662
}
662
663
if (getPrefs ().getOther ().getShowStatusBarIcon ()) {
@@ -685,24 +686,18 @@ public void bindKeyboardToInputView() {
685
686
// Bind the selected keyboard to the input view.
686
687
Keyboard sk = keyboardSwitcher .getCurrentKeyboard ();
687
688
mainKeyboardView .setKeyboard (sk );
688
- updateCursorCapsToInputView ();
689
+ dispatchCapsStateToInputView ();
689
690
}
690
691
}
691
692
692
- // 句首自動大小寫
693
- private void updateCursorCapsToInputView () {
694
- if (autoCaps .contentEquals ("false" ) || TextUtils .isEmpty (autoCaps )) return ;
695
- if ((autoCaps .contentEquals ("true" ) || Rime .isAsciiMode ())
693
+ /**
694
+ * Dispatches cursor caps info to input view in order to implement auto caps lock at the start of
695
+ * a sentence.
696
+ */
697
+ private void dispatchCapsStateToInputView () {
698
+ if ((isAutoCaps || Rime .isAsciiMode ())
696
699
&& (mainKeyboardView != null && !mainKeyboardView .isCapsOn ())) {
697
- final InputConnection ic = getCurrentInputConnection ();
698
- if (ic != null ) {
699
- int caps = 0 ;
700
- final EditorInfo ei = getCurrentInputEditorInfo ();
701
- if ((ei != null ) && (ei .inputType != EditorInfo .TYPE_NULL )) {
702
- caps = ic .getCursorCapsMode (ei .inputType );
703
- }
704
- mainKeyboardView .setShifted (false , caps != 0 );
705
- }
700
+ mainKeyboardView .setShifted (false , activeEditorInstance .getCursorCapsMode () != 0 );
706
701
}
707
702
}
708
703
@@ -714,14 +709,6 @@ public void commitText(String text) {
714
709
activeEditorInstance .commitText (text , true );
715
710
}
716
711
717
- public void keyPressVibrate () {
718
- if (inputFeedbackManager != null ) inputFeedbackManager .keyPressVibrate ();
719
- }
720
-
721
- public void keyPressSound () {
722
- if (inputFeedbackManager != null ) inputFeedbackManager .keyPressSound (0 );
723
- }
724
-
725
712
/**
726
713
* 如果爲{@link KeyEvent#KEYCODE_BACK Back鍵},則隱藏鍵盤
727
714
*
@@ -739,7 +726,7 @@ private boolean handleBack(int keyCode) {
739
726
public boolean onRimeKey (int [] event ) {
740
727
updateRimeOption ();
741
728
final boolean ret = Rime .onKey (event );
742
- activeEditorInstance .commitTextFromRime ();
729
+ activeEditorInstance .commitRimeText ();
743
730
return ret ;
744
731
}
745
732
@@ -904,10 +891,10 @@ public void updateComposing() {
904
891
activeEditorInstance .updateComposingText ();
905
892
if (ic != null && !isWinFixed ()) isCursorUpdated = ic .requestCursorUpdates (1 );
906
893
if (mCandidateRoot != null ) {
907
- if (isPopupWindowShown ) {
894
+ if (isPopupWindowEnabled ) {
908
895
final int startNum = mComposition .setWindow (minPopupSize , minPopupCheckSize );
909
896
mCandidate .setText (startNum );
910
- if (isWinFixed () || !isCursorUpdated ) showCompositionView ();
897
+ if (!isCursorUpdated ) showCompositionView ();
911
898
} else {
912
899
mCandidate .setText (0 );
913
900
}
0 commit comments