Example usage for android.text SpannableStringBuilder SpannableStringBuilder

List of usage examples for android.text SpannableStringBuilder SpannableStringBuilder

Introduction

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

Prototype

public SpannableStringBuilder() 

Source Link

Document

Create a new SpannableStringBuilder with empty contents

Usage

From source file:com.google.samples.apps.abelana.LoginActivity.java

private void displayDialog() {
    // Build the about body view and append the link to see OSS licenses
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(Html.fromHtml(getString(R.string.splash_dialog_body)));

    LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
    aboutBodyView.setText(aboutBody);//  w w  w  . ja  v  a 2  s .  c o  m
    aboutBodyView.setMovementMethod(new LinkMovementMethod());
    new AlertDialog.Builder(this).setTitle(getString(R.string.splash_dialog_title)).setView(aboutBodyView)
            .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).show();
}

From source file:com.chen.mail.browse.SendersView.java

public static SpannableStringBuilder createMessageInfo(Context context, Conversation conv,
        final boolean resourceCachingRequired) {
    SpannableStringBuilder messageInfo = new SpannableStringBuilder();

    try {//  ww w .ja  v a2s .co m
        ConversationInfo conversationInfo = conv.conversationInfo;
        int sendingStatus = conv.sendingState;
        boolean hasSenders = false;
        // This covers the case where the sender is "me" and this is a draft
        // message, which means this will only run once most of the time.
        for (MessageInfo m : conversationInfo.messageInfos) {
            if (!TextUtils.isEmpty(m.sender)) {
                hasSenders = true;
                break;
            }
        }
        getSenderResources(context, resourceCachingRequired);
        if (conversationInfo != null) {
            int count = conversationInfo.messageCount;
            int draftCount = conversationInfo.draftCount;
            boolean showSending = sendingStatus == UIProvider.ConversationSendingState.SENDING;
            if (count > 1) {
                messageInfo.append(count + "");
            }
            messageInfo.setSpan(
                    CharacterStyle.wrap(conv.read ? sMessageInfoReadStyleSpan : sMessageInfoUnreadStyleSpan), 0,
                    messageInfo.length(), 0);
            if (draftCount > 0) {
                // If we are showing a message count or any draft text and there
                // is at least 1 sender, prepend the sending state text with a
                // comma.
                if (hasSenders || count > 1) {
                    messageInfo.append(sSendersSplitToken);
                }
                SpannableStringBuilder draftString = new SpannableStringBuilder();
                if (draftCount == 1) {
                    draftString.append(sDraftSingularString);
                } else {
                    draftString.append(sDraftPluralString + String.format(sDraftCountFormatString, draftCount));
                }
                draftString.setSpan(CharacterStyle.wrap(sDraftsStyleSpan), 0, draftString.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                messageInfo.append(draftString);
            }
            if (showSending) {
                // If we are showing a message count or any draft text, prepend
                // the sending state text with a comma.
                if (count > 1 || draftCount > 0) {
                    messageInfo.append(sSendersSplitToken);
                }
                SpannableStringBuilder sending = new SpannableStringBuilder();
                sending.append(sSendingString);
                sending.setSpan(sSendingStyleSpan, 0, sending.length(), 0);
                messageInfo.append(sending);
            }
            // Prepend a space if we are showing other message info text.
            if (count > 1 || (draftCount > 0 && hasSenders) || showSending) {
                messageInfo.insert(0, sMessageCountSpacerString);
            }
        }
    } finally {
        if (!resourceCachingRequired) {
            clearResourceCache();
        }
    }

    return messageInfo;
}

From source file:com.android.talkback.speechrules.NodeSpeechRuleProcessor.java

private void appendDescriptionForTree(AccessibilityNodeInfoCompat announcedNode, SpannableStringBuilder builder,
        AccessibilityEvent event, AccessibilityNodeInfoCompat source,
        Set<AccessibilityNodeInfoCompat> visitedNodes) {
    if (announcedNode == null) {
        return;//from  ww w.j av  a2  s  . c o m
    }

    AccessibilityNodeInfoCompat visitedNode = AccessibilityNodeInfoCompat.obtain(announcedNode);
    if (!visitedNodes.add(visitedNode)) {
        visitedNode.recycle();
        return;
    }

    final AccessibilityEvent nodeEvent = (announcedNode.equals(source)) ? event : null;
    final CharSequence nodeDesc = getDescriptionForNode(announcedNode, nodeEvent);
    final boolean blockChildDescription = hasOverridingContentDescription(announcedNode);

    SpannableStringBuilder childStringBuilder = new SpannableStringBuilder();

    if (!blockChildDescription) {
        // Recursively append descriptions for visible and non-focusable child nodes.
        ReorderedChildrenIterator iterator = ReorderedChildrenIterator.createAscendingIterator(announcedNode);
        while (iterator.hasNext()) {
            AccessibilityNodeInfoCompat child = iterator.next();
            if (AccessibilityNodeInfoUtils.isVisible(child)
                    && !AccessibilityNodeInfoUtils.isAccessibilityFocusable(child)) {
                appendDescriptionForTree(child, childStringBuilder, event, source, visitedNodes);
            }
        }

        iterator.recycle();
    }

    // If any one of the following is satisfied:
    // 1. The root node has a description.
    // 2. The root has no override content description and the children have some description.
    // Then we should append the status information for this node.
    // This is used to avoid displaying checked/expanded status alone without node description.
    //
    if (!TextUtils.isEmpty(nodeDesc) || !TextUtils.isEmpty(childStringBuilder)) {
        appendExpandedOrCollapsedStatus(announcedNode, event, builder);
        appendCheckedStatus(announcedNode, event, builder);
    }

    StringBuilderUtils.appendWithSeparator(builder, nodeDesc);
    StringBuilderUtils.appendWithSeparator(builder, childStringBuilder);
}

From source file:org.fdroid.enigtext.notifications.MessageNotifier.java

private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret,
        NotificationState notificationState, boolean signal) {
    List<NotificationItem> notifications = notificationState.getNotifications();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    Recipient recipient = notifications.get(0).getIndividualRecipient();

    builder.setSmallIcon(R.drawable.icon_notification);
    builder.setLargeIcon(recipient.getContactPhoto());
    builder.setContentTitle(recipient.toShortString());
    builder.setContentText(notifications.get(0).getText());
    builder.setContentIntent(notifications.get(0).getPendingIntent(context));

    if (masterSecret != null) {
        builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read),
                notificationState.getMarkAsReadIntent(context, masterSecret));
    }//from  ww w. ja  v  a2s  . c  o  m

    SpannableStringBuilder content = new SpannableStringBuilder();

    for (NotificationItem item : notifications) {
        content.append(item.getBigStyleSummary());
        content.append('\n');
    }

    builder.setStyle(new BigTextStyle().bigText(content));

    setNotificationAlarms(context, builder, signal);

    if (signal) {
        builder.setTicker(notifications.get(0).getTickerText());
    }

    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID,
            builder.build());
}

