Search in sources :

Example 11 with ActionBarLayout

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

the class CameraScanActivity method showAsSheet.

public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate delegate) {
    if (parentFragment == null || parentFragment.getParentActivity() == null) {
        return null;
    }
    ActionBarLayout[] actionBarLayout = new ActionBarLayout[] { new ActionBarLayout(parentFragment.getParentActivity()) };
    BottomSheet bottomSheet = new BottomSheet(parentFragment.getParentActivity(), false) {

        {
            actionBarLayout[0].init(new ArrayList<>());
            CameraScanActivity fragment = new CameraScanActivity(type) {

                @Override
                public void finishFragment() {
                    dismiss();
                }

                @Override
                public void removeSelfFromStack() {
                    dismiss();
                }
            };
            fragment.needGalleryButton = gallery;
            actionBarLayout[0].addFragmentToStack(fragment);
            actionBarLayout[0].showLastFragment();
            actionBarLayout[0].setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
            fragment.setDelegate(delegate);
            containerView = actionBarLayout[0];
            setApplyBottomPadding(false);
            setApplyBottomPadding(false);
            setOnDismissListener(dialog -> fragment.onFragmentDestroy());
        }

        @Override
        protected boolean canDismissWithSwipe() {
            return false;
        }

        @Override
        public void onBackPressed() {
            if (actionBarLayout[0] == null || actionBarLayout[0].fragmentsStack.size() <= 1) {
                super.onBackPressed();
            } else {
                actionBarLayout[0].onBackPressed();
            }
        }

        @Override
        public void dismiss() {
            super.dismiss();
            actionBarLayout[0] = null;
        }
    };
    bottomSheet.show();
    return actionBarLayout;
}
Also used : BottomSheet(org.telegram.ui.ActionBar.BottomSheet) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout)

Example 12 with ActionBarLayout

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

the class LaunchActivity method runLinkRequest.

