Search in sources :

Example 6 with EmojiThemes

use of org.telegram.ui.ActionBar.EmojiThemes in project Telegram-FOSS by Telegram-FOSS-Team.

the class QrActivity method createView.

@Override
public View createView(Context context) {
    homeTheme.loadPreviewColors(currentAccount);
    isCurrentThemeDark = Theme.getActiveTheme().isDark();
    actionBar.setAddToContainer(false);
    actionBar.setBackground(null);
    actionBar.setItemsColor(0xffffffff, false);
    FrameLayout rootLayout = new FrameLayout(context) {

        private boolean prevIsPortrait;

        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            super.dispatchTouchEvent(ev);
            return true;
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            int height = MeasureSpec.getSize(heightMeasureSpec);
            boolean isPortrait = width < height;
            avatarImageView.setVisibility(isPortrait ? View.VISIBLE : View.GONE);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            if (isPortrait) {
                themeLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
                qrView.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(260), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(330), MeasureSpec.EXACTLY));
            } else {
                themeLayout.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(256), MeasureSpec.EXACTLY), heightMeasureSpec);
                qrView.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(260), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(310), MeasureSpec.EXACTLY));
            }
            if (prevIsPortrait != isPortrait) {
                qrView.onSizeChanged(qrView.getMeasuredWidth(), qrView.getMeasuredHeight(), 0, 0);
            }
            prevIsPortrait = isPortrait;
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            boolean isPortrait = getWidth() < getHeight();
            backgroundView.layout(0, 0, getWidth(), getHeight());
            int themeLayoutHeight = 0;
            if (themeLayout.getVisibility() == View.VISIBLE) {
                themeLayoutHeight = themeLayout.getMeasuredHeight();
            }
            int qrLeft = isPortrait ? (getWidth() - qrView.getMeasuredWidth()) / 2 : (getWidth() - themeLayout.getMeasuredWidth() - qrView.getMeasuredWidth()) / 2;
            int qrTop = isPortrait ? (getHeight() - themeLayoutHeight - qrView.getMeasuredHeight() - AndroidUtilities.dp(48)) / 2 + AndroidUtilities.dp(48 + 4) : (getHeight() - qrView.getMeasuredHeight()) / 2;
            qrView.layout(qrLeft, qrTop, qrLeft + qrView.getMeasuredWidth(), qrTop + qrView.getMeasuredHeight());
            if (isPortrait) {
                int avatarLeft = (getWidth() - avatarImageView.getMeasuredWidth()) / 2;
                int avatarTop = qrTop - AndroidUtilities.dp(48);
                avatarImageView.layout(avatarLeft, avatarTop, avatarLeft + avatarImageView.getMeasuredWidth(), avatarTop + avatarImageView.getMeasuredHeight());
            }
            if (themeLayout.getVisibility() == View.VISIBLE) {
                if (isPortrait) {
                    int themeLayoutLeft = (getWidth() - themeLayout.getMeasuredWidth()) / 2;
                    themeLayout.layout(themeLayoutLeft, bottom - themeLayoutHeight, themeLayoutLeft + themeLayout.getMeasuredWidth(), bottom);
                } else {
                    int themeLayoutTop = (getHeight() - themeLayout.getMeasuredHeight()) / 2;
                    themeLayout.layout(right - themeLayout.getMeasuredWidth(), themeLayoutTop, right, themeLayoutTop + themeLayout.getMeasuredHeight());
                }
            }
            logoImageView.layout(qrLeft + logoRect.left, qrTop + logoRect.top, qrLeft + logoRect.right, qrTop + logoRect.bottom);
            int closeLeft = isPortrait ? AndroidUtilities.dp(14) : AndroidUtilities.dp(17);
            int closeTop = AndroidUtilities.statusBarHeight + (isPortrait ? AndroidUtilities.dp(10) : AndroidUtilities.dp(5));
            closeImageView.layout(closeLeft, closeTop, closeLeft + closeImageView.getMeasuredWidth(), closeTop + closeImageView.getMeasuredHeight());
        }
    };
    backgroundView = new View(context) {

        @Override
        protected void onDraw(Canvas canvas) {
            if (prevMotionDrawable != null) {
                prevMotionDrawable.setBounds(0, 0, getWidth(), getHeight());
            }
            currMotionDrawable.setBounds(0, 0, getWidth(), getHeight());
            if (prevMotionDrawable != null)
                prevMotionDrawable.drawBackground(canvas);
            currMotionDrawable.drawBackground(canvas);
            if (prevMotionDrawable != null)
                prevMotionDrawable.drawPattern(canvas);
            currMotionDrawable.drawPattern(canvas);
            super.onDraw(canvas);
        }
    };
    rootLayout.addView(backgroundView);
    AvatarDrawable avatarDrawable = null;
    String username = null;
    ImageLocation imageLocationSmall = null;
    ImageLocation imageLocation = null;
    if (userId != 0) {
        TLRPC.User user = getMessagesController().getUser(userId);
        if (user != null) {
            username = user.username;
            avatarDrawable = new AvatarDrawable(user);
            imageLocationSmall = ImageLocation.getForUser(user, ImageLocation.TYPE_SMALL);
            imageLocation = ImageLocation.getForUser(user, ImageLocation.TYPE_BIG);
        }
    } else if (chatId != 0) {
        TLRPC.Chat chat = getMessagesController().getChat(chatId);
        if (chat != null) {
            username = chat.username;
            avatarDrawable = new AvatarDrawable(chat);
            imageLocationSmall = ImageLocation.getForChat(chat, ImageLocation.TYPE_SMALL);
            imageLocation = ImageLocation.getForChat(chat, ImageLocation.TYPE_BIG);
        }
    }
    String link = "https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/" + username;
    qrView = new QrView(context);
    qrView.setColors(0xFF71B654, 0xFF2C9077, 0xFF9ABB3E, 0xFF68B55E);
    qrView.setData(link, username);
    qrView.setCenterChangedListener((left, top, right, bottom) -> {
        logoRect.set(left, top, right, bottom);
        qrView.requestLayout();
    });
    rootLayout.addView(qrView);
    logoImageView = new RLottieImageView(context);
    logoImageView.setAutoRepeat(true);
    logoImageView.setAnimation(R.raw.qr_code_logo_2, 60, 60);
    logoImageView.playAnimation();
    rootLayout.addView(logoImageView);
    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(42));
    avatarImageView.setSize(AndroidUtilities.dp(84), AndroidUtilities.dp(84));
    rootLayout.addView(avatarImageView, LayoutHelper.createFrame(84, 84, Gravity.LEFT | Gravity.TOP));
    avatarImageView.setImage(imageLocation, "84_84", imageLocationSmall, "50_50", avatarDrawable, null, null, 0, null);
    closeImageView = new ImageView(context);
    closeImageView.setBackground(Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(34), 0x28000000, 0x28ffffff));
    closeImageView.setImageResource(R.drawable.ic_ab_back);
    closeImageView.setScaleType(ImageView.ScaleType.CENTER);
    closeImageView.setOnClickListener(v -> finishFragment());
    rootLayout.addView(closeImageView, LayoutHelper.createFrame(34, 34));
    emojiThemeIcon = Bitmap.createBitmap(AndroidUtilities.dp(32), AndroidUtilities.dp(32), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(emojiThemeIcon);
    AndroidUtilities.rectTmp.set(0f, 0f, emojiThemeIcon.getWidth(), emojiThemeIcon.getHeight());
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(5), AndroidUtilities.dp(5), paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
    Bitmap bitmap = BitmapFactory.decodeResource(ApplicationLoader.applicationContext.getResources(), R.drawable.msg_qr_mini);
    canvas.drawBitmap(bitmap, (emojiThemeIcon.getWidth() - bitmap.getWidth()) * 0.5f, (emojiThemeIcon.getHeight() - bitmap.getHeight()) * 0.5f, paint);
    canvas.setBitmap(null);
    themesViewController = new ThemeListViewController(this, getParentActivity().getWindow()) {

        @Override
        protected void setDarkTheme(boolean isDark) {
            super.setDarkTheme(isDark);
            isCurrentThemeDark = isDark;
            onItemSelected(currentTheme, selectedPosition, false);
        }
    };
    themeLayout = themesViewController.rootLayout;
    themesViewController.onCreate();
    themesViewController.setItemSelectedListener((theme, position) -> QrActivity.this.onItemSelected(theme, position, true));
    themesViewController.titleView.setText(LocaleController.getString("QrCode", R.string.QrCode));
    themesViewController.progressView.setViewType(FlickerLoadingView.QR_TYPE);
    themesViewController.shareButton.setOnClickListener(v -> {
        themesViewController.shareButton.setClickable(false);
        performShare();
    });
    rootLayout.addView(themeLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));
    currMotionDrawable.setIndeterminateAnimation(true);
    fragmentView = rootLayout;
    onItemSelected(currentTheme, 0, false);
    if (cachedThemes == null || cachedThemes.isEmpty()) {
        ChatThemeController.requestAllChatThemes(new ResultCallback<List<EmojiThemes>>() {

            @Override
            public void onComplete(List<EmojiThemes> result) {
                onDataLoaded(result);
                cachedThemes = result;
            }

            @Override
            public void onError(TLRPC.TL_error error) {
                Toast.makeText(getParentActivity(), error.text, Toast.LENGTH_SHORT).show();
            }
        }, true);
    } else {
        onDataLoaded(cachedThemes);
    }
    prevSystemUiVisibility = getParentActivity().getWindow().getDecorView().getSystemUiVisibility();
    applyScreenSettings();
    return fragmentView;
}
Also used : RLottieImageView(org.telegram.ui.Components.RLottieImageView) ImageLocation(org.telegram.messenger.ImageLocation) TLRPC(org.telegram.tgnet.TLRPC) EmojiThemes(org.telegram.ui.ActionBar.EmojiThemes) Bitmap(android.graphics.Bitmap) BackupImageView(org.telegram.ui.Components.BackupImageView) List(java.util.List) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) Canvas(android.graphics.Canvas) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) ThemeSmallPreviewView(org.telegram.ui.Components.ThemeSmallPreviewView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) PorterDuffXfermode(android.graphics.PorterDuffXfermode) FrameLayout(android.widget.FrameLayout) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable)

