Java Code Examples for org.telegram.ui.ActionBar.Theme#setSelectorDrawableColor()

The following examples show how to use org.telegram.ui.ActionBar.Theme#setSelectorDrawableColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagerSlidingTabStrip.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void addIconTab(final int position, Drawable drawable, CharSequence contentDescription) {
    ImageView tab = new ImageView(getContext()) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (pager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position);
            }
        }

        @Override
        public void setSelected(boolean selected) {
            super.setSelected(selected);
            Drawable background = getBackground();
            if (Build.VERSION.SDK_INT >= 21 && background != null) {
                int color = Theme.getColor(selected ? Theme.key_chat_emojiPanelIconSelected : Theme.key_chat_emojiBottomPanelIcon);
                Theme.setSelectorDrawableColor(background, Color.argb(30, Color.red(color), Color.green(color), Color.blue(color)), true);
            }
        }
    };
    tab.setFocusable(true);
    if (Build.VERSION.SDK_INT >= 21) {
        RippleDrawable rippleDrawable = (RippleDrawable) Theme.createSelectorDrawable(Theme.getColor(Theme.key_chat_emojiBottomPanelIcon));
        Theme.setRippleDrawableForceSoftware(rippleDrawable);
        tab.setBackground(rippleDrawable);
    }
    tab.setImageDrawable(drawable);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(v -> {
        if (pager.getAdapter() instanceof IconTabProvider) {
            if (!((IconTabProvider) pager.getAdapter()).canScrollToTab(position)) {
                return;
            }
        }
        pager.setCurrentItem(position, false);
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    tab.setContentDescription(contentDescription);
}
 
Example 2
Source File: PagerSlidingTabStrip.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void addIconTab(final int position, Drawable drawable, CharSequence contentDescription) {
    ImageView tab = new ImageView(getContext()) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (pager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position);
            }
        }

        @Override
        public void setSelected(boolean selected) {
            super.setSelected(selected);
            Drawable background = getBackground();
            if (Build.VERSION.SDK_INT >= 21 && background != null) {
                int color = Theme.getColor(selected ? Theme.key_chat_emojiPanelIconSelected : Theme.key_chat_emojiBottomPanelIcon);
                Theme.setSelectorDrawableColor(background, Color.argb(30, Color.red(color), Color.green(color), Color.blue(color)), true);
            }
        }
    };
    tab.setFocusable(true);
    if (Build.VERSION.SDK_INT >= 21) {
        RippleDrawable rippleDrawable = (RippleDrawable) Theme.createSelectorDrawable(Theme.getColor(Theme.key_chat_emojiBottomPanelIcon));
        Theme.setRippleDrawableForceSoftware(rippleDrawable);
        tab.setBackground(rippleDrawable);
    }
    tab.setImageDrawable(drawable);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(v -> {
        if (pager.getAdapter() instanceof IconTabProvider) {
            if (!((IconTabProvider) pager.getAdapter()).canScrollToTab(position)) {
                return;
            }
        }
        pager.setCurrentItem(position, false);
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    tab.setContentDescription(contentDescription);
}
 
Example 3
Source File: RecyclerListView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setListSelectorColor(int color)
{
    Theme.setSelectorDrawableColor(selectorDrawable, color, true);
}
 
Example 4
Source File: RecyclerListView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setListSelectorColor(int color)
{
    Theme.setSelectorDrawableColor(selectorDrawable, color, true);
}
 
Example 5
Source File: DrawerProfileCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    Drawable backgroundDrawable = Theme.getCachedWallpaper();
    String backgroundKey = applyBackground(false);
    boolean useImageBackground = !backgroundKey.equals(Theme.key_chats_menuTopBackground) && Theme.isCustomTheme() && !Theme.isPatternWallpaper() && backgroundDrawable != null && !(backgroundDrawable instanceof ColorDrawable) && !(backgroundDrawable instanceof GradientDrawable);
    boolean drawCatsShadow = false;
    int color;
    int darkBackColor = 0;
    if (!useImageBackground && Theme.hasThemeKey(Theme.key_chats_menuTopShadowCats)) {
        color = Theme.getColor(Theme.key_chats_menuTopShadowCats);
        drawCatsShadow = true;
    } else {
        if (Theme.hasThemeKey(Theme.key_chats_menuTopShadow)) {
            color = Theme.getColor(Theme.key_chats_menuTopShadow);
        } else {
            color = Theme.getServiceMessageColor() | 0xff000000;
        }
    }
    if (currentColor == null || currentColor != color) {
        currentColor = color;
        shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    }
    color = Theme.getColor(Theme.key_chats_menuName);
    if (currentMoonColor == null || currentColor != color) {
        currentMoonColor = color;
        darkThemeView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    }
    nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName));
    if (useImageBackground) {
        phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone));
        if (shadowView.getVisibility() != VISIBLE) {
            shadowView.setVisibility(VISIBLE);
        }
        if (backgroundDrawable instanceof ColorDrawable || backgroundDrawable instanceof GradientDrawable) {
            backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            backgroundDrawable.draw(canvas);
            darkBackColor = Theme.getColor(Theme.key_listSelector);
        } else if (backgroundDrawable instanceof BitmapDrawable) {
            Bitmap bitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
            float scaleX = (float) getMeasuredWidth() / (float) bitmap.getWidth();
            float scaleY = (float) getMeasuredHeight() / (float) bitmap.getHeight();
            float scale = scaleX < scaleY ? scaleY : scaleX;
            int width = (int) (getMeasuredWidth() / scale);
            int height = (int) (getMeasuredHeight() / scale);
            int x = (bitmap.getWidth() - width) / 2;
            int y = (bitmap.getHeight() - height) / 2;
            srcRect.set(x, y, x + width, y + height);
            destRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            try {
                canvas.drawBitmap(bitmap, srcRect, destRect, paint);
            } catch (Throwable e) {
                FileLog.e(e);
            }
            darkBackColor = (Theme.getServiceMessageColor() & 0x00ffffff) | 0x50000000;
        }
    } else {
        int visibility = drawCatsShadow? VISIBLE : INVISIBLE;
        if (shadowView.getVisibility() != visibility) {
            shadowView.setVisibility(visibility);
        }
        phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhoneCats));
        super.onDraw(canvas);
        darkBackColor = Theme.getColor(Theme.key_listSelector);
    }

    if (darkBackColor != 0) {
        if (darkBackColor != darkThemeBackgroundColor) {
            backPaint.setColor(darkThemeBackgroundColor = darkBackColor);
            if (Build.VERSION.SDK_INT >= 21) {
                Theme.setSelectorDrawableColor(darkThemeView.getBackground(), darkThemeBackgroundColor = darkBackColor, true);
            }
        }
        if (useImageBackground && backgroundDrawable instanceof BitmapDrawable) {
            canvas.drawCircle(darkThemeView.getX() + darkThemeView.getMeasuredWidth() / 2, darkThemeView.getY() + darkThemeView.getMeasuredHeight() / 2, AndroidUtilities.dp(17), backPaint);
        }
    }

    if (snowflakesEffect != null) {
        snowflakesEffect.onDraw(this, canvas);
    }
}
 
