private void setKeyboard(final Keyboard keyboard) {
   // Make {@link MainKeyboardView} visible and hide {@link EmojiPalettesView}.
   setMainKeyboardFrame();
   final MainKeyboardView keyboardView = mKeyboardView;
   final Keyboard oldKeyboard = keyboardView.getKeyboard();
   keyboardView.setKeyboard(keyboard);
   mCurrentInputView.setKeyboardGeometry(keyboard.mTopPadding);
   keyboardView.setKeyPreviewPopupEnabled(
       Settings.readKeyPreviewPopupEnabled(mPrefs, mResources),
       Settings.readKeyPreviewPopupDismissDelay(mPrefs, mResources));
   keyboardView.updateAutoCorrectionState(mIsAutoCorrectionActive);
   keyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
   final boolean subtypeChanged =
       (oldKeyboard == null) || !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
   final boolean needsToDisplayLanguage =
       mSubtypeSwitcher.needsToDisplayLanguage(keyboard.mId.mLocale);
   keyboardView.startDisplayLanguageOnSpacebar(
       subtypeChanged,
       needsToDisplayLanguage,
       RichInputMethodManager.getInstance().hasMultipleEnabledIMEsOrSubtypes(true));
 }
 public void onNetworkStateChanged() {
   if (mKeyboardView != null) {
     mKeyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
   }
 }