@@ -744,7 +744,7 @@ private void cleanComposingText() {
744744 private void handleShift (boolean isShifted ) {
745745 final boolean statusChanged = mKeyboardView .isShifted () != isShifted ;
746746
747- if (mCurrentKeyboard . getAlphabeticCapKeyboard () != null ) {
747+ if (mKeyboardView . getKeyboard () != getSymbolsKeyboard () ) {
748748 if (isShifted || mIsCapsLock ) {
749749 mKeyboardView .setKeyboard (mCurrentKeyboard .getAlphabeticCapKeyboard ());
750750 } else {
@@ -875,11 +875,19 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) {
875875 cleanComposingText ();
876876
877877 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+ }
878886 final int width = getKeyboardWidth (mCurrentKeyboard .getAlphabeticKeyboardWidth ());
879- final int height = getKeyboardHeight (mCurrentKeyboard . getAlphabeticKeyboardHeight () );
887+ final int height = getKeyboardHeight (currentHeight );
880888 if (width != mWidgetPlacement .width || height != mWidgetPlacement .height ) {
881889 mWidgetPlacement .width = width ;
882- mWidgetPlacement .height = height ;
890+ mWidgetPlacement .height = getKeyboardHeight ( mCurrentKeyboard . getAlphabeticKeyboardHeight ()) ;
883891 mWidgetPlacement .translationY = mCurrentKeyboard .getKeyboardTranslateYInWorld () -
884892 WidgetPlacement .unitFromMeters (getContext (), R .dimen .window_world_y );
885893 float defaultWorldWidth = mCurrentKeyboard .getKeyboardWorldWidth ();
@@ -964,11 +972,26 @@ private void handleDone() {
964972 private void handleModeChange () {
965973 Keyboard current = mKeyboardView .getKeyboard ();
966974 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 );
968979 mKeyboardView .setLayoutParams (mKeyboardView .getLayoutParams ());
969980 if (current == alphabetic ) {
970981 mCurrentKeyboard .getAlphabeticKeyboard ().setSpaceKeyLabel ("" );
971982 }
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+ }
972995 }
973996
974997 private void handleKey (int primaryCode , int [] keyCodes ) {
@@ -1023,7 +1046,7 @@ private void handleText(String aText, boolean skipCase) {
10231046 postInputCommand (() -> connection .commitText (text , 1 ));
10241047 }
10251048
1026- if (!mIsCapsLock ) {
1049+ if (!mIsCapsLock && mCurrentKeyboard . getAlphabeticCapKeyboard () == null ) {
10271050 handleShift (false );
10281051 }
10291052
@@ -1118,6 +1141,10 @@ private void updateSpecialKeyLabels() {
11181141 String enterText = mCurrentKeyboard .getEnterKeyText (mEditorInfo .imeOptions , mComposingText );
11191142 String modeChangeText = mCurrentKeyboard .getModeChangeKeyText ();
11201143 boolean changed = mCurrentKeyboard .getAlphabeticKeyboard ().setEnterKeyLabel (enterText );
1144+
1145+ if (mCurrentKeyboard .getAlphabeticCapKeyboard () != null ) {
1146+ mCurrentKeyboard .getAlphabeticCapKeyboard ().setEnterKeyLabel (enterText );
1147+ }
11211148 CustomKeyboard symbolsKeyboard = getSymbolsKeyboard ();
11221149 changed |= symbolsKeyboard .setModeChangeKeyLabel (modeChangeText );
11231150 symbolsKeyboard .setEnterKeyLabel (enterText );
0 commit comments