Search in sources :

Example 1 with StickerSetBulletinLayout

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

the class MediaDataController method toggleStickerSet.

/**
 * @param toggle 0 - remove, 1 - archive, 2 - add
 */
public void toggleStickerSet(Context context, TLObject stickerSetObject, int toggle, BaseFragment baseFragment, boolean showSettings, boolean showTooltip) {
    TLRPC.StickerSet stickerSet;
    TLRPC.TL_messages_stickerSet messages_stickerSet;
    if (stickerSetObject instanceof TLRPC.TL_messages_stickerSet) {
        messages_stickerSet = ((TLRPC.TL_messages_stickerSet) stickerSetObject);
        stickerSet = messages_stickerSet.set;
    } else if (stickerSetObject instanceof TLRPC.StickerSetCovered) {
        stickerSet = ((TLRPC.StickerSetCovered) stickerSetObject).set;
        if (toggle != 2) {
            messages_stickerSet = stickerSetsById.get(stickerSet.id);
            if (messages_stickerSet == null) {
                return;
            }
        } else {
            messages_stickerSet = null;
        }
    } else {
        throw new IllegalArgumentException("Invalid type of the given stickerSetObject: " + stickerSetObject.getClass());
    }
    int type = stickerSet.masks ? TYPE_MASK : TYPE_IMAGE;
    stickerSet.archived = toggle == 1;
    int currentIndex = 0;
    for (int a = 0; a < stickerSets[type].size(); a++) {
        TLRPC.TL_messages_stickerSet set = stickerSets[type].get(a);
        if (set.set.id == stickerSet.id) {
            currentIndex = a;
            stickerSets[type].remove(a);
            if (toggle == 2) {
                stickerSets[type].add(0, set);
            } else {
                stickerSetsById.remove(set.set.id);
                installedStickerSetsById.remove(set.set.id);
                stickerSetsByName.remove(set.set.short_name);
            }
            break;
        }
    }
    loadHash[type] = calcStickersHash(stickerSets[type]);
    putStickersToCache(type, stickerSets[type], loadDate[type], loadHash[type]);
    getNotificationCenter().postNotificationName(NotificationCenter.stickersDidLoad, type);
    if (toggle == 2) {
        if (!cancelRemovingStickerSet(stickerSet.id)) {
            toggleStickerSetInternal(context, toggle, baseFragment, showSettings, stickerSetObject, stickerSet, type, showTooltip);
        }
    } else if (!showTooltip || baseFragment == null) {
        toggleStickerSetInternal(context, toggle, baseFragment, showSettings, stickerSetObject, stickerSet, type, false);
    } else {
        StickerSetBulletinLayout bulletinLayout = new StickerSetBulletinLayout(context, stickerSetObject, toggle);
        int finalCurrentIndex = currentIndex;
        Bulletin.UndoButton undoButton = new Bulletin.UndoButton(context, false).setUndoAction(() -> {
            stickerSet.archived = false;
            stickerSets[type].add(finalCurrentIndex, messages_stickerSet);
            stickerSetsById.put(stickerSet.id, messages_stickerSet);
            installedStickerSetsById.put(stickerSet.id, messages_stickerSet);
            stickerSetsByName.put(stickerSet.short_name, messages_stickerSet);
            removingStickerSetsUndos.remove(stickerSet.id);
            loadHash[type] = calcStickersHash(stickerSets[type]);
            putStickersToCache(type, stickerSets[type], loadDate[type], loadHash[type]);
            getNotificationCenter().postNotificationName(NotificationCenter.stickersDidLoad, type);
        }).setDelayedAction(() -> toggleStickerSetInternal(context, toggle, baseFragment, showSettings, stickerSetObject, stickerSet, type, false));
        bulletinLayout.setButton(undoButton);
        removingStickerSetsUndos.put(stickerSet.id, undoButton::undo);
        Bulletin.make(baseFragment, bulletinLayout, Bulletin.DURATION_LONG).show();
    }
}
Also used : Bulletin(org.telegram.ui.Components.Bulletin) StickerSetBulletinLayout(org.telegram.ui.Components.StickerSetBulletinLayout) TLRPC(org.telegram.tgnet.TLRPC) Paint(android.graphics.Paint)

Example 2 with StickerSetBulletinLayout

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

the class MediaDataController method toggleStickerSetInternal.