private void runLinkRequest(final int intentAccount, final String username, final String group, final String sticker, final String botUser, final String botChat, final String message, final boolean hasUrl, final Integer messageId, final Long channelId, final Integer threadId, final Integer commentId, final String game, final HashMap<String, String> auth, final String lang, final String unsupportedUrl, final String code, final String loginToken, final TLRPC.TL_wallPaper wallPaper, final String theme, final String voicechat, final String livestream, final int state, final int videoTimestamp) {
    if (state == 0 && UserConfig.getActivatedAccountsCount() >= 2 && auth != null) {
        AlertsCreator.createAccountSelectDialog(this, account -> {
            if (account != intentAccount) {
                switchToAccount(account, true);
            }
            runLinkRequest(account, username, group, sticker, botUser, botChat, message, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, theme, voicechat, livestream, 1, videoTimestamp);
        }).show();
        return;
    } else if (code != null) {
        if (NotificationCenter.getGlobalInstance().hasObservers(NotificationCenter.didReceiveSmsCode)) {
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, code);
        } else {
            AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("OtherLoginCode", R.string.OtherLoginCode, code)));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            showAlertDialog(builder);
        }
        return;
    } else if (loginToken != null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
        builder.setTitle(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient));
        builder.setMessage(LocaleController.getString("AuthAnotherClientUrl", R.string.AuthAnotherClientUrl));
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        showAlertDialog(builder);
        return;
    }
    final AlertDialog progressDialog = new AlertDialog(this, 3);
    final int[] requestId = new int[] { 0 };
    Runnable cancelRunnable = null;
    if (username != null) {
        TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
        req.username = username;
        requestId[0] = ConnectionsManager.getInstance(intentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            if (!LaunchActivity.this.isFinishing()) {
                boolean hideProgressDialog = true;
                final TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
                if (error == null && actionBarLayout != null && (game == null && voicechat == null || game != null && !res.users.isEmpty() || voicechat != null && !res.chats.isEmpty() || livestream != null && !res.chats.isEmpty())) {
                    MessagesController.getInstance(intentAccount).putUsers(res.users, false);
                    MessagesController.getInstance(intentAccount).putChats(res.chats, false);
                    MessagesStorage.getInstance(intentAccount).putUsersAndChats(res.users, res.chats, false, true);
                    if (messageId != null && (commentId != null || threadId != null) && !res.chats.isEmpty()) {
                        requestId[0] = runCommentRequest(intentAccount, progressDialog, messageId, commentId, threadId, res.chats.get(0));
                        if (requestId[0] != 0) {
                            hideProgressDialog = false;
                        }
                    } else if (game != null) {
                        Bundle args = new Bundle();
                        args.putBoolean("onlySelect", true);
                        args.putBoolean("cantSendToChannels", true);
                        args.putInt("dialogsType", 1);
                        args.putString("selectAlertString", LocaleController.getString("SendGameToText", R.string.SendGameToText));
                        args.putString("selectAlertStringGroup", LocaleController.getString("SendGameToGroupText", R.string.SendGameToGroupText));
                        DialogsActivity fragment = new DialogsActivity(args);
                        fragment.setDelegate((fragment1, dids, message1, param) -> {
                            long did = dids.get(0);
                            TLRPC.TL_inputMediaGame inputMediaGame = new TLRPC.TL_inputMediaGame();
                            inputMediaGame.id = new TLRPC.TL_inputGameShortName();
                            inputMediaGame.id.short_name = game;
                            inputMediaGame.id.bot_id = MessagesController.getInstance(intentAccount).getInputUser(res.users.get(0));
                            SendMessagesHelper.getInstance(intentAccount).sendGame(MessagesController.getInstance(intentAccount).getInputPeer(did), inputMediaGame, 0, 0);
                            Bundle args1 = new Bundle();
                            args1.putBoolean("scrollToTopOnResume", true);
                            if (DialogObject.isEncryptedDialog(did)) {
                                args1.putInt("enc_id", DialogObject.getEncryptedChatId(did));
                            } else if (DialogObject.isUserDialog(did)) {
                                args1.putLong("user_id", did);
                            } else {
                                args1.putLong("chat_id", -did);
                            }
                            if (MessagesController.getInstance(intentAccount).checkCanOpenChat(args1, fragment1)) {
                                NotificationCenter.getInstance(intentAccount).postNotificationName(NotificationCenter.closeChats);
                                actionBarLayout.presentFragment(new ChatActivity(args1), true, false, true, false);
                            }
                        });
                        boolean removeLast;
                        if (AndroidUtilities.isTablet()) {
                            removeLast = layersActionBarLayout.fragmentsStack.size() > 0 && layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
                        } else {
                            removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
                        }
                        actionBarLayout.presentFragment(fragment, removeLast, true, true, false);
                        if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
                            SecretMediaViewer.getInstance().closePhoto(false, false);
                        } else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
                            PhotoViewer.getInstance().closePhoto(false, true);
                        } else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
                            ArticleViewer.getInstance().close(false, true);
                        }
                        if (GroupCallActivity.groupCallInstance != null) {
                            GroupCallActivity.groupCallInstance.dismiss();
                        }
                        drawerLayoutContainer.setAllowOpenDrawer(false, false);
                        if (AndroidUtilities.isTablet()) {
                            actionBarLayout.showLastFragment();
                            rightActionBarLayout.showLastFragment();
                        } else {
                            drawerLayoutContainer.setAllowOpenDrawer(true, false);
                        }
                    } else if (botChat != null) {
                        final TLRPC.User user = !res.users.isEmpty() ? res.users.get(0) : null;
                        if (user == null || user.bot && user.bot_nochats) {
                            try {
                                if (!mainFragmentsStack.isEmpty()) {
                                    BulletinFactory.of(mainFragmentsStack.get(mainFragmentsStack.size() - 1)).createErrorBulletin(LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups)).show();
                                }
                            } catch (Exception e) {
                                FileLog.e(e);
                            }
                            return;
                        }
                        Bundle args = new Bundle();
                        args.putBoolean("onlySelect", true);
                        args.putInt("dialogsType", 2);
                        args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupAlertText", R.string.AddToTheGroupAlertText, UserObject.getUserName(user), "%1$s"));
                        DialogsActivity fragment = new DialogsActivity(args);
                        fragment.setDelegate((fragment12, dids, message1, param) -> {
                            long did = dids.get(0);
                            Bundle args12 = new Bundle();
                            args12.putBoolean("scrollToTopOnResume", true);
                            args12.putLong("chat_id", -did);
                            if (mainFragmentsStack.isEmpty() || MessagesController.getInstance(intentAccount).checkCanOpenChat(args12, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
                                NotificationCenter.getInstance(intentAccount).postNotificationName(NotificationCenter.closeChats);
                                MessagesController.getInstance(intentAccount).addUserToChat(-did, user, 0, botChat, null, null);
                                actionBarLayout.presentFragment(new ChatActivity(args12), true, false, true, false);
                            }
                        });
                        presentFragment(fragment);
                    } else {
                        long dialog_id;
                        boolean isBot = false;
                        Bundle args = new Bundle();
                        if (!res.chats.isEmpty()) {
                            args.putLong("chat_id", res.chats.get(0).id);
                            dialog_id = -res.chats.get(0).id;
                        } else {
                            args.putLong("user_id", res.users.get(0).id);
                            dialog_id = res.users.get(0).id;
                        }
                        if (botUser != null && res.users.size() > 0 && res.users.get(0).bot) {
                            args.putString("botUser", botUser);
                            isBot = true;
                        }
                        if (messageId != null) {
                            args.putInt("message_id", messageId);
                        }
                        if (voicechat != null) {
                            args.putString("voicechat", voicechat);
                        }
                        if (livestream != null) {
                            args.putString("livestream", livestream);
                        }
                        if (videoTimestamp >= 0) {
                            args.putInt("video_timestamp", videoTimestamp);
                        }
                        BaseFragment lastFragment = !mainFragmentsStack.isEmpty() && voicechat == null ? mainFragmentsStack.get(mainFragmentsStack.size() - 1) : null;
                        if (lastFragment == null || MessagesController.getInstance(intentAccount).checkCanOpenChat(args, lastFragment)) {
                            if (isBot && lastFragment instanceof ChatActivity && ((ChatActivity) lastFragment).getDialogId() == dialog_id) {
                                ((ChatActivity) lastFragment).setBotUser(botUser);
                            } else {
                                MessagesController.getInstance(intentAccount).ensureMessagesLoaded(dialog_id, messageId == null ? 0 : messageId, new MessagesController.MessagesLoadedCallback() {

                                    @Override
                                    public void onMessagesLoaded(boolean fromCache) {
                                        try {
                                            progressDialog.dismiss();
                                        } catch (Exception e) {
                                            FileLog.e(e);
                                        }
                                        if (!LaunchActivity.this.isFinishing()) {
                                            ChatActivity fragment = new ChatActivity(args);
                                            actionBarLayout.presentFragment(fragment);
                                        }
                                    }

                                    @Override
                                    public void onError() {
                                        if (!LaunchActivity.this.isFinishing()) {
                                            BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
                                            AlertsCreator.showSimpleAlert(fragment, LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
                                        }
                                        try {
                                            progressDialog.dismiss();
                                        } catch (Exception e) {
                                            FileLog.e(e);
                                        }
                                    }
                                });
                                hideProgressDialog = false;
                            }
                        }
                    }
                } else {
                    try {
                        if (!mainFragmentsStack.isEmpty()) {
                            BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
                            if (error != null && error.text != null && error.text.startsWith("FLOOD_WAIT")) {
                                BulletinFactory.of(fragment).createErrorBulletin(LocaleController.getString("FloodWait", R.string.FloodWait)).show();
                            } else {
                                BulletinFactory.of(fragment).createErrorBulletin(LocaleController.getString("NoUsernameFound", R.string.NoUsernameFound)).show();
                            }
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                if (hideProgressDialog) {
                    try {
                        progressDialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
            }
        }, ConnectionsManager.RequestFlagFailOnServerErrors));
    } else if (group != null) {
        if (state == 0) {
            final TLRPC.TL_messages_checkChatInvite req = new TLRPC.TL_messages_checkChatInvite();
            req.hash = group;
            requestId[0] = ConnectionsManager.getInstance(intentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                if (!LaunchActivity.this.isFinishing()) {
                    boolean hideProgressDialog = true;
                    if (error == null && actionBarLayout != null) {
                        TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response;
                        if (invite.chat != null && (!ChatObject.isLeftFromChat(invite.chat) || !invite.chat.kicked && (!TextUtils.isEmpty(invite.chat.username) || invite instanceof TLRPC.TL_chatInvitePeek || invite.chat.has_geo))) {
                            MessagesController.getInstance(intentAccount).putChat(invite.chat, false);
                            ArrayList<TLRPC.Chat> chats = new ArrayList<>();
                            chats.add(invite.chat);
                            MessagesStorage.getInstance(intentAccount).putUsersAndChats(null, chats, false, true);
                            Bundle args = new Bundle();
                            args.putLong("chat_id", invite.chat.id);
                            if (mainFragmentsStack.isEmpty() || MessagesController.getInstance(intentAccount).checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
                                boolean[] canceled = new boolean[1];
                                progressDialog.setOnCancelListener(dialog -> canceled[0] = true);
                                MessagesController.getInstance(intentAccount).ensureMessagesLoaded(-invite.chat.id, 0, new MessagesController.MessagesLoadedCallback() {

                                    @Override
                                    public void onMessagesLoaded(boolean fromCache) {
                                        try {
                                            progressDialog.dismiss();
                                        } catch (Exception e) {
                                            FileLog.e(e);
                                        }
                                        if (canceled[0]) {
                                            return;
                                        }
                                        ChatActivity fragment = new ChatActivity(args);
                                        if (invite instanceof TLRPC.TL_chatInvitePeek) {
                                            fragment.setChatInvite(invite);
                                        }
                                        actionBarLayout.presentFragment(fragment);
                                    }

                                    @Override
                                    public void onError() {
                                        if (!LaunchActivity.this.isFinishing()) {
                                            BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
                                            AlertsCreator.showSimpleAlert(fragment, LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
                                        }
                                        try {
                                            progressDialog.dismiss();
                                        } catch (Exception e) {
                                            FileLog.e(e);
                                        }
                                    }
                                });
                                hideProgressDialog = false;
                            }
                        } else {
                            BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
                            fragment.showDialog(new JoinGroupAlert(LaunchActivity.this, invite, group, fragment));
                        }
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
                        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                        if (error.text.startsWith("FLOOD_WAIT")) {
                            builder.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
                        } else if (error.text.startsWith("INVITE_HASH_EXPIRED")) {
                            builder.setTitle(LocaleController.getString("ExpiredLink", R.string.ExpiredLink));
                            builder.setMessage(LocaleController.getString("InviteExpired", R.string.InviteExpired));
                        } else {
                            builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
                        }
                        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                        showAlertDialog(builder);
                    }
                    try {
                        if (hideProgressDialog) {
                            progressDialog.dismiss();
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
            }), ConnectionsManager.RequestFlagFailOnServerErrors);
        } else if (state == 1) {
            TLRPC.TL_messages_importChatInvite req = new TLRPC.TL_messages_importChatInvite();
            req.hash = group;
            ConnectionsManager.getInstance(intentAccount).sendRequest(req, (response, error) -> {
                if (error == null) {
                    TLRPC.Updates updates = (TLRPC.Updates) response;
                    MessagesController.getInstance(intentAccount).processUpdates(updates, false);
                }
                AndroidUtilities.runOnUIThread(() -> {
                    if (!LaunchActivity.this.isFinishing()) {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                        if (error == null) {
                            if (actionBarLayout != null) {
                                TLRPC.Updates updates = (TLRPC.Updates) response;
                                if (!updates.chats.isEmpty()) {
                                    TLRPC.Chat chat = updates.chats.get(0);
                                    chat.left = false;
                                    chat.kicked = false;
                                    MessagesController.getInstance(intentAccount).putUsers(updates.users, false);
                                    MessagesController.getInstance(intentAccount).putChats(updates.chats, false);
                                    Bundle args = new Bundle();
                                    args.putLong("chat_id", chat.id);
                                    if (mainFragmentsStack.isEmpty() || MessagesController.getInstance(intentAccount).checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
                                        ChatActivity fragment = new ChatActivity(args);
                                        NotificationCenter.getInstance(intentAccount).postNotificationName(NotificationCenter.closeChats);
                                        actionBarLayout.presentFragment(fragment, false, true, true, false);
                                    }
                                }
                            }
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            if (error.text.startsWith("FLOOD_WAIT")) {
                                builder.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
                            } else if (error.text.equals("USERS_TOO_MUCH")) {
                                builder.setMessage(LocaleController.getString("JoinToGroupErrorFull", R.string.JoinToGroupErrorFull));
                            } else {
                                builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
                            }
                            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                            showAlertDialog(builder);
                        }
                    }
                });
            }, ConnectionsManager.RequestFlagFailOnServerErrors);
        }
    } else if (sticker != null) {
        if (!mainFragmentsStack.isEmpty()) {
            TLRPC.TL_inputStickerSetShortName stickerset = new TLRPC.TL_inputStickerSetShortName();
            stickerset.short_name = sticker;
            BaseFragment fragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
            StickersAlert alert;
            if (fragment instanceof ChatActivity) {
                ChatActivity chatActivity = (ChatActivity) fragment;
                alert = new StickersAlert(LaunchActivity.this, fragment, stickerset, null, chatActivity.getChatActivityEnterViewForStickers(), chatActivity.getResourceProvider());
                alert.setCalcMandatoryInsets(chatActivity.isKeyboardVisible());
            } else {
                alert = new StickersAlert(LaunchActivity.this, fragment, stickerset, null, null);
            }
            fragment.showDialog(alert);
        }
        return;
    } else if (message != null) {
        Bundle args = new Bundle();
        args.putBoolean("onlySelect", true);
        args.putInt("dialogsType", 3);
        DialogsActivity fragment = new DialogsActivity(args);
        fragment.setDelegate((fragment13, dids, m, param) -> {
            long did = dids.get(0);
            Bundle args13 = new Bundle();
            args13.putBoolean("scrollToTopOnResume", true);
            args13.putBoolean("hasUrl", hasUrl);
            if (DialogObject.isEncryptedDialog(did)) {
                args13.putInt("enc_id", DialogObject.getEncryptedChatId(did));
            } else if (DialogObject.isUserDialog(did)) {
                args13.putLong("user_id", did);
            } else {
                args13.putLong("chat_id", -did);
            }
            if (MessagesController.getInstance(intentAccount).checkCanOpenChat(args13, fragment13)) {
                NotificationCenter.getInstance(intentAccount).postNotificationName(NotificationCenter.closeChats);
                MediaDataController.getInstance(intentAccount).saveDraft(did, 0, message, null, null, false);
                actionBarLayout.presentFragment(new ChatActivity(args13), true, false, true, false);
            }
        });
        presentFragment(fragment, false, true);
    } else if (auth != null) {
        final int bot_id = Utilities.parseInt(auth.get("bot_id"));
        if (bot_id == 0) {
            return;
        }
        final String payload = auth.get("payload");
        final String nonce = auth.get("nonce");
        final String callbackUrl = auth.get("callback_url");
        final TLRPC.TL_account_getAuthorizationForm req = new TLRPC.TL_account_getAuthorizationForm();
        req.bot_id = bot_id;
        req.scope = auth.get("scope");
        req.public_key = auth.get("public_key");
        requestId[0] = ConnectionsManager.getInstance(intentAccount).sendRequest(req, (response, error) -> {
            final TLRPC.TL_account_authorizationForm authorizationForm = (TLRPC.TL_account_authorizationForm) response;
            if (authorizationForm != null) {
                TLRPC.TL_account_getPassword req2 = new TLRPC.TL_account_getPassword();
                requestId[0] = ConnectionsManager.getInstance(intentAccount).sendRequest(req2, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> {
                    try {
                        progressDialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                    if (response1 != null) {
                        TLRPC.TL_account_password accountPassword = (TLRPC.TL_account_password) response1;
                        MessagesController.getInstance(intentAccount).putUsers(authorizationForm.users, false);
                        presentFragment(new PassportActivity(PassportActivity.TYPE_PASSWORD, req.bot_id, req.scope, req.public_key, payload, nonce, callbackUrl, authorizationForm, accountPassword));
                    }
                }));
            } else {
                AndroidUtilities.runOnUIThread(() -> {
                    try {
                        progressDialog.dismiss();
                        if ("APP_VERSION_OUTDATED".equals(error.text)) {
                            AlertsCreator.showUpdateAppAlert(LaunchActivity.this, LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                        } else {
                            showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text));
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                });
            }
        });
    } else if (unsupportedUrl != null) {
        TLRPC.TL_help_getDeepLinkInfo req = new TLRPC.TL_help_getDeepLinkInfo();
        req.path = unsupportedUrl;
        requestId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            try {
                progressDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (response instanceof TLRPC.TL_help_deepLinkInfo) {
                TLRPC.TL_help_deepLinkInfo res = (TLRPC.TL_help_deepLinkInfo) response;
                AlertsCreator.showUpdateAppAlert(LaunchActivity.this, res.message, res.update_app);
            }
        }));
    } else if (lang != null) {
        TLRPC.TL_langpack_getLanguage req = new TLRPC.TL_langpack_getLanguage();
        req.lang_code = lang;
        req.lang_pack = "android";
        requestId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            try {
                progressDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (response instanceof TLRPC.TL_langPackLanguage) {
                TLRPC.TL_langPackLanguage res = (TLRPC.TL_langPackLanguage) response;
                showAlertDialog(AlertsCreator.createLanguageAlert(LaunchActivity.this, res));
            } else if (error != null) {
                if ("LANG_CODE_NOT_SUPPORTED".equals(error.text)) {
                    showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("LanguageUnsupportedError", R.string.LanguageUnsupportedError)));
                } else {
                    showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text));
                }
            }
        }));
    } else if (wallPaper != null) {
        boolean ok = false;
        if (TextUtils.isEmpty(wallPaper.slug)) {
            try {
                WallpapersListActivity.ColorWallpaper colorWallpaper;
                if (wallPaper.settings.third_background_color != 0) {
                    colorWallpaper = new WallpapersListActivity.ColorWallpaper(Theme.COLOR_BACKGROUND_SLUG, wallPaper.settings.background_color, wallPaper.settings.second_background_color, wallPaper.settings.third_background_color, wallPaper.settings.fourth_background_color);
                } else {
                    colorWallpaper = new WallpapersListActivity.ColorWallpaper(Theme.COLOR_BACKGROUND_SLUG, wallPaper.settings.background_color, wallPaper.settings.second_background_color, AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false));
                }
                ThemePreviewActivity wallpaperActivity = new ThemePreviewActivity(colorWallpaper, null, true, false);
                AndroidUtilities.runOnUIThread(() -> presentFragment(wallpaperActivity));
                ok = true;
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
        if (!ok) {
            TLRPC.TL_account_getWallPaper req = new TLRPC.TL_account_getWallPaper();
            TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
            inputWallPaperSlug.slug = wallPaper.slug;
            req.wallpaper = inputWallPaperSlug;
            requestId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                try {
                    progressDialog.dismiss();
                } catch (Exception e) {
                    FileLog.e(e);
                }
                if (response instanceof TLRPC.TL_wallPaper) {
                    TLRPC.TL_wallPaper res = (TLRPC.TL_wallPaper) response;
                    Object object;
                    if (res.pattern) {
                        WallpapersListActivity.ColorWallpaper colorWallpaper = new WallpapersListActivity.ColorWallpaper(res.slug, wallPaper.settings.background_color, wallPaper.settings.second_background_color, wallPaper.settings.third_background_color, wallPaper.settings.fourth_background_color, AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false), wallPaper.settings.intensity / 100.0f, wallPaper.settings.motion, null);
                        colorWallpaper.pattern = res;
                        object = colorWallpaper;
                    } else {
                        object = res;
                    }
                    ThemePreviewActivity wallpaperActivity = new ThemePreviewActivity(object, null, true, false);
                    wallpaperActivity.setInitialModes(wallPaper.settings.blur, wallPaper.settings.motion);
                    presentFragment(wallpaperActivity);
                } else {
                    showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text));
                }
            }));
        }
    } else if (theme != null) {
        cancelRunnable = () -> {
            loadingThemeFileName = null;
            loadingThemeWallpaperName = null;
            loadingThemeWallpaper = null;
            loadingThemeInfo = null;
            loadingThemeProgressDialog = null;
            loadingTheme = null;
        };
        TLRPC.TL_account_getTheme req = new TLRPC.TL_account_getTheme();
        req.format = "android";
        TLRPC.TL_inputThemeSlug inputThemeSlug = new TLRPC.TL_inputThemeSlug();
        inputThemeSlug.slug = theme;
        req.theme = inputThemeSlug;
        requestId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
            int notFound = 2;
            if (response instanceof TLRPC.TL_theme) {
                TLRPC.TL_theme t = (TLRPC.TL_theme) response;
                TLRPC.ThemeSettings settings = null;
                if (t.settings.size() > 0) {
                    settings = t.settings.get(0);
                }
                if (settings != null) {
                    String key = Theme.getBaseThemeKey(settings);
                    Theme.ThemeInfo info = Theme.getTheme(key);
                    if (info != null) {
                        TLRPC.TL_wallPaper object;
                        if (settings.wallpaper instanceof TLRPC.TL_wallPaper) {
                            object = (TLRPC.TL_wallPaper) settings.wallpaper;
                            File path = FileLoader.getPathToAttach(object.document, true);
                            if (!path.exists()) {
                                loadingThemeProgressDialog = progressDialog;
                                loadingThemeAccent = true;
                                loadingThemeInfo = info;
                                loadingTheme = t;
                                loadingThemeWallpaper = object;
                                loadingThemeWallpaperName = FileLoader.getAttachFileName(object.document);
                                FileLoader.getInstance(currentAccount).loadFile(object.document, object, 1, 1);
                                return;
                            }
                        } else {
                            object = null;
                        }
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                        notFound = 0;
                        openThemeAccentPreview(t, object, info);
                    } else {
                        notFound = 1;
                    }
                } else if (t.document != null) {
                    loadingThemeAccent = false;
                    loadingTheme = t;
                    loadingThemeFileName = FileLoader.getAttachFileName(loadingTheme.document);
                    loadingThemeProgressDialog = progressDialog;
                    FileLoader.getInstance(currentAccount).loadFile(loadingTheme.document, t, 1, 1);
                    notFound = 0;
                } else {
                    notFound = 1;
                }
            } else if (error != null && "THEME_FORMAT_INVALID".equals(error.text)) {
                notFound = 1;
            }
            if (notFound != 0) {
                try {
                    progressDialog.dismiss();
                } catch (Exception e) {
                    FileLog.e(e);
                }
                if (notFound == 1) {
                    showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("ThemeNotSupported", R.string.ThemeNotSupported)));
                } else {
                    showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("ThemeNotFound", R.string.ThemeNotFound)));
                }
            }
        }));
    } else if (channelId != null && messageId != null) {
        if (threadId != null) {
            TLRPC.Chat chat = MessagesController.getInstance(intentAccount).getChat(channelId);
            if (chat != null) {
                requestId[0] = runCommentRequest(intentAccount, progressDialog, messageId, commentId, threadId, chat);
            } else {
                TLRPC.TL_channels_getChannels req = new TLRPC.TL_channels_getChannels();
                TLRPC.TL_inputChannel inputChannel = new TLRPC.TL_inputChannel();
                inputChannel.channel_id = channelId;
                req.id.add(inputChannel);
                requestId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                    boolean notFound = true;
                    if (response instanceof TLRPC.TL_messages_chats) {
                        TLRPC.TL_messages_chats res = (TLRPC.TL_messages_chats) response;
                        if (!res.chats.isEmpty()) {
                            notFound = false;
                            MessagesController.getInstance(currentAccount).putChats(res.chats, false);
                            requestId[0] = runCommentRequest(intentAccount, progressDialog, messageId, commentId, threadId, res.chats.get(0));
                        }
                    }
                    if (notFound) {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                        showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("LinkNotFound", R.string.LinkNotFound)));
                    }
                }));
            }
        } else {
            Bundle args = new Bundle();
            args.putLong("chat_id", channelId);
            args.putInt("message_id", messageId);
            BaseFragment lastFragment = !mainFragmentsStack.isEmpty() ? mainFragmentsStack.get(mainFragmentsStack.size() - 1) : null;
            if (lastFragment == null || MessagesController.getInstance(intentAccount).checkCanOpenChat(args, lastFragment)) {
                AndroidUtilities.runOnUIThread(() -> {
                    if (!actionBarLayout.presentFragment(new ChatActivity(args))) {
                        TLRPC.TL_channels_getChannels req = new TLRPC.TL_channels_getChannels();
                        TLRPC.TL_inputChannel inputChannel = new TLRPC.TL_inputChannel();
                        inputChannel.channel_id = channelId;
                        req.id.add(inputChannel);
                        requestId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                            try {
                                progressDialog.dismiss();
                            } catch (Exception e) {
                                FileLog.e(e);
                            }
                            boolean notFound = true;
                            if (response instanceof TLRPC.TL_messages_chats) {
                                TLRPC.TL_messages_chats res = (TLRPC.TL_messages_chats) response;
                                if (!res.chats.isEmpty()) {
                                    notFound = false;
                                    MessagesController.getInstance(currentAccount).putChats(res.chats, false);
                                    TLRPC.Chat chat = res.chats.get(0);
                                    if (lastFragment == null || MessagesController.getInstance(intentAccount).checkCanOpenChat(args, lastFragment)) {
                                        actionBarLayout.presentFragment(new ChatActivity(args));
                                    }
                                }
                            }
                            if (notFound) {
                                showAlertDialog(AlertsCreator.createSimpleAlert(LaunchActivity.this, LocaleController.getString("LinkNotFound", R.string.LinkNotFound)));
                            }
                        }));
                    }
                });
            }
        }
    }
    if (requestId[0] != 0) {
        final Runnable cancelRunnableFinal = cancelRunnable;
        progressDialog.setOnCancelListener(dialog -> {
            ConnectionsManager.getInstance(intentAccount).cancelRequest(requestId[0], true);
            if (cancelRunnableFinal != null) {
                cancelRunnableFinal.run();
            }
        });
        try {
            progressDialog.showDelayed(300);
        } catch (Exception ignore) {
        }
    }
}
Also used : 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) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) UpdateAppAlertDialog(org.telegram.ui.Components.UpdateAppAlertDialog) ArrayList(java.util.ArrayList) TLRPC(org.telegram.tgnet.TLRPC) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) JoinGroupAlert(org.telegram.ui.Components.JoinGroupAlert) StickersAlert(org.telegram.ui.Components.StickersAlert) UserObject(org.telegram.messenger.UserObject) ChatObject(org.telegram.messenger.ChatObject) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) File(java.io.File) MessagesController(org.telegram.messenger.MessagesController) Bundle(android.os.Bundle) ParseException(java.text.ParseException) Paint(android.graphics.Paint) Point(android.graphics.Point) Theme(org.telegram.ui.ActionBar.Theme)