Example 7 with EmojiThemes

use of org.telegram.ui.ActionBar.EmojiThemes in project Telegram-FOSS by Telegram-FOSS-Team.

the class QrActivity method onDataLoaded.

private void onDataLoaded(List<EmojiThemes> result) {
    if (result == null || result.isEmpty() || themesViewController == null) {
        return;
    }
    result.set(0, homeTheme);
    List<ChatThemeBottomSheet.ChatThemeItem> items = new ArrayList<>(result.size());
    for (int i = 0; i < result.size(); ++i) {
        EmojiThemes chatTheme = result.get(i);
        chatTheme.loadPreviewColors(currentAccount);
        ChatThemeBottomSheet.ChatThemeItem item = new ChatThemeBottomSheet.ChatThemeItem(chatTheme);
        item.themeIndex = isCurrentThemeDark ? 1 : 0;
        item.icon = getEmojiThemeIcon(chatTheme, isCurrentThemeDark);
        items.add(item);
    }
    themesViewController.adapter.setItems(items);
    int selectedPosition = -1;
    for (int i = 0; i != items.size(); ++i) {
        if (items.get(i).chatTheme.getEmoticon().equals(currentTheme.getEmoticon())) {
            themesViewController.selectedItem = items.get(i);
            selectedPosition = i;
            break;
        }
    }
    if (selectedPosition != -1) {
        themesViewController.setSelectedPosition(selectedPosition);
    }
    themesViewController.onDataLoaded();
}
Also used : EmojiThemes(org.telegram.ui.ActionBar.EmojiThemes) ChatThemeBottomSheet(org.telegram.ui.Components.ChatThemeBottomSheet) ArrayList(java.util.ArrayList) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 8 with EmojiThemes