private void toggleStickerSetInternal(Context context, int toggle, BaseFragment baseFragment, boolean showSettings, TLObject stickerSetObject, TLRPC.StickerSet stickerSet, int type, boolean showTooltip) {
    TLRPC.TL_inputStickerSetID stickerSetID = new TLRPC.TL_inputStickerSetID();
    stickerSetID.access_hash = stickerSet.access_hash;
    stickerSetID.id = stickerSet.id;
    if (toggle != 0) {
        TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet();
        req.stickerset = stickerSetID;
        req.archived = toggle == 1;
        getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            removingStickerSetsUndos.remove(stickerSet.id);
            if (response instanceof TLRPC.TL_messages_stickerSetInstallResultArchive) {
                processStickerSetInstallResultArchive(baseFragment, showSettings, type, (TLRPC.TL_messages_stickerSetInstallResultArchive) response);
            }
            loadStickers(type, false, false, true);
            if (error == null && showTooltip && baseFragment != null) {
                Bulletin.make(baseFragment, new StickerSetBulletinLayout(context, stickerSetObject, StickerSetBulletinLayout.TYPE_ADDED), Bulletin.DURATION_SHORT).show();
            }
        }));
    } else {
        TLRPC.TL_messages_uninstallStickerSet req = new TLRPC.TL_messages_uninstallStickerSet();
        req.stickerset = stickerSetID;
        getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            removingStickerSetsUndos.remove(stickerSet.id);
            loadStickers(type, false, true);
        }));
    }
}
Also used : StickerSetBulletinLayout(org.telegram.ui.Components.StickerSetBulletinLayout) TLRPC(org.telegram.tgnet.TLRPC)

Example 3 with StickerSetBulletinLayout

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

the class EmojiAnimationsOverlay method onTapItem.

public void onTapItem(ChatMessageCell view, ChatActivity chatActivity) {
    if (chatActivity.currentUser == null || chatActivity.isSecretChat() || view.getMessageObject() == null || view.getMessageObject().getId() < 0) {
        return;
    }
    boolean show = showAnimationForCell(view, -1, true, false);
    if (show && !EmojiData.hasEmojiSupportVibration(view.getMessageObject().getStickerEmoji())) {
        view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
    }
    Integer printingType = MessagesController.getInstance(currentAccount).getPrintingStringType(dialogId, threadMsgId);
    boolean canShowHint = true;
    if (printingType != null && printingType == 5) {
        canShowHint = false;
    }
    if (canShowHint && hintRunnable == null && show && (Bulletin.getVisibleBulletin() == null || !Bulletin.getVisibleBulletin().isShowing()) && SharedConfig.emojiInteractionsHintCount > 0 && UserConfig.getInstance(currentAccount).getClientUserId() != chatActivity.currentUser.id) {
        SharedConfig.updateEmojiInteractionsHintCount(SharedConfig.emojiInteractionsHintCount - 1);
        TLRPC.Document document = MediaDataController.getInstance(currentAccount).getEmojiAnimatedSticker(view.getMessageObject().getStickerEmoji());
        StickerSetBulletinLayout layout = new StickerSetBulletinLayout(chatActivity.getParentActivity(), null, StickerSetBulletinLayout.TYPE_EMPTY, document, chatActivity.getResourceProvider());
        layout.subtitleTextView.setVisibility(View.GONE);
        layout.titleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("EmojiInteractionTapHint", R.string.EmojiInteractionTapHint, chatActivity.currentUser.first_name)));
        layout.titleTextView.setTypeface(null);
        layout.titleTextView.setMaxLines(3);
        layout.titleTextView.setSingleLine(false);
        Bulletin bulletin = Bulletin.make(chatActivity, layout, Bulletin.DURATION_LONG);
        AndroidUtilities.runOnUIThread(hintRunnable = new Runnable() {

            @Override
            public void run() {
                bulletin.show();
                hintRunnable = null;
            }
        }, 1500);
    }
}
Also used : Bulletin(org.telegram.ui.Components.Bulletin) StickerSetBulletinLayout(org.telegram.ui.Components.StickerSetBulletinLayout) TLRPC(org.telegram.tgnet.TLRPC)

Example 4 with StickerSetBulletinLayout

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

the class LaunchActivity method didReceivedNotification.