Example 13 with ActionBarLayout

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

the class LaunchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    ApplicationLoader.postInitApplication();
    AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
    currentAccount = UserConfig.selectedAccount;
    if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
        Intent intent = getIntent();
        boolean isProxy = false;
        if (intent != null && intent.getAction() != null) {
            if (Intent.ACTION_SEND.equals(intent.getAction()) || Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
                super.onCreate(savedInstanceState);
                finish();
                return;
            } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
                Uri uri = intent.getData();
                if (uri != null) {
                    String url = uri.toString().toLowerCase();
                    isProxy = url.startsWith("tg:proxy") || url.startsWith("tg://proxy") || url.startsWith("tg:socks") || url.startsWith("tg://socks");
                }
            }
        }
        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        long crashed_time = preferences.getLong("intro_crashed_time", 0);
        boolean fromIntro = intent != null && intent.getBooleanExtra("fromIntro", false);
        if (fromIntro) {
            preferences.edit().putLong("intro_crashed_time", 0).commit();
        }
        if (!isProxy && Math.abs(crashed_time - System.currentTimeMillis()) >= 60 * 2 * 1000 && intent != null && !fromIntro) {
            preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", MODE_PRIVATE);
            Map<String, ?> state = preferences.getAll();
            if (state.isEmpty()) {
                Intent intent2 = new Intent(this, IntroActivity.class);
                intent2.setData(intent.getData());
                startActivity(intent2);
                super.onCreate(savedInstanceState);
                finish();
                return;
            }
        }
    }
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages);
    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) {
        }
        try {
            getWindow().setNavigationBarColor(0xff000000);
        } catch (Exception ignore) {
        }
    }
    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
        try {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 24) {
        AndroidUtilities.isInMultiwindow = isInMultiWindowMode();
    }
    Theme.createCommonChatResources();
    Theme.createDialogsResources(this);
    if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.appLocked) {
        SharedConfig.lastPauseTime = (int) (SystemClock.elapsedRealtime() / 1000);
    }
    AndroidUtilities.fillStatusBarHeight(this);
    actionBarLayout = new ActionBarLayout(this) {

        @Override
        public void setThemeAnimationValue(float value) {
            super.setThemeAnimationValue(value);
            if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
                ArticleViewer.getInstance().updateThemeColors(value);
            }
            drawerLayoutContainer.setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
            if (PhotoViewer.hasInstance()) {
                PhotoViewer.getInstance().updateColors();
            }
        }
    };
    frameLayout = new FrameLayout(this);
    setContentView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (Build.VERSION.SDK_INT >= 21) {
        themeSwitchImageView = new ImageView(this);
        themeSwitchImageView.setVisibility(View.GONE);
    }
    drawerLayoutContainer = new DrawerLayoutContainer(this) {

        @Override
        protected void onLayout(boolean changed, int l, int t, int r, int b) {
            super.onLayout(changed, l, t, r, b);
            setDrawerPosition(getDrawerPosition());
        }
    };
    drawerLayoutContainer.setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    frameLayout.addView(drawerLayoutContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    if (Build.VERSION.SDK_INT >= 21) {
        themeSwitchSunView = new View(this) {

            @Override
            protected void onDraw(Canvas canvas) {
                if (themeSwitchSunDrawable != null) {
                    themeSwitchSunDrawable.draw(canvas);
                    invalidate();
                }
            }
        };
        frameLayout.addView(themeSwitchSunView, LayoutHelper.createFrame(48, 48));
        themeSwitchSunView.setVisibility(View.GONE);
    }
    if (AndroidUtilities.isTablet()) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        RelativeLayout launchLayout = new RelativeLayout(this) {

            private boolean inLayout;

            @Override
            public void requestLayout() {
                if (inLayout) {
                    return;
                }
                super.requestLayout();
            }

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                inLayout = true;
                int width = MeasureSpec.getSize(widthMeasureSpec);
                int height = MeasureSpec.getSize(heightMeasureSpec);
                setMeasuredDimension(width, height);
                if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)) {
                    tabletFullSize = false;
                    int leftWidth = width / 100 * 35;
                    if (leftWidth < AndroidUtilities.dp(320)) {
                        leftWidth = AndroidUtilities.dp(320);
                    }
                    actionBarLayout.measure(MeasureSpec.makeMeasureSpec(leftWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                    shadowTabletSide.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                    rightActionBarLayout.measure(MeasureSpec.makeMeasureSpec(width - leftWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                } else {
                    tabletFullSize = true;
                    actionBarLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                }
                backgroundTablet.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                shadowTablet.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                layersActionBarLayout.measure(MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(530), width), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(528), height), MeasureSpec.EXACTLY));
                inLayout = false;
            }

            @Override
            protected void onLayout(boolean changed, int l, int t, int r, int b) {
                int width = r - l;
                int height = b - t;
                if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)) {
                    int leftWidth = width / 100 * 35;
                    if (leftWidth < AndroidUtilities.dp(320)) {
                        leftWidth = AndroidUtilities.dp(320);
                    }
                    shadowTabletSide.layout(leftWidth, 0, leftWidth + shadowTabletSide.getMeasuredWidth(), shadowTabletSide.getMeasuredHeight());
                    actionBarLayout.layout(0, 0, actionBarLayout.getMeasuredWidth(), actionBarLayout.getMeasuredHeight());
                    rightActionBarLayout.layout(leftWidth, 0, leftWidth + rightActionBarLayout.getMeasuredWidth(), rightActionBarLayout.getMeasuredHeight());
                } else {
                    actionBarLayout.layout(0, 0, actionBarLayout.getMeasuredWidth(), actionBarLayout.getMeasuredHeight());
                }
                int x = (width - layersActionBarLayout.getMeasuredWidth()) / 2;
                int y = (height - layersActionBarLayout.getMeasuredHeight()) / 2;
                layersActionBarLayout.layout(x, y, x + layersActionBarLayout.getMeasuredWidth(), y + layersActionBarLayout.getMeasuredHeight());
                backgroundTablet.layout(0, 0, backgroundTablet.getMeasuredWidth(), backgroundTablet.getMeasuredHeight());
                shadowTablet.layout(0, 0, shadowTablet.getMeasuredWidth(), shadowTablet.getMeasuredHeight());
            }
        };
        drawerLayoutContainer.addView(launchLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        backgroundTablet = new SizeNotifierFrameLayout(this) {

            @Override
            protected boolean isActionBarVisible() {
                return false;
            }
        };
        backgroundTablet.setOccupyStatusBar(false);
        backgroundTablet.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
        launchLayout.addView(backgroundTablet, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        launchLayout.addView(actionBarLayout);
        rightActionBarLayout = new ActionBarLayout(this);
        rightActionBarLayout.init(rightFragmentsStack);
        rightActionBarLayout.setDelegate(this);
        launchLayout.addView(rightActionBarLayout);
        shadowTabletSide = new FrameLayout(this);
        shadowTabletSide.setBackgroundColor(0x40295274);
        launchLayout.addView(shadowTabletSide);
        shadowTablet = new FrameLayout(this);
        shadowTablet.setVisibility(layerFragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
        shadowTablet.setBackgroundColor(0x7f000000);
        launchLayout.addView(shadowTablet);
        shadowTablet.setOnTouchListener((v, event) -> {
            if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
                float x = event.getX();
                float y = event.getY();
                int[] location = new int[2];
                layersActionBarLayout.getLocationOnScreen(location);
                int viewX = location[0];
                int viewY = location[1];
                if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
                    return false;
                } else {
                    if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
                        for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
                            layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
                            a--;
                        }
                        layersActionBarLayout.closeLastFragment(true);
                    }
                    return true;
                }
            }
            return false;
        });
        shadowTablet.setOnClickListener(v -> {
        });
        layersActionBarLayout = new ActionBarLayout(this);
        layersActionBarLayout.setRemoveActionBarExtraHeight(true);
        layersActionBarLayout.setBackgroundView(shadowTablet);
        layersActionBarLayout.setUseAlphaAnimations(true);
        layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
        layersActionBarLayout.init(layerFragmentsStack);
        layersActionBarLayout.setDelegate(this);
        layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
        layersActionBarLayout.setVisibility(layerFragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
        launchLayout.addView(layersActionBarLayout);
    } else {
        drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }
    sideMenuContainer = new FrameLayout(this);
    sideMenu = new RecyclerListView(this) {

        @Override
        public boolean drawChild(Canvas canvas, View child, long drawingTime) {
            int restore = -1;
            if (itemAnimator != null && itemAnimator.isRunning() && itemAnimator.isAnimatingChild(child)) {
                restore = canvas.save();
                canvas.clipRect(0, itemAnimator.getAnimationClipTop(), getMeasuredWidth(), getMeasuredHeight());
            }
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (restore >= 0) {
                canvas.restoreToCount(restore);
                invalidate();
                invalidateViews();
            }
            return result;
        }
    };
    itemAnimator = new SideMenultItemAnimator(sideMenu);
    sideMenu.setItemAnimator(itemAnimator);
    sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
    sideMenu.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    sideMenu.setAllowItemsInteractionDuringAnimation(false);
    sideMenu.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this, itemAnimator));
    sideMenuContainer.addView(sideMenu, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    drawerLayoutContainer.setDrawerLayout(sideMenuContainer);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) sideMenuContainer.getLayoutParams();
    Point screenSize = AndroidUtilities.getRealScreenSize();
    layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(AndroidUtilities.dp(320), Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56));
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    sideMenuContainer.setLayoutParams(layoutParams);
    sideMenu.setOnItemClickListener((view, position, x, y) -> {
        if (position == 0) {
            DrawerProfileCell profileCell = (DrawerProfileCell) view;
            if (profileCell.isInAvatar(x, y)) {
                openSettings(profileCell.hasAvatar());
            } else {
                drawerLayoutAdapter.setAccountsShown(!drawerLayoutAdapter.isAccountsShown(), true);
            }
        } else if (view instanceof DrawerUserCell) {
            switchToAccount(((DrawerUserCell) view).getAccountNumber(), true);
            drawerLayoutContainer.closeDrawer(false);
        } else if (view instanceof DrawerAddCell) {
            int freeAccount = -1;
            for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
                if (!UserConfig.getInstance(a).isClientActivated()) {
                    freeAccount = a;
                    break;
                }
            }
            if (freeAccount >= 0) {
                presentFragment(new LoginActivity(freeAccount));
            }
            drawerLayoutContainer.closeDrawer(false);
        } else {
            int id = drawerLayoutAdapter.getId(position);
            if (id == 2) {
                Bundle args = new Bundle();
                presentFragment(new GroupCreateActivity(args));
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 3) {
                Bundle args = new Bundle();
                args.putBoolean("onlyUsers", true);
                args.putBoolean("destroyAfterSelect", true);
                args.putBoolean("createSecretChat", true);
                args.putBoolean("allowBots", false);
                args.putBoolean("allowSelf", false);
                presentFragment(new ContactsActivity(args));
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 4) {
                SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                if (!BuildVars.DEBUG_VERSION && preferences.getBoolean("channel_intro", false)) {
                    Bundle args = new Bundle();
                    args.putInt("step", 0);
                    presentFragment(new ChannelCreateActivity(args));
                } else {
                    presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_CHANNEL_CREATE));
                    preferences.edit().putBoolean("channel_intro", true).commit();
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 6) {
                presentFragment(new ContactsActivity(null));
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 7) {
                presentFragment(new InviteContactsActivity());
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 8) {
                openSettings(false);
            } else if (id == 9) {
                Browser.openUrl(LaunchActivity.this, LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl));
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 10) {
                presentFragment(new CallLogActivity());
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 11) {
                Bundle args = new Bundle();
                args.putLong("user_id", UserConfig.getInstance(currentAccount).getClientUserId());
                presentFragment(new ChatActivity(args));
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 12) {
                if (Build.VERSION.SDK_INT >= 23) {
                    if (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                        presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_LOCATION_ACCESS));
                        drawerLayoutContainer.closeDrawer(false);
                        return;
                    }
                }
                boolean enabled = true;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                    LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
                    enabled = lm.isLocationEnabled();
                } else if (Build.VERSION.SDK_INT >= 19) {
                    try {
                        int mode = Settings.Secure.getInt(ApplicationLoader.applicationContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
                        enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
                    } catch (Throwable e) {
                        FileLog.e(e);
                    }
                }
                if (enabled) {
                    presentFragment(new PeopleNearbyActivity());
                } else {
                    presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_LOCATION_ENABLED));
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (id == 13) {
                Browser.openUrl(LaunchActivity.this, LocaleController.getString("TelegramFeaturesUrl", R.string.TelegramFeaturesUrl));
                drawerLayoutContainer.closeDrawer(false);
            }
        }
    });
    final ItemTouchHelper sideMenuTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0) {

        private RecyclerView.ViewHolder selectedViewHolder;

        @Override
        public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
            if (viewHolder.getItemViewType() != target.getItemViewType()) {
                return false;
            }
            drawerLayoutAdapter.swapElements(viewHolder.getAdapterPosition(), target.getAdapterPosition());
            return true;
        }

        @Override
        public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return false;
        }

        @Override
        public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
            clearSelectedViewHolder();
            if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
                selectedViewHolder = viewHolder;
                final View view = viewHolder.itemView;
                sideMenu.cancelClickRunnables(false);
                view.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
                if (Build.VERSION.SDK_INT >= 21) {
                    ObjectAnimator.ofFloat(view, "elevation", AndroidUtilities.dp(1)).setDuration(150).start();
                }
            }
        }

        @Override
        public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            clearSelectedViewHolder();
        }

        private void clearSelectedViewHolder() {
            if (selectedViewHolder != null) {
                final View view = selectedViewHolder.itemView;
                selectedViewHolder = null;
                view.setTranslationX(0f);
                view.setTranslationY(0f);
                if (Build.VERSION.SDK_INT >= 21) {
                    final ObjectAnimator animator = ObjectAnimator.ofFloat(view, "elevation", 0f);
                    animator.addListener(new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            view.setBackground(null);
                        }
                    });
                    animator.setDuration(150).start();
                }
            }
        }

        @Override
        public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
            final View view = viewHolder.itemView;
            if (drawerLayoutAdapter.isAccountsShown()) {
                RecyclerView.ViewHolder topViewHolder = recyclerView.findViewHolderForAdapterPosition(drawerLayoutAdapter.getFirstAccountPosition() - 1);
                RecyclerView.ViewHolder bottomViewHolder = recyclerView.findViewHolderForAdapterPosition(drawerLayoutAdapter.getLastAccountPosition() + 1);
                if (topViewHolder != null && topViewHolder.itemView != null && topViewHolder.itemView.getBottom() == view.getTop() && dY < 0f) {
                    dY = 0f;
                } else if (bottomViewHolder != null && bottomViewHolder.itemView != null && bottomViewHolder.itemView.getTop() == view.getBottom() && dY > 0f) {
                    dY = 0f;
                }
            }
            view.setTranslationX(dX);
            view.setTranslationY(dY);
        }
    });
    sideMenuTouchHelper.attachToRecyclerView(sideMenu);
    sideMenu.setOnItemLongClickListener((view, position) -> {
        if (view instanceof DrawerUserCell) {
            final int accountNumber = ((DrawerUserCell) view).getAccountNumber();
            if (accountNumber == currentAccount || AndroidUtilities.isTablet()) {
                sideMenuTouchHelper.startDrag(sideMenu.getChildViewHolder(view));
            } else {
                final BaseFragment fragment = new DialogsActivity(null) {

                    @Override
                    protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
                        super.onTransitionAnimationEnd(isOpen, backward);
                        if (!isOpen && backward) {
                            // closed
                            drawerLayoutContainer.setDrawCurrentPreviewFragmentAbove(false);
                        }
                    }

                    @Override
                    protected void onPreviewOpenAnimationEnd() {
                        super.onPreviewOpenAnimationEnd();
                        drawerLayoutContainer.setAllowOpenDrawer(false, false);
                        drawerLayoutContainer.setDrawCurrentPreviewFragmentAbove(false);
                        switchToAccount(accountNumber, true);
                    }
                };
                fragment.setCurrentAccount(accountNumber);
                actionBarLayout.presentFragmentAsPreview(fragment);
                drawerLayoutContainer.setDrawCurrentPreviewFragmentAbove(true);
                return true;
            }
        }
        return false;
    });
    drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
    actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
    actionBarLayout.init(mainFragmentsStack);
    actionBarLayout.setDelegate(this);
    Theme.loadWallpaper();
    checkCurrentAccount();
    updateCurrentConnectionState(currentAccount);
    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
    currentConnectionState = ConnectionsManager.getInstance(currentAccount).getConnectionState();
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.needShowAlert);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.reloadInterface);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.suggestedLangpack);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewTheme);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.needSetDayNightTheme);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.needCheckSystemBarColors);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetPasscode);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.notificationsCountUpdated);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.screenStateChanged);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.showBulletin);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.appUpdateAvailable);
    if (actionBarLayout.fragmentsStack.isEmpty()) {
        if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
            actionBarLayout.addFragmentToStack(new LoginActivity());
            drawerLayoutContainer.setAllowOpenDrawer(false, false);
        } else {
            DialogsActivity dialogsActivity = new DialogsActivity(null);
            dialogsActivity.setSideMenu(sideMenu);
            actionBarLayout.addFragmentToStack(dialogsActivity);
            drawerLayoutContainer.setAllowOpenDrawer(true, false);
        }
        try {
            if (savedInstanceState != null) {
                String fragmentName = savedInstanceState.getString("fragment");
                if (fragmentName != null) {
                    Bundle args = savedInstanceState.getBundle("args");
                    switch(fragmentName) {
                        case "chat":
                            if (args != null) {
                                ChatActivity chat = new ChatActivity(args);
                                if (actionBarLayout.addFragmentToStack(chat)) {
                                    chat.restoreSelfArgs(savedInstanceState);
                                }
                            }
                            break;
                        case "settings":
                            {
                                args.putLong("user_id", UserConfig.getInstance(currentAccount).clientUserId);
                                ProfileActivity settings = new ProfileActivity(args);
                                actionBarLayout.addFragmentToStack(settings);
                                settings.restoreSelfArgs(savedInstanceState);
                                break;
                            }
                        case "group":
                            if (args != null) {
                                GroupCreateFinalActivity group = new GroupCreateFinalActivity(args);
                                if (actionBarLayout.addFragmentToStack(group)) {
                                    group.restoreSelfArgs(savedInstanceState);
                                }
                            }
                            break;
                        case "channel":
                            if (args != null) {
                                ChannelCreateActivity channel = new ChannelCreateActivity(args);
                                if (actionBarLayout.addFragmentToStack(channel)) {
                                    channel.restoreSelfArgs(savedInstanceState);
                                }
                            }
                            break;
                        case "chat_profile":
                            if (args != null) {
                                ProfileActivity profile = new ProfileActivity(args);
                                if (actionBarLayout.addFragmentToStack(profile)) {
                                    profile.restoreSelfArgs(savedInstanceState);
                                }
                            }
                            break;
                        case "wallpapers":
                            {
                                WallpapersListActivity settings = new WallpapersListActivity(WallpapersListActivity.TYPE_ALL);
                                actionBarLayout.addFragmentToStack(settings);
                                settings.restoreSelfArgs(savedInstanceState);
                                break;
                            }
                    }
                }
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    } else {
        BaseFragment fragment = actionBarLayout.fragmentsStack.get(0);
        if (fragment instanceof DialogsActivity) {
            ((DialogsActivity) fragment).setSideMenu(sideMenu);
        }
        boolean allowOpen = true;
        if (AndroidUtilities.isTablet()) {
            allowOpen = actionBarLayout.fragmentsStack.size() <= 1 && layersActionBarLayout.fragmentsStack.isEmpty();
            if (layersActionBarLayout.fragmentsStack.size() == 1 && layersActionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
                allowOpen = false;
            }
        }
        if (actionBarLayout.fragmentsStack.size() == 1 && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
            allowOpen = false;
        }
        drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
    }
    checkLayout();
    checkSystemBarColors();
    handleIntent(getIntent(), false, savedInstanceState != null, false);
    try {
        String os1 = Build.DISPLAY;
        String os2 = Build.USER;
        if (os1 != null) {
            os1 = os1.toLowerCase();
        } else {
            os1 = "";
        }
        if (os2 != null) {
            os2 = os1.toLowerCase();
        } else {
            os2 = "";
        }
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("OS name " + os1 + " " + os2);
        }
        if ((os1.contains("flyme") || os2.contains("flyme")) && Build.VERSION.SDK_INT <= 24) {
            AndroidUtilities.incorrectDisplaySizeFix = true;
            final View view = getWindow().getDecorView().getRootView();
            view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener = () -> {
                int height = view.getMeasuredHeight();
                FileLog.d("height = " + height + " displayHeight = " + AndroidUtilities.displaySize.y);
                if (Build.VERSION.SDK_INT >= 21) {
                    height -= AndroidUtilities.statusBarHeight;
                }
                if (height > AndroidUtilities.dp(100) && height < AndroidUtilities.displaySize.y && height + AndroidUtilities.dp(100) > AndroidUtilities.displaySize.y) {
                    AndroidUtilities.displaySize.y = height;
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("fix display size y to " + AndroidUtilities.displaySize.y);
                    }
                }
            });
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    MediaController.getInstance().setBaseActivity(this, true);
    AndroidUtilities.startAppCenter(this);
    updateAppUpdateViews(false);
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) SideMenultItemAnimator(org.telegram.ui.Components.SideMenultItemAnimator) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) ObjectAnimator(android.animation.ObjectAnimator) Canvas(android.graphics.Canvas) RelativeLayout(android.widget.RelativeLayout) DrawerUserCell(org.telegram.ui.Cells.DrawerUserCell) DrawerLayoutContainer(org.telegram.ui.ActionBar.DrawerLayoutContainer) ActivityManager(android.app.ActivityManager) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) RecyclerListView(org.telegram.ui.Components.RecyclerListView) DrawerProfileCell(org.telegram.ui.Cells.DrawerProfileCell) Uri(android.net.Uri) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) LocationManager(android.location.LocationManager) SharedPreferences(android.content.SharedPreferences) ViewGroup(android.view.ViewGroup) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) Bundle(android.os.Bundle) DrawerLayoutAdapter(org.telegram.ui.Adapters.DrawerLayoutAdapter) DrawerAddCell(org.telegram.ui.Cells.DrawerAddCell) Intent(android.content.Intent) Point(android.graphics.Point) 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) ParseException(java.text.ParseException) Paint(android.graphics.Paint) Point(android.graphics.Point) SideMenultItemAnimator(org.telegram.ui.Components.SideMenultItemAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) FrameLayout(android.widget.FrameLayout) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 14 with ActionBarLayout