From source file:com.android.talkback.speechrules.RuleEditText.java

/**
 * Inverts the default priorities of text and content description.
 * If the field is a password, returns the content description or "password",
 * as well as the length of the password if it's not empty.
 *
 * @param context current context//w  ww . j a va 2s.  com
 * @param node    to get text from
 * @return A text description of the editable text area.
 */
private CharSequence getText(Context context, AccessibilityNodeInfoCompat node) {
    final CharSequence text = node.getText();
    final boolean shouldSpeakPasswords = SettingsCompatUtils.SecureCompatUtils.shouldSpeakPasswords(context);

    if (!TextUtils.isEmpty(text) && (!node.isPassword() || shouldSpeakPasswords)) {
        // Text is potentially user input, so we need to make sure we pronounce input that has
        // only symbols.
        return SpeechCleanupUtils.collapseRepeatedCharactersAndCleanUp(context, text);
    }

    SpannableStringBuilder output = new SpannableStringBuilder();

    final CharSequence contentDescription = node.getContentDescription();

    if (!TextUtils.isEmpty(contentDescription)) {
        // Less likely, but contentDescription is potentially user input, so we need to make
        // sure we pronounce input that has only symbols.
        StringBuilderUtils.append(output,
                SpeechCleanupUtils.collapseRepeatedCharactersAndCleanUp(context, contentDescription));
    } else if (node.isPassword() && !shouldSpeakPasswords) {
        StringBuilderUtils.append(output, context.getString(R.string.value_password));
    }

    if (node.isPassword() && !shouldSpeakPasswords && !TextUtils.isEmpty(text)) {
        // Note: never cleanup password speech because that will mess up the text length.
        StringBuilderUtils.append(output, context.getResources()
                .getQuantityString(R.plurals.template_password_character_count, text.length(), text.length()));
    }

    return output;
}

From source file:net.kourlas.voipms_sms.adapters.ConversationRecyclerViewAdapter.java