@Override
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, final int account, Object... args) {
    if (id == NotificationCenter.appDidLogout) {
        switchToAvailableAccountOrLogout();
    } else if (id == NotificationCenter.closeOtherAppActivities) {
        if (args[0] != this) {
            onFinish();
            finish();
        }
    } else if (id == NotificationCenter.didUpdateConnectionState) {
        int state = ConnectionsManager.getInstance(account).getConnectionState();
        if (currentConnectionState != state) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("switch to state " + state);
            }
            currentConnectionState = state;
            updateCurrentConnectionState(account);
        }
    } else if (id == NotificationCenter.mainUserInfoChanged) {
        drawerLayoutAdapter.notifyDataSetChanged();
    } else if (id == NotificationCenter.needShowAlert) {
        final Integer reason = (Integer) args[0];
        if (reason == 6 || reason == 3 && proxyErrorDialog != null) {
            return;
        } else if (reason == 4) {
            showTosActivity(account, (TLRPC.TL_help_termsOfService) args[1]);
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        if (reason != 2 && reason != 3) {
            builder.setNegativeButton(LocaleController.getString("MoreInfo", R.string.MoreInfo), (dialogInterface, i) -> {
                if (!mainFragmentsStack.isEmpty()) {
                    MessagesController.getInstance(account).openByUserName("spambot", mainFragmentsStack.get(mainFragmentsStack.size() - 1), 1);
                }
            });
        }
        if (reason == 5) {
            builder.setMessage(LocaleController.getString("NobodyLikesSpam3", R.string.NobodyLikesSpam3));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        } else if (reason == 0) {
            builder.setMessage(LocaleController.getString("NobodyLikesSpam1", R.string.NobodyLikesSpam1));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        } else if (reason == 1) {
            builder.setMessage(LocaleController.getString("NobodyLikesSpam2", R.string.NobodyLikesSpam2));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        } else if (reason == 2) {
            builder.setMessage((String) args[1]);
            String type = (String) args[2];
            if (type.startsWith("AUTH_KEY_DROP_")) {
                builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                builder.setNegativeButton(LocaleController.getString("LogOut", R.string.LogOut), (dialog, which) -> MessagesController.getInstance(currentAccount).performLogout(2));
            } else {
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            }
        } else if (reason == 3) {
            builder.setTitle(LocaleController.getString("Proxy", R.string.Proxy));
            builder.setMessage(LocaleController.getString("UseProxyTelegramError", R.string.UseProxyTelegramError));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            proxyErrorDialog = showAlertDialog(builder);
            return;
        }
        if (!mainFragmentsStack.isEmpty()) {
            mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(builder.create());
        }
    } else if (id == NotificationCenter.wasUnableToFindCurrentLocation) {
        final HashMap<String, MessageObject> waitingForLocation = (HashMap<String, MessageObject>) args[0];
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        builder.setNegativeButton(LocaleController.getString("ShareYouLocationUnableManually", R.string.ShareYouLocationUnableManually), (dialogInterface, i) -> {
            if (mainFragmentsStack.isEmpty()) {
                return;
            }
            BaseFragment lastFragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
            if (!AndroidUtilities.isGoogleMapsInstalled(lastFragment)) {
                return;
            }
            LocationActivity fragment = new LocationActivity(0);
            fragment.setDelegate((location, live, notify, scheduleDate) -> {
                for (HashMap.Entry<String, MessageObject> entry : waitingForLocation.entrySet()) {
                    MessageObject messageObject = entry.getValue();
                    SendMessagesHelper.getInstance(account).sendMessage(location, messageObject.getDialogId(), messageObject, null, null, null, notify, scheduleDate);
                }
            });
            presentFragment(fragment);
        });
        builder.setMessage(LocaleController.getString("ShareYouLocationUnable", R.string.ShareYouLocationUnable));
        if (!mainFragmentsStack.isEmpty()) {
            mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(builder.create());
        }
    } else if (id == NotificationCenter.didSetNewWallpapper) {
        if (sideMenu != null) {
            View child = sideMenu.getChildAt(0);
            if (child != null) {
                child.invalidate();
            }
        }
        if (backgroundTablet != null) {
            backgroundTablet.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
        }
    } else if (id == NotificationCenter.didSetPasscode) {
        if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
            try {
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
            } catch (Exception e) {
                FileLog.e(e);
            }
        } else if (!AndroidUtilities.hasFlagSecureFragment()) {
            try {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    } else if (id == NotificationCenter.reloadInterface) {
        boolean last = mainFragmentsStack.size() > 1 && mainFragmentsStack.get(mainFragmentsStack.size() - 1) instanceof ProfileActivity;
        if (last) {
            ProfileActivity profileActivity = (ProfileActivity) mainFragmentsStack.get(mainFragmentsStack.size() - 1);
            if (!profileActivity.isSettings()) {
                last = false;
            }
        }
        rebuildAllFragments(last);
    } else if (id == NotificationCenter.suggestedLangpack) {
        showLanguageAlert(false);
    } else if (id == NotificationCenter.openArticle) {
        if (mainFragmentsStack.isEmpty()) {
            return;
        }
        ArticleViewer.getInstance().setParentActivity(this, mainFragmentsStack.get(mainFragmentsStack.size() - 1));
        ArticleViewer.getInstance().open((TLRPC.TL_webPage) args[0], (String) args[1]);
    } else if (id == NotificationCenter.hasNewContactsToImport) {
        if (actionBarLayout == null || actionBarLayout.fragmentsStack.isEmpty()) {
            return;
        }
        final int type = (Integer) args[0];
        final HashMap<String, ContactsController.Contact> contactHashMap = (HashMap<String, ContactsController.Contact>) args[1];
        final boolean first = (Boolean) args[2];
        final boolean schedule = (Boolean) args[3];
        BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
        AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
        builder.setTitle(LocaleController.getString("UpdateContactsTitle", R.string.UpdateContactsTitle));
        builder.setMessage(LocaleController.getString("UpdateContactsMessage", R.string.UpdateContactsMessage));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> ContactsController.getInstance(account).syncPhoneBookByAlert(contactHashMap, first, schedule, false));
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) -> ContactsController.getInstance(account).syncPhoneBookByAlert(contactHashMap, first, schedule, true));
        builder.setOnBackButtonListener((dialogInterface, i) -> ContactsController.getInstance(account).syncPhoneBookByAlert(contactHashMap, first, schedule, true));
        AlertDialog dialog = builder.create();
        fragment.showDialog(dialog);
        dialog.setCanceledOnTouchOutside(false);
    } else if (id == NotificationCenter.didSetNewTheme) {
        Boolean nightTheme = (Boolean) args[0];
        if (!nightTheme) {
            if (sideMenu != null) {
                sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
                sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground));
                sideMenu.setListSelectorColor(Theme.getColor(Theme.key_listSelector));
                sideMenu.getAdapter().notifyDataSetChanged();
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                try {
                    setTaskDescription(new ActivityManager.TaskDescription(null, null, Theme.getColor(Theme.key_actionBarDefault) | 0xff000000));
                } catch (Exception ignore) {
                }
            }
        }
        drawerLayoutContainer.setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        boolean checkNavigationBarColor = true;
        if (args.length > 1) {
            checkNavigationBarColor = (boolean) args[1];
        }
        checkSystemBarColors(true, checkNavigationBarColor);
    } else if (id == NotificationCenter.needSetDayNightTheme) {
        boolean instant = false;
        if (Build.VERSION.SDK_INT >= 21 && args[2] != null) {
            if (themeSwitchImageView.getVisibility() == View.VISIBLE) {
                return;
            }
            try {
                int[] pos = (int[]) args[2];
                boolean toDark = (Boolean) args[4];
                RLottieImageView darkThemeView = (RLottieImageView) args[5];
                int w = drawerLayoutContainer.getMeasuredWidth();
                int h = drawerLayoutContainer.getMeasuredHeight();
                if (!toDark) {
                    darkThemeView.setVisibility(View.INVISIBLE);
                }
                Bitmap bitmap = Bitmap.createBitmap(drawerLayoutContainer.getMeasuredWidth(), drawerLayoutContainer.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas(bitmap);
                HashMap<View, Integer> viewLayerTypes = new HashMap<>();
                invalidateCachedViews(drawerLayoutContainer);
                drawerLayoutContainer.draw(canvas);
                frameLayout.removeView(themeSwitchImageView);
                if (toDark) {
                    frameLayout.addView(themeSwitchImageView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
                    themeSwitchSunView.setVisibility(View.GONE);
                } else {
                    frameLayout.addView(themeSwitchImageView, 1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
                    themeSwitchSunView.setTranslationX(pos[0] - AndroidUtilities.dp(14));
                    themeSwitchSunView.setTranslationY(pos[1] - AndroidUtilities.dp(14));
                    themeSwitchSunView.setVisibility(View.VISIBLE);
                    themeSwitchSunView.invalidate();
                }
                themeSwitchImageView.setImageBitmap(bitmap);
                themeSwitchImageView.setVisibility(View.VISIBLE);
                themeSwitchSunDrawable = darkThemeView.getAnimatedDrawable();
                float finalRadius = (float) Math.max(Math.sqrt((w - pos[0]) * (w - pos[0]) + (h - pos[1]) * (h - pos[1])), Math.sqrt(pos[0] * pos[0] + (h - pos[1]) * (h - pos[1])));
                float finalRadius2 = (float) Math.max(Math.sqrt((w - pos[0]) * (w - pos[0]) + pos[1] * pos[1]), Math.sqrt(pos[0] * pos[0] + pos[1] * pos[1]));
                finalRadius = Math.max(finalRadius, finalRadius2);
                Animator anim = ViewAnimationUtils.createCircularReveal(toDark ? drawerLayoutContainer : themeSwitchImageView, pos[0], pos[1], toDark ? 0 : finalRadius, toDark ? finalRadius : 0);
                anim.setDuration(400);
                anim.setInterpolator(Easings.easeInOutQuad);
                anim.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        themeSwitchImageView.setImageDrawable(null);
                        themeSwitchImageView.setVisibility(View.GONE);
                        themeSwitchSunView.setVisibility(View.GONE);
                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.themeAccentListUpdated);
                        if (!toDark) {
                            darkThemeView.setVisibility(View.VISIBLE);
                        }
                        DrawerProfileCell.switchingTheme = false;
                    }
                });
                anim.start();
                instant = true;
            } catch (Throwable e) {
                FileLog.e(e);
                try {
                    themeSwitchImageView.setImageDrawable(null);
                    frameLayout.removeView(themeSwitchImageView);
                    DrawerProfileCell.switchingTheme = false;
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
            }
        } else {
            DrawerProfileCell.switchingTheme = false;
        }
        Theme.ThemeInfo theme = (Theme.ThemeInfo) args[0];
        boolean nigthTheme = (Boolean) args[1];
        int accentId = (Integer) args[3];
        actionBarLayout.animateThemedValues(theme, accentId, nigthTheme, instant);
        if (AndroidUtilities.isTablet()) {
            layersActionBarLayout.animateThemedValues(theme, accentId, nigthTheme, instant);
            rightActionBarLayout.animateThemedValues(theme, accentId, nigthTheme, instant);
        }
    } else if (id == NotificationCenter.notificationsCountUpdated) {
        if (sideMenu != null) {
            Integer accountNum = (Integer) args[0];
            int count = sideMenu.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = sideMenu.getChildAt(a);
                if (child instanceof DrawerUserCell) {
                    if (((DrawerUserCell) child).getAccountNumber() == accountNum) {
                        child.invalidate();
                        break;
                    }
                }
            }
        }
    } else if (id == NotificationCenter.fileLoaded) {
        String path = (String) args[0];
        if (SharedConfig.isAppUpdateAvailable()) {
            String name = FileLoader.getAttachFileName(SharedConfig.pendingAppUpdate.document);
            if (name.equals(path)) {
                updateAppUpdateViews(true);
            }
        }
        if (loadingThemeFileName != null) {
            if (loadingThemeFileName.equals(path)) {
                loadingThemeFileName = null;
                File locFile = new File(ApplicationLoader.getFilesDirFixed(), "remote" + loadingTheme.id + ".attheme");
                Theme.ThemeInfo themeInfo = Theme.fillThemeValues(locFile, loadingTheme.title, loadingTheme);
                if (themeInfo != null) {
                    if (themeInfo.pathToWallpaper != null) {
                        File file = new File(themeInfo.pathToWallpaper);
                        if (!file.exists()) {
                            TLRPC.TL_account_getWallPaper req = new TLRPC.TL_account_getWallPaper();
                            TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
                            inputWallPaperSlug.slug = themeInfo.slug;
                            req.wallpaper = inputWallPaperSlug;
                            ConnectionsManager.getInstance(themeInfo.account).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                                if (response instanceof TLRPC.TL_wallPaper) {
                                    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) response;
                                    loadingThemeInfo = themeInfo;
                                    loadingThemeWallpaperName = FileLoader.getAttachFileName(wallPaper.document);
                                    loadingThemeWallpaper = wallPaper;
                                    FileLoader.getInstance(themeInfo.account).loadFile(wallPaper.document, wallPaper, 1, 1);
                                } else {
                                    onThemeLoadFinish();
                                }
                            }));
                            return;
                        }
                    }
                    Theme.ThemeInfo finalThemeInfo = Theme.applyThemeFile(locFile, loadingTheme.title, loadingTheme, true);
                    if (finalThemeInfo != null) {
                        presentFragment(new ThemePreviewActivity(finalThemeInfo, true, ThemePreviewActivity.SCREEN_TYPE_PREVIEW, false, false));
                    }
                }
                onThemeLoadFinish();
            }
        } else if (loadingThemeWallpaperName != null) {
            if (loadingThemeWallpaperName.equals(path)) {
                loadingThemeWallpaperName = null;
                File file = (File) args[1];
                if (loadingThemeAccent) {
                    openThemeAccentPreview(loadingTheme, loadingThemeWallpaper, loadingThemeInfo);
                    onThemeLoadFinish();
                } else {
                    Theme.ThemeInfo info = loadingThemeInfo;
                    Utilities.globalQueue.postRunnable(() -> {
                        info.createBackground(file, info.pathToWallpaper);
                        AndroidUtilities.runOnUIThread(() -> {
                            if (loadingTheme == null) {
                                return;
                            }
                            File locFile = new File(ApplicationLoader.getFilesDirFixed(), "remote" + loadingTheme.id + ".attheme");
                            Theme.ThemeInfo finalThemeInfo = Theme.applyThemeFile(locFile, loadingTheme.title, loadingTheme, true);
                            if (finalThemeInfo != null) {
                                presentFragment(new ThemePreviewActivity(finalThemeInfo, true, ThemePreviewActivity.SCREEN_TYPE_PREVIEW, false, false));
                            }
                            onThemeLoadFinish();
                        });
                    });
                }
            }
        }
    } else if (id == NotificationCenter.fileLoadFailed) {
        String path = (String) args[0];
        if (path.equals(loadingThemeFileName) || path.equals(loadingThemeWallpaperName)) {
            onThemeLoadFinish();
        }
        if (SharedConfig.isAppUpdateAvailable()) {
            String name = FileLoader.getAttachFileName(SharedConfig.pendingAppUpdate.document);
            if (name.equals(path)) {
                updateAppUpdateViews(true);
            }
        }
    } else if (id == NotificationCenter.screenStateChanged) {
        if (ApplicationLoader.mainInterfacePaused) {
            return;
        }
        if (ApplicationLoader.isScreenOn) {
            onPasscodeResume();
        } else {
            onPasscodePause();
        }
    } else if (id == NotificationCenter.needCheckSystemBarColors) {
        checkSystemBarColors();
    } else if (id == NotificationCenter.historyImportProgressChanged) {
        if (args.length > 1 && !mainFragmentsStack.isEmpty()) {
            AlertsCreator.processError(currentAccount, (TLRPC.TL_error) args[2], mainFragmentsStack.get(mainFragmentsStack.size() - 1), (TLObject) args[1]);
        }
    } else if (id == NotificationCenter.stickersImportComplete) {
        MediaDataController.getInstance(account).toggleStickerSet(this, (TLObject) args[0], 2, !mainFragmentsStack.isEmpty() ? mainFragmentsStack.get(mainFragmentsStack.size() - 1) : null, false, true);
    } else if (id == NotificationCenter.newSuggestionsAvailable) {
        sideMenu.invalidateViews();
    } else if (id == NotificationCenter.showBulletin) {
        if (!mainFragmentsStack.isEmpty()) {
            int type = (int) args[0];
            FrameLayout container = null;
            BaseFragment fragment = null;
            if (GroupCallActivity.groupCallUiVisible && GroupCallActivity.groupCallInstance != null) {
                container = GroupCallActivity.groupCallInstance.getContainer();
            }
            if (container == null) {
                fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
            }
            if (type == Bulletin.TYPE_NAME_CHANGED) {
                long peerId = (long) args[1];
                String text = peerId > 0 ? LocaleController.getString("YourNameChanged", R.string.YourNameChanged) : LocaleController.getString("CannelTitleChanged", R.string.ChannelTitleChanged);
                (container != null ? BulletinFactory.of(container, null) : BulletinFactory.of(fragment)).createErrorBulletin(text).show();
            } else if (type == Bulletin.TYPE_BIO_CHANGED) {
                long peerId = (long) args[1];
                String text = peerId > 0 ? LocaleController.getString("YourBioChanged", R.string.YourBioChanged) : LocaleController.getString("CannelDescriptionChanged", R.string.ChannelDescriptionChanged);
                (container != null ? BulletinFactory.of(container, null) : BulletinFactory.of(fragment)).createErrorBulletin(text).show();
            } else if (type == Bulletin.TYPE_STICKER) {
                TLRPC.Document sticker = (TLRPC.Document) args[1];
                StickerSetBulletinLayout layout = new StickerSetBulletinLayout(this, null, (int) args[2], sticker, null);
                if (fragment != null) {
                    Bulletin.make(fragment, layout, Bulletin.DURATION_SHORT).show();
                } else {
                    Bulletin.make(container, layout, Bulletin.DURATION_SHORT).show();
                }
            } else if (type == Bulletin.TYPE_ERROR) {
                if (fragment != null) {
                    BulletinFactory.of(fragment).createErrorBulletin((String) args[1]).show();
                } else {
                    BulletinFactory.of(container, null).createErrorBulletin((String) args[1]).show();
                }
            }
        }
    } else if (id == NotificationCenter.groupCallUpdated) {
        checkWasMutedByAdmin(false);
    } else if (id == NotificationCenter.fileLoadProgressChanged) {
        if (updateTextView != null && SharedConfig.isAppUpdateAvailable()) {
            String location = (String) args[0];
            String fileName = FileLoader.getAttachFileName(SharedConfig.pendingAppUpdate.document);
            if (fileName != null && fileName.equals(location)) {
                Long loadedSize = (Long) args[1];
                Long totalSize = (Long) args[2];
                float loadProgress = loadedSize / (float) totalSize;
                updateLayoutIcon.setProgress(loadProgress, true);
                updateTextView.setText(LocaleController.formatString("AppUpdateDownloading", R.string.AppUpdateDownloading, (int) (loadProgress * 100)));
            }
        }
    } else if (id == NotificationCenter.appUpdateAvailable) {
        updateAppUpdateViews(mainFragmentsStack.size() == 1);
    }
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) UpdateAppAlertDialog(org.telegram.ui.Components.UpdateAppAlertDialog) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AbstractSerializedData(org.telegram.tgnet.AbstractSerializedData) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) StickersAlert(org.telegram.ui.Components.StickersAlert) LocationController(org.telegram.messenger.LocationController) Bulletin(org.telegram.ui.Components.Bulletin) VoIPPendingCall(org.telegram.messenger.voip.VoIPPendingCall) MediaActionDrawable(org.telegram.ui.Components.MediaActionDrawable) ShortcutManagerCompat(androidx.core.content.pm.ShortcutManagerCompat) Manifest(android.Manifest) Matcher(java.util.regex.Matcher) DrawerProfileCell(org.telegram.ui.Cells.DrawerProfileCell) Map(java.util.Map) Shader(android.graphics.Shader) Canvas(android.graphics.Canvas) Function(androidx.arch.core.util.Function) UndoView(org.telegram.ui.Components.UndoView) ContactsLoadingObserver(org.telegram.messenger.ContactsLoadingObserver) Set(java.util.Set) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) FileLoader(org.telegram.messenger.FileLoader) GroupCallPip(org.telegram.ui.Components.GroupCallPip) ViewParent(android.view.ViewParent) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) SimpleDateFormat(java.text.SimpleDateFormat) SystemClock(android.os.SystemClock) AlertsCreator(org.telegram.ui.Components.AlertsCreator) WebRtcAudioTrack(org.webrtc.voiceengine.WebRtcAudioTrack) ArrayList(java.util.ArrayList) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) PhoneFormat(org.telegram.PhoneFormat.PhoneFormat) Menu(android.view.Menu) PasscodeView(org.telegram.ui.Components.PasscodeView) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) Settings(android.provider.Settings) JoinGroupAlert(org.telegram.ui.Components.JoinGroupAlert) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) LinearGradient(android.graphics.LinearGradient) Parcelable(android.os.Parcelable) R(org.telegram.messenger.R) LanguageCell(org.telegram.ui.Cells.LanguageCell) SideMenultItemAnimator(org.telegram.ui.Components.SideMenultItemAnimator) TextUtils(android.text.TextUtils) InputStreamReader(java.io.InputStreamReader) DrawerLayoutContainer(org.telegram.ui.ActionBar.DrawerLayoutContainer) File(java.io.File) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) DrawerAddCell(org.telegram.ui.Cells.DrawerAddCell) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) MessagesStorage(org.telegram.messenger.MessagesStorage) Configuration(android.content.res.Configuration) Easings(org.telegram.ui.Components.Easings) BufferedReader(java.io.BufferedReader) ChatObject(org.telegram.messenger.ChatObject) CameraController(org.telegram.messenger.camera.CameraController) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) ActionMode(android.view.ActionMode) LinearLayout(android.widget.LinearLayout) RadialProgress2(org.telegram.ui.Components.RadialProgress2) PackageManager(android.content.pm.PackageManager) Date(java.util.Date) DrawerLayoutAdapter(org.telegram.ui.Adapters.DrawerLayoutAdapter) WindowManager(android.view.WindowManager) AccountInstance(org.telegram.messenger.AccountInstance) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) VideoCapturerDevice(org.telegram.messenger.voip.VideoCapturerDevice) Animator(android.animation.Animator) ApplicationLoader(org.telegram.messenger.ApplicationLoader) ContactsContract(android.provider.ContactsContract) MediaController(org.telegram.messenger.MediaController) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TermsOfServiceView(org.telegram.ui.Components.TermsOfServiceView) Matrix(android.graphics.Matrix) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) ImageLoader(org.telegram.messenger.ImageLoader) DrawerUserCell(org.telegram.ui.Cells.DrawerUserCell) Utilities(org.telegram.messenger.Utilities) RLottieImageView(org.telegram.ui.Components.RLottieImageView) ObjectAnimator(android.animation.ObjectAnimator) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ViewAnimationUtils(android.view.ViewAnimationUtils) SendMessagesHelper(org.telegram.messenger.SendMessagesHelper) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) BlockingUpdateView(org.telegram.ui.Components.BlockingUpdateView) ViewGroup(android.view.ViewGroup) UserConfig(org.telegram.messenger.UserConfig) List(java.util.List) TextView(android.widget.TextView) PhonebookShareAlert(org.telegram.ui.Components.PhonebookShareAlert) RelativeLayout(android.widget.RelativeLayout) Pattern(java.util.regex.Pattern) Location(android.location.Location) LocationManager(android.location.LocationManager) Window(android.view.Window) ActivityManager(android.app.ActivityManager) Context(android.content.Context) KeyEvent(android.view.KeyEvent) VoIPService(org.telegram.messenger.voip.VoIPService) Theme(org.telegram.ui.ActionBar.Theme) BulletinFactory(org.telegram.ui.Components.BulletinFactory) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) SharingLocationsAlert(org.telegram.ui.Components.SharingLocationsAlert) AudioManager(android.media.AudioManager) MotionEvent(android.view.MotionEvent) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) MediaDataController(org.telegram.messenger.MediaDataController) Build(android.os.Build) ShortcutInfoCompat(androidx.core.content.pm.ShortcutInfoCompat) Cursor(android.database.Cursor) Browser(org.telegram.messenger.browser.Browser) EmbedBottomSheet(org.telegram.ui.Components.EmbedBottomSheet) DialogObject(org.telegram.messenger.DialogObject) Point(android.graphics.Point) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) StatFs(android.os.StatFs) Bitmap(android.graphics.Bitmap) Base64(android.util.Base64) ViewTreeObserver(android.view.ViewTreeObserver) UpdateAppAlertDialog(org.telegram.ui.Components.UpdateAppAlertDialog) Activity(android.app.Activity) RecyclerListView(org.telegram.ui.Components.RecyclerListView) StickerSetBulletinLayout(org.telegram.ui.Components.StickerSetBulletinLayout) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) InputStream(java.io.InputStream) HashMap(java.util.HashMap) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) TLRPC(org.telegram.tgnet.TLRPC) Canvas(android.graphics.Canvas) DrawerUserCell(org.telegram.ui.Cells.DrawerUserCell) File(java.io.File) ContactsController(org.telegram.messenger.ContactsController) RLottieImageView(org.telegram.ui.Components.RLottieImageView) StickerSetBulletinLayout(org.telegram.ui.Components.StickerSetBulletinLayout) ActivityManager(android.app.ActivityManager) Bitmap(android.graphics.Bitmap) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ImageView(android.widget.ImageView) UndoView(org.telegram.ui.Components.UndoView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) PasscodeView(org.telegram.ui.Components.PasscodeView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TermsOfServiceView(org.telegram.ui.Components.TermsOfServiceView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BlockingUpdateView(org.telegram.ui.Components.BlockingUpdateView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Paint(android.graphics.Paint) Point(android.graphics.Point) ParseException(java.text.ParseException) SideMenultItemAnimator(org.telegram.ui.Components.SideMenultItemAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) TLObject(org.telegram.tgnet.TLObject) FrameLayout(android.widget.FrameLayout) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) Theme(org.telegram.ui.ActionBar.Theme) MessageObject(org.telegram.messenger.MessageObject)

Aggregations

TLRPC (org.telegram.tgnet.TLRPC)3 StickerSetBulletinLayout (org.telegram.ui.Components.StickerSetBulletinLayout)3 Paint (android.graphics.Paint)2 Bulletin (org.telegram.ui.Components.Bulletin)2 Manifest (android.Manifest)1 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 Activity (android.app.Activity)1 ActivityManager (android.app.ActivityManager)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 PackageManager (android.content.pm.PackageManager)1 Configuration (android.content.res.Configuration)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Color (android.graphics.Color)1 LinearGradient (android.graphics.LinearGradient)1