Example usage for android.text SpannableString setSpan

List of usage examples for android.text SpannableString setSpan

Introduction

In this page you can find the example usage for android.text SpannableString setSpan.

Prototype

public void setSpan(Object what, int start, int end, int flags) 

Source Link

Usage

From source file:com.ichi2.anki2.Reviewer.java

private void displayCardQuestion() {
    // show timer, if activated in the deck's preferences
    initTimer();/*from   ww  w . j av  a  2  s .co  m*/

    sDisplayAnswer = false;

    if (mButtonHeight == 0 && mRelativeButtonSize != 100) {
        mButtonHeight = mFlipCard.getHeight() * mRelativeButtonSize / 100;
        mFlipCard.setHeight(mButtonHeight);
        mEase1.setHeight(mButtonHeight);
        mEase2.setHeight(mButtonHeight);
        mEase3.setHeight(mButtonHeight);
        mEase4.setHeight(mButtonHeight);
    }

    setInterface();

    String question = mCurrentCard.getQuestion(mCurrentSimpleInterface);
    question = typeAnsQuestionFilter(question);

    if (mPrefFixArabic) {
        question = ArabicUtilities.reshapeSentence(question, true);
    }

    Log.i(AnkiDroidApp.TAG, "question: '" + question + "'");

    String displayString = "";

    if (mCurrentSimpleInterface) {
        mCardContent = convertToSimple(question);
        if (mCardContent.length() == 0) {
            SpannableString hint = new SpannableString(
                    getResources().getString(R.string.simple_interface_hint, R.string.card_details_question));
            hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, mCardContent.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mCardContent = hint;
        }
    } else {
        // If the user wants to write the answer
        if (typeAnswer()) {
            mAnswerField.setVisibility(View.VISIBLE);

            // Show soft keyboard
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.showSoftInput(mAnswerField, InputMethodManager.SHOW_FORCED);
        }

        displayString = enrichWithQADiv(question, false);

        if (mSpeakText) {
            // ReadText.setLanguageInformation(Model.getModel(DeckManager.getMainDeck(),
            // mCurrentCard.getCardModelId(), false).getId(), mCurrentCard.getCardModelId());
        }

        if (mPrefRecord) {
            Recorder.reset();
            // check for auto record
            try {
                if (mSched.getCol().getDecks().confForDid(mCurrentCard.getDid()).getBoolean("autoRecord")) {
                    Recorder.startRecording();
                }
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }

    }

    updateCard(displayString);
    hideEaseButtons();

    // If the user want to show answer automatically
    if (mPrefUseTimer) {
        mTimeoutHandler.removeCallbacks(mShowAnswerTask);
        mTimeoutHandler.postDelayed(mShowAnswerTask, mWaitAnswerSecond * 1000);
    }
}

From source file:com.ichi2.anki2.Reviewer.java

private void displayCardAnswer() {
    Log.i(AnkiDroidApp.TAG, "displayCardAnswer");

    // prevent answering (by e.g. gestures) before card is loaded
    if (mCurrentCard == null) {
        return;/*from   w  w  w.  ja v  a  2  s. com*/
    }

    sDisplayAnswer = true;
    setFlipCardAnimation();

    String answer = mCurrentCard.getAnswer(mCurrentSimpleInterface);
    answer = typeAnsAnswerFilter(answer);

    String displayString = "";

    if (mCurrentSimpleInterface) {
        mCardContent = convertToSimple(answer);
        if (mCardContent.length() == 0) {
            SpannableString hint = new SpannableString(
                    getResources().getString(R.string.simple_interface_hint, R.string.card_details_answer));
            hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, mCardContent.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mCardContent = hint;
        }
    } else {
        Sound.stopSounds();
        Recorder.stopRecording();

        if (mPrefFixArabic) {
            // reshape
            answer = ArabicUtilities.reshapeSentence(answer, true);
        }

        // If the user wrote an answer
        if (typeAnswer()) {
            mAnswerField.setVisibility(View.GONE);
            if (mCurrentCard != null) {
                if (mPrefFixArabic) {
                    // reshape
                    mTypeCorrect = ArabicUtilities.reshapeSentence(mTypeCorrect, true);
                }
                // Obtain the user answer and the correct answer
                String userAnswer = mAnswerField.getText().toString();
                Matcher matcher = sSpanPattern.matcher(Utils.stripHTMLMedia(mTypeCorrect));
                String correctAnswer = matcher.replaceAll("");
                matcher = sBrPattern.matcher(correctAnswer);
                correctAnswer = matcher.replaceAll("\n");
                matcher = Sound.sSoundPattern.matcher(correctAnswer);
                correctAnswer = matcher.replaceAll("");
                Log.i(AnkiDroidApp.TAG, "correct answer = " + correctAnswer);

                // Obtain the diff and send it to updateCard
                DiffEngine diff = new DiffEngine();

                StringBuffer span = new StringBuffer();
                span.append("<span style=\"font-family: '").append(mTypeFont).append("'; font-size: ")
                        .append(mTypeSize).append("px\">");
                span.append(diff.diff_prettyHtml(diff.diff_main(userAnswer, correctAnswer), mNightMode));
                span.append("</span>");
                span.append("<br/>").append(answer);
                displayString = enrichWithQADiv(span.toString(), true);
            }

            // Hide soft keyboard
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(mAnswerField.getWindowToken(), 0);
        } else {
            displayString = enrichWithQADiv(answer, true);
        }
    }

    mIsSelecting = false;
    updateCard(displayString);
    showEaseButtons();

    // If the user want to show next question automatically
    if (mPrefUseTimer) {
        mTimeoutHandler.removeCallbacks(mShowQuestionTask);
        mTimeoutHandler.postDelayed(mShowQuestionTask, mWaitQuestionSecond * 1000);
    }
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private void displayCardQuestion() {
    // show timer, if activated in the deck's preferences
    initTimer();/* ww w . ja va2s .  c om*/

    sDisplayAnswer = false;

    if (mButtonHeight == 0 && mRelativeButtonSize != 100) {
        mButtonHeight = mFlipCard.getHeight() * mRelativeButtonSize / 100;
        mFlipCard.setHeight(mButtonHeight);
        mEase1.setHeight(mButtonHeight);
        mEase2.setHeight(mButtonHeight);
        mEase3.setHeight(mButtonHeight);
        mEase4.setHeight(mButtonHeight);
    }

    setInterface();

    String question = mCurrentCard.getQuestion(mCurrentSimpleInterface);
    question = typeAnsQuestionFilter(question);

    if (mPrefFixArabic) {
        question = ArabicUtilities.reshapeSentence(question, true);
    }

    // Log.i(AnkiDroidApp.TAG, "question: '" + question + "'");

    String displayString = "";

    if (mCurrentSimpleInterface) {
        mCardContent = convertToSimple(question);
        if (mCardContent.length() == 0) {
            SpannableString hint = new SpannableString(
                    getResources().getString(R.string.simple_interface_hint, R.string.card_details_question));
            hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, mCardContent.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mCardContent = hint;
        }
    } else {
        // If the user wants to write the answer
        if (typeAnswer()) {
            mAnswerField.setVisibility(View.VISIBLE);

            // Show soft keyboard
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.showSoftInput(mAnswerField, InputMethodManager.SHOW_FORCED);
        }

        displayString = enrichWithQADiv(question, false);

        if (mSpeakText) {
            // ReadText.setLanguageInformation(Model.getModel(DeckManager.getMainDeck(),
            // mCurrentCard.getCardModelId(), false).getId(), mCurrentCard.getCardModelId());
        }
    }

    updateCard(displayString);
    hideEaseButtons();

    // If the user want to show answer automatically
    if (mPrefUseTimer) {
        mTimeoutHandler.removeCallbacks(mShowAnswerTask);
        mTimeoutHandler.postDelayed(mShowAnswerTask, mWaitAnswerSecond * 1000);
    }
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private void displayCardAnswer() {
    // Log.i(AnkiDroidApp.TAG, "displayCardAnswer");

    // prevent answering (by e.g. gestures) before card is loaded
    if (mCurrentCard == null) {
        return;//from  w  w  w .  j  av a 2  s  .com
    }

    sDisplayAnswer = true;
    setFlipCardAnimation();

    String answer = mCurrentCard.getAnswer(mCurrentSimpleInterface);
    answer = typeAnsAnswerFilter(answer);

    String displayString = "";

    if (mCurrentSimpleInterface) {
        mCardContent = convertToSimple(answer);
        if (mCardContent.length() == 0) {
            SpannableString hint = new SpannableString(
                    getResources().getString(R.string.simple_interface_hint, R.string.card_details_answer));
            hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, mCardContent.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mCardContent = hint;
        }
    } else {
        Sound.stopSounds();

        if (mPrefFixArabic) {
            // reshape
            answer = ArabicUtilities.reshapeSentence(answer, true);
        }

        // If the user wrote an answer
        if (typeAnswer()) {
            mAnswerField.setVisibility(View.GONE);
            if (mCurrentCard != null) {
                if (mPrefFixArabic) {
                    // reshape
                    mTypeCorrect = ArabicUtilities.reshapeSentence(mTypeCorrect, true);
                }
                // Obtain the user answer and the correct answer
                String userAnswer = mAnswerField.getText().toString();
                Matcher matcher = sSpanPattern.matcher(Utils.stripHTMLMedia(mTypeCorrect));
                String correctAnswer = matcher.replaceAll("");
                matcher = sBrPattern.matcher(correctAnswer);
                correctAnswer = matcher.replaceAll("\n");
                matcher = Sound.sSoundPattern.matcher(correctAnswer);
                correctAnswer = matcher.replaceAll("");
                // Log.i(AnkiDroidApp.TAG, "correct answer = " + correctAnswer);

                // Obtain the diff and send it to updateCard
                DiffEngine diff = new DiffEngine();

                StringBuffer span = new StringBuffer();
                span.append("<span style=\"font-family: '").append(mTypeFont).append("'; font-size: ")
                        .append(mTypeSize).append("px\">");
                span.append(diff.diff_prettyHtml(diff.diff_main(userAnswer, correctAnswer), mNightMode));
                span.append("</span>");
                span.append("<br/>").append(answer);
                displayString = enrichWithQADiv(span.toString(), true);
            }

            // Hide soft keyboard
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(mAnswerField.getWindowToken(), 0);
        } else {
            displayString = enrichWithQADiv(answer, true);
        }
    }

    mIsSelecting = false;
    updateCard(displayString);
    showEaseButtons();

    // If the user want to show next question automatically
    if (mPrefUseTimer) {
        mTimeoutHandler.removeCallbacks(mShowQuestionTask);
        mTimeoutHandler.postDelayed(mShowQuestionTask, mWaitQuestionSecond * 1000);
    }
}

From source file:com.ichi2.anki2.Reviewer.java

private void updateScreenCounts() {
    if (mCurrentCard == null) {
        return;/*from   ww w.  j  a  v  a 2s .  c  o  m*/
    }

    try {
        String[] title = mSched.getCol().getDecks().get(mCurrentCard.getDid()).getString("name").split("::");
        AnkiDroidApp.getCompat().setTitle(this, title[title.length - 1], mInvertedColors);
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }

    int[] counts = mSched.counts(mCurrentCard);

    int eta = mSched.eta(counts, false);
    AnkiDroidApp.getCompat().setSubtitle(this,
            getResources().getQuantityString(R.plurals.reviewer_window_title, eta, eta), mInvertedColors);

    SpannableString newCount = new SpannableString(String.valueOf(counts[0]));
    SpannableString lrnCount = new SpannableString(String.valueOf(counts[1]));
    SpannableString revCount = new SpannableString(String.valueOf(counts[2]));
    if (mPrefHideDueCount) {
        revCount = new SpannableString("???");
    }

    switch (mCurrentCard.getQueue()) {
    case Card.TYPE_NEW:
        newCount.setSpan(new UnderlineSpan(), 0, newCount.length(), 0);
        break;
    case Card.TYPE_LRN:
        lrnCount.setSpan(new UnderlineSpan(), 0, lrnCount.length(), 0);
        break;
    case Card.TYPE_REV:
        revCount.setSpan(new UnderlineSpan(), 0, revCount.length(), 0);
        break;
    }

    mTextBarRed.setText(newCount);
    mTextBarBlack.setText(lrnCount);
    mTextBarBlue.setText(revCount);
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private void updateScreenCounts() {
    if (mCurrentCard == null) {
        return;//from   w w w.j ava2  s  .  co m
    }

    try {
        String[] title = mSched.getCol().getDecks().get(mCurrentCard.getDid()).getString("name").split("::");
        AnkiDroidApp.getCompat().setTitle(this, title[title.length - 1], mInvertedColors);
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }

    int[] counts = mSched.counts(mCurrentCard);

    int eta = mSched.eta(counts, false);
    //        AnkiDroidApp.getCompat().setSubtitle(this, getResources().getQuantityString(R.plurals.reviewer_window_title, eta, eta), mInvertedColors);

    SpannableString newCount = new SpannableString(String.valueOf(counts[0]));
    SpannableString lrnCount = new SpannableString(String.valueOf(counts[1]));
    SpannableString revCount = new SpannableString(String.valueOf(counts[2]));
    if (mPrefHideDueCount) {
        revCount = new SpannableString("???");
    }

    switch (mCurrentCard.getQueue()) {
    case Card.TYPE_NEW:
        newCount.setSpan(new UnderlineSpan(), 0, newCount.length(), 0);
        break;
    case Card.TYPE_LRN:
        lrnCount.setSpan(new UnderlineSpan(), 0, lrnCount.length(), 0);
        break;
    case Card.TYPE_REV:
        revCount.setSpan(new UnderlineSpan(), 0, revCount.length(), 0);
        break;
    }

    //   mTextBarRed.setText(newCount);
    //   mTextBarBlack.setText(lrnCount);
    //   mTextBarBlue.setText(revCount);

    mTextBarRed.setText(getString(R.string.subtitle_new) + " " + newCount);
    mTextBarBlack.setText(getString(R.string.subtitle_learning) + " " + lrnCount);
    mTextBarBlue.setText(getString(R.string.subtitle_review) + " " + revCount);
}

From source file:im.vector.activity.VectorRoomActivity.java

/**
 * Refresh the notifications area./*  w w  w.j  av a  2  s. c  o  m*/
 */
private void refreshNotificationsArea() {
    // sanity check
    // might happen when the application is logged out
    if ((null == mSession.getDataHandler()) || (null == mRoom)) {
        return;
    }

    int iconId = -1;
    int textColor = -1;
    boolean isAreaVisible = false;
    SpannableString text = new SpannableString("");
    boolean hasUnsentEvent = false;

    // remove any listeners
    mNotificationTextView.setOnClickListener(null);
    mNotificationIconImageView.setOnClickListener(null);

    //  no network
    if (!Matrix.getInstance(this).isConnected()) {
        isAreaVisible = true;
        iconId = R.drawable.error;
        textColor = R.color.vector_fuchsia_color;
        text = new SpannableString(getResources().getString(R.string.room_offline_notification));
    } else {
        Collection<Event> undeliveredEvents = mSession.getDataHandler().getStore()
                .getUndeliverableEvents(mRoom.getRoomId());
        if ((null != undeliveredEvents) && (undeliveredEvents.size() > 0)) {
            hasUnsentEvent = true;
            isAreaVisible = true;
            iconId = R.drawable.error;

            String part1 = getResources().getString(R.string.room_unsent_messages_notification);
            String part2 = getResources().getString(R.string.room_prompt_resent);

            text = new SpannableString(part1 + " " + part2);
            text.setSpan(new UnderlineSpan(), part1.length() + 1, part1.length() + part2.length() + 1, 0);
            textColor = R.color.vector_fuchsia_color;

            mNotificationTextView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mVectorMessageListFragment.resendUnsentMessages();
                    refreshNotificationsArea();
                }
            });
        } else if ((null != mIsScrolledToTheBottom) && (!mIsScrolledToTheBottom)) {
            isAreaVisible = true;

            int unreadCount = 0;

            RoomSummary summary = mRoom.getDataHandler().getStore().getSummary(mRoom.getRoomId());

            if (null != summary) {
                unreadCount = mRoom.getDataHandler().getStore().eventsCountAfter(mRoom.getRoomId(),
                        summary.getLatestReadEventId());
            }

            if (unreadCount > 0) {
                iconId = R.drawable.newmessages;
                textColor = R.color.vector_fuchsia_color;

                if (unreadCount == 1) {
                    text = new SpannableString(
                            getResources().getString(R.string.room_new_message_notification));
                } else {
                    text = new SpannableString(
                            getResources().getString(R.string.room_new_messages_notification, unreadCount));
                }
            } else {
                iconId = R.drawable.scrolldown;
                textColor = R.color.vector_text_gray_color;

                if (!TextUtils.isEmpty(mLatestTypingMessage)) {
                    text = new SpannableString(mLatestTypingMessage);
                }
            }

            mNotificationTextView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mVectorMessageListFragment.scrollToBottom(0);
                }
            });

            mNotificationIconImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mVectorMessageListFragment.scrollToBottom(0);
                }
            });

        } else if (!TextUtils.isEmpty(mLatestTypingMessage)) {
            isAreaVisible = true;

            iconId = R.drawable.vector_typing;
            text = new SpannableString(mLatestTypingMessage);
            textColor = R.color.vector_text_gray_color;
        }
    }

    if (TextUtils.isEmpty(mEventId)) {
        mNotificationsArea.setVisibility(isAreaVisible ? View.VISIBLE : View.INVISIBLE);
    }

    if ((-1 != iconId) && (-1 != textColor)) {
        mNotificationIconImageView.setImageResource(iconId);
        mNotificationTextView.setText(text);
        mNotificationTextView.setTextColor(getResources().getColor(textColor));
    }

    //
    if (null != mResendUnsentMenuItem) {
        mResendUnsentMenuItem.setVisible(hasUnsentEvent);
    }

    if (null != mResendDeleteMenuItem) {
        mResendDeleteMenuItem.setVisible(hasUnsentEvent);
    }
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

