Search in sources :

Example 66 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project xabber-android by redsolution.

the class AvatarManager method getDefaultAccountAvatar.

@NonNull
public Drawable getDefaultAccountAvatar(String account) {
    Drawable[] layers = new Drawable[2];
    layers[0] = new ColorDrawable(ColorManager.getInstance().getAccountPainter().getAccountMainColor(account));
    layers[1] = application.getResources().getDrawable(R.drawable.ic_avatar_1);
    return new LayerDrawable(layers);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) NonNull(android.support.annotation.NonNull)

Example 67 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project robolectric by robolectric.

the class ShadowResourcesTest method testGetColorDrawable.

@Test
public void testGetColorDrawable() {
    Drawable drawable = resources.getDrawable(R.color.color_with_alpha);
    assertThat(drawable).isInstanceOf(ColorDrawable.class);
    assertThat(((ColorDrawable) drawable).getColor()).isEqualTo(0x802C76AD);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Test(org.junit.Test)

Example 68 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project robolectric by robolectric.

the class ShadowThemeTest method whenNotSetOnActivityInManifest_activityGetsThemeFromApplicationInManifest.

@Test
public void whenNotSetOnActivityInManifest_activityGetsThemeFromApplicationInManifest() throws Exception {
    TestActivity activity = buildActivity(TestActivity.class).create().get();
    Button theButton = (Button) activity.findViewById(R.id.button);
    ColorDrawable background = (ColorDrawable) theButton.getBackground();
    assertThat(background.getColor()).isEqualTo(0xff00ff00);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Button(android.widget.Button) Test(org.junit.Test)

Example 69 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project xabber-android by redsolution.

the class ChatScrollIndicatorAdapter method update.

public void update(ArrayList<AbstractChat> activeChats) {
    final LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final int size = activeChats.size() + 1;
    linearLayout.removeAllViews();
    for (int i = 0; i < size; i++) {
        View view;
        if (i == 0) {
            view = inflater.inflate(R.layout.chat_scroll_indicator_item_square, linearLayout, false);
        } else {
            view = inflater.inflate(R.layout.chat_scroll_indicator_item_circle, linearLayout, false);
        }
        linearLayout.addView(view);
        final AccountViewHolder accountViewHolder = new AccountViewHolder(view);
        final AccountPainter accountPainter = ColorManager.getInstance().getAccountPainter();
        if (i > 0) {
            final String account = activeChats.get(i - 1).getAccount();
            ((GradientDrawable) accountViewHolder.body.getDrawable()).setColor(accountPainter.getAccountMainColor(account));
            ((GradientDrawable) accountViewHolder.selection.getDrawable()).setColor(accountPainter.getAccountMainColor(account));
        } else {
            accountViewHolder.body.setImageDrawable(new ColorDrawable(accountPainter.getDefaultMainColor()));
            accountViewHolder.selection.setImageDrawable(new ColorDrawable(accountPainter.getDefaultMainColor()));
        }
        view.setTag(accountViewHolder);
    }
}
Also used : AccountPainter(com.xabber.android.ui.color.AccountPainter) ColorDrawable(android.graphics.drawable.ColorDrawable) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) View(android.view.View) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 70 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project xabber-android by redsolution.

the class ContactItemInflater method setUpContactView.

public View setUpContactView(View convertView, ViewGroup parent, final AbstractContact contact) {
    final View view;
    final ContactListItemViewHolder viewHolder;
    if (convertView == null) {
        view = LayoutInflater.from(context).inflate(R.layout.contact_list_item, parent, false);
        viewHolder = new ContactListItemViewHolder(view);
        view.setTag(viewHolder);
    } else {
        view = convertView;
        viewHolder = (ContactListItemViewHolder) view.getTag();
    }
    if (contact.isConnected()) {
        viewHolder.offlineShadow.setVisibility(View.GONE);
    } else {
        viewHolder.offlineShadow.setVisibility(View.VISIBLE);
    }
    viewHolder.color.setImageDrawable(new ColorDrawable(ColorManager.getInstance().getAccountPainter().getAccountMainColor(contact.getAccount())));
    viewHolder.color.setVisibility(View.VISIBLE);
    if (SettingsManager.contactsShowAvatars()) {
        viewHolder.avatar.setVisibility(View.VISIBLE);
        viewHolder.avatar.setImageDrawable(contact.getAvatarForContactList());
    } else {
        viewHolder.avatar.setVisibility(View.GONE);
    }
    viewHolder.avatar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onAvatarClick(contact);
        }
    });
    viewHolder.name.setText(contact.getName());
    MessageManager messageManager = MessageManager.getInstance();
    if (MUCManager.getInstance().isMucPrivateChat(contact.getAccount(), contact.getUser())) {
        viewHolder.name.setTextColor(ColorManager.getInstance().getColorMucPrivateChatText());
    } else if (messageManager.hasActiveChat(contact.getAccount(), contact.getUser())) {
        viewHolder.name.setTextColor(ColorManager.getInstance().getActiveChatTextColor());
    } else {
        viewHolder.name.setTextColor(ColorManager.getInstance().getColorMain());
    }
    if (MUCManager.getInstance().hasRoom(contact.getAccount(), contact.getUser())) {
        viewHolder.mucIndicator.setVisibility(View.VISIBLE);
        viewHolder.mucIndicator.setImageResource(R.drawable.ic_muc_indicator_black_16dp);
    } else if (MUCManager.getInstance().isMucPrivateChat(contact.getAccount(), contact.getUser())) {
        viewHolder.mucIndicator.setVisibility(View.VISIBLE);
        viewHolder.mucIndicator.setImageResource(R.drawable.ic_muc_private_chat_indicator_black_16dp);
    } else {
        viewHolder.mucIndicator.setVisibility(View.GONE);
    }
    String statusText;
    viewHolder.outgoingMessageIndicator.setVisibility(View.GONE);
    viewHolder.smallRightText.setVisibility(View.GONE);
    viewHolder.smallRightIcon.setVisibility(View.GONE);
    ClientSoftware clientSoftware = contact.getClientSoftware();
    if (clientSoftware == ClientSoftware.unknown) {
        viewHolder.largeClientIcon.setVisibility(View.GONE);
    } else {
        viewHolder.largeClientIcon.setVisibility(View.VISIBLE);
        viewHolder.largeClientIcon.setImageLevel(clientSoftware.ordinal());
    }
    if (messageManager.hasActiveChat(contact.getAccount(), contact.getUser())) {
        AbstractChat chat = messageManager.getChat(contact.getAccount(), contact.getUser());
        statusText = chat.getLastText().trim();
        view.setBackgroundColor(ColorManager.getInstance().getActiveChatBackgroundColor());
        viewHolder.separator.setBackgroundColor(ColorManager.getInstance().getActiveChatSeparatorColor());
        viewHolder.largeClientIcon.setColorFilter(ColorManager.getInstance().getActiveChatLargeClientIconColor());
        if (!statusText.isEmpty()) {
            viewHolder.smallRightText.setText(StringUtils.getSmartTimeText(context, chat.getLastTime()));
            viewHolder.smallRightText.setVisibility(View.VISIBLE);
            if (!chat.isLastMessageIncoming()) {
                viewHolder.outgoingMessageIndicator.setText(context.getString(R.string.sender_is_you) + ": ");
                viewHolder.outgoingMessageIndicator.setVisibility(View.VISIBLE);
                viewHolder.outgoingMessageIndicator.setTextColor(ColorManager.getInstance().getAccountPainter().getAccountMainColor(contact.getAccount()));
            }
            viewHolder.smallRightIcon.setImageResource(R.drawable.ic_client_small);
            viewHolder.smallRightIcon.setVisibility(View.VISIBLE);
            viewHolder.smallRightIcon.setImageLevel(clientSoftware.ordinal());
            viewHolder.largeClientIcon.setVisibility(View.GONE);
        }
    } else {
        statusText = contact.getStatusText().trim();
        view.setBackgroundColor(ColorManager.getInstance().getContactBackground());
        viewHolder.separator.setBackgroundColor(ColorManager.getInstance().getContactSeparatorColor());
        viewHolder.largeClientIcon.setColorFilter(ColorManager.getInstance().getContactLargeClientIconColor());
    }
    if (statusText.isEmpty()) {
        viewHolder.secondLineMessage.setVisibility(View.GONE);
    } else {
        viewHolder.secondLineMessage.setVisibility(View.VISIBLE);
        viewHolder.secondLineMessage.setText(Emoticons.getSmiledText(context, statusText, viewHolder.secondLineMessage));
    }
    viewHolder.statusIcon.setImageLevel(contact.getStatusMode().getStatusLevel());
    return view;
}
Also used : MessageManager(com.xabber.android.data.message.MessageManager) ColorDrawable(android.graphics.drawable.ColorDrawable) AbstractChat(com.xabber.android.data.message.AbstractChat) ClientSoftware(com.xabber.android.data.extension.capability.ClientSoftware) View(android.view.View)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)519 View (android.view.View)112 Drawable (android.graphics.drawable.Drawable)102 BitmapDrawable (android.graphics.drawable.BitmapDrawable)67 ImageView (android.widget.ImageView)62 TextView (android.widget.TextView)55 Bitmap (android.graphics.Bitmap)51 AdapterView (android.widget.AdapterView)32 LinearLayout (android.widget.LinearLayout)32 Test (org.junit.Test)31 Canvas (android.graphics.Canvas)29 ListView (android.widget.ListView)27 FrameLayout (android.widget.FrameLayout)23 ViewGroup (android.view.ViewGroup)22 Handler (android.os.Handler)20 TransitionDrawable (android.graphics.drawable.TransitionDrawable)19 Paint (android.graphics.Paint)18 StateListDrawable (android.graphics.drawable.StateListDrawable)17 WindowManager (android.view.WindowManager)17 Point (android.graphics.Point)16