/**
   * Reset components depending inputFrameHeight or imeWindowHeight. This should be called when
   * inputFrameHeight and/or imeWindowHeight are updated.
   */
  void resetHeightDependingComponents() {
    // Create In/Out animation which dropshadows share between CandidateView and SymbolInputView.
    {
      CandidateView candidateView = getCandidateView();
      int windowHeight = imeWindowHeight;
      int inputFrameHeight = getInputFrameHeight();
      int candidateViewHeight = windowHeight - inputFrameHeight;
      long duration = getResources().getInteger(R.integer.candidate_frame_transition_duration);
      float fromAlpha = 0.0f;
      float toAlpha = 1.0f;

      candidateViewInAnimation =
          createCandidateViewTransitionAnimation(
              candidateViewHeight, 0, fromAlpha, toAlpha, duration);
      candidateView.setInAnimation(candidateViewInAnimation);
      dropShadowCandidateViewInAnimation =
          createAlphaAnimation(1.0f - fromAlpha, 1.0f - toAlpha, duration);

      candidateViewOutAnimation =
          createCandidateViewTransitionAnimation(
              0, candidateViewHeight, toAlpha, fromAlpha, duration);
      candidateView.setOutAnimation(candidateViewOutAnimation);
      dropShadowCandidateViewOutAnimation =
          createAlphaAnimation(1.0f - toAlpha, 1.0f - fromAlpha, duration);
    }

    SymbolInputView symbolInputView = getSymbolInputView();
    {
      long duration = getResources().getInteger(R.integer.symbol_input_transition_duration_in);
      float fromAlpha = 0.3f;
      float toAlpha = 1.0f;

      symbolInputViewInAnimation = createAlphaAnimation(fromAlpha, toAlpha, duration);
      symbolInputView.setInAnimation(symbolInputViewInAnimation);
      dropShadowSymbolInputViewInAnimation =
          createAlphaAnimation(1.0f - fromAlpha, 1.0f - toAlpha, duration);

      symbolInputViewOutAnimation = createAlphaAnimation(toAlpha, fromAlpha, duration);
      symbolInputView.setOutAnimation(symbolInputViewOutAnimation);
      dropShadowSymbolInputViewOutAnimation =
          createAlphaAnimation(1.0f - toAlpha, 1.0f - fromAlpha, duration);
    }

    // Reset drop shadow height.
    int shortHeight = getInputFrameHeight() + dimensionPixelSize.translucentBorderHeight;
    int longHeight = imeWindowHeight;
    leftFrameStubProxy.setDropShadowHeight(shortHeight, longHeight);
    rightFrameStubProxy.setDropShadowHeight(shortHeight, longHeight);

    // Reset side adjust buttons height.
    leftFrameStubProxy.resetAdjustButtonBottomMargin(getInputFrameHeight());
    rightFrameStubProxy.resetAdjustButtonBottomMargin(getInputFrameHeight());
  }
 @Override
 public void setSuggestions(
     @NotNull List<String> suggestions, boolean completions, boolean typedWordValid) {
   if (candidateView != null) {
     candidateView.setSuggestions(suggestions, completions, typedWordValid);
   }
 }
  public void setCommand(Command outCommand) {
    checkInflated();

    CandidateView candidateView = getCandidateView();
    if (outCommand.getOutput().getAllCandidateWords().getCandidatesCount() > 0) {
      // Call CandidateView#update only if there are some candidates in the output.
      // In such case the candidate view will clear its canvas.
      candidateView.update(outCommand);
      startCandidateViewInAnimation();

    } else {
      // We don't call update method here, because it will clear the view's contents during the
      // animation.
      // TODO(hidehiko): Clear the candidates when the animation is finished.
      startCandidateViewOutAnimation();
    }
  }
  private void showPage(int page) {
    if (isPageEmpty(page)) {
      candidateView.setCandidates("");
      enableArrow(leftArrow, false);
      enableArrow(rightArrow, false);
    } else {
      final int start = page * CandidateView.MAX_CANDIDATE_COUNT;
      final int end = start + Math.min(words.length() - start, CandidateView.MAX_CANDIDATE_COUNT);

      candidateView.setCandidates(words.substring(start, end));
      if (highlightDefault) {
        candidateView.highlightDefault();
      }
      enableArrow(leftArrow, (page > 0) ? true : false);
      enableArrow(rightArrow, (page < pageCount - 1) ? true : false);
    }
    currentPage = page;
  }
  public void reset() {
    checkInflated();

    // Reset keyboard frame and view.
    resetKeyboardFrameVisibility();
    resetKeyboardViewState();

    // Reset candidate view.
    CandidateView candidateView = getCandidateView();
    candidateView.clearAnimation();
    candidateView.setVisibility(View.GONE);
    candidateView.reset();

    // Reset symbol input view visibility. Set Visibility directly (without animation).
    SymbolInputView symbolInputView = getSymbolInputView();
    symbolInputView.clearAnimation();
    symbolInputView.setVisibility(View.GONE);

    resetFullscreenMode();
    setLayoutAdjustmentAndNarrowMode(layoutAdjustment, narrowMode);
    collapseDropShadowAndBackground();
    updateBackgroundColor();
  }
 @Override
 public View onCreateCandidatesView() {
   candidateView = new CandidateView(getInputMethodService());
   candidateView.setKeyboardController(getKeyboardController());
   return candidateView;
 }
 @Override
 public void clearCandidateView() {
   if (candidateView != null) {
     candidateView.clear();
   }
 }
 public boolean pickHighlighted() {
   return candidateView.pickHighlighted();
 }
 public void setCandidateViewListener(CandidateView.CandidateViewListener listener) {
   candidateView.setCandidateViewListener(listener);
 }