Example 6
Source File: RecyclerListView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void setListSelectorColor(int color) {
    Theme.setSelectorDrawableColor(selectorDrawable, color, true);
}
 
Example 7
Source File: ChatAttachAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void checkColors() {
    if (buttonsRecyclerView == null) {
        return;
    }
    int count = buttonsRecyclerView.getChildCount();
    for (int a = 0; a < count; a++) {
        applyAttachButtonColors(buttonsRecyclerView.getChildAt(a));
    }
    selectedTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));

    doneItem.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));

    selectedMenuItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack));
    Theme.setDrawableColor(selectedMenuItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector));
    selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false);
    selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), true);
    selectedMenuItem.redrawPopup(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));

    searchItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack));
    Theme.setDrawableColor(searchItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector));

    commentTextView.updateColors();

    if (sendPopupLayout != null) {
        for (int a = 0; a < itemCells.length; a++) {
            if (itemCells[a] != null) {
                itemCells[a].setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon));
                itemCells[a].setSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector));
            }
        }
        sendPopupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
        if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
            sendPopupLayout.invalidate();
        }
    }

    Theme.setSelectorDrawableColor(writeButtonDrawable, Theme.getColor(Theme.key_dialogFloatingButton), false);
    Theme.setSelectorDrawableColor(writeButtonDrawable, Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true);
    writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));

    actionBarShadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine));

    buttonsRecyclerView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
    buttonsRecyclerView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));

    frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));

    selectedCountView.invalidate();

    actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
    actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
    actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));

    Theme.setDrawableColor(shadowDrawable, Theme.getColor(Theme.key_dialogBackground));

    containerView.invalidate();

    for (int a = 0; a < layouts.length; a++) {
        if (layouts[a] != null) {
            layouts[a].checkColors();
        }
    }
}
 