@Override
public void onBindViewHolder(MessageViewHolder messageViewHolder, int i) {
    Message message = messages.get(i);/*from  www. ja  v a 2 s .  c  o  m*/
    int viewType = getItemViewType(i);

    if (viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_RIGHT_PRIMARY) {
        QuickContactBadge contactBadge = messageViewHolder.getContactBadge();
        if (viewType == ITEM_LEFT_PRIMARY) {
            contactBadge.assignContactFromPhone(message.getContact(), true);
        } else {
            contactBadge.assignContactFromPhone(message.getDid(), true);
        }
        String photoUri;
        if (viewType == ITEM_LEFT_PRIMARY) {
            photoUri = Utils.getContactPhotoUri(applicationContext, message.getContact());

        } else {
            photoUri = Utils.getContactPhotoUri(applicationContext, ContactsContract.Profile.CONTENT_URI);
            if (photoUri == null) {
                photoUri = Utils.getContactPhotoUri(applicationContext, message.getDid());
            }
        }
        if (photoUri != null) {
            contactBadge.setImageURI(Uri.parse(photoUri));
        } else {
            contactBadge.setImageToDefault();
        }
    }

    View smsContainer = messageViewHolder.getSmsContainer();

    TextView messageText = messageViewHolder.getMessageText();
    SpannableStringBuilder messageTextBuilder = new SpannableStringBuilder();
    messageTextBuilder.append(message.getText());
    if (!filterConstraint.equals("")) {
        int index = message.getText().toLowerCase().indexOf(filterConstraint.toLowerCase());
        if (index != -1) {
            messageTextBuilder.setSpan(
                    new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)),
                    index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE);
            messageTextBuilder.setSpan(
                    new ForegroundColorSpan(ContextCompat.getColor(applicationContext, R.color.dark_gray)),
                    index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE);
        }
    }
    messageText.setText(messageTextBuilder);

    TextView dateText = messageViewHolder.getDateText();
    if (!message.isDelivered()) {
        if (!message.isDeliveryInProgress()) {
            SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder();
            if (isItemChecked(i)) {
                dateTextBuilder
                        .append(applicationContext.getString(R.string.conversation_message_not_sent_selected));
            } else {
                dateTextBuilder.append(applicationContext.getString(R.string.conversation_message_not_sent));
            }
            dateTextBuilder.setSpan(
                    new ForegroundColorSpan(
                            isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white)
                                    : ContextCompat.getColor(applicationContext,
                                            android.R.color.holo_red_dark)),
                    0, dateTextBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            dateText.setText(dateTextBuilder);
            dateText.setVisibility(View.VISIBLE);
        } else {
            dateText.setText(applicationContext.getString(R.string.conversation_message_sending));
            dateText.setVisibility(View.VISIBLE);
        }
    } else if (i == messages.size() - 1
            || ((viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_LEFT_SECONDARY)
                    && getItemViewType(i + 1) != ITEM_LEFT_SECONDARY)
            || ((viewType == ITEM_RIGHT_PRIMARY || viewType == ITEM_RIGHT_SECONDARY)
                    && getItemViewType(i + 1) != ITEM_RIGHT_SECONDARY)) {
        dateText.setText(Utils.getFormattedDate(applicationContext, message.getDate(), false));
        dateText.setVisibility(View.VISIBLE);
    } else {
        dateText.setVisibility(View.GONE);
    }

    if (viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_LEFT_SECONDARY) {
        smsContainer.setBackgroundResource(isItemChecked(i) ? android.R.color.holo_blue_dark : R.color.primary);
    } else {
        smsContainer.setBackgroundResource(
                isItemChecked(i) ? android.R.color.holo_blue_dark : android.R.color.white);
        messageText.setTextColor(
                isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white)
                        : ContextCompat.getColor(applicationContext, R.color.dark_gray));
        messageText.setLinkTextColor(
                isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white)
                        : ContextCompat.getColor(applicationContext, R.color.dark_gray));
        dateText.setTextColor(
                isItemChecked(i) ? ContextCompat.getColor(applicationContext, R.color.message_translucent_white)
                        : ContextCompat.getColor(applicationContext, R.color.message_translucent_dark_grey));
    }
}

From source file:com.android.mail.browse.SendersView.java

