public View onCreateInputView(final boolean isHardwareAcceleratedDrawingEnabled) {
    if (mKeyboardView != null) {
      mKeyboardView.closing();
    }

    setContextThemeWrapper(mLatinIME, mKeyboardTheme);
    mCurrentInputView =
        (InputView) LayoutInflater.from(mThemeContext).inflate(R.layout.input_view, null);
    mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame);
    mEmojiPalettesView =
        (EmojiPalettesView) mCurrentInputView.findViewById(R.id.emoji_keyboard_view);

    mKeyboardView = (MainKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view);
    mKeyboardView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
    mKeyboardView.setKeyboardActionListener(mLatinIME);
    mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
    mEmojiPalettesView.setKeyboardActionListener(mLatinIME);

    // This always needs to be set since the accessibility state can
    // potentially change without the input view being re-created.
    AccessibleKeyboardViewProxy.getInstance().setView(mKeyboardView);

    return mCurrentInputView;
  }
 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));
 }