use of org.telegram.ui.ActionBar.EmojiThemes in project Telegram-FOSS by Telegram-FOSS-Team.

the class QrActivity method onItemSelected.

private void onItemSelected(EmojiThemes newTheme, int position, boolean withAnimation) {
    selectedPosition = position;
    final EmojiThemes prevTheme = currentTheme;
    final boolean isDarkTheme = isCurrentThemeDark;
    currentTheme = newTheme;
    EmojiThemes.ThemeItem themeItem = currentTheme.getThemeItem(isDarkTheme ? 1 : 0);
    float duration = 1f;
    if (patternAlphaAnimator != null) {
        // from = (float) patternAlphaAnimator.getAnimatedValue();
        duration *= Math.max(.5f, 1f - (float) patternAlphaAnimator.getAnimatedValue());
        patternAlphaAnimator.cancel();
    }
    prevMotionDrawable = currMotionDrawable;
    prevMotionDrawable.setIndeterminateAnimation(false);
    prevMotionDrawable.setAlpha(255);
    currMotionDrawable = new MotionBackgroundDrawable();
    currMotionDrawable.setCallback(backgroundView);
    currMotionDrawable.setColors(themeItem.patternBgColor, themeItem.patternBgGradientColor1, themeItem.patternBgGradientColor2, themeItem.patternBgGradientColor3);
    currMotionDrawable.setParentView(backgroundView);
    currMotionDrawable.setPatternAlpha(1f);
    currMotionDrawable.setIndeterminateAnimation(true);
    if (prevMotionDrawable != null)
        currMotionDrawable.posAnimationProgress = prevMotionDrawable.posAnimationProgress;
    qrView.setPosAnimationProgress(currMotionDrawable.posAnimationProgress);
    TLRPC.WallPaper wallPaper = currentTheme.getWallpaper(isDarkTheme ? 1 : 0);
    if (wallPaper != null) {
        currMotionDrawable.setPatternBitmap(wallPaper.settings.intensity);
        final long startedLoading = SystemClock.elapsedRealtime();
        currentTheme.loadWallpaper(isDarkTheme ? 1 : 0, pair -> {
            if (pair != null && currentTheme.getTlTheme(isDarkTheme ? 1 : 0) != null) {
                final long themeId = pair.first;
                final Bitmap bitmap = pair.second;
                if (themeId == currentTheme.getTlTheme(isDarkTheme ? 1 : 0).id && bitmap != null) {
                    long elapsed = SystemClock.elapsedRealtime() - startedLoading;
                    onPatternLoaded(bitmap, currMotionDrawable.getIntensity(), elapsed > 150);
                }
            }
        });
    } else {
        currMotionDrawable.setPatternBitmap(34, SvgHelper.getBitmap(R.raw.default_pattern, backgroundView.getWidth(), backgroundView.getHeight(), Color.BLACK));
    }
    currMotionDrawable.setPatternColorFilter(currMotionDrawable.getPatternColor());
    int[] newQrColors = qrColorsMap.get(newTheme.emoji + (isDarkTheme ? "n" : "d"));
    if (withAnimation) {
        currMotionDrawable.setAlpha(255);
        currMotionDrawable.setBackgroundAlpha(0f);
        patternAlphaAnimator = ValueAnimator.ofFloat(0f, 1f);
        patternAlphaAnimator.addUpdateListener(animation -> {
            float progress = (float) animation.getAnimatedValue();
            if (prevMotionDrawable != null) {
                prevMotionDrawable.setBackgroundAlpha(1f);
                prevMotionDrawable.setPatternAlpha(1f - progress);
            }
            currMotionDrawable.setBackgroundAlpha(progress);
            currMotionDrawable.setPatternAlpha(progress);
            // currMotionDrawable.setAlpha((int) (255f * progress));
            if (newQrColors != null) {
                int color1 = ColorUtils.blendARGB(prevQrColors[0], newQrColors[0], progress);
                int color2 = ColorUtils.blendARGB(prevQrColors[1], newQrColors[1], progress);
                int color3 = ColorUtils.blendARGB(prevQrColors[2], newQrColors[2], progress);
                int color4 = ColorUtils.blendARGB(prevQrColors[3], newQrColors[3], progress);
                qrView.setColors(color1, color2, color3, color4);
            }
            backgroundView.invalidate();
        });
        patternAlphaAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                if (newQrColors != null) {
                    System.arraycopy(newQrColors, 0, prevQrColors, 0, 4);
                }
                prevMotionDrawable = null;
                patternAlphaAnimator = null;
                currMotionDrawable.setBackgroundAlpha(1f);
                currMotionDrawable.setPatternAlpha(1f);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                float progress = (float) ((ValueAnimator) animation).getAnimatedValue();
                if (newQrColors != null) {
                    int color1 = ColorUtils.blendARGB(prevQrColors[0], newQrColors[0], progress);
                    int color2 = ColorUtils.blendARGB(prevQrColors[1], newQrColors[1], progress);
                    int color3 = ColorUtils.blendARGB(prevQrColors[2], newQrColors[2], progress);
                    int color4 = ColorUtils.blendARGB(prevQrColors[3], newQrColors[3], progress);
                    int[] colors = new int[] { color1, color2, color3, color4 };
                    System.arraycopy(colors, 0, prevQrColors, 0, 4);
                }
            }
        });
        patternAlphaAnimator.setDuration((int) (250 * duration));
        patternAlphaAnimator.start();
    } else {
        if (newQrColors != null) {
            qrView.setColors(newQrColors[0], newQrColors[1], newQrColors[2], newQrColors[3]);
            System.arraycopy(newQrColors, 0, prevQrColors, 0, 4);
        }
        prevMotionDrawable = null;
        backgroundView.invalidate();
    }
    Theme.ThemeInfo currentThemeInfo = isCurrentThemeDark ? Theme.getCurrentNightTheme() : Theme.getCurrentTheme();
    ActionBarLayout.ThemeAnimationSettings animationSettings = new ActionBarLayout.ThemeAnimationSettings(null, currentThemeInfo.currentAccentId, isCurrentThemeDark, !withAnimation);
    animationSettings.applyTheme = false;
    animationSettings.onlyTopFragment = true;
    animationSettings.resourcesProvider = getResourceProvider();
    animationSettings.duration = (int) (250 * duration);
    if (withAnimation) {
        resourcesProvider.initColors(prevTheme, isCurrentThemeDark);
    } else {
        resourcesProvider.initColors(currentTheme, isCurrentThemeDark);
    }
    animationSettings.afterStartDescriptionsAddedRunnable = () -> {
        resourcesProvider.initColors(currentTheme, isCurrentThemeDark);
    };
    parentLayout.animateThemedValues(animationSettings);
}
Also used : MotionBackgroundDrawable(org.telegram.ui.Components.MotionBackgroundDrawable) ValueAnimator(android.animation.ValueAnimator) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) TLRPC(org.telegram.tgnet.TLRPC) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) EmojiThemes(org.telegram.ui.ActionBar.EmojiThemes) Bitmap(android.graphics.Bitmap) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Theme(org.telegram.ui.ActionBar.Theme)