public static SpannableStringBuilder createMessageInfo(Context context, Conversation conv,
        final boolean resourceCachingRequired) {
    SpannableStringBuilder messageInfo = new SpannableStringBuilder();

    try {//from  w ww. j  a  v  a  2s  . co  m
        final ConversationInfo conversationInfo = conv.conversationInfo;
        final int sendingStatus = conv.sendingState;
        boolean hasSenders = false;
        // This covers the case where the sender is "me" and this is a draft
        // message, which means this will only run once most of the time.
        for (ParticipantInfo p : conversationInfo.participantInfos) {
            if (!TextUtils.isEmpty(p.name)) {
                hasSenders = true;
                break;
            }
        }
        getSenderResources(context, resourceCachingRequired);
        final int count = conversationInfo.messageCount;
        final int draftCount = conversationInfo.draftCount;
        if (count > 1) {
            appendMessageInfo(messageInfo, Integer.toString(count),
                    CharacterStyle.wrap(conv.read ? sMessageInfoReadStyleSpan : sMessageInfoUnreadStyleSpan),
                    false, conv.read);
        }

        boolean appendSplitToken = hasSenders || count > 1;
        if (draftCount > 0) {
            final CharSequence draftText;
            if (draftCount == 1) {
                draftText = sDraftSingularString;
            } else {
                draftText = sDraftPluralString + String.format(sDraftCountFormatString, draftCount);
            }

            appendMessageInfo(messageInfo, draftText, sDraftsStyleSpan, appendSplitToken, conv.read);
        }

        final boolean showState = sendingStatus == UIProvider.ConversationSendingState.SENDING
                || sendingStatus == UIProvider.ConversationSendingState.RETRYING
                || sendingStatus == UIProvider.ConversationSendingState.SEND_ERROR;
        if (showState) {
            appendSplitToken |= draftCount > 0;

            final CharSequence statusText;
            final Object span;
            if (sendingStatus == UIProvider.ConversationSendingState.SENDING) {
                statusText = sSendingString;
                span = sSendingStyleSpan;
            } else if (sendingStatus == UIProvider.ConversationSendingState.RETRYING) {
                statusText = sSendingString;
                span = sSendingStyleSpan;
            } else {
                statusText = sFailedString;
                span = sFailedStyleSpan;
            }

            appendMessageInfo(messageInfo, statusText, span, appendSplitToken, conv.read);
        }

        // Prepend a space if we are showing other message info text.
        if (count > 1 || (draftCount > 0 && hasSenders) || showState) {
            messageInfo.insert(0, sMessageCountSpacerString);
        }
    } finally {
        if (!resourceCachingRequired) {
            clearResourceCache();
        }
    }

    return messageInfo;
}