@SuppressWarnings("unused")
public void updatePagerTitle(int page) {
    TextView tvLeft = null; // (TextView)findViewById(R.id.title_left);
    TextView tvRight = null; //(TextView)findViewById(R.id.title_right);
    String left = "";
    SpannableStringBuilder ssb = new SpannableStringBuilder();
    for (int i = 0; i < page; i++) {
        OpenFragment f = mViewPagerAdapter.getItem(i);
        if (f instanceof ContentFragment) {
            OpenPath p = ((ContentFragment) f).getPath();
            left += p.getName();/*from   w  w w  .java 2s. c  o  m*/
            if (p.isDirectory() && !left.endsWith("/"))
                left += "/";
        }
    }
    SpannableString srLeft = new SpannableString(left);
    srLeft.setSpan(new ForegroundColorSpan(Color.GRAY), 0, left.length(), Spanned.SPAN_COMPOSING);
    ssb.append(srLeft);
    //ssb.setSpan(new ForegroundColorSpan(Color.GRAY), 0, left.length(), Spanned.SPAN_COMPOSING);
    OpenFragment curr = mViewPagerAdapter.getItem(page);
    if (curr instanceof ContentFragment) {
        OpenPath pCurr = ((ContentFragment) curr).getPath();
        ssb.append(pCurr.getName());
        if (pCurr.isDirectory())
            ssb.append("/");
    }
    String right = "";
    for (int i = page + 1; i < mViewPagerAdapter.getCount(); i++) {
        OpenFragment f = mViewPagerAdapter.getItem(i);
        if (f instanceof ContentFragment) {
            OpenPath p = ((ContentFragment) f).getPath();
            right += p.getName();
            if (p.isDirectory() && !right.endsWith("/"))
                right += "/";
        }
    }
    SpannableString srRight = new SpannableString(right);
    srRight.setSpan(new ForegroundColorSpan(Color.GRAY), 0, right.length(), Spanned.SPAN_COMPOSING);
    ssb.append(srRight);
    updateTitle(ssb);
}