Example 8
Source File: DrawerProfileCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    Drawable backgroundDrawable = Theme.getCachedWallpaper();
    String backgroundKey = applyBackground(false);
    boolean useImageBackground = !backgroundKey.equals(Theme.key_chats_menuTopBackground) && Theme.isCustomTheme() && !Theme.isPatternWallpaper() && backgroundDrawable != null && !(backgroundDrawable instanceof ColorDrawable) && !(backgroundDrawable instanceof GradientDrawable);
    boolean drawCatsShadow = false;
    int color;
    int darkBackColor = 0;
    if (!useImageBackground && Theme.hasThemeKey(Theme.key_chats_menuTopShadowCats)) {
        color = Theme.getColor(Theme.key_chats_menuTopShadowCats);
        drawCatsShadow = true;
    } else {
        if (Theme.hasThemeKey(Theme.key_chats_menuTopShadow)) {
            color = Theme.getColor(Theme.key_chats_menuTopShadow);
        } else {
            color = Theme.getServiceMessageColor() | 0xff000000;
        }
    }
    if (currentColor == null || currentColor != color) {
        currentColor = color;
        shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    }
    color = Theme.getColor(Theme.key_chats_menuName);
    if (currentMoonColor == null || currentColor != color) {
        currentMoonColor = color;
        darkThemeView.getDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    }
    nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName));
    if (useImageBackground) {
        phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone));
        if (shadowView.getVisibility() != VISIBLE) {
            shadowView.setVisibility(VISIBLE);
        }
        if (backgroundDrawable instanceof ColorDrawable || backgroundDrawable instanceof GradientDrawable) {
            backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            backgroundDrawable.draw(canvas);
            darkBackColor = Theme.getColor(Theme.key_listSelector);
        } else if (backgroundDrawable instanceof BitmapDrawable) {
            Bitmap bitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
            float scaleX = (float) getMeasuredWidth() / (float) bitmap.getWidth();
            float scaleY = (float) getMeasuredHeight() / (float) bitmap.getHeight();
            float scale = scaleX < scaleY ? scaleY : scaleX;
            int width = (int) (getMeasuredWidth() / scale);
            int height = (int) (getMeasuredHeight() / scale);
            int x = (bitmap.getWidth() - width) / 2;
            int y = (bitmap.getHeight() - height) / 2;
            srcRect.set(x, y, x + width, y + height);
            destRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            try {
                canvas.drawBitmap(bitmap, srcRect, destRect, paint);
            } catch (Throwable e) {
                FileLog.e(e);
            }
            darkBackColor = (Theme.getServiceMessageColor() & 0x00ffffff) | 0x50000000;
        }
    } else {
        int visibility = drawCatsShadow? VISIBLE : INVISIBLE;
        if (shadowView.getVisibility() != visibility) {
            shadowView.setVisibility(visibility);
        }
        phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhoneCats));
        super.onDraw(canvas);
        darkBackColor = Theme.getColor(Theme.key_listSelector);
    }

    if (darkBackColor != 0) {
        if (darkBackColor != darkThemeBackgroundColor) {
            backPaint.setColor(darkThemeBackgroundColor = darkBackColor);
            if (Build.VERSION.SDK_INT >= 21) {
                Theme.setSelectorDrawableColor(darkThemeView.getBackground(), darkThemeBackgroundColor = darkBackColor, true);
            }
        }
        if (useImageBackground && backgroundDrawable instanceof BitmapDrawable) {
            canvas.drawCircle(darkThemeView.getX() + darkThemeView.getMeasuredWidth() / 2, darkThemeView.getY() + darkThemeView.getMeasuredHeight() / 2, AndroidUtilities.dp(17), backPaint);
        }
    }

    if (snowflakesEffect != null) {
        snowflakesEffect.onDraw(this, canvas);
    }
}
 
Example 9
Source File: RecyclerListView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void setListSelectorColor(int color) {
    Theme.setSelectorDrawableColor(selectorDrawable, color, true);
}
 
Example 10
Source File: ChatAttachAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void checkColors() {
    if (buttonsRecyclerView == null) {
        return;
    }
    int count = buttonsRecyclerView.getChildCount();
    for (int a = 0; a < count; a++) {
        applyAttachButtonColors(buttonsRecyclerView.getChildAt(a));
    }
    selectedTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));

    doneItem.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));

    selectedMenuItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack));
    Theme.setDrawableColor(selectedMenuItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector));
    selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false);
    selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), true);
    selectedMenuItem.redrawPopup(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));

    searchItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack));
    Theme.setDrawableColor(searchItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector));

    commentTextView.updateColors();

    if (sendPopupLayout != null) {
        for (int a = 0; a < itemCells.length; a++) {
            if (itemCells[a] != null) {
                itemCells[a].setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon));
                itemCells[a].setSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector));
            }
        }
        sendPopupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
        if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
            sendPopupLayout.invalidate();
        }
    }

    Theme.setSelectorDrawableColor(writeButtonDrawable, Theme.getColor(Theme.key_dialogFloatingButton), false);
    Theme.setSelectorDrawableColor(writeButtonDrawable, Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true);
    writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));

    actionBarShadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine));

    buttonsRecyclerView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
    buttonsRecyclerView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));

    frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));

    selectedCountView.invalidate();

    actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
    actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
    actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));

    Theme.setDrawableColor(shadowDrawable, Theme.getColor(Theme.key_dialogBackground));

    containerView.invalidate();

    for (int a = 0; a < layouts.length; a++) {
        if (layouts[a] != null) {
            layouts[a].checkColors();
        }
    }
}