From source file:org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView vKeyId = (TextView) view.findViewById(R.id.subkey_item_key_id);
    TextView vKeyDetails = (TextView) view.findViewById(R.id.subkey_item_details);
    TextView vKeyExpiry = (TextView) view.findViewById(R.id.subkey_item_expiry);
    ImageView vCertifyIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_certify);
    ImageView vSignIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_sign);
    ImageView vEncryptIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_encrypt);
    ImageView vAuthenticateIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_authenticate);
    ImageView vEditImage = (ImageView) view.findViewById(R.id.subkey_item_edit_image);
    ImageView vStatus = (ImageView) view.findViewById(R.id.subkey_item_status);

    // not used:/* ww  w . j  av  a 2s  .  c  o  m*/
    ImageView deleteImage = (ImageView) view.findViewById(R.id.subkey_item_delete_button);
    deleteImage.setVisibility(View.GONE);

    long keyId = cursor.getLong(INDEX_KEY_ID);
    vKeyId.setText(KeyFormattingUtils.beautifyKeyId(keyId));

    // may be set with additional "stripped" later on
    SpannableStringBuilder algorithmStr = new SpannableStringBuilder();
    algorithmStr.append(KeyFormattingUtils.getAlgorithmInfo(context, cursor.getInt(INDEX_ALGORITHM),
            cursor.getInt(INDEX_KEY_SIZE), cursor.getString(INDEX_KEY_CURVE_OID)));

    SubkeyChange change = mSaveKeyringParcel != null ? mSaveKeyringParcel.getSubkeyChange(keyId) : null;

    if (change != null && (change.mDummyStrip || change.mMoveKeyToSecurityToken)) {
        if (change.mDummyStrip) {
            algorithmStr.append(", ");
            final SpannableString boldStripped = new SpannableString(context.getString(R.string.key_stripped));
            boldStripped.setSpan(new StyleSpan(Typeface.BOLD), 0, boldStripped.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            algorithmStr.append(boldStripped);
        }
        if (change.mMoveKeyToSecurityToken) {
            algorithmStr.append(", ");
            final SpannableString boldDivert = new SpannableString(context.getString(R.string.key_divert));
            boldDivert.setSpan(new StyleSpan(Typeface.BOLD), 0, boldDivert.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            algorithmStr.append(boldDivert);
        }
    } else {
        switch (SecretKeyType.fromNum(cursor.getInt(INDEX_HAS_SECRET))) {
        case GNU_DUMMY:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_stripped));
            break;
        case DIVERT_TO_CARD:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_divert));
            break;
        case PASSPHRASE_EMPTY:
            algorithmStr.append(", ");
            algorithmStr.append(context.getString(R.string.key_no_passphrase));
            break;
        case UNAVAILABLE:
            // don't show this on pub keys
            //algorithmStr += ", " + context.getString(R.string.key_unavailable);
            break;
        }
    }
    vKeyDetails.setText(algorithmStr, TextView.BufferType.SPANNABLE);

    boolean isMasterKey = cursor.getInt(INDEX_RANK) == 0;
    if (isMasterKey) {
        vKeyId.setTypeface(null, Typeface.BOLD);
    } else {
        vKeyId.setTypeface(null, Typeface.NORMAL);
    }

    // Set icons according to properties
    vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE);
    vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 0 ? View.VISIBLE : View.GONE);
    vSignIcon.setVisibility(cursor.getInt(INDEX_CAN_SIGN) != 0 ? View.VISIBLE : View.GONE);
    vAuthenticateIcon.setVisibility(cursor.getInt(INDEX_CAN_AUTHENTICATE) != 0 ? View.VISIBLE : View.GONE);

    boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;

    Date expiryDate = null;
    if (!cursor.isNull(INDEX_EXPIRY)) {
        expiryDate = new Date(cursor.getLong(INDEX_EXPIRY) * 1000);
    }

    // for edit key
    if (mSaveKeyringParcel != null) {
        boolean revokeThisSubkey = (mSaveKeyringParcel.mRevokeSubKeys.contains(keyId));

        if (revokeThisSubkey) {
            if (!isRevoked) {
                isRevoked = true;
            }
        }

        SaveKeyringParcel.SubkeyChange subkeyChange = mSaveKeyringParcel.getSubkeyChange(keyId);
        if (subkeyChange != null) {
            if (subkeyChange.mExpiry == null || subkeyChange.mExpiry == 0L) {
                expiryDate = null;
            } else {
                expiryDate = new Date(subkeyChange.mExpiry * 1000);
            }
        }

        vEditImage.setVisibility(View.VISIBLE);
    } else {
        vEditImage.setVisibility(View.GONE);
    }

    boolean isExpired;
    if (expiryDate != null) {
        isExpired = expiryDate.before(new Date());
        Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        expiryCal.setTime(expiryDate);
        // convert from UTC to time zone of device
        expiryCal.setTimeZone(TimeZone.getDefault());

        vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": "
                + DateFormat.getDateFormat(context).format(expiryCal.getTime()));
    } else {
        isExpired = false;

        vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " + context.getString(R.string.none));
    }

    // if key is expired or revoked...
    boolean isInvalid = isRevoked || isExpired;
    if (isInvalid) {
        vStatus.setVisibility(View.VISIBLE);

        vCertifyIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vSignIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vEncryptIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);
        vAuthenticateIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                PorterDuff.Mode.SRC_IN);

        if (isRevoked) {
            vStatus.setImageResource(R.drawable.status_signature_revoked_cutout_24dp);
            vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                    PorterDuff.Mode.SRC_IN);
        } else if (isExpired) {
            vStatus.setImageResource(R.drawable.status_signature_expired_cutout_24dp);
            vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray),
                    PorterDuff.Mode.SRC_IN);
        }
    } else {
        vStatus.setVisibility(View.GONE);

        vKeyId.setTextColor(mDefaultTextColor);
        vKeyDetails.setTextColor(mDefaultTextColor);
        vKeyExpiry.setTextColor(mDefaultTextColor);

        vCertifyIcon.clearColorFilter();
        vSignIcon.clearColorFilter();
        vEncryptIcon.clearColorFilter();
        vAuthenticateIcon.clearColorFilter();
    }
    vKeyId.setEnabled(!isInvalid);
    vKeyDetails.setEnabled(!isInvalid);
    vKeyExpiry.setEnabled(!isInvalid);
}

From source file:com.gh4a.fragment.RepositoryFragment.java

