@@ -744,7 +744,7 @@ private void cleanComposingText() {
744
744
private void handleShift (boolean isShifted ) {
745
745
final boolean statusChanged = mKeyboardView .isShifted () != isShifted ;
746
746
747
- if (mCurrentKeyboard . getAlphabeticCapKeyboard () != null ) {
747
+ if (mKeyboardView . getKeyboard () != getSymbolsKeyboard () ) {
748
748
if (isShifted || mIsCapsLock ) {
749
749
mKeyboardView .setKeyboard (mCurrentKeyboard .getAlphabeticCapKeyboard ());
750
750
} else {
@@ -875,11 +875,19 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) {
875
875
cleanComposingText ();
876
876
877
877
mCurrentKeyboard = aKeyboard ;
878
+
879
+ // For the case when switching from a symbol keyboard to a alphabetic keyboard.
880
+ float currentHeight = 0.0f ;
881
+ if (mKeyboardView .getKeyboard () == mCurrentKeyboard .getSymbolsKeyboard ()) {
882
+ currentHeight = mCurrentKeyboard .getSymbolKeyboardHeight ();
883
+ } else {
884
+ currentHeight = mCurrentKeyboard .getAlphabeticKeyboardHeight ();
885
+ }
878
886
final int width = getKeyboardWidth (mCurrentKeyboard .getAlphabeticKeyboardWidth ());
879
- final int height = getKeyboardHeight (mCurrentKeyboard . getAlphabeticKeyboardHeight () );
887
+ final int height = getKeyboardHeight (currentHeight );
880
888
if (width != mWidgetPlacement .width || height != mWidgetPlacement .height ) {
881
889
mWidgetPlacement .width = width ;
882
- mWidgetPlacement .height = height ;
890
+ mWidgetPlacement .height = getKeyboardHeight ( mCurrentKeyboard . getAlphabeticKeyboardHeight ()) ;
883
891
mWidgetPlacement .translationY = mCurrentKeyboard .getKeyboardTranslateYInWorld () -
884
892
WidgetPlacement .unitFromMeters (getContext (), R .dimen .window_world_y );
885
893
float defaultWorldWidth = mCurrentKeyboard .getKeyboardWorldWidth ();
@@ -964,11 +972,26 @@ private void handleDone() {
964
972
private void handleModeChange () {
965
973
Keyboard current = mKeyboardView .getKeyboard ();
966
974
Keyboard alphabetic = mCurrentKeyboard .getAlphabeticKeyboard ();
967
- mKeyboardView .setKeyboard (current == alphabetic ? getSymbolsKeyboard () : alphabetic );
975
+ Keyboard alphabetiCap = mCurrentKeyboard .getAlphabeticCapKeyboard ();
976
+ final boolean isAlphabeticMode = current == alphabetic || current == alphabetiCap ;
977
+
978
+ mKeyboardView .setKeyboard (isAlphabeticMode ? getSymbolsKeyboard () : alphabetic );
968
979
mKeyboardView .setLayoutParams (mKeyboardView .getLayoutParams ());
969
980
if (current == alphabetic ) {
970
981
mCurrentKeyboard .getAlphabeticKeyboard ().setSpaceKeyLabel ("" );
971
982
}
983
+
984
+ // Adjust the layout of the keyboard container because it might be changed by alphabetic keyboards
985
+ // which have various height.
986
+ if (isAlphabeticMode ) {
987
+ ViewGroup .LayoutParams params = mKeyboardContainer .getLayoutParams ();
988
+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getSymbolKeyboardHeight ());
989
+ mKeyboardContainer .setLayoutParams (params );
990
+ } else {
991
+ ViewGroup .LayoutParams params = mKeyboardContainer .getLayoutParams ();
992
+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardHeight ());
993
+ mKeyboardContainer .setLayoutParams (params );
994
+ }
972
995
}
973
996
974
997
private void handleKey (int primaryCode , int [] keyCodes ) {
@@ -1023,7 +1046,7 @@ private void handleText(String aText, boolean skipCase) {
1023
1046
postInputCommand (() -> connection .commitText (text , 1 ));
1024
1047
}
1025
1048
1026
- if (!mIsCapsLock ) {
1049
+ if (!mIsCapsLock && mCurrentKeyboard . getAlphabeticCapKeyboard () == null ) {
1027
1050
handleShift (false );
1028
1051
}
1029
1052
@@ -1118,6 +1141,10 @@ private void updateSpecialKeyLabels() {
1118
1141
String enterText = mCurrentKeyboard .getEnterKeyText (mEditorInfo .imeOptions , mComposingText );
1119
1142
String modeChangeText = mCurrentKeyboard .getModeChangeKeyText ();
1120
1143
boolean changed = mCurrentKeyboard .getAlphabeticKeyboard ().setEnterKeyLabel (enterText );
1144
+
1145
+ if (mCurrentKeyboard .getAlphabeticCapKeyboard () != null ) {
1146
+ mCurrentKeyboard .getAlphabeticCapKeyboard ().setEnterKeyLabel (enterText );
1147
+ }
1121
1148
CustomKeyboard symbolsKeyboard = getSymbolsKeyboard ();
1122
1149
changed |= symbolsKeyboard .setModeChangeKeyLabel (modeChangeText );
1123
1150
symbolsKeyboard .setEnterKeyLabel (enterText );
0 commit comments