Example 9 with EmojiThemes

use of org.telegram.ui.ActionBar.EmojiThemes in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatThemeController method preloadAllWallpaperImages.

public static void preloadAllWallpaperImages(boolean isDark) {
    for (EmojiThemes chatTheme : allChatThemes) {
        TLRPC.TL_theme theme = chatTheme.getTlTheme(isDark ? 1 : 0);
        if (theme == null) {
            continue;
        }
        long themeId = theme.id;
        if (getPatternFile(themeId).exists()) {
            continue;
        }
        chatTheme.loadWallpaper(isDark ? 1 : 0, null);
    }
}
Also used : EmojiThemes(org.telegram.ui.ActionBar.EmojiThemes) TLRPC(org.telegram.tgnet.TLRPC)

Example 10 with EmojiThemes

use of org.telegram.ui.ActionBar.EmojiThemes in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatThemeController method requestAllChatThemes.

public static void requestAllChatThemes(final ResultCallback<List<EmojiThemes>> callback, boolean withDefault) {
    if (themesHash == 0 || lastReloadTimeMs == 0) {
        init();
    }
    boolean needReload = System.currentTimeMillis() - lastReloadTimeMs > reloadTimeoutMs;
    if (allChatThemes == null || allChatThemes.isEmpty() || needReload) {
        TLRPC.TL_account_getChatThemes request = new TLRPC.TL_account_getChatThemes();
        request.hash = themesHash;
        ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(request, (response, error) -> chatThemeQueue.postRunnable(() -> {
            boolean isError = false;
            final List<EmojiThemes> chatThemes;
            if (response instanceof TLRPC.TL_account_themes) {
                TLRPC.TL_account_themes resp = (TLRPC.TL_account_themes) response;
                themesHash = resp.hash;
                lastReloadTimeMs = System.currentTimeMillis();
                SharedPreferences.Editor editor = getSharedPreferences().edit();
                editor.clear();
                editor.putLong("hash", themesHash);
                editor.putLong("lastReload", lastReloadTimeMs);
                editor.putInt("count", resp.themes.size());
                chatThemes = new ArrayList<>(resp.themes.size());
                for (int i = 0; i < resp.themes.size(); ++i) {
                    TLRPC.TL_theme tlChatTheme = resp.themes.get(i);
                    Emoji.preloadEmoji(tlChatTheme.emoticon);
                    SerializedData data = new SerializedData(tlChatTheme.getObjectSize());
                    tlChatTheme.serializeToStream(data);
                    editor.putString("theme_" + i, Utilities.bytesToHex(data.toByteArray()));
                    EmojiThemes chatTheme = new EmojiThemes(tlChatTheme, false);
                    chatTheme.preloadWallpaper();
                    chatThemes.add(chatTheme);
                }
                editor.apply();
            } else if (response instanceof TLRPC.TL_account_themesNotModified) {
                chatThemes = getAllChatThemesFromPrefs();
            } else {
                chatThemes = null;
                isError = true;
                AndroidUtilities.runOnUIThread(() -> callback.onError(error));
            }
            if (!isError) {
                if (withDefault && !chatThemes.get(0).showAsDefaultStub) {
                    chatThemes.add(0, EmojiThemes.createChatThemesDefault());
                }
                for (EmojiThemes theme : chatThemes) {
                    theme.initColors();
                }
                AndroidUtilities.runOnUIThread(() -> {
                    allChatThemes = new ArrayList<>(chatThemes);
                    callback.onComplete(chatThemes);
                });
            }
        }));
    } else {
        List<EmojiThemes> chatThemes = new ArrayList<>(allChatThemes);
        if (withDefault && !chatThemes.get(0).showAsDefaultStub) {
            chatThemes.add(0, EmojiThemes.createChatThemesDefault());
        }
        for (EmojiThemes theme : chatThemes) {
            theme.initColors();
        }
        callback.onComplete(chatThemes);
    }
}
Also used : ArrayList(java.util.ArrayList) SerializedData(org.telegram.tgnet.SerializedData) TLRPC(org.telegram.tgnet.TLRPC) EmojiThemes(org.telegram.ui.ActionBar.EmojiThemes) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

EmojiThemes (org.telegram.ui.ActionBar.EmojiThemes)11 TLRPC (org.telegram.tgnet.TLRPC)7 ArrayList (java.util.ArrayList)5 SuppressLint (android.annotation.SuppressLint)4 Paint (android.graphics.Paint)4 TextPaint (android.text.TextPaint)3 SharedPreferences (android.content.SharedPreferences)2 Bitmap (android.graphics.Bitmap)2 List (java.util.List)2 SerializedData (org.telegram.tgnet.SerializedData)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 Canvas (android.graphics.Canvas)1 PorterDuffXfermode (android.graphics.PorterDuffXfermode)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1