From source file:im.neon.activity.VectorRoomActivity.java

/**
 * Refresh the notifications area.//from w  ww .  j  a  va  2  s  .c o  m
 */
private void refreshNotificationsArea() {
    // sanity check
    // might happen when the application is logged out
    if ((null == mSession.getDataHandler()) || (null == mRoom) || (null != sRoomPreviewData)) {
        return;
    }

    int iconId = -1;
    int textColor = -1;
    boolean isAreaVisible = false;
    SpannableString text = new SpannableString("");
    boolean hasUnsentEvent = false;

    // remove any listeners
    mNotificationTextView.setOnClickListener(null);
    mNotificationIconImageView.setOnClickListener(null);

    //  no network
    if (!Matrix.getInstance(this).isConnected()) {
        isAreaVisible = true;
        iconId = R.drawable.error;
        textColor = R.color.vector_fuchsia_color;
        text = new SpannableString(getResources().getString(R.string.room_offline_notification));
    } else {
        List<Event> undeliveredEvents = mSession.getDataHandler().getStore()
                .getUndeliverableEvents(mRoom.getRoomId());
        List<Event> unknownDeviceEvents = mSession.getDataHandler().getStore()
                .getUnknownDeviceEvents(mRoom.getRoomId());

        boolean hasUndeliverableEvents = (null != undeliveredEvents) && (undeliveredEvents.size() > 0);
        boolean hasUnknownDeviceEvents = (null != unknownDeviceEvents) && (unknownDeviceEvents.size() > 0);

        if (hasUndeliverableEvents || hasUnknownDeviceEvents) {
            hasUnsentEvent = true;
            isAreaVisible = true;
            iconId = R.drawable.error;

            String cancelAll = getResources().getString(R.string.room_prompt_cancel);
            String resendAll = getResources().getString(R.string.room_prompt_resend);
            String message = getResources()
                    .getString(hasUnknownDeviceEvents ? R.string.room_unknown_devices_messages_notification
                            : R.string.room_unsent_messages_notification, resendAll, cancelAll);

            int cancelAllPos = message.indexOf(cancelAll);
            int resendAllPos = message.indexOf(resendAll);

            text = new SpannableString(message);

            // cancelAllPos should always be > 0 but a GA crash reported here
            if (cancelAllPos >= 0) {
                text.setSpan(new cancelAllClickableSpan(), cancelAllPos, cancelAllPos + cancelAll.length(), 0);
            }

            // resendAllPos should always be > 0 but a GA crash reported here
            if (resendAllPos >= 0) {
                text.setSpan(new resendAllClickableSpan(), resendAllPos, resendAllPos + resendAll.length(), 0);
            }

            mNotificationTextView.setMovementMethod(LinkMovementMethod.getInstance());
            textColor = R.color.vector_fuchsia_color;

        } else if ((null != mIsScrolledToTheBottom) && (!mIsScrolledToTheBottom)) {
            isAreaVisible = true;

            int unreadCount = 0;

            RoomSummary summary = mRoom.getDataHandler().getStore().getSummary(mRoom.getRoomId());

            if (null != summary) {
                unreadCount = mRoom.getDataHandler().getStore().eventsCountAfter(mRoom.getRoomId(),
                        summary.getLatestReadEventId());
            }

            if (unreadCount > 0) {
                iconId = R.drawable.newmessages;
                textColor = R.color.vector_fuchsia_color;

                if (unreadCount == 1) {
                    text = new SpannableString(
                            getResources().getString(R.string.room_new_message_notification));
                } else {
                    text = new SpannableString(
                            getResources().getString(R.string.room_new_messages_notification, unreadCount));
                }
            } else {
                iconId = R.drawable.scrolldown;
                textColor = R.color.vector_text_gray_color;

                if (!TextUtils.isEmpty(mLatestTypingMessage)) {
                    text = new SpannableString(mLatestTypingMessage);
                }
            }

            mNotificationTextView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mVectorMessageListFragment.scrollToBottom(0);
                }
            });

            mNotificationIconImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mVectorMessageListFragment.scrollToBottom(0);
                }
            });

        } else if (!TextUtils.isEmpty(mLatestTypingMessage)) {
            isAreaVisible = true;

            iconId = R.drawable.vector_typing;
            text = new SpannableString(mLatestTypingMessage);
            textColor = R.color.vector_text_gray_color;
        }
    }

    if (TextUtils.isEmpty(mEventId)) {
        mNotificationsArea.setVisibility(isAreaVisible ? View.VISIBLE : View.INVISIBLE);
    }

    if ((-1 != iconId) && (-1 != textColor)) {
        mNotificationIconImageView.setImageResource(iconId);
        mNotificationTextView.setText(text);
        mNotificationTextView.setTextColor(getResources().getColor(textColor));
    }

    //
    if (null != mResendUnsentMenuItem) {
        mResendUnsentMenuItem.setVisible(hasUnsentEvent);
    }

    if (null != mResendDeleteMenuItem) {
        mResendDeleteMenuItem.setVisible(hasUnsentEvent);
    }

    if (null != mSearchInRoomMenuItem) {
        // the server search does not work on encrypted rooms.
        mSearchInRoomMenuItem.setVisible(!mRoom.isEncrypted());
    }
}