Java Code Examples for org.telegram.ui.ActionBar.Theme#hasThemeKey()
The following examples show how to use
org.telegram.ui.ActionBar.Theme#hasThemeKey() .
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: StatisticActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void recolor() { chartView.updateColors(); chartView.invalidate(); zoomedChartView.updateColors(); zoomedChartView.invalidate(); chartHeaderView.recolor(); chartHeaderView.invalidate(); if (data != null && data.chartData != null && data.chartData.lines != null && data.chartData.lines.size() > 1) { for (int i = 0; i < data.chartData.lines.size(); i++) { int color; if (data.chartData.lines.get(i).colorKey != null && Theme.hasThemeKey(data.chartData.lines.get(i).colorKey)) { color = Theme.getColor(data.chartData.lines.get(i).colorKey); } else { boolean darkBackground = ColorUtils.calculateLuminance(Theme.getColor(Theme.key_windowBackgroundWhite)) < 0.5f; color = darkBackground ? data.chartData.lines.get(i).colorDark : data.chartData.lines.get(i).color; } if (i < checkBoxes.size()) { checkBoxes.get(i).recolor(color); } } } progressView.setProgressColor(Theme.getColor(Theme.key_progressCircle)); errorTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray4)); }
Example 2
Source File: DrawerProfileCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public String applyBackground(boolean force) { String currentTag = (String) getTag(); String backgroundKey = Theme.hasThemeKey(Theme.key_chats_menuTopBackground) && Theme.getColor(Theme.key_chats_menuTopBackground) != 0 ? Theme.key_chats_menuTopBackground : Theme.key_chats_menuTopBackgroundCats; if (force || !backgroundKey.equals(currentTag)) { setBackgroundColor(Theme.getColor(backgroundKey)); setTag(backgroundKey); } return backgroundKey; }
Example 3
Source File: LineViewData.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void updateColors() { if (line.colorKey != null && Theme.hasThemeKey(line.colorKey)) { lineColor = Theme.getColor(line.colorKey); } else { int color = Theme.getColor(Theme.key_windowBackgroundWhite); boolean darkBackground = ColorUtils.calculateLuminance(color) < 0.5f; lineColor = darkBackground ? line.colorDark : line.color; } paint.setColor(lineColor); bottomLinePaint.setColor(lineColor); selectionPaint.setColor(lineColor); }
Example 4
Source File: StatisticActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void recolor() { chartView.updateColors(); chartView.invalidate(); zoomedChartView.updateColors(); zoomedChartView.invalidate(); chartHeaderView.recolor(); chartHeaderView.invalidate(); if (data != null && data.chartData != null && data.chartData.lines != null && data.chartData.lines.size() > 1) { for (int i = 0; i < data.chartData.lines.size(); i++) { int color; if (data.chartData.lines.get(i).colorKey != null && Theme.hasThemeKey(data.chartData.lines.get(i).colorKey)) { color = Theme.getColor(data.chartData.lines.get(i).colorKey); } else { boolean darkBackground = ColorUtils.calculateLuminance(Theme.getColor(Theme.key_windowBackgroundWhite)) < 0.5f; color = darkBackground ? data.chartData.lines.get(i).colorDark : data.chartData.lines.get(i).color; } if (i < checkBoxes.size()) { checkBoxes.get(i).recolor(color); } } } progressView.setProgressColor(Theme.getColor(Theme.key_progressCircle)); errorTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray4)); }
Example 5
Source File: DrawerProfileCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public String applyBackground(boolean force) { String currentTag = (String) getTag(); String backgroundKey = Theme.hasThemeKey(Theme.key_chats_menuTopBackground) && Theme.getColor(Theme.key_chats_menuTopBackground) != 0 ? Theme.key_chats_menuTopBackground : Theme.key_chats_menuTopBackgroundCats; if (force || !backgroundKey.equals(currentTag)) { setBackgroundColor(Theme.getColor(backgroundKey)); setTag(backgroundKey); } return backgroundKey; }
Example 6
Source File: LineViewData.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void updateColors() { if (line.colorKey != null && Theme.hasThemeKey(line.colorKey)) { lineColor = Theme.getColor(line.colorKey); } else { int color = Theme.getColor(Theme.key_windowBackgroundWhite); boolean darkBackground = ColorUtils.calculateLuminance(color) < 0.5f; lineColor = darkBackground ? line.colorDark : line.color; } paint.setColor(lineColor); bottomLinePaint.setColor(lineColor); selectionPaint.setColor(lineColor); }
Example 7
Source File: DrawerProfileCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onDraw(Canvas canvas) { Drawable backgroundDrawable = Theme.getCachedWallpaper(); int color; 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)); } nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName)); if (Theme.isCustomTheme() && backgroundDrawable != null) { phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone)); shadowView.setVisibility(VISIBLE); if (backgroundDrawable instanceof ColorDrawable) { backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); backgroundDrawable.draw(canvas); } 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); } } } else { shadowView.setVisibility(INVISIBLE); phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhoneCats)); super.onDraw(canvas); } }
Example 8
Source File: DrawerProfileCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onDraw(Canvas canvas) { Drawable backgroundDrawable = Theme.getCachedWallpaper(); int color; 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)); } nameTextView.setTextColor(Theme.getColor(Theme.key_chats_menuName)); if (Theme.isCustomTheme() && backgroundDrawable != null) { phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhone)); shadowView.setVisibility(VISIBLE); if (backgroundDrawable instanceof ColorDrawable) { backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); backgroundDrawable.draw(canvas); } 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); } } } else { shadowView.setVisibility(INVISIBLE); phoneTextView.setTextColor(Theme.getColor(Theme.key_chats_menuPhoneCats)); super.onDraw(canvas); } }
Example 9
Source File: StatisticActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public ArrayList<ThemeDescription> getThemeDescriptions() { ThemeDescription.ThemeDescriptionDelegate themeDelegate = () -> { if (recyclerListView != null) { int count = recyclerListView.getChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getChildAt(a)); } count = recyclerListView.getHiddenChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getHiddenChildAt(a)); } count = recyclerListView.getCachedChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getCachedChildAt(a)); } count = recyclerListView.getAttachedScrapChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getAttachedScrapChildAt(a)); } recyclerListView.getRecycledViewPool().clear(); } if (sharedUi != null) { sharedUi.invalidate(); } }; ArrayList<ThemeDescription> arrayList = new ArrayList<>(); arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"message"}, null, null, null, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"views"}, null, null, null, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"shares"}, null, null, null, Theme.key_dialogTextGray4)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"date"}, null, null, null, Theme.key_dialogTextGray4)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartSignature)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartSignatureAlpha)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartHintLine)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartActiveLine)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartInactivePickerChart)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartActivePickerChart)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_dialogBackground)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_windowBackgroundWhite)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_windowBackgroundWhiteGrayText2)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_actionBarActionModeDefaultSelector)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundGray)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundGrayShadow)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundWhiteGreenText2)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundWhiteRedText5)); arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite)); arrayList.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_player_actionBarTitle)); arrayList.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getSubtitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_player_actionBarSubtitle, null)); for (int i = 0; i < 9; i++) { ChartViewData chartViewData; if (i == 0) { chartViewData = growthData; } else if (i == 1) { chartViewData = followersData; } else if (i == 2) { chartViewData = interactionsData; } else if (i == 3) { chartViewData = ivInteractionsData; } else if (i == 4) { chartViewData = viewsBySourceData; } else if (i == 5) { chartViewData = newFollowersBySourceData; } else if (i == 6) { chartViewData = notificationsData; } else if (i == 7) { chartViewData = topHoursData; } else { chartViewData = languagesData; } if (chartViewData != null && chartViewData.chartData != null) { for (ChartData.Line l : chartViewData.chartData.lines) { if (l.colorKey != null) { if (!Theme.hasThemeKey(l.colorKey)) { Theme.setColor(l.colorKey, Theme.isCurrentThemeNight() ? l.colorDark : l.color, false); Theme.setDefaultColor(l.colorKey, l.color); } arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, l.colorKey)); } } } } return arrayList; }
Example 10
Source File: DrawerProfileCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@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 11
Source File: ThemePreviewActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void setBackgroundColor(int color, int num, boolean applyNow) { if (num == 0) { backgroundColor = color; } else { backgroundGradientColor = color; } if (checkBoxView != null) { for (int a = 0; a < checkBoxView.length; a++) { if (checkBoxView[a] != null) { if (num == 0) { checkBoxView[a].setBackgroundColor(color); } else { checkBoxView[a].setBackgroundGradientColor(color); } } } } if (backgroundGradientColor != 0) { GradientDrawable gradientDrawable = new GradientDrawable(BackgroundGradientDrawable.getGradientOrientation(backgroundRotation), new int[]{backgroundColor, backgroundGradientColor}); backgroundImage.setBackground(gradientDrawable); patternColor = AndroidUtilities.getPatternColor(AndroidUtilities.getAverageColor(backgroundColor, backgroundGradientColor)); } else { backgroundImage.setBackgroundColor(backgroundColor); patternColor = AndroidUtilities.getPatternColor(backgroundColor); } if (!Theme.hasThemeKey(Theme.key_chat_serviceBackground)) { Theme.applyChatServiceMessageColor(new int[]{patternColor, patternColor, patternColor, patternColor}); } if (backgroundImage != null) { backgroundImage.getImageReceiver().setColorFilter(new PorterDuffColorFilter(patternColor, blendMode)); backgroundImage.getImageReceiver().setAlpha(currentIntensity); backgroundImage.invalidate(); } if (listView2 != null) { listView2.invalidateViews(); } if (buttonsContainer != null) { for (int a = 0, N = buttonsContainer.getChildCount(); a < N; a++) { buttonsContainer.getChildAt(a).invalidate(); } } if (radialProgress != null) { radialProgress.setColors(Theme.key_chat_serviceBackground, Theme.key_chat_serviceBackground, Theme.key_chat_serviceText, Theme.key_chat_serviceText); } }
Example 12
Source File: LegendSignatureView.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setData(int index, long date, ArrayList<LineViewData> lines, boolean animateChanges) { int n = holdes.length; if (animateChanges) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionSet transition = new TransitionSet(); transition. addTransition(new Fade(Fade.OUT).setDuration(100)). addTransition(new ChangeBounds().setDuration(150)). addTransition(new Fade(Fade.IN).setDuration(100)); transition.setOrdering(TransitionSet.ORDERING_SEQUENTIAL); TransitionManager.beginDelayedTransition(this, transition); } } if (isTopHourChart) { time.setText(String.format(Locale.ENGLISH, "%02d:00", date)); } else { time.setText(formatData(new Date(date))); if (useHour) hourTime.setText(hourFormat.format(date)); } int sum = 0; for (int i = 0; i < n; i++) { if (lines.get(i).enabled) sum += lines.get(i).line.y[index]; } for (int i = 0; i < n; i++) { Holder h = holdes[i]; if (!lines.get(i).enabled) { h.root.setVisibility(View.GONE); } else { ChartData.Line l = lines.get(i).line; if (h.root.getMeasuredHeight() == 0) { h.root.requestLayout(); } h.root.setVisibility(View.VISIBLE); h.value.setText(formatWholeNumber(l.y[index])); h.signature.setText(l.name); if (l.colorKey != null && Theme.hasThemeKey(l.colorKey)) { h.value.setTextColor(Theme.getColor(l.colorKey)); } else { h.value.setTextColor(Theme.getCurrentTheme().isDark() ? l.colorDark : l.color); } h.signature.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); if (showPercentage && h.percentage != null) { h.percentage.setVisibility(VISIBLE); h.percentage.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); float v = lines.get(i).line.y[index] / (float) sum; if (v < 0.1f && v != 0f) { h.percentage.setText(String.format(Locale.ENGLISH, "%.1f%s", (100f * v), "%")); } else { h.percentage.setText(String.format(Locale.ENGLISH, "%d%s", Math.round(100 * v), "%")); } } } } if (zoomEnabled) { canGoZoom = sum > 0; chevron.setVisibility(sum > 0 ? View.VISIBLE : View.GONE); } else { canGoZoom = false; chevron.setVisibility(View.GONE); } }
Example 13
Source File: StatisticActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public ArrayList<ThemeDescription> getThemeDescriptions() { ThemeDescription.ThemeDescriptionDelegate themeDelegate = () -> { if (recyclerListView != null) { int count = recyclerListView.getChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getChildAt(a)); } count = recyclerListView.getHiddenChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getHiddenChildAt(a)); } count = recyclerListView.getCachedChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getCachedChildAt(a)); } count = recyclerListView.getAttachedScrapChildCount(); for (int a = 0; a < count; a++) { recolorRecyclerItem(recyclerListView.getAttachedScrapChildAt(a)); } recyclerListView.getRecycledViewPool().clear(); } if (sharedUi != null) { sharedUi.invalidate(); } }; ArrayList<ThemeDescription> arrayList = new ArrayList<>(); arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"message"}, null, null, null, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"views"}, null, null, null, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"shares"}, null, null, null, Theme.key_dialogTextGray4)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{StatisticPostInfoCell.class}, new String[]{"date"}, null, null, null, Theme.key_dialogTextGray4)); arrayList.add(new ThemeDescription(recyclerListView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_dialogTextBlack)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartSignature)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartSignatureAlpha)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartHintLine)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartActiveLine)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartInactivePickerChart)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_statisticChartActivePickerChart)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_dialogBackground)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_windowBackgroundWhite)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_windowBackgroundWhiteGrayText2)); arrayList.add(new ThemeDescription(null, 0, null, null, null, null, themeDelegate, Theme.key_actionBarActionModeDefaultSelector)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundGray)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundGrayShadow)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundWhiteGreenText2)); arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, Theme.key_windowBackgroundWhiteRedText5)); arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite)); arrayList.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_player_actionBarTitle)); arrayList.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getSubtitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_player_actionBarSubtitle, null)); for (int i = 0; i < 9; i++) { ChartViewData chartViewData; if (i == 0) { chartViewData = growthData; } else if (i == 1) { chartViewData = followersData; } else if (i == 2) { chartViewData = interactionsData; } else if (i == 3) { chartViewData = ivInteractionsData; } else if (i == 4) { chartViewData = viewsBySourceData; } else if (i == 5) { chartViewData = newFollowersBySourceData; } else if (i == 6) { chartViewData = notificationsData; } else if (i == 7) { chartViewData = topHoursData; } else { chartViewData = languagesData; } if (chartViewData != null && chartViewData.chartData != null) { for (ChartData.Line l : chartViewData.chartData.lines) { if (l.colorKey != null) { if (!Theme.hasThemeKey(l.colorKey)) { Theme.setColor(l.colorKey, Theme.isCurrentThemeNight() ? l.colorDark : l.color, false); Theme.setDefaultColor(l.colorKey, l.color); } arrayList.add(new ThemeDescription(null, 0, null, null, null, themeDelegate, l.colorKey)); } } } } return arrayList; }
Example 14
Source File: DrawerProfileCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
@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 15
Source File: ThemePreviewActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void setBackgroundColor(int color, int num, boolean applyNow) { if (num == 0) { backgroundColor = color; } else { backgroundGradientColor = color; } if (checkBoxView != null) { for (int a = 0; a < checkBoxView.length; a++) { if (checkBoxView[a] != null) { if (num == 0) { checkBoxView[a].setBackgroundColor(color); } else { checkBoxView[a].setBackgroundGradientColor(color); } } } } if (backgroundGradientColor != 0) { GradientDrawable gradientDrawable = new GradientDrawable(BackgroundGradientDrawable.getGradientOrientation(backgroundRotation), new int[]{backgroundColor, backgroundGradientColor}); backgroundImage.setBackground(gradientDrawable); patternColor = AndroidUtilities.getPatternColor(AndroidUtilities.getAverageColor(backgroundColor, backgroundGradientColor)); } else { backgroundImage.setBackgroundColor(backgroundColor); patternColor = AndroidUtilities.getPatternColor(backgroundColor); } if (!Theme.hasThemeKey(Theme.key_chat_serviceBackground)) { Theme.applyChatServiceMessageColor(new int[]{patternColor, patternColor, patternColor, patternColor}); } if (backgroundImage != null) { backgroundImage.getImageReceiver().setColorFilter(new PorterDuffColorFilter(patternColor, blendMode)); backgroundImage.getImageReceiver().setAlpha(currentIntensity); backgroundImage.invalidate(); } if (listView2 != null) { listView2.invalidateViews(); } if (buttonsContainer != null) { for (int a = 0, N = buttonsContainer.getChildCount(); a < N; a++) { buttonsContainer.getChildAt(a).invalidate(); } } if (radialProgress != null) { radialProgress.setColors(Theme.key_chat_serviceBackground, Theme.key_chat_serviceBackground, Theme.key_chat_serviceText, Theme.key_chat_serviceText); } }
Example 16
Source File: LegendSignatureView.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setData(int index, long date, ArrayList<LineViewData> lines, boolean animateChanges) { int n = holdes.length; if (animateChanges) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionSet transition = new TransitionSet(); transition. addTransition(new Fade(Fade.OUT).setDuration(100)). addTransition(new ChangeBounds().setDuration(150)). addTransition(new Fade(Fade.IN).setDuration(100)); transition.setOrdering(TransitionSet.ORDERING_SEQUENTIAL); TransitionManager.beginDelayedTransition(this, transition); } } if (isTopHourChart) { time.setText(String.format(Locale.ENGLISH, "%02d:00", date)); } else { time.setText(formatData(new Date(date))); if (useHour) hourTime.setText(hourFormat.format(date)); } int sum = 0; for (int i = 0; i < n; i++) { if (lines.get(i).enabled) sum += lines.get(i).line.y[index]; } for (int i = 0; i < n; i++) { Holder h = holdes[i]; if (!lines.get(i).enabled) { h.root.setVisibility(View.GONE); } else { ChartData.Line l = lines.get(i).line; if (h.root.getMeasuredHeight() == 0) { h.root.requestLayout(); } h.root.setVisibility(View.VISIBLE); h.value.setText(formatWholeNumber(l.y[index])); h.signature.setText(l.name); if (l.colorKey != null && Theme.hasThemeKey(l.colorKey)) { h.value.setTextColor(Theme.getColor(l.colorKey)); } else { h.value.setTextColor(Theme.getCurrentTheme().isDark() ? l.colorDark : l.color); } h.signature.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); if (showPercentage && h.percentage != null) { h.percentage.setVisibility(VISIBLE); h.percentage.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); float v = lines.get(i).line.y[index] / (float) sum; if (v < 0.1f && v != 0f) { h.percentage.setText(String.format(Locale.ENGLISH, "%.1f%s", (100f * v), "%")); } else { h.percentage.setText(String.format(Locale.ENGLISH, "%d%s", Math.round(100 * v), "%")); } } } } if (zoomEnabled) { canGoZoom = sum > 0; chevron.setVisibility(sum > 0 ? View.VISIBLE : View.GONE); } else { canGoZoom = false; chevron.setVisibility(View.GONE); } }