Search in sources :

Example 1 with CardHtml

use of com.ichi2.anki.cardviewer.CardHtml in project Anki-Android by ankidroid.

the class AbstractFlashcardViewer method displayCardQuestion.

protected void displayCardQuestion(boolean reload) {
    Timber.d("displayCardQuestion()");
    sDisplayAnswer = false;
    mBackButtonPressedToReturn = false;
    setInterface();
    mTypeAnswer.setInput("");
    mTypeAnswer.updateInfo(mCurrentCard, getResources());
    if (!mCurrentCard.isEmpty() && mTypeAnswer.validForEditText()) {
        // Show text entry based on if the user wants to write the answer
        mAnswerField.setVisibility(View.VISIBLE);
        LanguageHintService.applyLanguageHint(mAnswerField, mTypeAnswer.getLanguageHint());
    } else {
        mAnswerField.setVisibility(View.GONE);
    }
    CardHtml content = mHtmlGenerator.generateHtml(mCurrentCard, reload, Side.FRONT);
    updateCard(content);
    hideEaseButtons();
    mAutomaticAnswer.onDisplayQuestion();
    // If Card-based TTS is enabled, we "automatic display" after the TTS has finished as we don't know the duration
    if (!mTTS.isEnabled()) {
        mAutomaticAnswer.scheduleAutomaticDisplayAnswer(mUseTimerDynamicMS);
    }
    Timber.i("AbstractFlashcardViewer:: Question successfully shown for card id %d", mCurrentCard.getId());
}
Also used : CardHtml(com.ichi2.anki.cardviewer.CardHtml)

Example 2 with CardHtml

use of com.ichi2.anki.cardviewer.CardHtml in project Anki-Android by ankidroid.

the class AbstractFlashcardViewer method displayCardAnswer.

protected void displayCardAnswer() {
    // #7294 Required in case the animation end action does not fire:
    actualHideEaseButtons();
    Timber.d("displayCardAnswer()");
    mMissingImageHandler.onCardSideChange();
    mBackButtonPressedToReturn = false;
    // prevent answering (by e.g. gestures) before card is loaded
    if (mCurrentCard == null) {
        return;
    }
    // TODO needs testing: changing a card's model without flipping it back to the front
    // (such as editing a card, then editing the card template)
    mTypeAnswer.updateInfo(mCurrentCard, getResources());
    // but sometimes failed to do so (e.g. if an OnKeyListener is attached).
    if (mTypeAnswer.validForEditText()) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(mAnswerField.getWindowToken(), 0);
    }
    sDisplayAnswer = true;
    mSoundPlayer.stopSounds();
    mAnswerField.setVisibility(View.GONE);
    // Clean up the user answer and the correct answer
    if (!mTypeAnswer.useInputTag()) {
        mTypeAnswer.setInput(mAnswerField.getText().toString());
    }
    mIsSelecting = false;
    CardHtml answerContent = mHtmlGenerator.generateHtml(mCurrentCard, false, Side.BACK);
    updateCard(answerContent);
    displayAnswerBottomBar();
    mAutomaticAnswer.onDisplayAnswer();
    // If Card-based TTS is enabled, we "automatic display" after the TTS has finished as we don't know the duration
    if (!mTTS.isEnabled()) {
        mAutomaticAnswer.scheduleAutomaticDisplayQuestion(mUseTimerDynamicMS);
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) CardHtml(com.ichi2.anki.cardviewer.CardHtml)

Aggregations

CardHtml (com.ichi2.anki.cardviewer.CardHtml)2 InputMethodManager (android.view.inputmethod.InputMethodManager)1