Search in sources :

Example 1 with AnimatedArrowDrawable

use of org.telegram.ui.Components.AnimatedArrowDrawable in project Telegram-FOSS by Telegram-FOSS-Team.

the class ThemeDescription method setColor.

public void setColor(int color, boolean useDefault, boolean save) {
    if (save) {
        Theme.setColor(currentKey, color, useDefault);
    }
    currentColor = color;
    if (alphaOverride > 0) {
        color = Color.argb(alphaOverride, Color.red(color), Color.green(color), Color.blue(color));
    }
    if (paintToUpdate != null) {
        for (int a = 0; a < paintToUpdate.length; a++) {
            if ((changeFlags & FLAG_LINKCOLOR) != 0 && paintToUpdate[a] instanceof TextPaint) {
                ((TextPaint) paintToUpdate[a]).linkColor = color;
            } else {
                paintToUpdate[a].setColor(color);
            }
        }
    }
    if (drawablesToUpdate != null) {
        for (int a = 0; a < drawablesToUpdate.length; a++) {
            if (drawablesToUpdate[a] == null) {
                continue;
            }
            if (drawablesToUpdate[a] instanceof BackDrawable) {
                ((BackDrawable) drawablesToUpdate[a]).setColor(color);
            } else if (drawablesToUpdate[a] instanceof ScamDrawable) {
                ((ScamDrawable) drawablesToUpdate[a]).setColor(color);
            } else if (drawablesToUpdate[a] instanceof RLottieDrawable) {
                if (lottieLayerName != null) {
                    ((RLottieDrawable) drawablesToUpdate[a]).setLayerColor(lottieLayerName + ".**", color);
                }
            } else if (drawablesToUpdate[a] instanceof CombinedDrawable) {
                if ((changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                    ((CombinedDrawable) drawablesToUpdate[a]).getBackground().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                } else {
                    ((CombinedDrawable) drawablesToUpdate[a]).getIcon().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                }
            } else if (drawablesToUpdate[a] instanceof AvatarDrawable) {
                ((AvatarDrawable) drawablesToUpdate[a]).setColor(color);
            } else if (drawablesToUpdate[a] instanceof AnimatedArrowDrawable) {
                ((AnimatedArrowDrawable) drawablesToUpdate[a]).setColor(color);
            } else {
                drawablesToUpdate[a].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
            }
        }
    }
    if (viewToInvalidate != null && listClasses == null && listClassesFieldName == null) {
        if ((changeFlags & FLAG_CHECKTAG) == 0 || checkTag(currentKey, viewToInvalidate)) {
            if ((changeFlags & FLAG_BACKGROUND) != 0) {
                Drawable background = viewToInvalidate.getBackground();
                if (background instanceof MessageBackgroundDrawable) {
                    ((MessageBackgroundDrawable) background).setColor(color);
                    ((MessageBackgroundDrawable) background).setCustomPaint(null);
                } else {
                    viewToInvalidate.setBackgroundColor(color);
                }
            }
            if ((changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
                    if (viewToInvalidate instanceof EditTextBoldCursor) {
                        ((EditTextBoldCursor) viewToInvalidate).setErrorLineColor(color);
                    }
                } else {
                    Drawable drawable = viewToInvalidate.getBackground();
                    if (drawable instanceof CombinedDrawable) {
                        if ((changeFlags & FLAG_DRAWABLESELECTEDSTATE) != 0) {
                            drawable = ((CombinedDrawable) drawable).getBackground();
                        } else {
                            drawable = ((CombinedDrawable) drawable).getIcon();
                        }
                    }
                    if (drawable != null) {
                        if (drawable instanceof StateListDrawable || Build.VERSION.SDK_INT >= 21 && drawable instanceof RippleDrawable) {
                            Theme.setSelectorDrawableColor(drawable, color, (changeFlags & FLAG_DRAWABLESELECTEDSTATE) != 0);
                        } else if (drawable instanceof ShapeDrawable) {
                            ((ShapeDrawable) drawable).getPaint().setColor(color);
                        } else {
                            drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                        }
                    }
                }
            }
        }
    }
    if (viewToInvalidate instanceof ActionBar) {
        if ((changeFlags & FLAG_AB_ITEMSCOLOR) != 0) {
            ((ActionBar) viewToInvalidate).setItemsColor(color, false);
        }
        if ((changeFlags & FLAG_AB_TITLECOLOR) != 0) {
            ((ActionBar) viewToInvalidate).setTitleColor(color);
        }
        if ((changeFlags & FLAG_AB_SELECTORCOLOR) != 0) {
            ((ActionBar) viewToInvalidate).setItemsBackgroundColor(color, false);
        }
        if ((changeFlags & FLAG_AB_AM_SELECTORCOLOR) != 0) {
            ((ActionBar) viewToInvalidate).setItemsBackgroundColor(color, true);
        }
        if ((changeFlags & FLAG_AB_AM_ITEMSCOLOR) != 0) {
            ((ActionBar) viewToInvalidate).setItemsColor(color, true);
        }
        if ((changeFlags & FLAG_AB_SUBTITLECOLOR) != 0) {
            ((ActionBar) viewToInvalidate).setSubtitleColor(color);
        }
        if ((changeFlags & FLAG_AB_AM_BACKGROUND) != 0) {
            ((ActionBar) viewToInvalidate).setActionModeColor(color);
        }
        if ((changeFlags & FLAG_AB_AM_TOPBACKGROUND) != 0) {
            ((ActionBar) viewToInvalidate).setActionModeTopColor(color);
        }
        if ((changeFlags & FLAG_AB_SEARCHPLACEHOLDER) != 0) {
            ((ActionBar) viewToInvalidate).setSearchTextColor(color, true);
        }
        if ((changeFlags & FLAG_AB_SEARCH) != 0) {
            ((ActionBar) viewToInvalidate).setSearchTextColor(color, false);
        }
        if ((changeFlags & FLAG_AB_SUBMENUITEM) != 0) {
            ((ActionBar) viewToInvalidate).setPopupItemsColor(color, (changeFlags & FLAG_IMAGECOLOR) != 0, false);
        }
        if ((changeFlags & FLAG_AB_SUBMENUBACKGROUND) != 0) {
            ((ActionBar) viewToInvalidate).setPopupBackgroundColor(color, false);
        }
    }
    if (viewToInvalidate instanceof VideoTimelineView) {
        ((VideoTimelineView) viewToInvalidate).setColor(color);
    }
    if (viewToInvalidate instanceof EmptyTextProgressView) {
        if ((changeFlags & FLAG_TEXTCOLOR) != 0) {
            ((EmptyTextProgressView) viewToInvalidate).setTextColor(color);
        } else if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
            ((EmptyTextProgressView) viewToInvalidate).setProgressBarColor(color);
        }
    }
    if (viewToInvalidate instanceof RadialProgressView) {
        ((RadialProgressView) viewToInvalidate).setProgressColor(color);
    } else if (viewToInvalidate instanceof LineProgressView) {
        if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
            ((LineProgressView) viewToInvalidate).setProgressColor(color);
        } else {
            ((LineProgressView) viewToInvalidate).setBackColor(color);
        }
    } else if (viewToInvalidate instanceof ContextProgressView) {
        ((ContextProgressView) viewToInvalidate).updateColors();
    } else if (viewToInvalidate instanceof SeekBarView) {
        if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
            ((SeekBarView) viewToInvalidate).setOuterColor(color);
        }
    }
    if ((changeFlags & FLAG_TEXTCOLOR) != 0) {
        if ((changeFlags & FLAG_CHECKTAG) == 0 || checkTag(currentKey, viewToInvalidate)) {
            if (viewToInvalidate instanceof TextView) {
                ((TextView) viewToInvalidate).setTextColor(color);
            } else if (viewToInvalidate instanceof NumberTextView) {
                ((NumberTextView) viewToInvalidate).setTextColor(color);
            } else if (viewToInvalidate instanceof SimpleTextView) {
                ((SimpleTextView) viewToInvalidate).setTextColor(color);
            } else if (viewToInvalidate instanceof ChatBigEmptyView) {
                ((ChatBigEmptyView) viewToInvalidate).setTextColor(color);
            }
        }
    }
    if ((changeFlags & FLAG_CURSORCOLOR) != 0) {
        if (viewToInvalidate instanceof EditTextBoldCursor) {
            ((EditTextBoldCursor) viewToInvalidate).setCursorColor(color);
        }
    }
    if ((changeFlags & FLAG_HINTTEXTCOLOR) != 0) {
        if (viewToInvalidate instanceof EditTextBoldCursor) {
            if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
                ((EditTextBoldCursor) viewToInvalidate).setHeaderHintColor(color);
            } else {
                ((EditTextBoldCursor) viewToInvalidate).setHintColor(color);
            }
        } else if (viewToInvalidate instanceof EditText) {
            ((EditText) viewToInvalidate).setHintTextColor(color);
        }
    }
    if (viewToInvalidate != null && (changeFlags & FLAG_SERVICEBACKGROUND) != 0) {
    }
    if ((changeFlags & FLAG_IMAGECOLOR) != 0) {
        if ((changeFlags & FLAG_CHECKTAG) == 0 || checkTag(currentKey, viewToInvalidate)) {
            if (viewToInvalidate instanceof ImageView) {
                if ((changeFlags & FLAG_USEBACKGROUNDDRAWABLE) != 0) {
                    Drawable drawable = ((ImageView) viewToInvalidate).getDrawable();
                    if (drawable instanceof StateListDrawable || Build.VERSION.SDK_INT >= 21 && drawable instanceof RippleDrawable) {
                        Theme.setSelectorDrawableColor(drawable, color, (changeFlags & FLAG_DRAWABLESELECTEDSTATE) != 0);
                    }
                } else {
                    ((ImageView) viewToInvalidate).setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                }
            } else if (viewToInvalidate instanceof BackupImageView) {
            // ((BackupImageView) viewToInvalidate).setResourceImageColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
            } else if (viewToInvalidate instanceof SimpleTextView) {
                SimpleTextView textView = (SimpleTextView) viewToInvalidate;
                textView.setSideDrawablesColor(color);
            } else if (viewToInvalidate instanceof TextView) {
                Drawable[] drawables = ((TextView) viewToInvalidate).getCompoundDrawables();
                if (drawables != null) {
                    for (int a = 0; a < drawables.length; a++) {
                        if (drawables[a] != null) {
                            drawables[a].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                        }
                    }
                }
            }
        }
    }
    if (viewToInvalidate instanceof ScrollView) {
        if ((changeFlags & FLAG_LISTGLOWCOLOR) != 0) {
            AndroidUtilities.setScrollViewEdgeEffectColor((ScrollView) viewToInvalidate, color);
        }
    }
    if (viewToInvalidate instanceof ViewPager) {
        if ((changeFlags & FLAG_LISTGLOWCOLOR) != 0) {
            AndroidUtilities.setViewPagerEdgeEffectColor((ViewPager) viewToInvalidate, color);
        }
    }
    if (viewToInvalidate instanceof RecyclerListView) {
        RecyclerListView recyclerListView = (RecyclerListView) viewToInvalidate;
        if ((changeFlags & FLAG_SELECTOR) != 0) {
            recyclerListView.setListSelectorColor(color);
        }
        if ((changeFlags & FLAG_FASTSCROLL) != 0) {
            recyclerListView.updateFastScrollColors();
        }
        if ((changeFlags & FLAG_LISTGLOWCOLOR) != 0) {
            recyclerListView.setGlowColor(color);
        }
        if ((changeFlags & FLAG_SECTIONS) != 0) {
            ArrayList<View> headers = recyclerListView.getHeaders();
            if (headers != null) {
                for (int a = 0; a < headers.size(); a++) {
                    processViewColor(headers.get(a), color);
                }
            }
            headers = recyclerListView.getHeadersCache();
            if (headers != null) {
                for (int a = 0; a < headers.size(); a++) {
                    processViewColor(headers.get(a), color);
                }
            }
            View header = recyclerListView.getPinnedHeader();
            if (header != null) {
                processViewColor(header, color);
            }
        }
    } else if (viewToInvalidate != null && (listClasses == null || listClasses.length == 0)) {
        if ((changeFlags & FLAG_SELECTOR) != 0) {
            viewToInvalidate.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        } else if ((changeFlags & FLAG_SELECTORWHITE) != 0) {
            viewToInvalidate.setBackgroundDrawable(Theme.getSelectorDrawable(true));
        }
    }
    if (listClasses != null) {
        if (viewToInvalidate instanceof RecyclerListView) {
            RecyclerListView recyclerListView = (RecyclerListView) viewToInvalidate;
            recyclerListView.getRecycledViewPool().clear();
            int count = recyclerListView.getHiddenChildCount();
            for (int a = 0; a < count; a++) {
                processViewColor(recyclerListView.getHiddenChildAt(a), color);
            }
            count = recyclerListView.getCachedChildCount();
            for (int a = 0; a < count; a++) {
                processViewColor(recyclerListView.getCachedChildAt(a), color);
            }
            count = recyclerListView.getAttachedScrapChildCount();
            for (int a = 0; a < count; a++) {
                processViewColor(recyclerListView.getAttachedScrapChildAt(a), color);
            }
        }
        if (viewToInvalidate instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) viewToInvalidate;
            int count = viewGroup.getChildCount();
            for (int a = 0; a < count; a++) {
                processViewColor(viewGroup.getChildAt(a), color);
            }
        }
        processViewColor(viewToInvalidate, color);
    }
    if (delegate != null) {
        delegate.didSetColor();
    }
    if (viewToInvalidate != null) {
        viewToInvalidate.invalidate();
    }
}
Also used : ContextProgressView(org.telegram.ui.Components.ContextProgressView) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) StateListDrawable(android.graphics.drawable.StateListDrawable) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ScamDrawable(org.telegram.ui.Components.ScamDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) BackupImageView(org.telegram.ui.Components.BackupImageView) TextView(android.widget.TextView) NumberTextView(org.telegram.ui.Components.NumberTextView) NumberTextView(org.telegram.ui.Components.NumberTextView) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) VideoTimelineView(org.telegram.ui.Components.VideoTimelineView) EditText(android.widget.EditText) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) ViewGroup(android.view.ViewGroup) AnimatedArrowDrawable(org.telegram.ui.Components.AnimatedArrowDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) LetterDrawable(org.telegram.ui.Components.LetterDrawable) ScamDrawable(org.telegram.ui.Components.ScamDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) SeekBarView(org.telegram.ui.Components.SeekBarView) ViewPager(androidx.viewpager.widget.ViewPager) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) View(android.view.View) ContextProgressView(org.telegram.ui.Components.ContextProgressView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) VideoTimelineView(org.telegram.ui.Components.VideoTimelineView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) SeekBarView(org.telegram.ui.Components.SeekBarView) BackupImageView(org.telegram.ui.Components.BackupImageView) LineProgressView(org.telegram.ui.Components.LineProgressView) NumberTextView(org.telegram.ui.Components.NumberTextView) ScrollView(android.widget.ScrollView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) RippleDrawable(android.graphics.drawable.RippleDrawable) ScrollView(android.widget.ScrollView) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) LineProgressView(org.telegram.ui.Components.LineProgressView) AnimatedArrowDrawable(org.telegram.ui.Components.AnimatedArrowDrawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable)

Aggregations

Paint (android.graphics.Paint)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 RippleDrawable (android.graphics.drawable.RippleDrawable)1 ShapeDrawable (android.graphics.drawable.ShapeDrawable)1 StateListDrawable (android.graphics.drawable.StateListDrawable)1 TextPaint (android.text.TextPaint)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 ViewPager (androidx.viewpager.widget.ViewPager)1 AnimatedArrowDrawable (org.telegram.ui.Components.AnimatedArrowDrawable)1 AvatarDrawable (org.telegram.ui.Components.AvatarDrawable)1 BackupImageView (org.telegram.ui.Components.BackupImageView)1 ChatBigEmptyView (org.telegram.ui.Components.ChatBigEmptyView)1