Search in sources :

Example 21 with Drawable

use of android.graphics.drawable.Drawable in project nmid-headline by miao1007.

the class EditPage method genBackground.

private void genBackground() {
    background = new ColorDrawable(DIM_COLOR);
    if (backgroundView != null) {
        try {
            Bitmap bgBm = captureView(backgroundView, backgroundView.getWidth(), backgroundView.getHeight());
            bgBm = blur(bgBm, 20, 8);
            BitmapDrawable blurBm = new BitmapDrawable(activity.getResources(), bgBm);
            background = new LayerDrawable(new Drawable[] { blurBm, background });
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 22 with Drawable

use of android.graphics.drawable.Drawable in project k-9 by k9mail.

the class MessageListAdapter method bindView.

@Override
public void bindView(View view, Context context, Cursor cursor) {
    Account account = fragment.getAccountFromCursor(cursor);
    String fromList = cursor.getString(SENDER_LIST_COLUMN);
    String toList = cursor.getString(TO_LIST_COLUMN);
    String ccList = cursor.getString(CC_LIST_COLUMN);
    Address[] fromAddrs = Address.unpack(fromList);
    Address[] toAddrs = Address.unpack(toList);
    Address[] ccAddrs = Address.unpack(ccList);
    boolean fromMe = fragment.messageHelper.toMe(account, fromAddrs);
    boolean toMe = fragment.messageHelper.toMe(account, toAddrs);
    boolean ccMe = fragment.messageHelper.toMe(account, ccAddrs);
    CharSequence displayName = fragment.messageHelper.getDisplayName(account, fromAddrs, toAddrs);
    CharSequence displayDate = DateUtils.getRelativeTimeSpanString(context, cursor.getLong(DATE_COLUMN));
    Address counterpartyAddress = fetchCounterPartyAddress(fromMe, toAddrs, ccAddrs, fromAddrs);
    int threadCount = (fragment.showingThreadedList) ? cursor.getInt(THREAD_COUNT_COLUMN) : 0;
    String subject = MlfUtils.buildSubject(cursor.getString(SUBJECT_COLUMN), fragment.getString(R.string.general_no_subject), threadCount);
    boolean read = (cursor.getInt(READ_COLUMN) == 1);
    boolean flagged = (cursor.getInt(FLAGGED_COLUMN) == 1);
    boolean answered = (cursor.getInt(ANSWERED_COLUMN) == 1);
    boolean forwarded = (cursor.getInt(FORWARDED_COLUMN) == 1);
    boolean hasAttachments = (cursor.getInt(ATTACHMENT_COUNT_COLUMN) > 0);
    MessageViewHolder holder = (MessageViewHolder) view.getTag();
    int maybeBoldTypeface = (read) ? Typeface.NORMAL : Typeface.BOLD;
    long uniqueId = cursor.getLong(fragment.uniqueIdColumn);
    boolean selected = fragment.selected.contains(uniqueId);
    holder.chip.setBackgroundColor(account.getChipColor());
    if (fragment.checkboxes) {
        holder.selected.setChecked(selected);
    }
    if (fragment.stars) {
        holder.flagged.setChecked(flagged);
    }
    holder.position = cursor.getPosition();
    if (holder.contactBadge != null) {
        updateContactBadge(holder, counterpartyAddress);
    }
    setBackgroundColor(view, selected, read);
    if (fragment.activeMessage != null) {
        changeBackgroundColorIfActiveMessage(cursor, account, view);
    }
    updateWithThreadCount(holder, threadCount);
    CharSequence beforePreviewText = (fragment.senderAboveSubject) ? subject : displayName;
    String sigil = recipientSigil(toMe, ccMe);
    SpannableStringBuilder messageStringBuilder = new SpannableStringBuilder(sigil).append(beforePreviewText);
    if (fragment.previewLines > 0) {
        String preview = getPreview(cursor);
        messageStringBuilder.append(" ").append(preview);
    }
    holder.preview.setText(messageStringBuilder, TextView.BufferType.SPANNABLE);
    formatPreviewText(holder.preview, beforePreviewText, sigil);
    Drawable statusHolder = buildStatusHolder(forwarded, answered);
    if (holder.from != null) {
        holder.from.setTypeface(Typeface.create(holder.from.getTypeface(), maybeBoldTypeface));
        if (fragment.senderAboveSubject) {
            holder.from.setCompoundDrawablesWithIntrinsicBounds(// left
            statusHolder, // top
            null, // right
            hasAttachments ? mAttachmentIcon : null, // bottom
            null);
            holder.from.setText(displayName);
        } else {
            holder.from.setText(new SpannableStringBuilder(sigil).append(displayName));
        }
    }
    if (holder.subject != null) {
        if (!fragment.senderAboveSubject) {
            holder.subject.setCompoundDrawablesWithIntrinsicBounds(// left
            statusHolder, // top
            null, // right
            hasAttachments ? mAttachmentIcon : null, // bottom
            null);
        }
        holder.subject.setTypeface(Typeface.create(holder.subject.getTypeface(), maybeBoldTypeface));
        holder.subject.setText(subject);
    }
    holder.date.setText(displayDate);
}
Also used : Account(com.fsck.k9.Account) Address(com.fsck.k9.mail.Address) Drawable(android.graphics.drawable.Drawable) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 23 with Drawable

use of android.graphics.drawable.Drawable in project qksms by moezbhatti.

the class QKActivity method colorMenuIcons.

public void colorMenuIcons(Menu menu, int color) {
    // Toolbar navigation icon
    Drawable navigationIcon = mToolbar.getNavigationIcon();
    if (navigationIcon != null) {
        navigationIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
        mToolbar.setNavigationIcon(navigationIcon);
    }
    // Overflow icon
    colorOverflowButtonWhenReady(color);
    // Other icons
    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        Drawable newIcon = menuItem.getIcon();
        if (newIcon != null) {
            newIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
            menuItem.setIcon(newIcon);
        }
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) MenuItem(android.view.MenuItem)

Example 24 with Drawable

use of android.graphics.drawable.Drawable in project qksms by moezbhatti.

the class SearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(SearchViewHolder holder, int position) {
    SearchData data = getItem(position);
    holder.mData = data;
    holder.mClickListener = mItemClickListener;
    holder.root.setOnClickListener(holder);
    holder.root.setOnLongClickListener(holder);
    if (data.contact != null) {
        Drawable avatarDrawable = data.contact.getAvatar(mContext, null);
        holder.avatar.setImageDrawable(avatarDrawable);
        holder.avatar.setContactName(data.contact.getName());
        holder.name.setText(data.contact.getName());
    } else {
        holder.avatar.setImageDrawable(null);
        holder.avatar.setContactName(null);
        holder.name.setText(null);
    }
    holder.date.setText(DateFormatter.getConversationTimestamp(mContext, data.date));
    if (mQuery != null) {
        // We need to make the search string bold within the full message
        // Get all of the start positions of the query within the messages
        ArrayList<Integer> indices = new ArrayList<>();
        int index = data.body.toLowerCase().indexOf(mQuery.toLowerCase());
        while (index >= 0) {
            indices.add(index);
            index = data.body.toLowerCase().indexOf(mQuery.toLowerCase(), index + 1);
        }
        // Make all instances of the search query bold
        SpannableStringBuilder sb = new SpannableStringBuilder(data.body);
        for (int i : indices) {
            StyleSpan span = new StyleSpan(Typeface.BOLD);
            sb.setSpan(span, i, i + mQuery.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        }
        holder.snippet.setText(sb);
    }
}
Also used : StyleSpan(android.text.style.StyleSpan) Drawable(android.graphics.drawable.Drawable) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 25 with Drawable

use of android.graphics.drawable.Drawable in project Signal-Android by WhisperSystems.

the class MultiWaveView method internalSetTargetResources.

private void internalSetTargetResources(int resourceId) {
    Resources res = getContext().getResources();
    TypedArray array = res.obtainTypedArray(resourceId);
    int count = array.length();
    ArrayList<TargetDrawable> targetDrawables = new ArrayList<TargetDrawable>(count);
    for (int i = 0; i < count; i++) {
        Drawable drawable = array.getDrawable(i);
        targetDrawables.add(new TargetDrawable(res, drawable));
    }
    array.recycle();
    mTargetResourceId = resourceId;
    mTargetDrawables = targetDrawables;
    updateTargetPositions();
}
Also used : TypedArray(android.content.res.TypedArray) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) Resources(android.content.res.Resources) SuppressLint(android.annotation.SuppressLint)

Aggregations

Drawable (android.graphics.drawable.Drawable)4516 BitmapDrawable (android.graphics.drawable.BitmapDrawable)795 View (android.view.View)579 Bitmap (android.graphics.Bitmap)476 ColorDrawable (android.graphics.drawable.ColorDrawable)473 ImageView (android.widget.ImageView)471 TextView (android.widget.TextView)439 Paint (android.graphics.Paint)322 LayerDrawable (android.graphics.drawable.LayerDrawable)314 Test (org.junit.Test)276 Context (android.content.Context)267 Resources (android.content.res.Resources)252 Rect (android.graphics.Rect)243 PackageManager (android.content.pm.PackageManager)233 StateListDrawable (android.graphics.drawable.StateListDrawable)212 TypedArray (android.content.res.TypedArray)205 Intent (android.content.Intent)155 ViewGroup (android.view.ViewGroup)148 AnimationDrawable (android.graphics.drawable.AnimationDrawable)147 ArrayList (java.util.ArrayList)139