private void fillData() {
    TextView tvRepoName = (TextView) mContentView.findViewById(R.id.tv_repo_name);
    SpannableStringBuilder repoName = new SpannableStringBuilder();
    repoName.append(mRepository.getOwner().getLogin());
    repoName.append("/");
    repoName.append(mRepository.getName());
    repoName.setSpan(new IntentSpan(tvRepoName.getContext()) {
        @Override/* w  ww  . j  av a  2 s .  com*/
        protected Intent getIntent() {
            return IntentUtils.getUserActivityIntent(getActivity(), mRepository.getOwner());
        }
    }, 0, mRepository.getOwner().getLogin().length(), 0);
    tvRepoName.setText(repoName);
    tvRepoName.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);

    TextView tvParentRepo = (TextView) mContentView.findViewById(R.id.tv_parent);
    if (mRepository.isFork() && mRepository.getParent() != null) {
        Repository parent = mRepository.getParent();
        tvParentRepo.setVisibility(View.VISIBLE);
        tvParentRepo.setText(
                getString(R.string.forked_from, parent.getOwner().getLogin() + "/" + parent.getName()));
        tvParentRepo.setOnClickListener(this);
        tvParentRepo.setTag(parent);
    } else {
        tvParentRepo.setVisibility(View.GONE);
    }

    fillTextView(R.id.tv_desc, 0, mRepository.getDescription());
    fillTextView(R.id.tv_language, R.string.repo_language, mRepository.getLanguage());
    fillTextView(R.id.tv_url, 0, !StringUtils.isBlank(mRepository.getHomepage()) ? mRepository.getHomepage()
            : mRepository.getHtmlUrl());

    mContentView.findViewById(R.id.cell_stargazers).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_forks).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_pull_requests).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_contributors_label).setOnClickListener(this);
    mContentView.findViewById(R.id.other_info).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_releases_label).setOnClickListener(this);

    Permissions permissions = mRepository.getPermissions();
    updateClickableLabel(R.id.tv_collaborators_label, permissions != null && permissions.hasPushAccess());
    updateClickableLabel(R.id.tv_downloads_label, mRepository.isHasDownloads());
    updateClickableLabel(R.id.tv_wiki_label, mRepository.isHasWiki());

    TextView tvStargazersCount = (TextView) mContentView.findViewById(R.id.tv_stargazers_count);
    tvStargazersCount.setText(String.valueOf(mRepository.getWatchers()));

    TextView tvForksCount = (TextView) mContentView.findViewById(R.id.tv_forks_count);
    tvForksCount.setText(String.valueOf(mRepository.getForks()));

    LinearLayout llIssues = (LinearLayout) mContentView.findViewById(R.id.cell_issues);

    if (mRepository.isHasIssues()) {
        llIssues.setVisibility(View.VISIBLE);
        llIssues.setOnClickListener(this);
        // value will be filled when PR count arrives
    } else {
        llIssues.setVisibility(View.GONE);
    }

    mContentView.findViewById(R.id.tv_private)
            .setVisibility(mRepository.isPrivate() ? View.VISIBLE : View.GONE);

}

From source file:org.thoughtcrime.securesms.notifications.MessageNotifier.java

private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret,
        NotificationState notificationState, boolean signal) {
    if (notificationState.getNotifications().isEmpty()) {
        ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(NOTIFICATION_ID);
        return;//from   w w  w.  j a va 2  s .  co m
    }

    List<NotificationItem> notifications = notificationState.getNotifications();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    Recipient recipient = notifications.get(0).getIndividualRecipient();

    builder.setSmallIcon(R.drawable.icon_notification);
    builder.setLargeIcon(recipient.getContactPhoto());
    builder.setContentTitle(recipient.toShortString());
    builder.setContentText(notifications.get(0).getText());
    builder.setContentIntent(notifications.get(0).getPendingIntent(context));
    builder.setContentInfo(String.valueOf(notificationState.getMessageCount()));

    if (masterSecret != null) {
        builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read),
                notificationState.getMarkAsReadIntent(context, masterSecret));
    }

    SpannableStringBuilder content = new SpannableStringBuilder();

    for (NotificationItem item : notifications) {
        content.append(item.getBigStyleSummary());
        content.append('\n');
    }

    builder.setStyle(new BigTextStyle().bigText(content));

    setNotificationAlarms(context, builder, signal);

    if (signal) {
        builder.setTicker(notifications.get(0).getTickerText());
    }

    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID,
            builder.build());
}