use of org.telegram.ui.ActionBar.ActionBarLayout 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)

Example 15 with ActionBarLayout

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

the class LaunchActivity method runImportRequest.

private void runImportRequest(final Uri importUri, ArrayList<Uri> documents) {
    final int intentAccount = UserConfig.selectedAccount;
    final AlertDialog progressDialog = new AlertDialog(this, 3);
    final int[] requestId = new int[] { 0 };
    Runnable cancelRunnable = null;
    String content;
    InputStream inputStream = null;
    try {
        int linesCount = 0;
        inputStream = getContentResolver().openInputStream(importUri);
        BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder total = new StringBuilder();
        for (String line; (line = r.readLine()) != null && linesCount < 100; ) {
            total.append(line).append('\n');
            linesCount++;
        }
        content = total.toString();
    } catch (Exception e) {
        FileLog.e(e);
        return;
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (Exception e2) {
            FileLog.e(e2);
        }
    }
    final TLRPC.TL_messages_checkHistoryImport req = new TLRPC.TL_messages_checkHistoryImport();
    req.import_head = content;
    requestId[0] = ConnectionsManager.getInstance(intentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (!LaunchActivity.this.isFinishing()) {
            if (response != null && actionBarLayout != null) {
                final TLRPC.TL_messages_historyImportParsed res = (TLRPC.TL_messages_historyImportParsed) response;
                Bundle args = new Bundle();
                args.putBoolean("onlySelect", true);
                args.putString("importTitle", res.title);
                args.putBoolean("allowSwitchAccount", true);
                if (res.pm) {
                    args.putInt("dialogsType", 12);
                } else if (res.group) {
                    args.putInt("dialogsType", 11);
                } else {
                    String uri = importUri.toString();
                    Set<String> uris = MessagesController.getInstance(intentAccount).exportPrivateUri;
                    boolean ok = false;
                    for (String u : uris) {
                        if (uri.contains(u)) {
                            args.putInt("dialogsType", 12);
                            ok = true;
                            break;
                        }
                    }
                    if (!ok) {
                        uris = MessagesController.getInstance(intentAccount).exportGroupUri;
                        for (String u : uris) {
                            if (uri.contains(u)) {
                                args.putInt("dialogsType", 11);
                                ok = true;
                                break;
                            }
                        }
                        if (!ok) {
                            args.putInt("dialogsType", 13);
                        }
                    }
                }
                if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
                    SecretMediaViewer.getInstance().closePhoto(false, false);
                } else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
                    PhotoViewer.getInstance().closePhoto(false, true);
                } else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
                    ArticleViewer.getInstance().close(false, true);
                }
                if (GroupCallActivity.groupCallInstance != null) {
                    GroupCallActivity.groupCallInstance.dismiss();
                }
                drawerLayoutContainer.setAllowOpenDrawer(false, false);
                if (AndroidUtilities.isTablet()) {
                    actionBarLayout.showLastFragment();
                    rightActionBarLayout.showLastFragment();
                } else {
                    drawerLayoutContainer.setAllowOpenDrawer(true, false);
                }
                DialogsActivity fragment = new DialogsActivity(args);
                fragment.setDelegate(this);
                boolean removeLast;
                if (AndroidUtilities.isTablet()) {
                    removeLast = layersActionBarLayout.fragmentsStack.size() > 0 && layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
                } else {
                    removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
                }
                actionBarLayout.presentFragment(fragment, removeLast, false, true, false);
            } else {
                if (documentsUrisArray == null) {
                    documentsUrisArray = new ArrayList<>();
                }
                documentsUrisArray.add(0, exportingChatUri);
                exportingChatUri = null;
                openDialogsToSend(true);
            }
            try {
                progressDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors));
    final Runnable cancelRunnableFinal = cancelRunnable;
    progressDialog.setOnCancelListener(dialog -> {
        ConnectionsManager.getInstance(intentAccount).cancelRequest(requestId[0], true);
        if (cancelRunnableFinal != null) {
            cancelRunnableFinal.run();
        }
    });
    try {
        progressDialog.showDelayed(300);
    } catch (Exception ignore) {
    }
}
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) Set(java.util.Set) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Bundle(android.os.Bundle) Paint(android.graphics.Paint) Point(android.graphics.Point) ParseException(java.text.ParseException) TLRPC(org.telegram.tgnet.TLRPC) BufferedReader(java.io.BufferedReader)

Aggregations

ActionBarLayout (org.telegram.ui.ActionBar.ActionBarLayout)15 BaseFragment (org.telegram.ui.ActionBar.BaseFragment)9 ViewGroup (android.view.ViewGroup)8 FrameLayout (android.widget.FrameLayout)8 Paint (android.graphics.Paint)7 View (android.view.View)7 TextView (android.widget.TextView)7 Animator (android.animation.Animator)6 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)6 ObjectAnimator (android.animation.ObjectAnimator)6 Intent (android.content.Intent)6 SharedPreferences (android.content.SharedPreferences)6 Canvas (android.graphics.Canvas)6 Bundle (android.os.Bundle)6 ActivityManager (android.app.ActivityManager)4 Point (android.graphics.Point)4 LocationManager (android.location.LocationManager)4 Uri (android.net.Uri)4 ImageView (android.widget.ImageView)4 RelativeLayout (android.widget.RelativeLayout)4