@@ -280,9 +280,7 @@ public void releaseWidget() {
280280 protected void initializeWidgetPlacement (WidgetPlacement aPlacement ) {
281281 Context context = getContext ();
282282 aPlacement .width = getKeyboardWidth (WidgetPlacement .dpDimension (context , R .dimen .keyboard_alphabetic_width ));
283- aPlacement .height = WidgetPlacement .dpDimension (context , R .dimen .keyboard_height );
284- aPlacement .height += WidgetPlacement .dpDimension (context , R .dimen .autocompletion_widget_line_height );
285- aPlacement .height += WidgetPlacement .dpDimension (context , R .dimen .keyboard_layout_padding );
283+ aPlacement .height = getKeyboardHeight (WidgetPlacement .dpDimension (context , R .dimen .keyboard_height ));
286284 aPlacement .anchorX = 0.5f ;
287285 aPlacement .anchorY = 0.0f ;
288286 aPlacement .parentAnchorY = 0.0f ;
@@ -331,6 +329,13 @@ private int getKeyboardWidth(float aAlphabeticWidth) {
331329 return (int ) width ;
332330 }
333331
332+ private int getKeyboardHeight (float aAlphabeticHeight ) {
333+ float height = aAlphabeticHeight ;
334+ height += WidgetPlacement .dpDimension (getContext (), R .dimen .autocompletion_widget_line_height );
335+ height += WidgetPlacement .dpDimension (getContext (), R .dimen .keyboard_layout_padding );
336+ return (int ) height ;
337+ }
338+
334339 private void resetKeyboardLayout () {
335340 if ((mEditorInfo .inputType & EditorInfo .TYPE_CLASS_NUMBER ) == EditorInfo .TYPE_CLASS_NUMBER ) {
336341 mKeyboardView .setKeyboard (getSymbolsKeyboard ());
@@ -723,19 +728,25 @@ private void handleLanguageChange(KeyboardInterface aKeyboard) {
723728
724729 mCurrentKeyboard = aKeyboard ;
725730 final int width = getKeyboardWidth (mCurrentKeyboard .getAlphabeticKeyboardWidth ());
726- if (width != mWidgetPlacement .width ) {
731+ final int height = getKeyboardHeight (mCurrentKeyboard .getAlphabeticKeyboardHeight ());
732+ if (width != mWidgetPlacement .width || height != mWidgetPlacement .height ) {
727733 mWidgetPlacement .width = width ;
734+ mWidgetPlacement .height = height ;
728735 float defaultWorldWidth = WidgetPlacement .floatDimension (getContext (), R .dimen .keyboard_world_width );
729736 int defaultKeyboardWidth = getKeyboardWidth (mKeyboards .get (0 ).getAlphabeticKeyboardWidth ());
730737 mWidgetPlacement .worldWidth = defaultWorldWidth * ((float ) width / (float ) defaultKeyboardWidth );
731738 mWidgetManager .updateWidget (this );
732739 ViewGroup .LayoutParams params = mKeyboardContainer .getLayoutParams ();
733740 params .width = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardWidth ());
741+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardHeight ());
734742 mKeyboardContainer .setLayoutParams (params );
735743 }
736744
737745 RelativeLayout .LayoutParams params = (RelativeLayout .LayoutParams )mKeyboardLayout .getLayoutParams ();
738746 params .topMargin = mCurrentKeyboard .supportsAutoCompletion () ? WidgetPlacement .pixelDimension (getContext (), R .dimen .keyboard_margin_top_without_autocompletion ) : 0 ;
747+ if (height != params .height ) {
748+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardHeight ());
749+ }
739750 mKeyboardLayout .setLayoutParams (params );
740751
741752 SettingsStore .getInstance (getContext ()).setSelectedKeyboard (aKeyboard .getLocale ());
@@ -810,10 +821,36 @@ private void handleModeChange() {
810821 Keyboard current = mKeyboardView .getKeyboard ();
811822 Keyboard alphabetic = mCurrentKeyboard .getAlphabeticKeyboard ();
812823 mKeyboardView .setKeyboard (current == alphabetic ? getSymbolsKeyboard () : alphabetic );
813- mKeyboardView . setLayoutParams ( mKeyboardView . getLayoutParams ());
824+
814825 if (current == alphabetic ) {
826+ final int width = getKeyboardWidth (mKeyboards .get (0 ).getAlphabeticKeyboardWidth ());
827+ mWidgetPlacement .width = width ;
828+
829+ float defaultWorldWidth = WidgetPlacement .floatDimension (getContext (), R .dimen .keyboard_world_width );
830+ int defaultKeyboardWidth = getKeyboardWidth (mKeyboards .get (0 ).getAlphabeticKeyboardWidth ());
831+ mWidgetPlacement .worldWidth = defaultWorldWidth * ((float ) width / (float ) defaultKeyboardWidth );
832+ mWidgetManager .updateWidget (this );
833+ ViewGroup .LayoutParams params = mKeyboardContainer .getLayoutParams ();
834+ params .width = WidgetPlacement .convertDpToPixel (getContext (), mKeyboards .get (0 ).getAlphabeticKeyboardWidth ());
835+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mKeyboards .get (0 ).getAlphabeticKeyboardHeight ());
836+ mKeyboardContainer .setLayoutParams (params );
837+
815838 mCurrentKeyboard .getAlphabeticKeyboard ().setSpaceKeyLabel ("" );
839+ } else {
840+ final int width = getKeyboardWidth (mCurrentKeyboard .getAlphabeticKeyboardWidth ());
841+ mWidgetPlacement .width = width ;
842+
843+ float defaultWorldWidth = WidgetPlacement .floatDimension (getContext (), R .dimen .keyboard_world_width );
844+ int defaultKeyboardWidth = getKeyboardWidth (mKeyboards .get (0 ).getAlphabeticKeyboardWidth ());
845+ mWidgetPlacement .worldWidth = defaultWorldWidth * ((float ) width / (float ) defaultKeyboardWidth );
846+ mWidgetManager .updateWidget (this );
847+ ViewGroup .LayoutParams params = mKeyboardContainer .getLayoutParams ();
848+ params .width = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardWidth ());
849+ params .height = WidgetPlacement .convertDpToPixel (getContext (), mCurrentKeyboard .getAlphabeticKeyboardHeight ());
850+ mKeyboardContainer .setLayoutParams (params );
816851 }
852+
853+ mKeyboardView .setLayoutParams (mKeyboardView .getLayoutParams ());
817854 }
818855
819856 private void handleKey (int primaryCode , int [] keyCodes ) {
0 commit comments