Search in sources :

Example 1 with FragmentContextView

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

the class ProfileActivity method createView.

@Override
public View createView(Context context) {
    Theme.createProfileResources(context);
    Theme.createChatResources(context, false);
    searchTransitionOffset = 0;
    searchTransitionProgress = 1f;
    searchMode = false;
    hasOwnBackground = true;
    extraHeight = AndroidUtilities.dp(88f);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(final int id) {
            if (getParentActivity() == null) {
                return;
            }
            if (id == -1) {
                finishFragment();
            } else if (id == block_contact) {
                TLRPC.User user = getMessagesController().getUser(userId);
                if (user == null) {
                    return;
                }
                if (!isBot || MessagesController.isSupportUser(user)) {
                    if (userBlocked) {
                        getMessagesController().unblockPeer(userId);
                        if (BulletinFactory.canShowBulletin(ProfileActivity.this)) {
                            BulletinFactory.createBanBulletin(ProfileActivity.this, false).show();
                        }
                    } else {
                        if (reportSpam) {
                            AlertsCreator.showBlockReportSpamAlert(ProfileActivity.this, userId, user, null, currentEncryptedChat, false, null, param -> {
                                if (param == 1) {
                                    getNotificationCenter().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
                                    getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
                                    playProfileAnimation = 0;
                                    finishFragment();
                                } else {
                                    getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, userId);
                                }
                            }, null);
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setTitle(LocaleController.getString("BlockUser", R.string.BlockUser));
                            builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureBlockContact2", R.string.AreYouSureBlockContact2, ContactsController.formatName(user.first_name, user.last_name))));
                            builder.setPositiveButton(LocaleController.getString("BlockContact", R.string.BlockContact), (dialogInterface, i) -> {
                                getMessagesController().blockPeer(userId);
                                if (BulletinFactory.canShowBulletin(ProfileActivity.this)) {
                                    BulletinFactory.createBanBulletin(ProfileActivity.this, true).show();
                                }
                            });
                            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                            AlertDialog dialog = builder.create();
                            showDialog(dialog);
                            TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
                            if (button != null) {
                                button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                            }
                        }
                    }
                } else {
                    if (!userBlocked) {
                        getMessagesController().blockPeer(userId);
                    } else {
                        getMessagesController().unblockPeer(userId);
                        getSendMessagesHelper().sendMessage("/start", userId, null, null, null, false, null, null, null, true, 0, null);
                        finishFragment();
                    }
                }
            } else if (id == add_contact) {
                TLRPC.User user = getMessagesController().getUser(userId);
                Bundle args = new Bundle();
                args.putLong("user_id", user.id);
                args.putBoolean("addContact", true);
                presentFragment(new ContactAddActivity(args));
            } else if (id == share_contact) {
                Bundle args = new Bundle();
                args.putBoolean("onlySelect", true);
                args.putInt("dialogsType", 3);
                args.putString("selectAlertString", LocaleController.getString("SendContactToText", R.string.SendContactToText));
                args.putString("selectAlertStringGroup", LocaleController.getString("SendContactToGroupText", R.string.SendContactToGroupText));
                DialogsActivity fragment = new DialogsActivity(args);
                fragment.setDelegate(ProfileActivity.this);
                presentFragment(fragment);
            } else if (id == edit_contact) {
                Bundle args = new Bundle();
                args.putLong("user_id", userId);
                presentFragment(new ContactAddActivity(args));
            } else if (id == delete_contact) {
                final TLRPC.User user = getMessagesController().getUser(userId);
                if (user == null || getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("DeleteContact", R.string.DeleteContact));
                builder.setMessage(LocaleController.getString("AreYouSureDeleteContact", R.string.AreYouSureDeleteContact));
                builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
                    ArrayList<TLRPC.User> arrayList = new ArrayList<>();
                    arrayList.add(user);
                    getContactsController().deleteContact(arrayList, true);
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                AlertDialog dialog = builder.create();
                showDialog(dialog);
                TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (button != null) {
                    button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                }
            } else if (id == leave_group) {
                leaveChatPressed();
            } else if (id == edit_channel) {
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                ChatEditActivity fragment = new ChatEditActivity(args);
                fragment.setInfo(chatInfo);
                presentFragment(fragment);
            } else if (id == invite_to_group) {
                final TLRPC.User user = getMessagesController().getUser(userId);
                if (user == null) {
                    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((fragment1, dids, message, param) -> {
                    long did = dids.get(0);
                    Bundle args1 = new Bundle();
                    args1.putBoolean("scrollToTopOnResume", true);
                    args1.putLong("chat_id", -did);
                    if (!getMessagesController().checkCanOpenChat(args1, fragment1)) {
                        return;
                    }
                    getNotificationCenter().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
                    getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
                    getMessagesController().addUserToChat(-did, user, 0, null, ProfileActivity.this, null);
                    presentFragment(new ChatActivity(args1), true);
                    removeSelfFromStack();
                });
                presentFragment(fragment);
            } else if (id == share) {
                try {
                    String text = null;
                    if (userId != 0) {
                        TLRPC.User user = getMessagesController().getUser(userId);
                        if (user == null) {
                            return;
                        }
                        if (botInfo != null && userInfo != null && !TextUtils.isEmpty(userInfo.about)) {
                            text = String.format("%s https://" + getMessagesController().linkPrefix + "/%s", userInfo.about, user.username);
                        } else {
                            text = String.format("https://" + getMessagesController().linkPrefix + "/%s", user.username);
                        }
                    } else if (chatId != 0) {
                        TLRPC.Chat chat = getMessagesController().getChat(chatId);
                        if (chat == null) {
                            return;
                        }
                        if (chatInfo != null && !TextUtils.isEmpty(chatInfo.about)) {
                            text = String.format("%s\nhttps://" + getMessagesController().linkPrefix + "/%s", chatInfo.about, chat.username);
                        } else {
                            text = String.format("https://" + getMessagesController().linkPrefix + "/%s", chat.username);
                        }
                    }
                    if (TextUtils.isEmpty(text)) {
                        return;
                    }
                    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("text/plain");
                    intent.putExtra(Intent.EXTRA_TEXT, text);
                    startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (id == add_shortcut) {
                try {
                    long did;
                    if (currentEncryptedChat != null) {
                        did = DialogObject.makeEncryptedDialogId(currentEncryptedChat.id);
                    } else if (userId != 0) {
                        did = userId;
                    } else if (chatId != 0) {
                        did = -chatId;
                    } else {
                        return;
                    }
                    getMediaDataController().installShortcut(did);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (id == call_item || id == video_call_item) {
                if (userId != 0) {
                    TLRPC.User user = getMessagesController().getUser(userId);
                    if (user != null) {
                        VoIPHelper.startCall(user, id == video_call_item, userInfo != null && userInfo.video_calls_available, getParentActivity(), userInfo, getAccountInstance());
                    }
                } else if (chatId != 0) {
                    ChatObject.Call call = getMessagesController().getGroupCall(chatId, false);
                    if (call == null) {
                        VoIPHelper.showGroupCallAlert(ProfileActivity.this, currentChat, null, false, getAccountInstance());
                    } else {
                        VoIPHelper.startCall(currentChat, null, null, false, getParentActivity(), ProfileActivity.this, getAccountInstance());
                    }
                }
            } else if (id == search_members) {
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                args.putInt("type", ChatUsersActivity.TYPE_USERS);
                args.putBoolean("open_search", true);
                ChatUsersActivity fragment = new ChatUsersActivity(args);
                fragment.setInfo(chatInfo);
                presentFragment(fragment);
            } else if (id == add_member) {
                openAddMember();
            } else if (id == statistics) {
                TLRPC.Chat chat = getMessagesController().getChat(chatId);
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                args.putBoolean("is_megagroup", chat.megagroup);
                StatisticActivity fragment = new StatisticActivity(args);
                presentFragment(fragment);
            } else if (id == view_discussion) {
                openDiscussion();
            } else if (id == start_secret_chat) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("AreYouSureSecretChatTitle", R.string.AreYouSureSecretChatTitle));
                builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat));
                builder.setPositiveButton(LocaleController.getString("Start", R.string.Start), (dialogInterface, i) -> {
                    creatingChat = true;
                    getSecretChatHelper().startSecretChat(getParentActivity(), getMessagesController().getUser(userId));
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (id == gallery_menu_save) {
                if (getParentActivity() == null) {
                    return;
                }
                if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    getParentActivity().requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 4);
                    return;
                }
                ImageLocation location = avatarsViewPager.getImageLocation(avatarsViewPager.getRealPosition());
                if (location == null) {
                    return;
                }
                final boolean isVideo = location.imageType == FileLoader.IMAGE_TYPE_ANIMATION;
                File f = FileLoader.getPathToAttach(location.location, isVideo ? "mp4" : null, true);
                if (f.exists()) {
                    MediaController.saveFile(f.toString(), getParentActivity(), 0, null, null, () -> {
                        if (getParentActivity() == null) {
                            return;
                        }
                        BulletinFactory.createSaveToGalleryBulletin(ProfileActivity.this, isVideo, null).show();
                    });
                }
            } else if (id == edit_name) {
                presentFragment(new ChangeNameActivity());
            } else if (id == logout) {
                presentFragment(new LogoutActivity());
            } else if (id == set_as_main) {
                int position = avatarsViewPager.getRealPosition();
                TLRPC.Photo photo = avatarsViewPager.getPhoto(position);
                if (photo == null) {
                    return;
                }
                avatarsViewPager.startMovePhotoToBegin(position);
                TLRPC.TL_photos_updateProfilePhoto req = new TLRPC.TL_photos_updateProfilePhoto();
                req.id = new TLRPC.TL_inputPhoto();
                req.id.id = photo.id;
                req.id.access_hash = photo.access_hash;
                req.id.file_reference = photo.file_reference;
                UserConfig userConfig = getUserConfig();
                getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                    avatarsViewPager.finishSettingMainPhoto();
                    if (response instanceof TLRPC.TL_photos_photo) {
                        TLRPC.TL_photos_photo photos_photo = (TLRPC.TL_photos_photo) response;
                        getMessagesController().putUsers(photos_photo.users, false);
                        TLRPC.User user = getMessagesController().getUser(userConfig.clientUserId);
                        if (photos_photo.photo instanceof TLRPC.TL_photo) {
                            avatarsViewPager.replaceFirstPhoto(photo, photos_photo.photo);
                            if (user != null) {
                                user.photo.photo_id = photos_photo.photo.id;
                                userConfig.setCurrentUser(user);
                                userConfig.saveConfig(true);
                            }
                        }
                    }
                }));
                undoView.showWithAction(userId, UndoView.ACTION_PROFILE_PHOTO_CHANGED, photo.video_sizes.isEmpty() ? null : 1);
                TLRPC.User user = getMessagesController().getUser(userConfig.clientUserId);
                TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 800);
                if (user != null) {
                    TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 90);
                    user.photo.photo_id = photo.id;
                    user.photo.photo_small = smallSize.location;
                    user.photo.photo_big = bigSize.location;
                    userConfig.setCurrentUser(user);
                    userConfig.saveConfig(true);
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
                    updateProfileData();
                }
                avatarsViewPager.commitMoveToBegin();
            } else if (id == edit_avatar) {
                int position = avatarsViewPager.getRealPosition();
                ImageLocation location = avatarsViewPager.getImageLocation(position);
                if (location == null) {
                    return;
                }
                File f = FileLoader.getPathToAttach(PhotoViewer.getFileLocation(location), PhotoViewer.getFileLocationExt(location), true);
                boolean isVideo = location.imageType == FileLoader.IMAGE_TYPE_ANIMATION;
                String thumb;
                if (isVideo) {
                    ImageLocation imageLocation = avatarsViewPager.getRealImageLocation(position);
                    thumb = FileLoader.getPathToAttach(PhotoViewer.getFileLocation(imageLocation), PhotoViewer.getFileLocationExt(imageLocation), true).getAbsolutePath();
                } else {
                    thumb = null;
                }
                imageUpdater.openPhotoForEdit(f.getAbsolutePath(), thumb, 0, isVideo);
            } else if (id == delete_avatar) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                ImageLocation location = avatarsViewPager.getImageLocation(avatarsViewPager.getRealPosition());
                if (location == null) {
                    return;
                }
                if (location.imageType == FileLoader.IMAGE_TYPE_ANIMATION) {
                    builder.setTitle(LocaleController.getString("AreYouSureDeleteVideoTitle", R.string.AreYouSureDeleteVideoTitle));
                    builder.setMessage(LocaleController.formatString("AreYouSureDeleteVideo", R.string.AreYouSureDeleteVideo));
                } else {
                    builder.setTitle(LocaleController.getString("AreYouSureDeletePhotoTitle", R.string.AreYouSureDeletePhotoTitle));
                    builder.setMessage(LocaleController.formatString("AreYouSureDeletePhoto", R.string.AreYouSureDeletePhoto));
                }
                builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
                    int position = avatarsViewPager.getRealPosition();
                    TLRPC.Photo photo = avatarsViewPager.getPhoto(position);
                    if (avatarsViewPager.getRealCount() == 1) {
                        setForegroundImage(true);
                    }
                    if (photo == null || avatarsViewPager.getRealPosition() == 0) {
                        getMessagesController().deleteUserPhoto(null);
                    } else {
                        TLRPC.TL_inputPhoto inputPhoto = new TLRPC.TL_inputPhoto();
                        inputPhoto.id = photo.id;
                        inputPhoto.access_hash = photo.access_hash;
                        inputPhoto.file_reference = photo.file_reference;
                        if (inputPhoto.file_reference == null) {
                            inputPhoto.file_reference = new byte[0];
                        }
                        getMessagesController().deleteUserPhoto(inputPhoto);
                        getMessagesStorage().clearUserPhoto(userId, photo.id);
                    }
                    if (avatarsViewPager.removePhotoAtIndex(position)) {
                        avatarsViewPager.setVisibility(View.GONE);
                        avatarImage.setForegroundAlpha(1f);
                        avatarContainer.setVisibility(View.VISIBLE);
                        doNotSetForeground = true;
                        final View view = layoutManager.findViewByPosition(0);
                        if (view != null) {
                            listView.smoothScrollBy(0, view.getTop() - AndroidUtilities.dp(88), CubicBezierInterpolator.EASE_OUT_QUINT);
                        }
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                AlertDialog alertDialog = builder.create();
                showDialog(alertDialog);
                TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (button != null) {
                    button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                }
            } else if (id == add_photo) {
                onWriteButtonClick();
            } else if (id == qr_button) {
                Bundle args = new Bundle();
                args.putLong("chat_id", chatId);
                args.putLong("user_id", userId);
                presentFragment(new QrActivity(args));
            }
        }
    });
    if (sharedMediaLayout != null) {
        sharedMediaLayout.onDestroy();
    }
    final long did;
    if (dialogId != 0) {
        did = dialogId;
    } else if (userId != 0) {
        did = userId;
    } else {
        did = -chatId;
    }
    ArrayList<Integer> users = chatInfo != null && chatInfo.participants != null && chatInfo.participants.participants.size() > 5 ? sortedUsers : null;
    sharedMediaLayout = new SharedMediaLayout(context, did, sharedMediaPreloader, userInfo != null ? userInfo.common_chats_count : 0, sortedUsers, chatInfo, users != null, this, this, SharedMediaLayout.VIEW_TYPE_PROFILE_ACTIVITY) {

        @Override
        protected void onSelectedTabChanged() {
            updateSelectedMediaTabText();
        }

        @Override
        protected boolean canShowSearchItem() {
            return mediaHeaderVisible;
        }

        @Override
        protected void onSearchStateChanged(boolean expanded) {
            if (SharedConfig.smoothKeyboard) {
                AndroidUtilities.removeAdjustResize(getParentActivity(), classGuid);
            }
            listView.stopScroll();
            avatarContainer2.setPivotY(avatarContainer.getPivotY() + avatarContainer.getMeasuredHeight() / 2f);
            avatarContainer2.setPivotX(avatarContainer2.getMeasuredWidth() / 2f);
            AndroidUtilities.updateViewVisibilityAnimated(avatarContainer2, !expanded, 0.95f, true);
            callItem.setVisibility(expanded || !callItemVisible ? GONE : INVISIBLE);
            videoCallItem.setVisibility(expanded || !videoCallItemVisible ? GONE : INVISIBLE);
            editItem.setVisibility(expanded || !editItemVisible ? GONE : INVISIBLE);
            otherItem.setVisibility(expanded ? GONE : INVISIBLE);
            if (qrItem != null) {
                qrItem.setVisibility(expanded ? GONE : INVISIBLE);
            }
        }

        @Override
        protected boolean onMemberClick(TLRPC.ChatParticipant participant, boolean isLong) {
            return ProfileActivity.this.onMemberClick(participant, isLong);
        }
    };
    sharedMediaLayout.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.MATCH_PARENT));
    ActionBarMenu menu = actionBar.createMenu();
    if (userId == getUserConfig().clientUserId) {
        qrItem = menu.addItem(qr_button, R.drawable.msg_qr_mini, getResourceProvider());
        qrItem.setVisibility(isQrNeedVisible() ? View.VISIBLE : View.GONE);
        qrItem.setContentDescription(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan));
    }
    if (imageUpdater != null) {
        searchItem = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {

            @Override
            public Animator getCustomToggleTransition() {
                searchMode = !searchMode;
                if (!searchMode) {
                    searchItem.clearFocusOnSearchView();
                }
                if (searchMode) {
                    searchItem.getSearchField().setText("");
                }
                return searchExpandTransition(searchMode);
            }

            @Override
            public void onTextChanged(EditText editText) {
                searchAdapter.search(editText.getText().toString().toLowerCase());
            }
        });
        searchItem.setContentDescription(LocaleController.getString("SearchInSettings", R.string.SearchInSettings));
        searchItem.setSearchFieldHint(LocaleController.getString("SearchInSettings", R.string.SearchInSettings));
        sharedMediaLayout.getSearchItem().setVisibility(View.GONE);
        if (expandPhoto) {
            searchItem.setVisibility(View.GONE);
        }
    }
    videoCallItem = menu.addItem(video_call_item, R.drawable.profile_video);
    videoCallItem.setContentDescription(LocaleController.getString("VideoCall", R.string.VideoCall));
    if (chatId != 0) {
        callItem = menu.addItem(call_item, R.drawable.msg_voicechat2);
        if (ChatObject.isChannelOrGiga(currentChat)) {
            callItem.setContentDescription(LocaleController.getString("VoipChannelVoiceChat", R.string.VoipChannelVoiceChat));
        } else {
            callItem.setContentDescription(LocaleController.getString("VoipGroupVoiceChat", R.string.VoipGroupVoiceChat));
        }
    } else {
        callItem = menu.addItem(call_item, R.drawable.ic_call);
        callItem.setContentDescription(LocaleController.getString("Call", R.string.Call));
    }
    editItem = menu.addItem(edit_channel, R.drawable.group_edit_profile);
    editItem.setContentDescription(LocaleController.getString("Edit", R.string.Edit));
    otherItem = menu.addItem(10, R.drawable.ic_ab_other);
    otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
    int scrollTo;
    int scrollToPosition = 0;
    Object writeButtonTag = null;
    if (listView != null && imageUpdater != null) {
        scrollTo = layoutManager.findFirstVisibleItemPosition();
        View topView = layoutManager.findViewByPosition(scrollTo);
        if (topView != null) {
            scrollToPosition = topView.getTop() - listView.getPaddingTop();
        } else {
            scrollTo = -1;
        }
        writeButtonTag = writeButton.getTag();
    } else {
        scrollTo = -1;
    }
    createActionBarMenu(false);
    listAdapter = new ListAdapter(context);
    searchAdapter = new SearchAdapter(context);
    avatarDrawable = new AvatarDrawable();
    avatarDrawable.setProfile(true);
    fragmentView = new NestedFrameLayout(context) {

        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            if (pinchToZoomHelper.isInOverlayMode()) {
                return pinchToZoomHelper.onTouchEvent(ev);
            }
            if (sharedMediaLayout != null && sharedMediaLayout.isInFastScroll() && sharedMediaLayout.isPinnedToTop()) {
                return sharedMediaLayout.dispatchFastScrollEvent(ev);
            }
            if (sharedMediaLayout != null && sharedMediaLayout.checkPinchToZoom(ev)) {
                return true;
            }
            return super.dispatchTouchEvent(ev);
        }

        private boolean ignoreLayout;

        private Paint grayPaint = new Paint();

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

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            final int actionBarHeight = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
            if (listView != null) {
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
                if (layoutParams.topMargin != actionBarHeight) {
                    layoutParams.topMargin = actionBarHeight;
                }
            }
            if (searchListView != null) {
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) searchListView.getLayoutParams();
                if (layoutParams.topMargin != actionBarHeight) {
                    layoutParams.topMargin = actionBarHeight;
                }
            }
            int height = MeasureSpec.getSize(heightMeasureSpec);
            super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
            boolean changed = false;
            if (lastMeasuredContentWidth != getMeasuredWidth() || lastMeasuredContentHeight != getMeasuredHeight()) {
                changed = lastMeasuredContentWidth != 0 && lastMeasuredContentWidth != getMeasuredWidth();
                listContentHeight = 0;
                int count = listAdapter.getItemCount();
                lastMeasuredContentWidth = getMeasuredWidth();
                lastMeasuredContentHeight = getMeasuredHeight();
                int ws = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
                int hs = MeasureSpec.makeMeasureSpec(listView.getMeasuredHeight(), MeasureSpec.UNSPECIFIED);
                positionToOffset.clear();
                for (int i = 0; i < count; i++) {
                    int type = listAdapter.getItemViewType(i);
                    positionToOffset.put(i, listContentHeight);
                    if (type == 13) {
                        listContentHeight += listView.getMeasuredHeight();
                    } else {
                        RecyclerView.ViewHolder holder = listAdapter.createViewHolder(null, type);
                        listAdapter.onBindViewHolder(holder, i);
                        holder.itemView.measure(ws, hs);
                        listContentHeight += holder.itemView.getMeasuredHeight();
                    }
                }
                if (emptyView != null) {
                    ((LayoutParams) emptyView.getLayoutParams()).topMargin = AndroidUtilities.dp(88) + AndroidUtilities.statusBarHeight;
                }
            }
            if (!fragmentOpened && (expandPhoto || openAnimationInProgress && playProfileAnimation == 2)) {
                ignoreLayout = true;
                if (expandPhoto) {
                    if (searchItem != null) {
                        searchItem.setAlpha(0.0f);
                        searchItem.setEnabled(false);
                        searchItem.setVisibility(GONE);
                    }
                    nameTextView[1].setTextColor(Color.WHITE);
                    onlineTextView[1].setTextColor(Color.argb(179, 255, 255, 255));
                    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR, false);
                    actionBar.setItemsColor(Color.WHITE, false);
                    overlaysView.setOverlaysVisible();
                    overlaysView.setAlphaValue(1.0f, false);
                    avatarImage.setForegroundAlpha(1.0f);
                    avatarContainer.setVisibility(View.GONE);
                    avatarsViewPager.resetCurrentItem();
                    avatarsViewPager.setVisibility(View.VISIBLE);
                    expandPhoto = false;
                }
                allowPullingDown = true;
                isPulledDown = true;
                if (otherItem != null) {
                    if (!getMessagesController().isChatNoForwards(currentChat)) {
                        otherItem.showSubItem(gallery_menu_save);
                    } else {
                        otherItem.hideSubItem(gallery_menu_save);
                    }
                    if (imageUpdater != null) {
                        otherItem.showSubItem(edit_avatar);
                        otherItem.showSubItem(delete_avatar);
                        otherItem.hideSubItem(logout);
                    }
                }
                currentExpanAnimatorFracture = 1.0f;
                int paddingTop;
                int paddingBottom;
                if (isInLandscapeMode) {
                    paddingTop = AndroidUtilities.dp(88f);
                    paddingBottom = 0;
                } else {
                    paddingTop = listView.getMeasuredWidth();
                    paddingBottom = Math.max(0, getMeasuredHeight() - (listContentHeight + AndroidUtilities.dp(88) + actionBarHeight));
                }
                if (banFromGroup != 0) {
                    paddingBottom += AndroidUtilities.dp(48);
                    listView.setBottomGlowOffset(AndroidUtilities.dp(48));
                } else {
                    listView.setBottomGlowOffset(0);
                }
                initialAnimationExtraHeight = paddingTop - actionBarHeight;
                layoutManager.scrollToPositionWithOffset(0, -actionBarHeight);
                listView.setPadding(0, paddingTop, 0, paddingBottom);
                measureChildWithMargins(listView, widthMeasureSpec, 0, heightMeasureSpec, 0);
                listView.layout(0, actionBarHeight, listView.getMeasuredWidth(), actionBarHeight + listView.getMeasuredHeight());
                ignoreLayout = false;
            } else if (fragmentOpened && !openAnimationInProgress && !firstLayout) {
                ignoreLayout = true;
                int paddingTop;
                int paddingBottom;
                if (isInLandscapeMode || AndroidUtilities.isTablet()) {
                    paddingTop = AndroidUtilities.dp(88f);
                    paddingBottom = 0;
                } else {
                    paddingTop = listView.getMeasuredWidth();
                    paddingBottom = Math.max(0, getMeasuredHeight() - (listContentHeight + AndroidUtilities.dp(88) + actionBarHeight));
                }
                if (banFromGroup != 0) {
                    paddingBottom += AndroidUtilities.dp(48);
                    listView.setBottomGlowOffset(AndroidUtilities.dp(48));
                } else {
                    listView.setBottomGlowOffset(0);
                }
                int currentPaddingTop = listView.getPaddingTop();
                View view = null;
                int pos = RecyclerView.NO_POSITION;
                for (int i = 0; i < listView.getChildCount(); i++) {
                    int p = listView.getChildAdapterPosition(listView.getChildAt(i));
                    if (p != RecyclerView.NO_POSITION) {
                        view = listView.getChildAt(i);
                        pos = p;
                        break;
                    }
                }
                if (view == null) {
                    view = listView.getChildAt(0);
                    if (view != null) {
                        RecyclerView.ViewHolder holder = listView.findContainingViewHolder(view);
                        pos = holder.getAdapterPosition();
                        if (pos == RecyclerView.NO_POSITION) {
                            pos = holder.getPosition();
                        }
                    }
                }
                int top = paddingTop;
                if (view != null) {
                    top = view.getTop();
                }
                boolean layout = false;
                if (actionBar.isSearchFieldVisible() && sharedMediaRow >= 0) {
                    layoutManager.scrollToPositionWithOffset(sharedMediaRow, -paddingTop);
                    layout = true;
                } else if (invalidateScroll || currentPaddingTop != paddingTop) {
                    if (savedScrollPosition >= 0) {
                        layoutManager.scrollToPositionWithOffset(savedScrollPosition, savedScrollOffset - paddingTop);
                    } else if ((!changed || !allowPullingDown) && view != null) {
                        if (pos == 0 && !allowPullingDown && top > AndroidUtilities.dp(88)) {
                            top = AndroidUtilities.dp(88);
                        }
                        layoutManager.scrollToPositionWithOffset(pos, top - paddingTop);
                        layout = true;
                    } else {
                        layoutManager.scrollToPositionWithOffset(0, AndroidUtilities.dp(88) - paddingTop);
                    }
                }
                if (currentPaddingTop != paddingTop || listView.getPaddingBottom() != paddingBottom) {
                    listView.setPadding(0, paddingTop, 0, paddingBottom);
                    layout = true;
                }
                if (layout) {
                    measureChildWithMargins(listView, widthMeasureSpec, 0, heightMeasureSpec, 0);
                    try {
                        listView.layout(0, actionBarHeight, listView.getMeasuredWidth(), actionBarHeight + listView.getMeasuredHeight());
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                ignoreLayout = false;
            }
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            savedScrollPosition = -1;
            firstLayout = false;
            invalidateScroll = false;
            checkListViewScroll();
        }

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

        private final ArrayList<View> sortedChildren = new ArrayList<>();

        private final Comparator<View> viewComparator = (view, view2) -> (int) (view.getY() - view2.getY());

        @Override
        protected void dispatchDraw(Canvas canvas) {
            whitePaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
            if (listView.getVisibility() == VISIBLE) {
                grayPaint.setColor(Theme.getColor(Theme.key_windowBackgroundGray));
                if (transitionAnimationInProress) {
                    whitePaint.setAlpha((int) (255 * listView.getAlpha()));
                }
                if (transitionAnimationInProress) {
                    grayPaint.setAlpha((int) (255 * listView.getAlpha()));
                }
                int count = listView.getChildCount();
                sortedChildren.clear();
                boolean hasRemovingItems = false;
                for (int i = 0; i < count; i++) {
                    View child = listView.getChildAt(i);
                    if (listView.getChildAdapterPosition(child) != RecyclerView.NO_POSITION) {
                        sortedChildren.add(listView.getChildAt(i));
                    } else {
                        hasRemovingItems = true;
                    }
                }
                Collections.sort(sortedChildren, viewComparator);
                boolean hasBackground = false;
                float lastY = listView.getY();
                count = sortedChildren.size();
                if (!openAnimationInProgress && count > 0 && !hasRemovingItems) {
                    lastY += sortedChildren.get(0).getY();
                }
                float alpha = 1f;
                for (int i = 0; i < count; i++) {
                    View child = sortedChildren.get(i);
                    boolean currentHasBackground = child.getBackground() != null;
                    int currentY = (int) (listView.getY() + child.getY());
                    if (hasBackground == currentHasBackground) {
                        if (child.getAlpha() == 1f) {
                            alpha = 1f;
                        }
                        continue;
                    }
                    if (hasBackground) {
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, grayPaint);
                    } else {
                        if (alpha != 1f) {
                            canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, grayPaint);
                            whitePaint.setAlpha((int) (255 * alpha));
                            canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, whitePaint);
                            whitePaint.setAlpha(255);
                        } else {
                            canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), currentY, whitePaint);
                        }
                    }
                    hasBackground = currentHasBackground;
                    lastY = currentY;
                    alpha = child.getAlpha();
                }
                if (hasBackground) {
                    canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), grayPaint);
                } else {
                    if (alpha != 1f) {
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), grayPaint);
                        whitePaint.setAlpha((int) (255 * alpha));
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), whitePaint);
                        whitePaint.setAlpha(255);
                    } else {
                        canvas.drawRect(listView.getX(), lastY, listView.getX() + listView.getMeasuredWidth(), listView.getBottom(), whitePaint);
                    }
                }
            } else {
                int top = searchListView.getTop();
                canvas.drawRect(0, top + extraHeight + searchTransitionOffset, getMeasuredWidth(), top + getMeasuredHeight(), whitePaint);
            }
            super.dispatchDraw(canvas);
            if (profileTransitionInProgress && parentLayout.fragmentsStack.size() > 1) {
                BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
                if (fragment instanceof ChatActivity) {
                    ChatActivity chatActivity = (ChatActivity) fragment;
                    FragmentContextView fragmentContextView = chatActivity.getFragmentContextView();
                    if (fragmentContextView != null && fragmentContextView.isCallStyle()) {
                        float progress = extraHeight / AndroidUtilities.dpf2(fragmentContextView.getStyleHeight());
                        if (progress > 1f) {
                            progress = 1f;
                        }
                        canvas.save();
                        canvas.translate(fragmentContextView.getX(), fragmentContextView.getY());
                        fragmentContextView.setDrawOverlay(true);
                        fragmentContextView.setCollapseTransition(true, extraHeight, progress);
                        fragmentContextView.draw(canvas);
                        fragmentContextView.setCollapseTransition(false, extraHeight, progress);
                        fragmentContextView.setDrawOverlay(false);
                        canvas.restore();
                    }
                }
            }
            if (scrimPaint.getAlpha() > 0) {
                canvas.drawRect(0, 0, getWidth(), getHeight(), scrimPaint);
            }
            if (scrimView != null) {
                int c = canvas.save();
                canvas.translate(scrimView.getLeft(), scrimView.getTop());
                if (scrimView == actionBar.getBackButton()) {
                    int r = Math.max(scrimView.getMeasuredWidth(), scrimView.getMeasuredHeight()) / 2;
                    int wasAlpha = actionBarBackgroundPaint.getAlpha();
                    actionBarBackgroundPaint.setAlpha((int) (wasAlpha * (scrimPaint.getAlpha() / 255f) / 0.3f));
                    canvas.drawCircle(r, r, r * 0.8f, actionBarBackgroundPaint);
                    actionBarBackgroundPaint.setAlpha(wasAlpha);
                }
                scrimView.draw(canvas);
                canvas.restoreToCount(c);
            }
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (pinchToZoomHelper.isInOverlayMode() && (child == avatarContainer2 || child == actionBar || child == writeButton)) {
                return true;
            }
            return super.drawChild(canvas, child, drawingTime);
        }
    };
    fragmentView.setWillNotDraw(false);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    listView = new RecyclerListView(context) {

        private VelocityTracker velocityTracker;

        @Override
        protected boolean canHighlightChildAt(View child, float x, float y) {
            return !(child instanceof AboutLinkCell);
        }

        @Override
        protected boolean allowSelectChildAtPosition(View child) {
            return child != sharedMediaLayout;
        }

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

        @Override
        protected void requestChildOnScreen(View child, View focused) {
        }

        @Override
        public void invalidate() {
            super.invalidate();
            if (fragmentView != null) {
                fragmentView.invalidate();
            }
        }

        @Override
        public boolean onTouchEvent(MotionEvent e) {
            final int action = e.getAction();
            if (action == MotionEvent.ACTION_DOWN) {
                if (velocityTracker == null) {
                    velocityTracker = VelocityTracker.obtain();
                } else {
                    velocityTracker.clear();
                }
                velocityTracker.addMovement(e);
            } else if (action == MotionEvent.ACTION_MOVE) {
                if (velocityTracker != null) {
                    velocityTracker.addMovement(e);
                    velocityTracker.computeCurrentVelocity(1000);
                    listViewVelocityY = velocityTracker.getYVelocity(e.getPointerId(e.getActionIndex()));
                }
            } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                if (velocityTracker != null) {
                    velocityTracker.recycle();
                    velocityTracker = null;
                }
            }
            final boolean result = super.onTouchEvent(e);
            if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                if (allowPullingDown) {
                    final View view = layoutManager.findViewByPosition(0);
                    if (view != null) {
                        if (isPulledDown) {
                            final int actionBarHeight = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
                            listView.smoothScrollBy(0, view.getTop() - listView.getMeasuredWidth() + actionBarHeight, CubicBezierInterpolator.EASE_OUT_QUINT);
                        } else {
                            listView.smoothScrollBy(0, view.getTop() - AndroidUtilities.dp(88), CubicBezierInterpolator.EASE_OUT_QUINT);
                        }
                    }
                }
            }
            return result;
        }

        @Override
        public boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (getItemAnimator().isRunning() && child.getBackground() == null && child.getTranslationY() != 0) {
                boolean useAlpha = listView.getChildAdapterPosition(child) == sharedMediaRow && child.getAlpha() != 1f;
                if (useAlpha) {
                    whitePaint.setAlpha((int) (255 * listView.getAlpha() * child.getAlpha()));
                }
                canvas.drawRect(listView.getX(), child.getY(), listView.getX() + listView.getMeasuredWidth(), child.getY() + child.getHeight(), whitePaint);
                if (useAlpha) {
                    whitePaint.setAlpha((int) (255 * listView.getAlpha()));
                }
            }
            return super.drawChild(canvas, child, drawingTime);
        }
    };
    listView.setVerticalScrollBarEnabled(false);
    DefaultItemAnimator defaultItemAnimator = new DefaultItemAnimator() {

        int animationIndex = -1;

        @Override
        protected void onAllAnimationsDone() {
            super.onAllAnimationsDone();
            getNotificationCenter().onAnimationFinish(animationIndex);
        }

        @Override
        public void runPendingAnimations() {
            boolean removalsPending = !mPendingRemovals.isEmpty();
            boolean movesPending = !mPendingMoves.isEmpty();
            boolean changesPending = !mPendingChanges.isEmpty();
            boolean additionsPending = !mPendingAdditions.isEmpty();
            if (removalsPending || movesPending || additionsPending || changesPending) {
                ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f);
                valueAnimator.addUpdateListener(valueAnimator1 -> listView.invalidate());
                valueAnimator.setDuration(getMoveDuration());
                valueAnimator.start();
                animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
            }
            super.runPendingAnimations();
        }

        @Override
        protected long getAddAnimationDelay(long removeDuration, long moveDuration, long changeDuration) {
            return 0;
        }

        @Override
        protected long getMoveAnimationDelay() {
            return 0;
        }

        @Override
        public long getMoveDuration() {
            return 220;
        }

        @Override
        public long getRemoveDuration() {
            return 220;
        }

        @Override
        public long getAddDuration() {
            return 220;
        }
    };
    listView.setItemAnimator(defaultItemAnimator);
    defaultItemAnimator.setSupportsChangeAnimations(false);
    defaultItemAnimator.setDelayAnimations(false);
    listView.setClipToPadding(false);
    listView.setHideIfEmpty(false);
    layoutManager = new LinearLayoutManager(context) {

        @Override
        public boolean supportsPredictiveItemAnimations() {
            return imageUpdater != null;
        }

        @Override
        public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
            final View view = layoutManager.findViewByPosition(0);
            if (view != null && !openingAvatar) {
                final int canScroll = view.getTop() - AndroidUtilities.dp(88);
                if (!allowPullingDown && canScroll > dy) {
                    dy = canScroll;
                    if (avatarsViewPager.hasImages() && avatarImage.getImageReceiver().hasNotThumb() && !isInLandscapeMode && !AndroidUtilities.isTablet()) {
                        allowPullingDown = avatarBig == null;
                    }
                } else if (allowPullingDown) {
                    if (dy >= canScroll) {
                        dy = canScroll;
                        allowPullingDown = false;
                    } else if (listView.getScrollState() == RecyclerListView.SCROLL_STATE_DRAGGING) {
                        if (!isPulledDown) {
                            dy /= 2;
                        }
                    }
                }
            }
            return super.scrollVerticallyBy(dy, recycler, state);
        }
    };
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.mIgnoreTopPadding = false;
    listView.setLayoutManager(layoutManager);
    listView.setGlowColor(0);
    listView.setAdapter(listAdapter);
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
    listView.setOnItemClickListener((view, position, x, y) -> {
        if (getParentActivity() == null) {
            return;
        }
        if (position == settingsKeyRow) {
            Bundle args = new Bundle();
            args.putInt("chat_id", DialogObject.getEncryptedChatId(dialogId));
            presentFragment(new IdenticonActivity(args));
        } else if (position == settingsTimerRow) {
            showDialog(AlertsCreator.createTTLAlert(getParentActivity(), currentEncryptedChat, null).create());
        } else if (position == notificationsRow) {
            if (LocaleController.isRTL && x <= AndroidUtilities.dp(76) || !LocaleController.isRTL && x >= view.getMeasuredWidth() - AndroidUtilities.dp(76)) {
                NotificationsCheckCell checkCell = (NotificationsCheckCell) view;
                boolean checked = !checkCell.isChecked();
                boolean defaultEnabled = getNotificationsController().isGlobalNotificationsEnabled(did);
                if (checked) {
                    SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                    SharedPreferences.Editor editor = preferences.edit();
                    if (defaultEnabled) {
                        editor.remove("notify2_" + did);
                    } else {
                        editor.putInt("notify2_" + did, 0);
                    }
                    getMessagesStorage().setDialogFlags(did, 0);
                    editor.commit();
                    TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(did);
                    if (dialog != null) {
                        dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
                    }
                } else {
                    int untilTime = Integer.MAX_VALUE;
                    SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
                    SharedPreferences.Editor editor = preferences.edit();
                    long flags;
                    if (!defaultEnabled) {
                        editor.remove("notify2_" + did);
                        flags = 0;
                    } else {
                        editor.putInt("notify2_" + did, 2);
                        flags = 1;
                    }
                    getNotificationsController().removeNotificationsForDialog(did);
                    getMessagesStorage().setDialogFlags(did, flags);
                    editor.commit();
                    TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(did);
                    if (dialog != null) {
                        dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
                        if (defaultEnabled) {
                            dialog.notify_settings.mute_until = untilTime;
                        }
                    }
                }
                getNotificationsController().updateServerNotificationsSettings(did);
                checkCell.setChecked(checked);
                RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findViewHolderForPosition(notificationsRow);
                if (holder != null) {
                    listAdapter.onBindViewHolder(holder, notificationsRow);
                }
                return;
            }
            AlertsCreator.showCustomNotificationsDialog(ProfileActivity.this, did, -1, null, currentAccount, param -> listAdapter.notifyItemChanged(notificationsRow));
        } else if (position == unblockRow) {
            getMessagesController().unblockPeer(userId);
            if (BulletinFactory.canShowBulletin(ProfileActivity.this)) {
                BulletinFactory.createBanBulletin(ProfileActivity.this, false).show();
            }
        } else if (position == sendMessageRow) {
            onWriteButtonClick();
        } else if (position == reportRow) {
            AlertsCreator.createReportAlert(getParentActivity(), getDialogId(), 0, ProfileActivity.this, null);
        } else if (position >= membersStartRow && position < membersEndRow) {
            TLRPC.ChatParticipant participant;
            if (!sortedUsers.isEmpty()) {
                participant = chatInfo.participants.participants.get(sortedUsers.get(position - membersStartRow));
            } else {
                participant = chatInfo.participants.participants.get(position - membersStartRow);
            }
            onMemberClick(participant, false);
        } else if (position == addMemberRow) {
            openAddMember();
        } else if (position == usernameRow) {
            if (currentChat != null) {
                try {
                    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("text/plain");
                    if (!TextUtils.isEmpty(chatInfo.about)) {
                        intent.putExtra(Intent.EXTRA_TEXT, currentChat.title + "\n" + chatInfo.about + "\nhttps://" + getMessagesController().linkPrefix + "/" + currentChat.username);
                    } else {
                        intent.putExtra(Intent.EXTRA_TEXT, currentChat.title + "\nhttps://" + getMessagesController().linkPrefix + "/" + currentChat.username);
                    }
                    getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        } else if (position == locationRow) {
            if (chatInfo.location instanceof TLRPC.TL_channelLocation) {
                LocationActivity fragment = new LocationActivity(LocationActivity.LOCATION_TYPE_GROUP_VIEW);
                fragment.setChatLocation(chatId, (TLRPC.TL_channelLocation) chatInfo.location);
                presentFragment(fragment);
            }
        } else if (position == joinRow) {
            getMessagesController().addUserToChat(currentChat.id, getUserConfig().getCurrentUser(), 0, null, ProfileActivity.this, null);
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeSearchByActiveAction);
        } else if (position == subscribersRow) {
            Bundle args = new Bundle();
            args.putLong("chat_id", chatId);
            args.putInt("type", ChatUsersActivity.TYPE_USERS);
            ChatUsersActivity fragment = new ChatUsersActivity(args);
            fragment.setInfo(chatInfo);
            presentFragment(fragment);
        } else if (position == subscribersRequestsRow) {
            MemberRequestsActivity activity = new MemberRequestsActivity(chatId);
            presentFragment(activity);
        } else if (position == administratorsRow) {
            Bundle args = new Bundle();
            args.putLong("chat_id", chatId);
            args.putInt("type", ChatUsersActivity.TYPE_ADMIN);
            ChatUsersActivity fragment = new ChatUsersActivity(args);
            fragment.setInfo(chatInfo);
            presentFragment(fragment);
        } else if (position == blockedUsersRow) {
            Bundle args = new Bundle();
            args.putLong("chat_id", chatId);
            args.putInt("type", ChatUsersActivity.TYPE_BANNED);
            ChatUsersActivity fragment = new ChatUsersActivity(args);
            fragment.setInfo(chatInfo);
            presentFragment(fragment);
        } else if (position == notificationRow) {
            presentFragment(new NotificationsSettingsActivity());
        } else if (position == privacyRow) {
            presentFragment(new PrivacySettingsActivity());
        } else if (position == dataRow) {
            presentFragment(new DataSettingsActivity());
        } else if (position == chatRow) {
            presentFragment(new ThemeActivity(ThemeActivity.THEME_TYPE_BASIC));
        } else if (position == filtersRow) {
            presentFragment(new FiltersSetupActivity());
        } else if (position == devicesRow) {
            presentFragment(new SessionsActivity(0));
        } else if (position == questionRow) {
            showDialog(AlertsCreator.createSupportAlert(ProfileActivity.this));
        } else if (position == faqRow) {
            Browser.openUrl(getParentActivity(), LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl));
        } else if (position == policyRow) {
            Browser.openUrl(getParentActivity(), LocaleController.getString("PrivacyPolicyUrl", R.string.PrivacyPolicyUrl));
        } else if (position == sendLogsRow) {
            sendLogs(false);
        } else if (position == sendLastLogsRow) {
            sendLogs(true);
        } else if (position == clearLogsRow) {
            FileLog.cleanupLogs();
        } else if (position == switchBackendRow) {
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder1 = new AlertDialog.Builder(getParentActivity());
            builder1.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
            builder1.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder1.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
                SharedConfig.pushAuthKey = null;
                SharedConfig.pushAuthKeyId = null;
                SharedConfig.saveConfig();
                getConnectionsManager().switchBackend(true);
            });
            builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder1.create());
        } else if (position == languageRow) {
            presentFragment(new LanguageSelectActivity());
        } else if (position == setUsernameRow) {
            presentFragment(new ChangeUsernameActivity());
        } else if (position == bioRow) {
            if (userInfo != null) {
                presentFragment(new ChangeBioActivity());
            }
        } else if (position == numberRow) {
            presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_CHANGE_PHONE_NUMBER));
        } else if (position == setAvatarRow) {
            onWriteButtonClick();
        } else {
            processOnClickOrPress(position, view);
        }
    });
    listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {

        private int pressCount = 0;

        @Override
        public boolean onItemClick(View view, int position) {
            if (position == versionRow) {
                pressCount++;
                if (pressCount >= 2 || BuildVars.DEBUG_PRIVATE_VERSION) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle(LocaleController.getString("DebugMenu", R.string.DebugMenu));
                    CharSequence[] items;
                    items = new CharSequence[] { LocaleController.getString("DebugMenuImportContacts", R.string.DebugMenuImportContacts), LocaleController.getString("DebugMenuReloadContacts", R.string.DebugMenuReloadContacts), LocaleController.getString("DebugMenuResetContacts", R.string.DebugMenuResetContacts), LocaleController.getString("DebugMenuResetDialogs", R.string.DebugMenuResetDialogs), BuildVars.DEBUG_VERSION ? null : (BuildVars.LOGS_ENABLED ? LocaleController.getString("DebugMenuDisableLogs", R.string.DebugMenuDisableLogs) : LocaleController.getString("DebugMenuEnableLogs", R.string.DebugMenuEnableLogs)), SharedConfig.inappCamera ? LocaleController.getString("DebugMenuDisableCamera", R.string.DebugMenuDisableCamera) : LocaleController.getString("DebugMenuEnableCamera", R.string.DebugMenuEnableCamera), LocaleController.getString("DebugMenuClearMediaCache", R.string.DebugMenuClearMediaCache), LocaleController.getString("DebugMenuCallSettings", R.string.DebugMenuCallSettings), null, BuildVars.DEBUG_PRIVATE_VERSION || BuildVars.isStandaloneApp() ? LocaleController.getString("DebugMenuCheckAppUpdate", R.string.DebugMenuCheckAppUpdate) : null, LocaleController.getString("DebugMenuReadAllDialogs", R.string.DebugMenuReadAllDialogs), SharedConfig.pauseMusicOnRecord ? LocaleController.getString("DebugMenuDisablePauseMusic", R.string.DebugMenuDisablePauseMusic) : LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), BuildVars.DEBUG_VERSION && !AndroidUtilities.isTablet() && Build.VERSION.SDK_INT >= 23 ? (SharedConfig.smoothKeyboard ? LocaleController.getString("DebugMenuDisableSmoothKeyboard", R.string.DebugMenuDisableSmoothKeyboard) : LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard)) : null, BuildVars.DEBUG_PRIVATE_VERSION ? (SharedConfig.disableVoiceAudioEffects ? "Enable voip audio effects" : "Disable voip audio effects") : null, Build.VERSION.SDK_INT >= 21 ? (SharedConfig.noStatusBar ? "Show status bar background" : "Hide status bar background") : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Clean app update" : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Reset suggestions" : null };
                    builder.setItems(items, (dialog, which) -> {
                        if (which == 0) {
                            getUserConfig().syncContacts = true;
                            getUserConfig().saveConfig(false);
                            getContactsController().forceImportContacts();
                        } else if (which == 1) {
                            getContactsController().loadContacts(false, 0);
                        } else if (which == 2) {
                            getContactsController().resetImportedContacts();
                        } else if (which == 3) {
                            getMessagesController().forceResetDialogs();
                        } else if (which == 4) {
                            BuildVars.LOGS_ENABLED = !BuildVars.LOGS_ENABLED;
                            SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
                            sharedPreferences.edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED).commit();
                            updateRowsIds();
                            listAdapter.notifyDataSetChanged();
                        } else if (which == 5) {
                            SharedConfig.toggleInappCamera();
                        } else if (which == 6) {
                            getMessagesStorage().clearSentMedia();
                            SharedConfig.setNoSoundHintShowed(false);
                            SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
                            editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("reminderhint").remove("soundHint").remove("themehint").remove("bganimationhint").remove("filterhint").commit();
                            MessagesController.getEmojiSettings(currentAccount).edit().remove("featured_hidden").commit();
                            SharedConfig.textSelectionHintShows = 0;
                            SharedConfig.lockRecordAudioVideoHint = 0;
                            SharedConfig.stickersReorderingHintUsed = false;
                            SharedConfig.forwardingOptionsHintShown = false;
                            SharedConfig.messageSeenHintCount = 3;
                            SharedConfig.emojiInteractionsHintCount = 3;
                            SharedConfig.dayNightThemeSwitchHintCount = 3;
                            SharedConfig.fastScrollHintCount = 3;
                            ChatThemeController.getInstance(currentAccount).clearCache();
                        } else if (which == 7) {
                            VoIPHelper.showCallDebugSettings(getParentActivity());
                        } else if (which == 8) {
                            SharedConfig.toggleRoundCamera16to9();
                        } else if (which == 9) {
                            ((LaunchActivity) getParentActivity()).checkAppUpdate(true);
                        } else if (which == 10) {
                            getMessagesStorage().readAllDialogs(-1);
                        } else if (which == 11) {
                            SharedConfig.togglePauseMusicOnRecord();
                        } else if (which == 12) {
                            SharedConfig.toggleSmoothKeyboard();
                            if (SharedConfig.smoothKeyboard && getParentActivity() != null) {
                                getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
                            }
                        } else if (which == 13) {
                            SharedConfig.toggleDisableVoiceAudioEffects();
                        } else if (which == 14) {
                            SharedConfig.toggleNoStatusBar();
                            if (getParentActivity() != null && Build.VERSION.SDK_INT >= 21) {
                                if (SharedConfig.noStatusBar) {
                                    getParentActivity().getWindow().setStatusBarColor(0);
                                } else {
                                    getParentActivity().getWindow().setStatusBarColor(0x33000000);
                                }
                            }
                        } else if (which == 15) {
                            SharedConfig.pendingAppUpdate = null;
                            SharedConfig.saveConfig();
                            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.appUpdateAvailable);
                        } else if (which == 16) {
                            Set<String> suggestions = getMessagesController().pendingSuggestions;
                            suggestions.add("VALIDATE_PHONE_NUMBER");
                            suggestions.add("VALIDATE_PASSWORD");
                            getNotificationCenter().postNotificationName(NotificationCenter.newSuggestionsAvailable);
                        }
                    });
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    showDialog(builder.create());
                } else {
                    try {
                        Toast.makeText(getParentActivity(), "¯\\_(ツ)_/¯", Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                return true;
            } else if (position >= membersStartRow && position < membersEndRow) {
                final TLRPC.ChatParticipant participant;
                if (!sortedUsers.isEmpty()) {
                    participant = visibleChatParticipants.get(sortedUsers.get(position - membersStartRow));
                } else {
                    participant = visibleChatParticipants.get(position - membersStartRow);
                }
                return onMemberClick(participant, true);
            } else {
                return processOnClickOrPress(position, view);
            }
        }
    });
    if (searchItem != null) {
        searchListView = new RecyclerListView(context);
        searchListView.setVerticalScrollBarEnabled(false);
        searchListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        searchListView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue));
        searchListView.setAdapter(searchAdapter);
        searchListView.setItemAnimator(null);
        searchListView.setVisibility(View.GONE);
        searchListView.setLayoutAnimation(null);
        searchListView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
        searchListView.setOnItemClickListener((view, position) -> {
            if (position < 0) {
                return;
            }
            Object object = numberRow;
            boolean add = true;
            if (searchAdapter.searchWas) {
                if (position < searchAdapter.searchResults.size()) {
                    object = searchAdapter.searchResults.get(position);
                } else {
                    position -= searchAdapter.searchResults.size() + 1;
                    if (position >= 0 && position < searchAdapter.faqSearchResults.size()) {
                        object = searchAdapter.faqSearchResults.get(position);
                    }
                }
            } else {
                if (!searchAdapter.recentSearches.isEmpty()) {
                    position--;
                }
                if (position >= 0 && position < searchAdapter.recentSearches.size()) {
                    object = searchAdapter.recentSearches.get(position);
                } else {
                    position -= searchAdapter.recentSearches.size() + 1;
                    if (position >= 0 && position < searchAdapter.faqSearchArray.size()) {
                        object = searchAdapter.faqSearchArray.get(position);
                        add = false;
                    }
                }
            }
            if (object instanceof SearchAdapter.SearchResult) {
                SearchAdapter.SearchResult result = (SearchAdapter.SearchResult) object;
                result.open();
            } else if (object instanceof MessagesController.FaqSearchResult) {
                MessagesController.FaqSearchResult result = (MessagesController.FaqSearchResult) object;
                NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.openArticle, searchAdapter.faqWebPage, result.url);
            }
            if (add && object != null) {
                searchAdapter.addRecent(object);
            }
        });
        searchListView.setOnItemLongClickListener((view, position) -> {
            if (searchAdapter.isSearchWas() || searchAdapter.recentSearches.isEmpty()) {
                return false;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(LocaleController.getString("ClearSearch", R.string.ClearSearch));
            builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), (dialogInterface, i) -> searchAdapter.clearRecent());
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
            return true;
        });
        searchListView.setOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
                }
            }
        });
        searchListView.setAnimateEmptyView(true, 1);
        emptyView = new StickerEmptyView(context, null, 1);
        emptyView.setAnimateLayoutChange(true);
        emptyView.subtitle.setVisibility(View.GONE);
        emptyView.setVisibility(View.GONE);
        frameLayout.addView(emptyView);
        searchAdapter.loadFaqWebPage();
    }
    if (banFromGroup != 0) {
        TLRPC.Chat chat = getMessagesController().getChat(banFromGroup);
        if (currentChannelParticipant == null) {
            TLRPC.TL_channels_getParticipant req = new TLRPC.TL_channels_getParticipant();
            req.channel = MessagesController.getInputChannel(chat);
            req.participant = getMessagesController().getInputPeer(userId);
            getConnectionsManager().sendRequest(req, (response, error) -> {
                if (response != null) {
                    AndroidUtilities.runOnUIThread(() -> currentChannelParticipant = ((TLRPC.TL_channels_channelParticipant) response).participant);
                }
            });
        }
        FrameLayout frameLayout1 = new FrameLayout(context) {

            @Override
            protected void onDraw(Canvas canvas) {
                int bottom = Theme.chat_composeShadowDrawable.getIntrinsicHeight();
                Theme.chat_composeShadowDrawable.setBounds(0, 0, getMeasuredWidth(), bottom);
                Theme.chat_composeShadowDrawable.draw(canvas);
                canvas.drawRect(0, bottom, getMeasuredWidth(), getMeasuredHeight(), Theme.chat_composeBackgroundPaint);
            }
        };
        frameLayout1.setWillNotDraw(false);
        frameLayout.addView(frameLayout1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.LEFT | Gravity.BOTTOM));
        frameLayout1.setOnClickListener(v -> {
            ChatRightsEditActivity fragment = new ChatRightsEditActivity(userId, banFromGroup, null, chat.default_banned_rights, currentChannelParticipant != null ? currentChannelParticipant.banned_rights : null, "", ChatRightsEditActivity.TYPE_BANNED, true, false);
            fragment.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {

                @Override
                public void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank) {
                    removeSelfFromStack();
                }

                @Override
                public void didChangeOwner(TLRPC.User user) {
                    undoView.showWithAction(-chatId, currentChat.megagroup ? UndoView.ACTION_OWNER_TRANSFERED_GROUP : UndoView.ACTION_OWNER_TRANSFERED_CHANNEL, user);
                }
            });
            presentFragment(fragment);
        });
        TextView textView = new TextView(context);
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        textView.setGravity(Gravity.CENTER);
        textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        textView.setText(LocaleController.getString("BanFromTheGroup", R.string.BanFromTheGroup));
        frameLayout1.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 1, 0, 0));
        listView.setPadding(0, AndroidUtilities.dp(88), 0, AndroidUtilities.dp(48));
        listView.setBottomGlowOffset(AndroidUtilities.dp(48));
    } else {
        listView.setPadding(0, AndroidUtilities.dp(88), 0, 0);
    }
    topView = new TopView(context);
    topView.setBackgroundColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue));
    frameLayout.addView(topView);
    avatarContainer = new FrameLayout(context);
    avatarContainer2 = new FrameLayout(context) {

        @Override
        protected void dispatchDraw(Canvas canvas) {
            super.dispatchDraw(canvas);
            if (transitionOnlineText != null) {
                canvas.save();
                canvas.translate(onlineTextView[0].getX(), onlineTextView[0].getY());
                canvas.saveLayerAlpha(0, 0, transitionOnlineText.getMeasuredWidth(), transitionOnlineText.getMeasuredHeight(), (int) (255 * (1f - animationProgress)), Canvas.ALL_SAVE_FLAG);
                transitionOnlineText.draw(canvas);
                canvas.restore();
                canvas.restore();
                invalidate();
            }
        }
    };
    AndroidUtilities.updateViewVisibilityAnimated(avatarContainer2, true, 1f, false);
    frameLayout.addView(avatarContainer2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.START, 0, 0, 0, 0));
    avatarContainer.setPivotX(0);
    avatarContainer.setPivotY(0);
    avatarContainer2.addView(avatarContainer, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 64, 0, 0, 0));
    avatarImage = new AvatarImageView(context) {

        @Override
        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(info);
            if (getImageReceiver().hasNotThumb()) {
                info.setText(LocaleController.getString("AccDescrProfilePicture", R.string.AccDescrProfilePicture));
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, LocaleController.getString("Open", R.string.Open)));
                    info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, LocaleController.getString("AccDescrOpenInPhotoViewer", R.string.AccDescrOpenInPhotoViewer)));
                }
            } else {
                info.setVisibleToUser(false);
            }
        }
    };
    avatarImage.getImageReceiver().setAllowDecodeSingleFrame(true);
    avatarImage.setRoundRadius(AndroidUtilities.dp(21));
    avatarImage.setPivotX(0);
    avatarImage.setPivotY(0);
    avatarContainer.addView(avatarImage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    avatarImage.setOnClickListener(v -> {
        if (avatarBig != null) {
            return;
        }
        if (!AndroidUtilities.isTablet() && !isInLandscapeMode && avatarImage.getImageReceiver().hasNotThumb()) {
            openingAvatar = true;
            allowPullingDown = true;
            View child = null;
            for (int i = 0; i < listView.getChildCount(); i++) {
                if (listView.getChildAdapterPosition(listView.getChildAt(i)) == 0) {
                    child = listView.getChildAt(i);
                    break;
                }
            }
            if (child != null) {
                RecyclerView.ViewHolder holder = listView.findContainingViewHolder(child);
                if (holder != null) {
                    Integer offset = positionToOffset.get(holder.getAdapterPosition());
                    if (offset != null) {
                        listView.smoothScrollBy(0, -(offset + (listView.getPaddingTop() - child.getTop() - actionBar.getMeasuredHeight())), CubicBezierInterpolator.EASE_OUT_QUINT);
                        return;
                    }
                }
            }
        }
        openAvatar();
    });
    avatarImage.setOnLongClickListener(v -> {
        if (avatarBig != null) {
            return false;
        }
        openAvatar();
        return false;
    });
    avatarProgressView = new RadialProgressView(context) {

        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        {
            paint.setColor(0x55000000);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            if (avatarImage != null && avatarImage.getImageReceiver().hasNotThumb()) {
                paint.setAlpha((int) (0x55 * avatarImage.getImageReceiver().getCurrentAlpha()));
                canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
            }
            super.onDraw(canvas);
        }
    };
    avatarProgressView.setSize(AndroidUtilities.dp(26));
    avatarProgressView.setProgressColor(0xffffffff);
    avatarProgressView.setNoProgress(false);
    avatarContainer.addView(avatarProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    timeItem = new ImageView(context);
    timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5));
    timeItem.setScaleType(ImageView.ScaleType.CENTER);
    timeItem.setAlpha(0.0f);
    timeItem.setImageDrawable(timerDrawable = new TimerDrawable(context));
    frameLayout.addView(timeItem, LayoutHelper.createFrame(34, 34, Gravity.TOP | Gravity.LEFT));
    updateTimeItem();
    showAvatarProgress(false, false);
    if (avatarsViewPager != null) {
        avatarsViewPager.onDestroy();
    }
    overlaysView = new OverlaysView(context);
    avatarsViewPager = new ProfileGalleryView(context, userId != 0 ? userId : -chatId, actionBar, listView, avatarImage, getClassGuid(), overlaysView);
    avatarsViewPager.setChatInfo(chatInfo);
    avatarContainer2.addView(avatarsViewPager);
    avatarContainer2.addView(overlaysView);
    avatarImage.setAvatarsViewPager(avatarsViewPager);
    avatarsViewPagerIndicatorView = new PagerIndicatorView(context);
    avatarContainer2.addView(avatarsViewPagerIndicatorView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    frameLayout.addView(actionBar);
    for (int a = 0; a < nameTextView.length; a++) {
        if (playProfileAnimation == 0 && a == 0) {
            continue;
        }
        nameTextView[a] = new SimpleTextView(context);
        if (a == 1) {
            nameTextView[a].setTextColor(Theme.getColor(Theme.key_profile_title));
        } else {
            nameTextView[a].setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
        }
        nameTextView[a].setTextSize(18);
        nameTextView[a].setGravity(Gravity.LEFT);
        nameTextView[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        nameTextView[a].setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
        nameTextView[a].setPivotX(0);
        nameTextView[a].setPivotY(0);
        nameTextView[a].setAlpha(a == 0 ? 0.0f : 1.0f);
        if (a == 1) {
            nameTextView[a].setScrollNonFitText(true);
            nameTextView[a].setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        }
        int rightMargin = a == 0 ? (48 + ((callItemVisible && userId != 0) ? 48 : 0)) : 0;
        avatarContainer2.addView(nameTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, rightMargin, 0));
    }
    for (int a = 0; a < onlineTextView.length; a++) {
        onlineTextView[a] = new SimpleTextView(context);
        onlineTextView[a].setTextColor(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue));
        onlineTextView[a].setTextSize(14);
        onlineTextView[a].setGravity(Gravity.LEFT);
        onlineTextView[a].setAlpha(a == 0 || a == 2 ? 0.0f : 1.0f);
        if (a > 0) {
            onlineTextView[a].setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        }
        avatarContainer2.addView(onlineTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, a == 0 ? 48 : 8, 0));
    }
    mediaCounterTextView = new AudioPlayerAlert.ClippingTextViewSwitcher(context) {

        @Override
        protected TextView createTextView() {
            TextView textView = new TextView(context);
            textView.setTextColor(Theme.getColor(Theme.key_player_actionBarSubtitle));
            textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            textView.setSingleLine(true);
            textView.setEllipsize(TextUtils.TruncateAt.END);
            textView.setGravity(Gravity.LEFT);
            return textView;
        }
    };
    mediaCounterTextView.setAlpha(0.0f);
    avatarContainer2.addView(mediaCounterTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 8, 0));
    updateProfileData();
    writeButton = new RLottieImageView(context);
    Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY));
    CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground)), 0, 0);
    combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
    writeButton.setBackground(combinedDrawable);
    if (userId != 0) {
        if (imageUpdater != null) {
            cameraDrawable = new RLottieDrawable(R.raw.camera_outline, "" + R.raw.camera_outline, AndroidUtilities.dp(56), AndroidUtilities.dp(56), false, null);
            writeButton.setAnimation(cameraDrawable);
            writeButton.setContentDescription(LocaleController.getString("AccDescrChangeProfilePicture", R.string.AccDescrChangeProfilePicture));
            writeButton.setPadding(AndroidUtilities.dp(2), 0, 0, AndroidUtilities.dp(2));
        } else {
            writeButton.setImageResource(R.drawable.profile_newmsg);
            writeButton.setContentDescription(LocaleController.getString("AccDescrOpenChat", R.string.AccDescrOpenChat));
        }
    } else {
        writeButton.setImageResource(R.drawable.profile_discuss);
        writeButton.setContentDescription(LocaleController.getString("ViewDiscussion", R.string.ViewDiscussion));
    }
    writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_profile_actionIcon), PorterDuff.Mode.MULTIPLY));
    writeButton.setScaleType(ImageView.ScaleType.CENTER);
    frameLayout.addView(writeButton, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0));
    writeButton.setOnClickListener(v -> {
        if (writeButton.getTag() != null) {
            return;
        }
        onWriteButtonClick();
    });
    needLayout(false);
    if (scrollTo != -1) {
        if (writeButtonTag != null) {
            writeButton.setTag(0);
            writeButton.setScaleX(0.2f);
            writeButton.setScaleY(0.2f);
            writeButton.setAlpha(0.0f);
        }
    }
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            }
            if (openingAvatar && newState != RecyclerView.SCROLL_STATE_SETTLING) {
                openingAvatar = false;
            }
            if (searchItem != null) {
                scrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
                searchItem.setEnabled(!scrolling && !isPulledDown);
            }
            sharedMediaLayout.scrollingByUser = listView.scrollingByUser;
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (fwdRestrictedHint != null) {
                fwdRestrictedHint.hide();
            }
            checkListViewScroll();
            if (participantsMap != null && !usersEndReached && layoutManager.findLastVisibleItemPosition() > membersEndRow - 8) {
                getChannelParticipants(false);
            }
            sharedMediaLayout.setPinnedToTop(sharedMediaLayout.getY() == 0);
        }
    });
    undoView = new UndoView(context);
    frameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
    expandAnimator = ValueAnimator.ofFloat(0f, 1f);
    expandAnimator.addUpdateListener(anim -> {
        final int newTop = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
        final float value = AndroidUtilities.lerp(expandAnimatorValues, currentExpanAnimatorFracture = anim.getAnimatedFraction());
        avatarContainer.setScaleX(avatarScale);
        avatarContainer.setScaleY(avatarScale);
        avatarContainer.setTranslationX(AndroidUtilities.lerp(avatarX, 0f, value));
        avatarContainer.setTranslationY(AndroidUtilities.lerp((float) Math.ceil(avatarY), 0f, value));
        avatarImage.setRoundRadius((int) AndroidUtilities.lerp(AndroidUtilities.dpf2(21f), 0f, value));
        if (searchItem != null) {
            searchItem.setAlpha(1.0f - value);
            searchItem.setScaleY(1.0f - value);
            searchItem.setVisibility(View.VISIBLE);
            searchItem.setClickable(searchItem.getAlpha() > .5f);
            if (qrItem != null) {
                float translation = AndroidUtilities.dp(48) * value;
                // if (searchItem.getVisibility() == View.VISIBLE)
                // translation += AndroidUtilities.dp(48);
                qrItem.setTranslationX(translation);
                avatarsViewPagerIndicatorView.setTranslationX(translation - AndroidUtilities.dp(48));
            }
        }
        if (extraHeight > AndroidUtilities.dp(88f) && expandProgress < 0.33f) {
            refreshNameAndOnlineXY();
        }
        if (scamDrawable != null) {
            scamDrawable.setColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_avatar_subtitleInProfileBlue), Color.argb(179, 255, 255, 255), value));
        }
        if (lockIconDrawable != null) {
            lockIconDrawable.setColorFilter(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_lockIcon), Color.WHITE, value), PorterDuff.Mode.MULTIPLY);
        }
        if (verifiedCrossfadeDrawable != null) {
            verifiedCrossfadeDrawable.setProgress(value);
        }
        final float k = AndroidUtilities.dpf2(8f);
        final float nameTextViewXEnd = AndroidUtilities.dpf2(16f) - nameTextView[1].getLeft();
        final float nameTextViewYEnd = newTop + extraHeight - AndroidUtilities.dpf2(38f) - nameTextView[1].getBottom();
        final float nameTextViewCx = k + nameX + (nameTextViewXEnd - nameX) / 2f;
        final float nameTextViewCy = k + nameY + (nameTextViewYEnd - nameY) / 2f;
        final float nameTextViewX = (1 - value) * (1 - value) * nameX + 2 * (1 - value) * value * nameTextViewCx + value * value * nameTextViewXEnd;
        final float nameTextViewY = (1 - value) * (1 - value) * nameY + 2 * (1 - value) * value * nameTextViewCy + value * value * nameTextViewYEnd;
        final float onlineTextViewXEnd = AndroidUtilities.dpf2(16f) - onlineTextView[1].getLeft();
        final float onlineTextViewYEnd = newTop + extraHeight - AndroidUtilities.dpf2(18f) - onlineTextView[1].getBottom();
        final float onlineTextViewCx = k + onlineX + (onlineTextViewXEnd - onlineX) / 2f;
        final float onlineTextViewCy = k + onlineY + (onlineTextViewYEnd - onlineY) / 2f;
        final float onlineTextViewX = (1 - value) * (1 - value) * onlineX + 2 * (1 - value) * value * onlineTextViewCx + value * value * onlineTextViewXEnd;
        final float onlineTextViewY = (1 - value) * (1 - value) * onlineY + 2 * (1 - value) * value * onlineTextViewCy + value * value * onlineTextViewYEnd;
        nameTextView[1].setTranslationX(nameTextViewX);
        nameTextView[1].setTranslationY(nameTextViewY);
        onlineTextView[1].setTranslationX(onlineTextViewX);
        onlineTextView[1].setTranslationY(onlineTextViewY);
        mediaCounterTextView.setTranslationX(onlineTextViewX);
        mediaCounterTextView.setTranslationY(onlineTextViewY);
        final Object onlineTextViewTag = onlineTextView[1].getTag();
        int statusColor;
        if (onlineTextViewTag instanceof String) {
            statusColor = Theme.getColor((String) onlineTextViewTag);
        } else {
            statusColor = Theme.getColor(Theme.key_avatar_subtitleInProfileBlue);
        }
        onlineTextView[1].setTextColor(ColorUtils.blendARGB(statusColor, Color.argb(179, 255, 255, 255), value));
        if (extraHeight > AndroidUtilities.dp(88f)) {
            nameTextView[1].setPivotY(AndroidUtilities.lerp(0, nameTextView[1].getMeasuredHeight(), value));
            nameTextView[1].setScaleX(AndroidUtilities.lerp(1.12f, 1.67f, value));
            nameTextView[1].setScaleY(AndroidUtilities.lerp(1.12f, 1.67f, value));
        }
        needLayoutText(Math.min(1f, extraHeight / AndroidUtilities.dp(88f)));
        nameTextView[1].setTextColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_profile_title), Color.WHITE, value));
        actionBar.setItemsColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_actionBarDefaultIcon), Color.WHITE, value), false);
        avatarImage.setForegroundAlpha(value);
        final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
        params.width = (int) AndroidUtilities.lerp(AndroidUtilities.dpf2(42f), listView.getMeasuredWidth() / avatarScale, value);
        params.height = (int) AndroidUtilities.lerp(AndroidUtilities.dpf2(42f), (extraHeight + newTop) / avatarScale, value);
        params.leftMargin = (int) AndroidUtilities.lerp(AndroidUtilities.dpf2(64f), 0f, value);
        avatarContainer.requestLayout();
    });
    expandAnimator.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
    expandAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            actionBar.setItemsBackgroundColor(isPulledDown ? Theme.ACTION_BAR_WHITE_SELECTOR_COLOR : Theme.getColor(Theme.key_avatar_actionBarSelectorBlue), false);
            avatarImage.clearForeground();
            doNotSetForeground = false;
        }
    });
    updateRowsIds();
    updateSelectedMediaTabText();
    fwdRestrictedHint = new HintView(getParentActivity(), 9);
    fwdRestrictedHint.setAlpha(0);
    frameLayout.addView(fwdRestrictedHint, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 12, 0, 12, 0));
    sharedMediaLayout.setForwardRestrictedHint(fwdRestrictedHint);
    ViewGroup decorView;
    if (Build.VERSION.SDK_INT >= 21) {
        decorView = (ViewGroup) getParentActivity().getWindow().getDecorView();
    } else {
        decorView = frameLayout;
    }
    pinchToZoomHelper = new PinchToZoomHelper(decorView, frameLayout) {

        Paint statusBarPaint;

        @Override
        protected void invalidateViews() {
            super.invalidateViews();
            fragmentView.invalidate();
            for (int i = 0; i < avatarsViewPager.getChildCount(); i++) {
                avatarsViewPager.getChildAt(i).invalidate();
            }
            if (writeButton != null) {
                writeButton.invalidate();
            }
        }

        @Override
        protected void drawOverlays(Canvas canvas, float alpha, float parentOffsetX, float parentOffsetY, float clipTop, float clipBottom) {
            if (alpha > 0) {
                AndroidUtilities.rectTmp.set(0, 0, avatarsViewPager.getMeasuredWidth(), avatarsViewPager.getMeasuredHeight() + AndroidUtilities.dp(30));
                canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (255 * alpha), Canvas.ALL_SAVE_FLAG);
                avatarContainer2.draw(canvas);
                if (actionBar.getOccupyStatusBar()) {
                    if (statusBarPaint == null) {
                        statusBarPaint = new Paint();
                        statusBarPaint.setColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (255 * 0.2f)));
                    }
                    canvas.drawRect(actionBar.getX(), actionBar.getY(), actionBar.getX() + actionBar.getMeasuredWidth(), actionBar.getY() + AndroidUtilities.statusBarHeight, statusBarPaint);
                }
                canvas.save();
                canvas.translate(actionBar.getX(), actionBar.getY());
                actionBar.draw(canvas);
                canvas.restore();
                if (writeButton != null && writeButton.getVisibility() == View.VISIBLE && writeButton.getAlpha() > 0) {
                    canvas.save();
                    float s = 0.5f + 0.5f * alpha;
                    canvas.scale(s, s, writeButton.getX() + writeButton.getMeasuredWidth() / 2f, writeButton.getY() + writeButton.getMeasuredHeight() / 2f);
                    canvas.translate(writeButton.getX(), writeButton.getY());
                    writeButton.draw(canvas);
                    canvas.restore();
                }
                canvas.restore();
            }
        }

        @Override
        protected boolean zoomEnabled(View child, ImageReceiver receiver) {
            if (!super.zoomEnabled(child, receiver)) {
                return false;
            }
            return listView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING;
        }
    };
    pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() {

        @Override
        public void onZoomStarted(MessageObject messageObject) {
            listView.cancelClickRunnables(true);
            if (sharedMediaLayout != null && sharedMediaLayout.getCurrentListView() != null) {
                sharedMediaLayout.getCurrentListView().cancelClickRunnables(true);
            }
            Bitmap bitmap = pinchToZoomHelper.getPhotoImage() == null ? null : pinchToZoomHelper.getPhotoImage().getBitmap();
            if (bitmap != null) {
                topView.setBackgroundColor(ColorUtils.blendARGB(AndroidUtilities.calcBitmapColor(bitmap), Theme.getColor(Theme.key_windowBackgroundWhite), 0.1f));
            }
        }
    });
    avatarsViewPager.setPinchToZoomHelper(pinchToZoomHelper);
    scrimPaint.setAlpha(0);
    actionBarBackgroundPaint.setColor(Theme.getColor(Theme.key_listSelector));
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Arrays(java.util.Arrays) Bundle(android.os.Bundle) BufferedInputStream(java.io.BufferedInputStream) SettingsSuggestionCell(org.telegram.ui.Cells.SettingsSuggestionCell) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Property(android.util.Property) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) RadialProgressView(org.telegram.ui.Components.RadialProgressView) Manifest(android.Manifest) Keep(androidx.annotation.Keep) ChatThemeController(org.telegram.messenger.ChatThemeController) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) Display(android.view.Display) Canvas(android.graphics.Canvas) ForegroundColorSpan(android.text.style.ForegroundColorSpan) ContextCompat(androidx.core.content.ContextCompat) NotificationsController(org.telegram.messenger.NotificationsController) ViewCompat(androidx.core.view.ViewCompat) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) BackButtonMenu(org.telegram.ui.Components.BackButtonMenu) UndoView(org.telegram.ui.Components.UndoView) AnimationProperties(org.telegram.ui.Components.AnimationProperties) Set(java.util.Set) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) HapticFeedbackConstants(android.view.HapticFeedbackConstants) CountDownLatch(java.util.concurrent.CountDownLatch) TextPaint(android.text.TextPaint) HintView(org.telegram.ui.Components.HintView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerCell(org.telegram.ui.Cells.DividerCell) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) FileLoader(org.telegram.messenger.FileLoader) ZipOutputStream(java.util.zip.ZipOutputStream) ViewPager(androidx.viewpager.widget.ViewPager) Dialog(android.app.Dialog) SystemClock(android.os.SystemClock) TimerDrawable(org.telegram.ui.Components.TimerDrawable) SettingsSearchCell(org.telegram.ui.Cells.SettingsSearchCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) BufferedOutputStream(java.io.BufferedOutputStream) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) SharedMediaLayout(org.telegram.ui.Components.SharedMediaLayout) FragmentContextView(org.telegram.ui.Components.FragmentContextView) TLRPC(org.telegram.tgnet.TLRPC) GradientDrawable(android.graphics.drawable.GradientDrawable) Toast(android.widget.Toast) PhoneFormat(org.telegram.PhoneFormat.PhoneFormat) IdenticonDrawable(org.telegram.ui.Components.IdenticonDrawable) BuildConfig(org.telegram.messenger.BuildConfig) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) LinkedHashSet(java.util.LinkedHashSet) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) UserCell(org.telegram.ui.Cells.UserCell) R(org.telegram.messenger.R) FileOutputStream(java.io.FileOutputStream) TextUtils(android.text.TextUtils) AboutLinkCell(org.telegram.ui.Cells.AboutLinkCell) File(java.io.File) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) GraySectionCell(org.telegram.ui.Cells.GraySectionCell) Configuration(android.content.res.Configuration) ColorUtils(androidx.core.graphics.ColorUtils) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) ImageUpdater(org.telegram.ui.Components.ImageUpdater) PackageManager(android.content.pm.PackageManager) WindowManager(android.view.WindowManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) CrossfadeDrawable(org.telegram.ui.Components.CrossfadeDrawable) Animator(android.animation.Animator) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) TextCell(org.telegram.ui.Cells.TextCell) Locale(java.util.Locale) MediaController(org.telegram.messenger.MediaController) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) DataSetObserver(android.database.DataSetObserver) ZipEntry(java.util.zip.ZipEntry) RectF(android.graphics.RectF) ImageLoader(org.telegram.messenger.ImageLoader) Utilities(org.telegram.messenger.Utilities) DiffUtil(androidx.recyclerview.widget.DiffUtil) RLottieImageView(org.telegram.ui.Components.RLottieImageView) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ViewGroup(android.view.ViewGroup) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) ScamDrawable(org.telegram.ui.Components.ScamDrawable) FileProvider(androidx.core.content.FileProvider) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Typeface(android.graphics.Typeface) NestedScrollingParentHelper(androidx.core.view.NestedScrollingParentHelper) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Spanned(android.text.Spanned) SparseIntArray(android.util.SparseIntArray) Theme(org.telegram.ui.ActionBar.Theme) TextDetailCell(org.telegram.ui.Cells.TextDetailCell) PagerAdapter(androidx.viewpager.widget.PagerAdapter) 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) HeaderCell(org.telegram.ui.Cells.HeaderCell) PackageInfo(android.content.pm.PackageInfo) HashSet(java.util.HashSet) VelocityTracker(android.view.VelocityTracker) MotionEvent(android.view.MotionEvent) NestedScrollingParent3(androidx.core.view.NestedScrollingParent3) ActionBar(org.telegram.ui.ActionBar.ActionBar) TLObject(org.telegram.tgnet.TLObject) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) MediaDataController(org.telegram.messenger.MediaDataController) Build(android.os.Build) SerializedData(org.telegram.tgnet.SerializedData) DialogInterface(android.content.DialogInterface) Browser(org.telegram.messenger.browser.Browser) ChatAvatarContainer(org.telegram.ui.Components.ChatAvatarContainer) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) Point(android.graphics.Point) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileInputStream(java.io.FileInputStream) FileLog(org.telegram.messenger.FileLog) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) ViewTreeObserver(android.view.ViewTreeObserver) Comparator(java.util.Comparator) ImageReceiver(org.telegram.messenger.ImageReceiver) Collections(java.util.Collections) RecyclerListView(org.telegram.ui.Components.RecyclerListView) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ArrayList(java.util.ArrayList) AboutLinkCell(org.telegram.ui.Cells.AboutLinkCell) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) EditText(android.widget.EditText) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TimerDrawable(org.telegram.ui.Components.TimerDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) IdenticonDrawable(org.telegram.ui.Components.IdenticonDrawable) CrossfadeDrawable(org.telegram.ui.Components.CrossfadeDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ScamDrawable(org.telegram.ui.Components.ScamDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) UserConfig(org.telegram.messenger.UserConfig) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) 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) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) AnimatorSet(android.animation.AnimatorSet) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) MessagesController(org.telegram.messenger.MessagesController) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageLocation(org.telegram.messenger.ImageLocation) UndoView(org.telegram.ui.Components.UndoView) VelocityTracker(android.view.VelocityTracker) SharedPreferences(android.content.SharedPreferences) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Intent(android.content.Intent) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) RecyclerView(androidx.recyclerview.widget.RecyclerView) SpannableStringBuilder(android.text.SpannableStringBuilder) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ValueAnimator(android.animation.ValueAnimator) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) ImageReceiver(org.telegram.messenger.ImageReceiver) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) RadialProgressView(org.telegram.ui.Components.RadialProgressView) TimerDrawable(org.telegram.ui.Components.TimerDrawable) Canvas(android.graphics.Canvas) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) File(java.io.File) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) SharedMediaLayout(org.telegram.ui.Components.SharedMediaLayout) RLottieImageView(org.telegram.ui.Components.RLottieImageView) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) Bitmap(android.graphics.Bitmap) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ProfileGalleryView(org.telegram.ui.Components.ProfileGalleryView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent) HintView(org.telegram.ui.Components.HintView) NotificationsCheckCell(org.telegram.ui.Cells.NotificationsCheckCell) FrameLayout(android.widget.FrameLayout) FragmentContextView(org.telegram.ui.Components.FragmentContextView) MessageObject(org.telegram.messenger.MessageObject)

Example 2 with FragmentContextView

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

the class DialogsActivity method createView.

@Override
public View createView(final Context context) {
    searching = false;
    searchWas = false;
    pacmanAnimation = null;
    selectedDialogs.clear();
    maximumVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
    AndroidUtilities.runOnUIThread(() -> Theme.createChatResources(context, false));
    ActionBarMenu menu = actionBar.createMenu();
    if (!onlySelect && searchString == null && folderId == 0) {
        doneItem = new ActionBarMenuItem(context, null, Theme.getColor(Theme.key_actionBarDefaultSelector), Theme.getColor(Theme.key_actionBarDefaultIcon), true);
        doneItem.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
        actionBar.addView(doneItem, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.RIGHT, 0, 0, 10, 0));
        doneItem.setOnClickListener(v -> {
            filterTabsView.setIsEditing(false);
            showDoneItem(false);
        });
        doneItem.setAlpha(0.0f);
        doneItem.setVisibility(View.GONE);
        proxyDrawable = new ProxyDrawable(context);
        proxyItem = menu.addItem(2, proxyDrawable);
        proxyItem.setContentDescription(LocaleController.getString("ProxySettings", R.string.ProxySettings));
        passcodeDrawable = new RLottieDrawable(R.raw.passcode_lock_close, "passcode_lock_close", AndroidUtilities.dp(28), AndroidUtilities.dp(28), true, null);
        passcodeItem = menu.addItem(1, passcodeDrawable);
        passcodeItem.setContentDescription(LocaleController.getString("AccDescrPasscodeLock", R.string.AccDescrPasscodeLock));
        updatePasscodeButton();
        updateProxyButton(false);
    }
    searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {

        @Override
        public void onSearchExpand() {
            searching = true;
            if (switchItem != null) {
                switchItem.setVisibility(View.GONE);
            }
            if (proxyItem != null && proxyItemVisible) {
                proxyItem.setVisibility(View.GONE);
            }
            if (viewPages[0] != null) {
                if (searchString != null) {
                    viewPages[0].listView.hide();
                    if (searchViewPager != null) {
                        searchViewPager.searchListView.show();
                    }
                }
                if (!onlySelect) {
                    floatingButtonContainer.setVisibility(View.GONE);
                }
            }
            setScrollY(0);
            updatePasscodeButton();
            actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack));
        }

        @Override
        public boolean canCollapseSearch() {
            if (switchItem != null) {
                switchItem.setVisibility(View.VISIBLE);
            }
            if (proxyItem != null && proxyItemVisible) {
                proxyItem.setVisibility(View.VISIBLE);
            }
            if (searchString != null) {
                finishFragment();
                return false;
            }
            return true;
        }

        @Override
        public void onSearchCollapse() {
            searching = false;
            searchWas = false;
            if (viewPages[0] != null) {
                viewPages[0].listView.setEmptyView(folderId == 0 ? viewPages[0].progressView : null);
                if (!onlySelect) {
                    floatingButtonContainer.setVisibility(View.VISIBLE);
                    floatingHidden = true;
                    floatingButtonTranslation = AndroidUtilities.dp(100);
                    floatingButtonHideProgress = 1f;
                    updateFloatingButtonOffset();
                }
                showSearch(false, true);
            }
            updatePasscodeButton();
            if (menuDrawable != null) {
                if (actionBar.getBackButton().getDrawable() != menuDrawable) {
                    actionBar.setBackButtonDrawable(menuDrawable);
                    menuDrawable.setRotation(0, true);
                }
                actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu));
            }
        }

        @Override
        public void onTextChanged(EditText editText) {
            String text = editText.getText().toString();
            if (text.length() != 0 || (searchViewPager.dialogsSearchAdapter != null && searchViewPager.dialogsSearchAdapter.hasRecentSearch()) || searchFiltersWasShowed) {
                searchWas = true;
                if (!searchIsShowed) {
                    showSearch(true, true);
                }
            }
            searchViewPager.onTextChanged(text);
        }

        @Override
        public void onSearchFilterCleared(FiltersView.MediaFilterData filterData) {
            if (!searchIsShowed) {
                return;
            }
            searchViewPager.removeSearchFilter(filterData);
            searchViewPager.onTextChanged(searchItem.getSearchField().getText().toString());
            updateFiltersView(true, null, null, false, true);
        }

        @Override
        public boolean canToggleSearch() {
            return !actionBar.isActionModeShowed() && databaseMigrationHint == null;
        }
    });
    searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
    searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search));
    if (onlySelect) {
        actionBar.setBackButtonImage(R.drawable.ic_ab_back);
        if (initialDialogsType == 3 && selectAlertString == null) {
            actionBar.setTitle(LocaleController.getString("ForwardTo", R.string.ForwardTo));
        } else if (initialDialogsType == 10) {
            actionBar.setTitle(LocaleController.getString("SelectChats", R.string.SelectChats));
        } else {
            actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
        }
        actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
    } else {
        if (searchString != null || folderId != 0) {
            actionBar.setBackButtonDrawable(backDrawable = new BackDrawable(false));
        } else {
            actionBar.setBackButtonDrawable(menuDrawable = new MenuDrawable());
            actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu));
        }
        if (folderId != 0) {
            actionBar.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats));
        } else {
            if (BuildVars.DEBUG_VERSION) {
                actionBar.setTitle("Telegram Beta");
            } else {
                actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
            }
        }
        if (folderId == 0) {
            actionBar.setSupportsHolidayImage(true);
        }
    }
    if (!onlySelect) {
        actionBar.setAddToContainer(false);
        actionBar.setCastShadows(false);
        actionBar.setClipContent(true);
    }
    actionBar.setTitleActionRunnable(() -> {
        if (initialDialogsType != 10) {
            hideFloatingButton(false);
        }
        scrollToTop();
    });
    if (initialDialogsType == 0 && folderId == 0 && !onlySelect && TextUtils.isEmpty(searchString)) {
        scrimPaint = new Paint() {

            @Override
            public void setAlpha(int a) {
                super.setAlpha(a);
                if (fragmentView != null) {
                    fragmentView.invalidate();
                }
            }
        };
        filterTabsView = new FilterTabsView(context) {

            @Override
            public boolean onInterceptTouchEvent(MotionEvent ev) {
                getParent().requestDisallowInterceptTouchEvent(true);
                maybeStartTracking = false;
                return super.onInterceptTouchEvent(ev);
            }

            @Override
            public void setTranslationY(float translationY) {
                if (getTranslationY() != translationY) {
                    super.setTranslationY(translationY);
                    updateContextViewPosition();
                    if (fragmentView != null) {
                        fragmentView.invalidate();
                    }
                }
            }

            @Override
            protected void onLayout(boolean changed, int l, int t, int r, int b) {
                super.onLayout(changed, l, t, r, b);
                if (scrimView != null) {
                    scrimView.getLocationInWindow(scrimViewLocation);
                    fragmentView.invalidate();
                }
            }
        };
        filterTabsView.setVisibility(View.GONE);
        canShowFilterTabsView = false;
        filterTabsView.setDelegate(new FilterTabsView.FilterTabsViewDelegate() {

            private void showDeleteAlert(MessagesController.DialogFilter dialogFilter) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("FilterDelete", R.string.FilterDelete));
                builder.setMessage(LocaleController.getString("FilterDeleteAlert", R.string.FilterDeleteAlert));
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog2, which2) -> {
                    TLRPC.TL_messages_updateDialogFilter req = new TLRPC.TL_messages_updateDialogFilter();
                    req.id = dialogFilter.id;
                    getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                    }));
                    // if (getMessagesController().dialogFilters.size() > 1) {
                    // filterTabsView.beginCrossfade();
                    // }
                    getMessagesController().removeFilter(dialogFilter);
                    getMessagesStorage().deleteDialogFilter(dialogFilter);
                // filterTabsView.commitCrossfade();
                });
                AlertDialog alertDialog = builder.create();
                showDialog(alertDialog);
                TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (button != null) {
                    button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
                }
            }

            @Override
            public void onSamePageSelected() {
                scrollToTop();
            }

            @Override
            public void onPageReorder(int fromId, int toId) {
                for (int a = 0; a < viewPages.length; a++) {
                    if (viewPages[a].selectedType == fromId) {
                        viewPages[a].selectedType = toId;
                    } else if (viewPages[a].selectedType == toId) {
                        viewPages[a].selectedType = fromId;
                    }
                }
            }

            @Override
            public void onPageSelected(int id, boolean forward) {
                if (viewPages[0].selectedType == id) {
                    return;
                }
                ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
                if (id != Integer.MAX_VALUE && (id < 0 || id >= dialogFilters.size())) {
                    return;
                }
                if (parentLayout != null) {
                    parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId() || SharedConfig.getChatSwipeAction(currentAccount) != SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS);
                }
                viewPages[1].selectedType = id;
                viewPages[1].setVisibility(View.VISIBLE);
                viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth());
                showScrollbars(false);
                switchToCurrentSelectedMode(true);
                animatingForward = forward;
            }

            @Override
            public boolean canPerformActions() {
                return !searching;
            }

            @Override
            public void onPageScrolled(float progress) {
                if (progress == 1 && viewPages[1].getVisibility() != View.VISIBLE && !searching) {
                    return;
                }
                if (animatingForward) {
                    viewPages[0].setTranslationX(-progress * viewPages[0].getMeasuredWidth());
                    viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth() - progress * viewPages[0].getMeasuredWidth());
                } else {
                    viewPages[0].setTranslationX(progress * viewPages[0].getMeasuredWidth());
                    viewPages[1].setTranslationX(progress * viewPages[0].getMeasuredWidth() - viewPages[0].getMeasuredWidth());
                }
                if (progress == 1) {
                    ViewPage tempPage = viewPages[0];
                    viewPages[0] = viewPages[1];
                    viewPages[1] = tempPage;
                    viewPages[1].setVisibility(View.GONE);
                    showScrollbars(true);
                    updateCounters(false);
                    checkListLoad(viewPages[0]);
                    viewPages[0].dialogsAdapter.resume();
                    viewPages[1].dialogsAdapter.pause();
                }
            }

            @Override
            public int getTabCounter(int tabId) {
                if (tabId == Integer.MAX_VALUE) {
                    return getMessagesStorage().getMainUnreadCount();
                }
                ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
                if (tabId < 0 || tabId >= dialogFilters.size()) {
                    return 0;
                }
                return getMessagesController().dialogFilters.get(tabId).unreadCount;
            }

            @Override
            public boolean didSelectTab(FilterTabsView.TabView tabView, boolean selected) {
                if (actionBar.isActionModeShowed()) {
                    return false;
                }
                if (scrimPopupWindow != null) {
                    scrimPopupWindow.dismiss();
                    scrimPopupWindow = null;
                    scrimPopupWindowItems = null;
                    return false;
                }
                Rect rect = new Rect();
                MessagesController.DialogFilter dialogFilter;
                if (tabView.getId() == Integer.MAX_VALUE) {
                    dialogFilter = null;
                } else {
                    dialogFilter = getMessagesController().dialogFilters.get(tabView.getId());
                }
                ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity());
                popupLayout.setOnTouchListener(new View.OnTouchListener() {

                    private int[] pos = new int[2];

                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                            if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                                View contentView = scrimPopupWindow.getContentView();
                                contentView.getLocationInWindow(pos);
                                rect.set(pos[0], pos[1], pos[0] + contentView.getMeasuredWidth(), pos[1] + contentView.getMeasuredHeight());
                                if (!rect.contains((int) event.getX(), (int) event.getY())) {
                                    scrimPopupWindow.dismiss();
                                }
                            }
                        } else if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
                            if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                                scrimPopupWindow.dismiss();
                            }
                        }
                        return false;
                    }
                });
                popupLayout.setDispatchKeyEventListener(keyEvent -> {
                    if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                        scrimPopupWindow.dismiss();
                    }
                });
                Rect backgroundPaddings = new Rect();
                Drawable shadowDrawable = getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
                shadowDrawable.getPadding(backgroundPaddings);
                popupLayout.setBackgroundDrawable(shadowDrawable);
                popupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
                LinearLayout linearLayout = new LinearLayout(getParentActivity());
                ScrollView scrollView;
                if (Build.VERSION.SDK_INT >= 21) {
                    scrollView = new ScrollView(getParentActivity(), null, 0, R.style.scrollbarShapeStyle) {

                        @Override
                        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                            setMeasuredDimension(linearLayout.getMeasuredWidth(), getMeasuredHeight());
                        }
                    };
                } else {
                    scrollView = new ScrollView(getParentActivity());
                }
                scrollView.setClipToPadding(false);
                popupLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
                linearLayout.setMinimumWidth(AndroidUtilities.dp(200));
                linearLayout.setOrientation(LinearLayout.VERTICAL);
                scrimPopupWindowItems = new ActionBarMenuSubItem[3];
                for (int a = 0, N = (tabView.getId() == Integer.MAX_VALUE ? 2 : 3); a < N; a++) {
                    ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == N - 1);
                    if (a == 0) {
                        if (getMessagesController().dialogFilters.size() <= 1) {
                            continue;
                        }
                        cell.setTextAndIcon(LocaleController.getString("FilterReorder", R.string.FilterReorder), R.drawable.tabs_reorder);
                    } else if (a == 1) {
                        if (N == 2) {
                            cell.setTextAndIcon(LocaleController.getString("FilterEditAll", R.string.FilterEditAll), R.drawable.msg_edit);
                        } else {
                            cell.setTextAndIcon(LocaleController.getString("FilterEdit", R.string.FilterEdit), R.drawable.msg_edit);
                        }
                    } else {
                        cell.setTextAndIcon(LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), R.drawable.msg_delete);
                    }
                    scrimPopupWindowItems[a] = cell;
                    linearLayout.addView(cell);
                    final int i = a;
                    cell.setOnClickListener(v1 -> {
                        if (i == 0) {
                            resetScroll();
                            filterTabsView.setIsEditing(true);
                            showDoneItem(true);
                        } else if (i == 1) {
                            if (N == 2) {
                                presentFragment(new FiltersSetupActivity());
                            } else {
                                presentFragment(new FilterCreateActivity(dialogFilter));
                            }
                        } else if (i == 2) {
                            showDeleteAlert(dialogFilter);
                        }
                        if (scrimPopupWindow != null) {
                            scrimPopupWindow.dismiss();
                        }
                    });
                }
                scrollView.addView(linearLayout, LayoutHelper.createScroll(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
                scrimPopupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {

                    @Override
                    public void dismiss() {
                        super.dismiss();
                        if (scrimPopupWindow != this) {
                            return;
                        }
                        scrimPopupWindow = null;
                        scrimPopupWindowItems = null;
                        if (scrimAnimatorSet != null) {
                            scrimAnimatorSet.cancel();
                            scrimAnimatorSet = null;
                        }
                        scrimAnimatorSet = new AnimatorSet();
                        ArrayList<Animator> animators = new ArrayList<>();
                        animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0));
                        scrimAnimatorSet.playTogether(animators);
                        scrimAnimatorSet.setDuration(220);
                        scrimAnimatorSet.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                if (scrimView != null) {
                                    scrimView.setBackground(null);
                                    scrimView = null;
                                }
                                if (fragmentView != null) {
                                    fragmentView.invalidate();
                                }
                            }
                        });
                        scrimAnimatorSet.start();
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                            getParentActivity().getWindow().getDecorView().setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
                        }
                    }
                };
                tabView.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_actionBarDefault)));
                scrimPopupWindow.setDismissAnimationDuration(220);
                scrimPopupWindow.setOutsideTouchable(true);
                scrimPopupWindow.setClippingEnabled(true);
                scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
                scrimPopupWindow.setFocusable(true);
                popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
                scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
                scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
                scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
                tabView.getLocationInWindow(scrimViewLocation);
                int popupX = scrimViewLocation[0] + backgroundPaddings.left - AndroidUtilities.dp(16);
                if (popupX < AndroidUtilities.dp(6)) {
                    popupX = AndroidUtilities.dp(6);
                } else if (popupX > fragmentView.getMeasuredWidth() - AndroidUtilities.dp(6) - popupLayout.getMeasuredWidth()) {
                    popupX = fragmentView.getMeasuredWidth() - AndroidUtilities.dp(6) - popupLayout.getMeasuredWidth();
                }
                int popupY = scrimViewLocation[1] + tabView.getMeasuredHeight() - AndroidUtilities.dp(12);
                scrimPopupWindow.showAtLocation(fragmentView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
                scrimView = tabView;
                scrimViewSelected = selected;
                fragmentView.invalidate();
                if (scrimAnimatorSet != null) {
                    scrimAnimatorSet.cancel();
                }
                scrimAnimatorSet = new AnimatorSet();
                ArrayList<Animator> animators = new ArrayList<>();
                animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0, 50));
                scrimAnimatorSet.playTogether(animators);
                scrimAnimatorSet.setDuration(150);
                scrimAnimatorSet.start();
                return true;
            }

            @Override
            public boolean isTabMenuVisible() {
                return scrimPopupWindow != null && scrimPopupWindow.isShowing();
            }

            @Override
            public void onDeletePressed(int id) {
                showDeleteAlert(getMessagesController().dialogFilters.get(id));
            }
        });
    }
    if (allowSwitchAccount && UserConfig.getActivatedAccountsCount() > 1) {
        switchItem = menu.addItemWithWidth(1, 0, AndroidUtilities.dp(56));
        AvatarDrawable avatarDrawable = new AvatarDrawable();
        avatarDrawable.setTextSize(AndroidUtilities.dp(12));
        BackupImageView imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(18));
        switchItem.addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.CENTER));
        TLRPC.User user = getUserConfig().getCurrentUser();
        avatarDrawable.setInfo(user);
        imageView.getImageReceiver().setCurrentAccount(currentAccount);
        imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
        for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
            TLRPC.User u = AccountInstance.getInstance(a).getUserConfig().getCurrentUser();
            if (u != null) {
                AccountSelectCell cell = new AccountSelectCell(context, false);
                cell.setAccount(a, true);
                switchItem.addSubItem(10 + a, cell, AndroidUtilities.dp(230), AndroidUtilities.dp(48));
            }
        }
    }
    actionBar.setAllowOverlayTitle(true);
    if (sideMenu != null) {
        sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
        sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground));
        sideMenu.getAdapter().notifyDataSetChanged();
    }
    createActionMode(null);
    ContentView contentView = new ContentView(context);
    fragmentView = contentView;
    int pagesCount = folderId == 0 && initialDialogsType == 0 && !onlySelect ? 2 : 1;
    viewPages = new ViewPage[pagesCount];
    for (int a = 0; a < pagesCount; a++) {
        final ViewPage viewPage = new ViewPage(context) {

            @Override
            public void setTranslationX(float translationX) {
                super.setTranslationX(translationX);
                if (tabsAnimationInProgress) {
                    if (viewPages[0] == this) {
                        float scrollProgress = Math.abs(viewPages[0].getTranslationX()) / (float) viewPages[0].getMeasuredWidth();
                        filterTabsView.selectTabWithId(viewPages[1].selectedType, scrollProgress);
                    }
                }
            }
        };
        contentView.addView(viewPage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        viewPage.dialogsType = initialDialogsType;
        viewPages[a] = viewPage;
        viewPage.progressView = new FlickerLoadingView(context);
        viewPage.progressView.setViewType(FlickerLoadingView.DIALOG_CELL_TYPE);
        viewPage.progressView.setVisibility(View.GONE);
        viewPage.addView(viewPage.progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
        viewPage.listView = new DialogsRecyclerView(context, viewPage);
        viewPage.listView.setAccessibilityEnabled(false);
        viewPage.listView.setAnimateEmptyView(true, 0);
        viewPage.listView.setClipToPadding(false);
        viewPage.listView.setPivotY(0);
        viewPage.dialogsItemAnimator = new DialogsItemAnimator(viewPage.listView) {

            @Override
            public void onRemoveStarting(RecyclerView.ViewHolder item) {
                super.onRemoveStarting(item);
                if (viewPage.layoutManager.findFirstVisibleItemPosition() == 0) {
                    View v = viewPage.layoutManager.findViewByPosition(0);
                    if (v != null) {
                        v.invalidate();
                    }
                    if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
                        viewPage.archivePullViewState = ARCHIVE_ITEM_STATE_SHOWED;
                    }
                    if (viewPage.pullForegroundDrawable != null) {
                        viewPage.pullForegroundDrawable.doNotShow();
                    }
                }
            }

            @Override
            public void onRemoveFinished(RecyclerView.ViewHolder item) {
                if (dialogRemoveFinished == 2) {
                    dialogRemoveFinished = 1;
                }
            }

            @Override
            public void onAddFinished(RecyclerView.ViewHolder item) {
                if (dialogInsertFinished == 2) {
                    dialogInsertFinished = 1;
                }
            }

            @Override
            public void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) {
                if (dialogChangeFinished == 2) {
                    dialogChangeFinished = 1;
                }
            }

            @Override
            protected void onAllAnimationsDone() {
                if (dialogRemoveFinished == 1 || dialogInsertFinished == 1 || dialogChangeFinished == 1) {
                    onDialogAnimationFinished();
                }
            }
        };
        // viewPage.listView.setItemAnimator(viewPage.dialogsItemAnimator);
        viewPage.listView.setVerticalScrollBarEnabled(true);
        viewPage.listView.setInstantClick(true);
        viewPage.layoutManager = new LinearLayoutManager(context) {

            private boolean fixOffset;

            @Override
            public void scrollToPositionWithOffset(int position, int offset) {
                if (fixOffset) {
                    offset -= viewPage.listView.getPaddingTop();
                }
                super.scrollToPositionWithOffset(position, offset);
            }

            @Override
            public void prepareForDrop(@NonNull View view, @NonNull View target, int x, int y) {
                fixOffset = true;
                super.prepareForDrop(view, target, x, y);
                fixOffset = false;
            }

            @Override
            public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
                if (hasHiddenArchive() && position == 1) {
                    super.smoothScrollToPosition(recyclerView, state, position);
                } else {
                    LinearSmoothScrollerCustom linearSmoothScroller = new LinearSmoothScrollerCustom(recyclerView.getContext(), LinearSmoothScrollerCustom.POSITION_MIDDLE);
                    linearSmoothScroller.setTargetPosition(position);
                    startSmoothScroll(linearSmoothScroller);
                }
            }

            @Override
            public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
                if (viewPage.listView.fastScrollAnimationRunning) {
                    return 0;
                }
                boolean isDragging = viewPage.listView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING;
                int measuredDy = dy;
                int pTop = viewPage.listView.getPaddingTop();
                if (viewPage.dialogsType == 0 && !onlySelect && folderId == 0 && dy < 0 && getMessagesController().hasHiddenArchive() && viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
                    viewPage.listView.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
                    int currentPosition = viewPage.layoutManager.findFirstVisibleItemPosition();
                    if (currentPosition == 0) {
                        View view = viewPage.layoutManager.findViewByPosition(currentPosition);
                        if (view != null && (view.getBottom() - pTop) <= AndroidUtilities.dp(1)) {
                            currentPosition = 1;
                        }
                    }
                    if (!isDragging) {
                        View view = viewPage.layoutManager.findViewByPosition(currentPosition);
                        if (view != null) {
                            int dialogHeight = AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72) + 1;
                            int canScrollDy = -(view.getTop() - pTop) + (currentPosition - 1) * dialogHeight;
                            int positiveDy = Math.abs(dy);
                            if (canScrollDy < positiveDy) {
                                measuredDy = -canScrollDy;
                            }
                        }
                    } else if (currentPosition == 0) {
                        View v = viewPage.layoutManager.findViewByPosition(currentPosition);
                        float k = 1f + ((v.getTop() - pTop) / (float) v.getMeasuredHeight());
                        if (k > 1f) {
                            k = 1f;
                        }
                        viewPage.listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
                        measuredDy *= PullForegroundDrawable.startPullParallax - PullForegroundDrawable.endPullParallax * k;
                        if (measuredDy > -1) {
                            measuredDy = -1;
                        }
                        if (undoView[0].getVisibility() == View.VISIBLE) {
                            undoView[0].hide(true, 1);
                        }
                    }
                }
                if (viewPage.dialogsType == 0 && viewPage.listView.getViewOffset() != 0 && dy > 0 && isDragging) {
                    float ty = (int) viewPage.listView.getViewOffset();
                    ty -= dy;
                    if (ty < 0) {
                        measuredDy = (int) ty;
                        ty = 0;
                    } else {
                        measuredDy = 0;
                    }
                    viewPage.listView.setViewsOffset(ty);
                }
                if (viewPage.dialogsType == 0 && viewPage.archivePullViewState != ARCHIVE_ITEM_STATE_PINNED && hasHiddenArchive()) {
                    int usedDy = super.scrollVerticallyBy(measuredDy, recycler, state);
                    if (viewPage.pullForegroundDrawable != null) {
                        viewPage.pullForegroundDrawable.scrollDy = usedDy;
                    }
                    int currentPosition = viewPage.layoutManager.findFirstVisibleItemPosition();
                    View firstView = null;
                    if (currentPosition == 0) {
                        firstView = viewPage.layoutManager.findViewByPosition(currentPosition);
                    }
                    if (currentPosition == 0 && firstView != null && (firstView.getBottom() - pTop) >= AndroidUtilities.dp(4)) {
                        if (startArchivePullingTime == 0) {
                            startArchivePullingTime = System.currentTimeMillis();
                        }
                        if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
                            if (viewPage.pullForegroundDrawable != null) {
                                viewPage.pullForegroundDrawable.showHidden();
                            }
                        }
                        float k = 1f + ((firstView.getTop() - pTop) / (float) firstView.getMeasuredHeight());
                        if (k > 1f) {
                            k = 1f;
                        }
                        long pullingTime = System.currentTimeMillis() - startArchivePullingTime;
                        boolean canShowInternal = k > PullForegroundDrawable.SNAP_HEIGHT && pullingTime > PullForegroundDrawable.minPullingTime + 20;
                        if (canShowHiddenArchive != canShowInternal) {
                            canShowHiddenArchive = canShowInternal;
                            if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
                                viewPage.listView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
                                if (viewPage.pullForegroundDrawable != null) {
                                    viewPage.pullForegroundDrawable.colorize(canShowInternal);
                                }
                            }
                        }
                        if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && measuredDy - usedDy != 0 && dy < 0 && isDragging) {
                            float ty;
                            float tk = (viewPage.listView.getViewOffset() / PullForegroundDrawable.getMaxOverscroll());
                            tk = 1f - tk;
                            ty = (viewPage.listView.getViewOffset() - dy * PullForegroundDrawable.startPullOverScroll * tk);
                            viewPage.listView.setViewsOffset(ty);
                        }
                        if (viewPage.pullForegroundDrawable != null) {
                            viewPage.pullForegroundDrawable.pullProgress = k;
                            viewPage.pullForegroundDrawable.setListView(viewPage.listView);
                        }
                    } else {
                        startArchivePullingTime = 0;
                        canShowHiddenArchive = false;
                        viewPage.archivePullViewState = ARCHIVE_ITEM_STATE_HIDDEN;
                        if (viewPage.pullForegroundDrawable != null) {
                            viewPage.pullForegroundDrawable.resetText();
                            viewPage.pullForegroundDrawable.pullProgress = 0f;
                            viewPage.pullForegroundDrawable.setListView(viewPage.listView);
                        }
                    }
                    if (firstView != null) {
                        firstView.invalidate();
                    }
                    return usedDy;
                }
                return super.scrollVerticallyBy(measuredDy, recycler, state);
            }

            @Override
            public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
                if (BuildVars.DEBUG_PRIVATE_VERSION) {
                    try {
                        super.onLayoutChildren(recycler, state);
                    } catch (IndexOutOfBoundsException e) {
                        throw new RuntimeException("Inconsistency detected. " + "dialogsListIsFrozen=" + dialogsListFrozen + " lastUpdateAction=" + debugLastUpdateAction);
                    }
                } else {
                    try {
                        super.onLayoutChildren(recycler, state);
                    } catch (IndexOutOfBoundsException e) {
                        FileLog.e(e);
                        AndroidUtilities.runOnUIThread(() -> viewPage.dialogsAdapter.notifyDataSetChanged());
                    }
                }
            }
        };
        viewPage.layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        viewPage.listView.setLayoutManager(viewPage.layoutManager);
        viewPage.listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
        viewPage.addView(viewPage.listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        viewPage.listView.setOnItemClickListener((view, position) -> {
            if (initialDialogsType == 10) {
                onItemLongClick(view, position, 0, 0, viewPage.dialogsType, viewPage.dialogsAdapter);
                return;
            } else if ((initialDialogsType == 11 || initialDialogsType == 13) && position == 1) {
                Bundle args = new Bundle();
                args.putBoolean("forImport", true);
                long[] array = new long[] { getUserConfig().getClientUserId() };
                args.putLongArray("result", array);
                args.putInt("chatType", ChatObject.CHAT_TYPE_MEGAGROUP);
                String title = arguments.getString("importTitle");
                if (title != null) {
                    args.putString("title", title);
                }
                GroupCreateFinalActivity activity = new GroupCreateFinalActivity(args);
                activity.setDelegate(new GroupCreateFinalActivity.GroupCreateFinalActivityDelegate() {

                    @Override
                    public void didStartChatCreation() {
                    }

                    @Override
                    public void didFinishChatCreation(GroupCreateFinalActivity fragment, long chatId) {
                        ArrayList<Long> arrayList = new ArrayList<>();
                        arrayList.add(-chatId);
                        DialogsActivityDelegate dialogsActivityDelegate = delegate;
                        removeSelfFromStack();
                        dialogsActivityDelegate.didSelectDialogs(DialogsActivity.this, arrayList, null, true);
                    }

                    @Override
                    public void didFailChatCreation() {
                    }
                });
                presentFragment(activity);
                return;
            }
            onItemClick(view, position, viewPage.dialogsAdapter);
        });
        viewPage.listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() {

            @Override
            public boolean onItemClick(View view, int position, float x, float y) {
                if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && filterTabsView.isEditing()) {
                    return false;
                }
                return onItemLongClick(view, position, x, y, viewPage.dialogsType, viewPage.dialogsAdapter);
            }

            @Override
            public void onLongClickRelease() {
                finishPreviewFragment();
            }

            @Override
            public void onMove(float dx, float dy) {
                movePreviewFragment(dy);
            }
        });
        viewPage.swipeController = new SwipeController(viewPage);
        viewPage.recyclerItemsEnterAnimator = new RecyclerItemsEnterAnimator(viewPage.listView, false);
        viewPage.itemTouchhelper = new ItemTouchHelper(viewPage.swipeController);
        viewPage.itemTouchhelper.attachToRecyclerView(viewPage.listView);
        viewPage.listView.setOnScrollListener(new RecyclerView.OnScrollListener() {

            private boolean wasManualScroll;

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                    wasManualScroll = true;
                    scrollingManually = true;
                } else {
                    scrollingManually = false;
                }
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    wasManualScroll = false;
                    disableActionBarScrolling = false;
                    if (waitingForScrollFinished) {
                        waitingForScrollFinished = false;
                        if (updatePullAfterScroll) {
                            viewPage.listView.updatePullState();
                            updatePullAfterScroll = false;
                        }
                        viewPage.dialogsAdapter.notifyDataSetChanged();
                    }
                    if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && viewPages[0].listView == recyclerView) {
                        int scrollY = (int) -actionBar.getTranslationY();
                        int actionBarHeight = ActionBar.getCurrentActionBarHeight();
                        if (scrollY != 0 && scrollY != actionBarHeight) {
                            if (scrollY < actionBarHeight / 2) {
                                recyclerView.smoothScrollBy(0, -scrollY);
                            } else if (viewPages[0].listView.canScrollVertically(1)) {
                                recyclerView.smoothScrollBy(0, actionBarHeight - scrollY);
                            }
                        }
                    }
                }
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                viewPage.dialogsItemAnimator.onListScroll(-dy);
                checkListLoad(viewPage);
                if (initialDialogsType != 10 && wasManualScroll && floatingButtonContainer.getVisibility() != View.GONE && recyclerView.getChildCount() > 0) {
                    int firstVisibleItem = viewPage.layoutManager.findFirstVisibleItemPosition();
                    if (firstVisibleItem != RecyclerView.NO_POSITION) {
                        RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
                        if (!hasHiddenArchive() || holder != null && holder.getAdapterPosition() != 0) {
                            int firstViewTop = 0;
                            if (holder != null) {
                                firstViewTop = holder.itemView.getTop();
                            }
                            boolean goingDown;
                            boolean changed = true;
                            if (prevPosition == firstVisibleItem) {
                                final int topDelta = prevTop - firstViewTop;
                                goingDown = firstViewTop < prevTop;
                                changed = Math.abs(topDelta) > 1;
                            } else {
                                goingDown = firstVisibleItem > prevPosition;
                            }
                            if (changed && scrollUpdated && (goingDown || scrollingManually)) {
                                hideFloatingButton(goingDown);
                            }
                            prevPosition = firstVisibleItem;
                            prevTop = firstViewTop;
                            scrollUpdated = true;
                        }
                    }
                }
                if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && recyclerView == viewPages[0].listView && !searching && !actionBar.isActionModeShowed() && !disableActionBarScrolling && filterTabsViewIsVisible) {
                    if (dy > 0 && hasHiddenArchive() && viewPages[0].dialogsType == 0) {
                        View child = recyclerView.getChildAt(0);
                        if (child != null) {
                            RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(child);
                            if (holder.getAdapterPosition() == 0) {
                                int visiblePartAfterScroll = child.getMeasuredHeight() + (child.getTop() - recyclerView.getPaddingTop());
                                if (visiblePartAfterScroll + dy > 0) {
                                    if (visiblePartAfterScroll < 0) {
                                        dy = -visiblePartAfterScroll;
                                    } else {
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    float currentTranslation = actionBar.getTranslationY();
                    float newTranslation = currentTranslation - dy;
                    if (newTranslation < -ActionBar.getCurrentActionBarHeight()) {
                        newTranslation = -ActionBar.getCurrentActionBarHeight();
                    } else if (newTranslation > 0) {
                        newTranslation = 0;
                    }
                    if (newTranslation != currentTranslation) {
                        setScrollY(newTranslation);
                    }
                }
            }
        });
        viewPage.archivePullViewState = SharedConfig.archiveHidden ? ARCHIVE_ITEM_STATE_HIDDEN : ARCHIVE_ITEM_STATE_PINNED;
        if (viewPage.pullForegroundDrawable == null && folderId == 0) {
            viewPage.pullForegroundDrawable = new PullForegroundDrawable(LocaleController.getString("AccSwipeForArchive", R.string.AccSwipeForArchive), LocaleController.getString("AccReleaseForArchive", R.string.AccReleaseForArchive)) {

                @Override
                protected float getViewOffset() {
                    return viewPage.listView.getViewOffset();
                }
            };
            if (hasHiddenArchive()) {
                viewPage.pullForegroundDrawable.showHidden();
            } else {
                viewPage.pullForegroundDrawable.doNotShow();
            }
            viewPage.pullForegroundDrawable.setWillDraw(viewPage.archivePullViewState != ARCHIVE_ITEM_STATE_PINNED);
        }
        viewPage.dialogsAdapter = new DialogsAdapter(this, context, viewPage.dialogsType, folderId, onlySelect, selectedDialogs, currentAccount) {

            @Override
            public void notifyDataSetChanged() {
                viewPage.lastItemsCount = getItemCount();
                try {
                    super.notifyDataSetChanged();
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        };
        viewPage.dialogsAdapter.setForceShowEmptyCell(afterSignup);
        if (AndroidUtilities.isTablet() && openedDialogId != 0) {
            viewPage.dialogsAdapter.setOpenedDialogId(openedDialogId);
        }
        viewPage.dialogsAdapter.setArchivedPullDrawable(viewPage.pullForegroundDrawable);
        viewPage.listView.setAdapter(viewPage.dialogsAdapter);
        viewPage.listView.setEmptyView(folderId == 0 ? viewPage.progressView : null);
        viewPage.scrollHelper = new RecyclerAnimationScrollHelper(viewPage.listView, viewPage.layoutManager);
        if (a != 0) {
            viewPages[a].setVisibility(View.GONE);
        }
    }
    int type = 0;
    if (searchString != null) {
        type = 2;
    } else if (!onlySelect) {
        type = 1;
    }
    searchViewPager = new SearchViewPager(context, this, type, initialDialogsType, folderId, new SearchViewPager.ChatPreviewDelegate() {

        @Override
        public void startChatPreview(DialogCell cell) {
            showChatPreview(cell);
        }

        @Override
        public void move(float dy) {
            movePreviewFragment(dy);
        }

        @Override
        public void finish() {
            finishPreviewFragment();
        }
    });
    contentView.addView(searchViewPager);
    searchViewPager.dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() {

        @Override
        public void searchStateChanged(boolean search, boolean animated) {
            if (searchViewPager.emptyView.getVisibility() == View.VISIBLE) {
                animated = true;
            }
            if (searching && searchWas && searchViewPager.emptyView != null) {
                if (search || searchViewPager.dialogsSearchAdapter.getItemCount() != 0) {
                    searchViewPager.emptyView.showProgress(true, animated);
                } else {
                    searchViewPager.emptyView.showProgress(false, animated);
                }
            }
            if (search && searchViewPager.dialogsSearchAdapter.getItemCount() == 0) {
                searchViewPager.cancelEnterAnimation();
            }
        }

        @Override
        public void didPressedOnSubDialog(long did) {
            if (onlySelect) {
                if (!validateSlowModeDialog(did)) {
                    return;
                }
                if (!selectedDialogs.isEmpty()) {
                    boolean checked = addOrRemoveSelectedDialog(did, null);
                    findAndUpdateCheckBox(did, checked);
                    updateSelectedCount();
                    actionBar.closeSearchField();
                } else {
                    didSelectResult(did, true, false);
                }
            } else {
                Bundle args = new Bundle();
                if (DialogObject.isUserDialog(did)) {
                    args.putLong("user_id", did);
                } else {
                    args.putLong("chat_id", -did);
                }
                closeSearch();
                if (AndroidUtilities.isTablet() && viewPages != null) {
                    for (int a = 0; a < viewPages.length; a++) {
                        viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId = did);
                    }
                    updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
                }
                if (searchString != null) {
                    if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
                        getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
                        presentFragment(new ChatActivity(args));
                    }
                } else {
                    if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
                        presentFragment(new ChatActivity(args));
                    }
                }
            }
        }

        @Override
        public void needRemoveHint(long did) {
            if (getParentActivity() == null) {
                return;
            }
            TLRPC.User user = getMessagesController().getUser(did);
            if (user == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("ChatHintsDeleteAlertTitle", R.string.ChatHintsDeleteAlertTitle));
            builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("ChatHintsDeleteAlert", R.string.ChatHintsDeleteAlert, ContactsController.formatName(user.first_name, user.last_name))));
            builder.setPositiveButton(LocaleController.getString("StickersRemove", R.string.StickersRemove), (dialogInterface, i) -> getMediaDataController().removePeer(did));
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            AlertDialog dialog = builder.create();
            showDialog(dialog);
            TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            if (button != null) {
                button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
            }
        }

        @Override
        public void needClearList() {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("ClearSearchAlertTitle", R.string.ClearSearchAlertTitle));
            builder.setMessage(LocaleController.getString("ClearSearchAlert", R.string.ClearSearchAlert));
            builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), (dialogInterface, i) -> {
                if (searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) {
                    searchViewPager.dialogsSearchAdapter.clearRecentSearch();
                } else {
                    searchViewPager.dialogsSearchAdapter.clearRecentHashtags();
                }
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            AlertDialog dialog = builder.create();
            showDialog(dialog);
            TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            if (button != null) {
                button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
            }
        }

        @Override
        public void runResultsEnterAnimation() {
            if (searchViewPager != null) {
                searchViewPager.runResultsEnterAnimation();
            }
        }

        @Override
        public boolean isSelected(long dialogId) {
            return selectedDialogs.contains(dialogId);
        }
    });
    searchViewPager.searchListView.setOnItemClickListener((view, position) -> {
        if (initialDialogsType == 10) {
            onItemLongClick(view, position, 0, 0, -1, searchViewPager.dialogsSearchAdapter);
            return;
        }
        onItemClick(view, position, searchViewPager.dialogsSearchAdapter);
    });
    searchViewPager.searchListView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() {

        @Override
        public boolean onItemClick(View view, int position, float x, float y) {
            return onItemLongClick(view, position, x, y, -1, searchViewPager.dialogsSearchAdapter);
        }

        @Override
        public void onLongClickRelease() {
            finishPreviewFragment();
        }

        @Override
        public void onMove(float dx, float dy) {
            movePreviewFragment(dy);
        }
    });
    searchViewPager.setFilteredSearchViewDelegate((showMediaFilters, users, dates, archive) -> DialogsActivity.this.updateFiltersView(showMediaFilters, users, dates, archive, true));
    searchViewPager.setVisibility(View.GONE);
    filtersView = new FiltersView(getParentActivity(), null);
    filtersView.setOnItemClickListener((view, position) -> {
        filtersView.cancelClickRunnables(true);
        addSearchFilter(filtersView.getFilterAt(position));
    });
    contentView.addView(filtersView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP));
    filtersView.setVisibility(View.GONE);
    floatingButtonContainer = new FrameLayout(context);
    floatingButtonContainer.setVisibility(onlySelect && initialDialogsType != 10 || folderId != 0 ? View.GONE : View.VISIBLE);
    contentView.addView(floatingButtonContainer, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 4 : 0, 0, LocaleController.isRTL ? 0 : 4, 0));
    floatingButtonContainer.setOnClickListener(v -> {
        if (initialDialogsType == 10) {
            if (delegate == null || selectedDialogs.isEmpty()) {
                return;
            }
            delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, null, false);
        } else {
            Bundle args = new Bundle();
            args.putBoolean("destroyAfterSelect", true);
            presentFragment(new ContactsActivity(args));
        }
    });
    floatingButton = new RLottieImageView(context);
    floatingButton.setScaleType(ImageView.ScaleType.CENTER);
    Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
        drawable = combinedDrawable;
    }
    floatingButton.setBackgroundDrawable(drawable);
    floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
    if (initialDialogsType == 10) {
        floatingButton.setImageResource(R.drawable.floating_check);
        floatingButtonContainer.setContentDescription(LocaleController.getString("Done", R.string.Done));
    } else {
        floatingButton.setAnimation(R.raw.write_contacts_fab_icon, 52, 52);
        floatingButtonContainer.setContentDescription(LocaleController.getString("NewMessageTitle", R.string.NewMessageTitle));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        floatingButton.setStateListAnimator(animator);
        floatingButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }
    floatingButtonContainer.addView(floatingButton, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60), (Build.VERSION.SDK_INT >= 21 ? 56 : 60), Gravity.LEFT | Gravity.TOP, 10, 6, 10, 0));
    searchTabsView = null;
    if (!onlySelect && initialDialogsType == 0) {
        fragmentLocationContextView = new FragmentContextView(context, this, true);
        fragmentLocationContextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
        contentView.addView(fragmentLocationContextView);
        fragmentContextView = new FragmentContextView(context, this, false) {

            @Override
            protected void playbackSpeedChanged(float value) {
                if (Math.abs(value - 1.0f) > 0.001f || Math.abs(value - 1.8f) > 0.001f) {
                    getUndoView().showWithAction(0, Math.abs(value - 1.0f) > 0.001f ? UndoView.ACTION_PLAYBACK_SPEED_ENABLED : UndoView.ACTION_PLAYBACK_SPEED_DISABLED, value, null, null);
                }
            }
        };
        fragmentContextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
        contentView.addView(fragmentContextView);
        fragmentContextView.setAdditionalContextView(fragmentLocationContextView);
        fragmentLocationContextView.setAdditionalContextView(fragmentContextView);
    } else if (initialDialogsType == 3) {
        if (commentView != null) {
            commentView.onDestroy();
        }
        commentView = new ChatActivityEnterView(getParentActivity(), contentView, null, false) {

            @Override
            public boolean dispatchTouchEvent(MotionEvent ev) {
                if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                    AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
                }
                return super.dispatchTouchEvent(ev);
            }
        };
        commentView.setAllowStickersAndGifs(false, false);
        commentView.setForceShowSendButton(true, false);
        commentView.setVisibility(View.GONE);
        commentView.getSendButton().setAlpha(0);
        contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
        commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {

            @Override
            public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) {
                if (delegate == null || selectedDialogs.isEmpty()) {
                    return;
                }
                delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, message, false);
            }

            @Override
            public void onSwitchRecordMode(boolean video) {
            }

            @Override
            public void onTextSelectionChanged(int start, int end) {
            }

            @Override
            public void onStickersExpandedChange() {
            }

            @Override
            public void onPreAudioVideoRecord() {
            }

            @Override
            public void onTextChanged(final CharSequence text, boolean bigChange) {
            }

            @Override
            public void onTextSpansChanged(CharSequence text) {
            }

            @Override
            public void needSendTyping() {
            }

            @Override
            public void onAttachButtonHidden() {
            }

            @Override
            public void onAttachButtonShow() {
            }

            @Override
            public void onMessageEditEnd(boolean loading) {
            }

            @Override
            public void onWindowSizeChanged(int size) {
            }

            @Override
            public void onStickersTab(boolean opened) {
            }

            @Override
            public void didPressAttachButton() {
            }

            @Override
            public void needStartRecordVideo(int state, boolean notify, int scheduleDate) {
            }

            @Override
            public void needChangeVideoPreviewState(int state, float seekProgress) {
            }

            @Override
            public void needStartRecordAudio(int state) {
            }

            @Override
            public void needShowMediaBanHint() {
            }

            @Override
            public void onUpdateSlowModeButton(View button, boolean show, CharSequence time) {
            }

            @Override
            public void onSendLongClick() {
            }

            @Override
            public void onAudioVideoInterfaceUpdated() {
            }
        });
        writeButtonContainer = new FrameLayout(context) {

            @Override
            public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
                super.onInitializeAccessibilityNodeInfo(info);
                info.setText(LocaleController.formatPluralString("AccDescrShareInChats", selectedDialogs.size()));
                info.setClassName(Button.class.getName());
                info.setLongClickable(true);
                info.setClickable(true);
            }
        };
        writeButtonContainer.setFocusable(true);
        writeButtonContainer.setFocusableInTouchMode(true);
        writeButtonContainer.setVisibility(View.INVISIBLE);
        writeButtonContainer.setScaleX(0.2f);
        writeButtonContainer.setScaleY(0.2f);
        writeButtonContainer.setAlpha(0.0f);
        contentView.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 10));
        textPaint.setTextSize(AndroidUtilities.dp(12));
        textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        selectedCountView = new View(context) {

            @Override
            protected void onDraw(Canvas canvas) {
                String text = String.format("%d", Math.max(1, selectedDialogs.size()));
                int textSize = (int) Math.ceil(textPaint.measureText(text));
                int size = Math.max(AndroidUtilities.dp(16) + textSize, AndroidUtilities.dp(24));
                int cx = getMeasuredWidth() / 2;
                int cy = getMeasuredHeight() / 2;
                textPaint.setColor(getThemedColor(Theme.key_dialogRoundCheckBoxCheck));
                paint.setColor(getThemedColor(Theme.isCurrentThemeDark() ? Theme.key_voipgroup_inviteMembersBackground : Theme.key_dialogBackground));
                rect.set(cx - size / 2, 0, cx + size / 2, getMeasuredHeight());
                canvas.drawRoundRect(rect, AndroidUtilities.dp(12), AndroidUtilities.dp(12), paint);
                paint.setColor(getThemedColor(Theme.key_dialogRoundCheckBox));
                rect.set(cx - size / 2 + AndroidUtilities.dp(2), AndroidUtilities.dp(2), cx + size / 2 - AndroidUtilities.dp(2), getMeasuredHeight() - AndroidUtilities.dp(2));
                canvas.drawRoundRect(rect, AndroidUtilities.dp(10), AndroidUtilities.dp(10), paint);
                canvas.drawText(text, cx - textSize / 2, AndroidUtilities.dp(16.2f), textPaint);
            }
        };
        selectedCountView.setAlpha(0.0f);
        selectedCountView.setScaleX(0.2f);
        selectedCountView.setScaleY(0.2f);
        contentView.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -8, 9));
        FrameLayout writeButtonBackground = new FrameLayout(context);
        Drawable writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), getThemedColor(Theme.key_dialogFloatingButton), getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton));
        if (Build.VERSION.SDK_INT < 21) {
            Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
            shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
            CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
            combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            writeButtonDrawable = combinedDrawable;
        }
        writeButtonBackground.setBackgroundDrawable(writeButtonDrawable);
        writeButtonBackground.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            writeButtonBackground.setOutlineProvider(new ViewOutlineProvider() {

                @SuppressLint("NewApi")
                @Override
                public void getOutline(View view, Outline outline) {
                    outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
                }
            });
        }
        writeButtonBackground.setOnClickListener(v -> {
            if (delegate == null || selectedDialogs.isEmpty()) {
                return;
            }
            delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, commentView.getFieldText(), false);
        });
        writeButtonBackground.setOnLongClickListener(v -> {
            if (isNextButton) {
                return false;
            }
            onSendLongClick(writeButtonBackground);
            return true;
        });
        writeButton = new ImageView[2];
        for (int a = 0; a < 2; ++a) {
            writeButton[a] = new ImageView(context);
            writeButton[a].setImageResource(a == 1 ? R.drawable.actionbtn_next : R.drawable.attach_send);
            writeButton[a].setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
            writeButton[a].setScaleType(ImageView.ScaleType.CENTER);
            writeButtonBackground.addView(writeButton[a], LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.CENTER));
        }
        AndroidUtilities.updateViewVisibilityAnimated(writeButton[0], true, 0.5f, false);
        AndroidUtilities.updateViewVisibilityAnimated(writeButton[1], false, 0.5f, false);
        writeButtonContainer.addView(writeButtonBackground, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.LEFT | Gravity.TOP, Build.VERSION.SDK_INT >= 21 ? 2 : 0, 0, 0, 0));
    }
    if (filterTabsView != null) {
        contentView.addView(filterTabsView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 44));
    }
    if (!onlySelect) {
        final FrameLayout.LayoutParams layoutParams = LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT);
        if (inPreviewMode && Build.VERSION.SDK_INT >= 21) {
            layoutParams.topMargin = AndroidUtilities.statusBarHeight;
        }
        contentView.addView(actionBar, layoutParams);
    }
    if (searchString == null && initialDialogsType == 0) {
        updateLayout = new FrameLayout(context) {

            private Paint paint = new Paint();

            private Matrix matrix = new Matrix();

            private LinearGradient updateGradient;

            private int lastGradientWidth;

            @Override
            public void draw(Canvas canvas) {
                if (updateGradient != null) {
                    paint.setColor(0xffffffff);
                    paint.setShader(updateGradient);
                    updateGradient.setLocalMatrix(matrix);
                    canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), paint);
                    updateLayoutIcon.setBackgroundGradientDrawable(updateGradient);
                    updateLayoutIcon.draw(canvas);
                }
                super.draw(canvas);
            }

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                int width = MeasureSpec.getSize(widthMeasureSpec);
                if (lastGradientWidth != width) {
                    updateGradient = new LinearGradient(0, 0, width, 0, new int[] { 0xff69BF72, 0xff53B3AD }, new float[] { 0.0f, 1.0f }, Shader.TileMode.CLAMP);
                    lastGradientWidth = width;
                }
                int x = (getMeasuredWidth() - updateTextView.getMeasuredWidth()) / 2;
                updateLayoutIcon.setProgressRect(x, AndroidUtilities.dp(13), x + AndroidUtilities.dp(22), AndroidUtilities.dp(13 + 22));
            }

            @Override
            public void setTranslationY(float translationY) {
                super.setTranslationY(translationY);
                additionalFloatingTranslation2 = AndroidUtilities.dp(48) - translationY;
                if (additionalFloatingTranslation2 < 0) {
                    additionalFloatingTranslation2 = 0;
                }
                if (!floatingHidden) {
                    updateFloatingButtonOffset();
                }
            }
        };
        updateLayout.setWillNotDraw(false);
        updateLayout.setVisibility(View.INVISIBLE);
        updateLayout.setTranslationY(AndroidUtilities.dp(48));
        if (Build.VERSION.SDK_INT >= 21) {
            updateLayout.setBackground(Theme.getSelectorDrawable(0x40ffffff, false));
        }
        contentView.addView(updateLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
        updateLayout.setOnClickListener(v -> {
            if (!SharedConfig.isAppUpdateAvailable()) {
                return;
            }
            AndroidUtilities.openForView(SharedConfig.pendingAppUpdate.document, true, getParentActivity());
        });
        updateLayoutIcon = new RadialProgress2(updateLayout);
        updateLayoutIcon.setColors(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
        updateLayoutIcon.setCircleRadius(AndroidUtilities.dp(11));
        updateLayoutIcon.setAsMini();
        updateLayoutIcon.setIcon(MediaActionDrawable.ICON_UPDATE, true, false);
        updateTextView = new TextView(context);
        updateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        updateTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        updateTextView.setText(LocaleController.getString("AppUpdateNow", R.string.AppUpdateNow).toUpperCase());
        updateTextView.setTextColor(0xffffffff);
        updateTextView.setPadding(AndroidUtilities.dp(30), 0, 0, 0);
        updateLayout.addView(updateTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, 0));
    }
    for (int a = 0; a < 2; a++) {
        undoView[a] = new UndoView(context) {

            @Override
            public void setTranslationY(float translationY) {
                super.setTranslationY(translationY);
                if (this == undoView[0] && undoView[1].getVisibility() != VISIBLE) {
                    additionalFloatingTranslation = getMeasuredHeight() + AndroidUtilities.dp(8) - translationY;
                    if (additionalFloatingTranslation < 0) {
                        additionalFloatingTranslation = 0;
                    }
                    if (!floatingHidden) {
                        updateFloatingButtonOffset();
                    }
                }
            }

            @Override
            protected boolean canUndo() {
                for (int a = 0; a < viewPages.length; a++) {
                    if (viewPages[a].dialogsItemAnimator.isRunning()) {
                        return false;
                    }
                }
                return true;
            }

            @Override
            protected void onRemoveDialogAction(long currentDialogId, int action) {
                if (action == UndoView.ACTION_DELETE || action == UndoView.ACTION_DELETE_FEW) {
                    debugLastUpdateAction = 1;
                    setDialogsListFrozen(true);
                    if (frozenDialogsList != null) {
                        int selectedIndex = -1;
                        for (int i = 0; i < frozenDialogsList.size(); i++) {
                            if (frozenDialogsList.get(i).id == currentDialogId) {
                                selectedIndex = i;
                                break;
                            }
                        }
                        if (selectedIndex >= 0) {
                            TLRPC.Dialog dialog = frozenDialogsList.remove(selectedIndex);
                            viewPages[0].dialogsAdapter.notifyDataSetChanged();
                            int finalSelectedIndex = selectedIndex;
                            AndroidUtilities.runOnUIThread(() -> {
                                if (frozenDialogsList != null) {
                                    frozenDialogsList.add(finalSelectedIndex, dialog);
                                    viewPages[0].dialogsAdapter.notifyItemInserted(finalSelectedIndex);
                                    dialogInsertFinished = 2;
                                }
                            });
                        } else {
                            setDialogsListFrozen(false);
                        }
                    }
                }
            }
        };
        contentView.addView(undoView[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
    }
    if (folderId != 0) {
        viewPages[0].listView.setGlowColor(Theme.getColor(Theme.key_actionBarDefaultArchived));
        actionBar.setTitleColor(Theme.getColor(Theme.key_actionBarDefaultArchivedTitle));
        actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultArchivedIcon), false);
        actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultArchivedSelector), false);
        actionBar.setSearchTextColor(Theme.getColor(Theme.key_actionBarDefaultArchivedSearch), false);
        actionBar.setSearchTextColor(Theme.getColor(Theme.key_actionBarDefaultArchivedSearchPlaceholder), true);
    }
    if (!onlySelect && initialDialogsType == 0) {
        blurredView = new View(context) {

            @Override
            public void setAlpha(float alpha) {
                super.setAlpha(alpha);
                if (fragmentView != null) {
                    fragmentView.invalidate();
                }
            }
        };
        blurredView.setVisibility(View.GONE);
        contentView.addView(blurredView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    }
    actionBarDefaultPaint.setColor(Theme.getColor(folderId == 0 ? Theme.key_actionBarDefault : Theme.key_actionBarDefaultArchived));
    if (inPreviewMode) {
        final TLRPC.User currentUser = getUserConfig().getCurrentUser();
        avatarContainer = new ChatAvatarContainer(actionBar.getContext(), null, false);
        avatarContainer.setTitle(UserObject.getUserName(currentUser));
        avatarContainer.setSubtitle(LocaleController.formatUserStatus(currentAccount, currentUser));
        avatarContainer.setUserAvatar(currentUser, true);
        avatarContainer.setOccupyStatusBar(false);
        avatarContainer.setLeftPadding(AndroidUtilities.dp(10));
        actionBar.addView(avatarContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 40, 0));
        floatingButton.setVisibility(View.INVISIBLE);
        actionBar.setOccupyStatusBar(false);
        actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
        if (fragmentContextView != null) {
            contentView.removeView(fragmentContextView);
        }
        if (fragmentLocationContextView != null) {
            contentView.removeView(fragmentLocationContextView);
        }
    }
    searchIsShowed = false;
    updateFilterTabs(false, false);
    if (searchString != null) {
        showSearch(true, false);
        actionBar.openSearchField(searchString, false);
    } else if (initialSearchString != null) {
        showSearch(true, false);
        actionBar.openSearchField(initialSearchString, false);
        initialSearchString = null;
        if (filterTabsView != null) {
            filterTabsView.setTranslationY(-AndroidUtilities.dp(44));
        }
    } else {
        showSearch(false, false);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        FilesMigrationService.checkBottomSheet(this);
    }
    updateMenuButton(false);
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) StickersAlert(org.telegram.ui.Components.StickersAlert) RecyclerAnimationScrollHelper(org.telegram.ui.Components.RecyclerAnimationScrollHelper) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) Bulletin(org.telegram.ui.Components.Bulletin) Property(android.util.Property) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) MediaActionDrawable(org.telegram.ui.Components.MediaActionDrawable) FilterTabsView(org.telegram.ui.Components.FilterTabsView) Manifest(android.Manifest) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) StateListAnimator(android.animation.StateListAnimator) DrawerProfileCell(org.telegram.ui.Cells.DrawerProfileCell) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) Shader(android.graphics.Shader) Canvas(android.graphics.Canvas) TargetApi(android.annotation.TargetApi) NotificationsController(org.telegram.messenger.NotificationsController) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) Interpolator(android.view.animation.Interpolator) UndoView(org.telegram.ui.Components.UndoView) AnimationProperties(org.telegram.ui.Components.AnimationProperties) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) MenuDrawable(org.telegram.ui.ActionBar.MenuDrawable) RecyclerItemsEnterAnimator(org.telegram.ui.Components.RecyclerItemsEnterAnimator) Outline(android.graphics.Outline) HapticFeedbackConstants(android.view.HapticFeedbackConstants) DialogsAdapter(org.telegram.ui.Adapters.DialogsAdapter) TextPaint(android.text.TextPaint) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerCell(org.telegram.ui.Cells.DividerCell) FileLoader(org.telegram.messenger.FileLoader) ViewParent(android.view.ViewParent) ViewPager(androidx.viewpager.widget.ViewPager) Dialog(android.app.Dialog) DialogsSearchAdapter(org.telegram.ui.Adapters.DialogsSearchAdapter) SwipeGestureSettingsView(org.telegram.ui.Components.SwipeGestureSettingsView) AlertsCreator(org.telegram.ui.Components.AlertsCreator) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) FragmentContextView(org.telegram.ui.Components.FragmentContextView) TLRPC(org.telegram.tgnet.TLRPC) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) DialogsEmptyCell(org.telegram.ui.Cells.DialogsEmptyCell) FilesMigrationService(org.telegram.messenger.FilesMigrationService) DialogCell(org.telegram.ui.Cells.DialogCell) ProfileSearchCell(org.telegram.ui.Cells.ProfileSearchCell) JoinGroupAlert(org.telegram.ui.Components.JoinGroupAlert) SearchViewPager(org.telegram.ui.Components.SearchViewPager) ViewPagerFixed(org.telegram.ui.Components.ViewPagerFixed) LinearGradient(android.graphics.LinearGradient) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) UserCell(org.telegram.ui.Cells.UserCell) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) TextUtils(android.text.TextUtils) DialogsItemAnimator(org.telegram.ui.Components.DialogsItemAnimator) 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) ScrollView(android.widget.ScrollView) ContactsController(org.telegram.messenger.ContactsController) GraySectionCell(org.telegram.ui.Cells.GraySectionCell) Configuration(android.content.res.Configuration) ColorUtils(androidx.core.graphics.ColorUtils) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) FiltersView(org.telegram.ui.Adapters.FiltersView) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) RadialProgress2(org.telegram.ui.Components.RadialProgress2) PackageManager(android.content.pm.PackageManager) WindowManager(android.view.WindowManager) AccountInstance(org.telegram.messenger.AccountInstance) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) Animator(android.animation.Animator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ViewConfiguration(android.view.ViewConfiguration) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) PacmanAnimation(org.telegram.ui.Components.PacmanAnimation) TextCell(org.telegram.ui.Cells.TextCell) ArchiveHintInnerCell(org.telegram.ui.Cells.ArchiveHintInnerCell) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) 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) ImageLocation(org.telegram.messenger.ImageLocation) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ViewGroup(android.view.ViewGroup) StateSet(android.util.StateSet) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Context(android.content.Context) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) KeyEvent(android.view.KeyEvent) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) BulletinFactory(org.telegram.ui.Components.BulletinFactory) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) VelocityTracker(android.view.VelocityTracker) XiaomiUtilities(org.telegram.messenger.XiaomiUtilities) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) FiltersListBottomSheet(org.telegram.ui.Components.FiltersListBottomSheet) ActionBar(org.telegram.ui.ActionBar.ActionBar) LinearSmoothScrollerCustom(androidx.recyclerview.widget.LinearSmoothScrollerCustom) TLObject(org.telegram.tgnet.TLObject) HintDialogCell(org.telegram.ui.Cells.HintDialogCell) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) MediaDataController(org.telegram.messenger.MediaDataController) Build(android.os.Build) DrawerActionCell(org.telegram.ui.Cells.DrawerActionCell) DialogInterface(android.content.DialogInterface) ChatAvatarContainer(org.telegram.ui.Components.ChatAvatarContainer) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) AccountSelectCell(org.telegram.ui.Cells.AccountSelectCell) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) NumberTextView(org.telegram.ui.Components.NumberTextView) HashtagSearchCell(org.telegram.ui.Cells.HashtagSearchCell) Bitmap(android.graphics.Bitmap) ViewTreeObserver(android.view.ViewTreeObserver) Vibrator(android.os.Vibrator) ProxyDrawable(org.telegram.ui.Components.ProxyDrawable) Activity(android.app.Activity) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LoadingCell(org.telegram.ui.Cells.LoadingCell) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ArrayList(java.util.ArrayList) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Matrix(android.graphics.Matrix) Button(android.widget.Button) AccountSelectCell(org.telegram.ui.Cells.AccountSelectCell) EditText(android.widget.EditText) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) Rect(android.graphics.Rect) ChatAvatarContainer(org.telegram.ui.Components.ChatAvatarContainer) MenuDrawable(org.telegram.ui.ActionBar.MenuDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) MediaActionDrawable(org.telegram.ui.Components.MediaActionDrawable) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) MenuDrawable(org.telegram.ui.ActionBar.MenuDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ProxyDrawable(org.telegram.ui.Components.ProxyDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) LinearGradient(android.graphics.LinearGradient) DialogsSearchAdapter(org.telegram.ui.Adapters.DialogsSearchAdapter) MessagesController(org.telegram.messenger.MessagesController) SearchViewPager(org.telegram.ui.Components.SearchViewPager) FiltersView(org.telegram.ui.Adapters.FiltersView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) UndoView(org.telegram.ui.Components.UndoView) DialogsAdapter(org.telegram.ui.Adapters.DialogsAdapter) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) RecyclerAnimationScrollHelper(org.telegram.ui.Components.RecyclerAnimationScrollHelper) Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) StateListAnimator(android.animation.StateListAnimator) RecyclerItemsEnterAnimator(org.telegram.ui.Components.RecyclerItemsEnterAnimator) DialogsItemAnimator(org.telegram.ui.Components.DialogsItemAnimator) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) RadialProgress2(org.telegram.ui.Components.RadialProgress2) BackupImageView(org.telegram.ui.Components.BackupImageView) Dialog(android.app.Dialog) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) TextView(android.widget.TextView) NumberTextView(org.telegram.ui.Components.NumberTextView) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ProxyDrawable(org.telegram.ui.Components.ProxyDrawable) Canvas(android.graphics.Canvas) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) RecyclerItemsEnterAnimator(org.telegram.ui.Components.RecyclerItemsEnterAnimator) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) FilterTabsView(org.telegram.ui.Components.FilterTabsView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) StateListAnimator(android.animation.StateListAnimator) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) AnimatorSet(android.animation.AnimatorSet) DialogsItemAnimator(org.telegram.ui.Components.DialogsItemAnimator) DialogCell(org.telegram.ui.Cells.DialogCell) HintDialogCell(org.telegram.ui.Cells.HintDialogCell) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) FilterTabsView(org.telegram.ui.Components.FilterTabsView) UndoView(org.telegram.ui.Components.UndoView) SwipeGestureSettingsView(org.telegram.ui.Components.SwipeGestureSettingsView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) ScrollView(android.widget.ScrollView) FiltersView(org.telegram.ui.Adapters.FiltersView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) BackupImageView(org.telegram.ui.Components.BackupImageView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) NumberTextView(org.telegram.ui.Components.NumberTextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) LinearSmoothScrollerCustom(androidx.recyclerview.widget.LinearSmoothScrollerCustom) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) FragmentContextView(org.telegram.ui.Components.FragmentContextView) LinearLayout(android.widget.LinearLayout)

Example 3 with FragmentContextView

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

the class ChatActivity method createMenu.

private void createMenu(View v, boolean single, boolean listView, float x, float y, boolean searchGroup) {
    if (actionBar.isActionModeShowed() || reportType >= 0) {
        return;
    }
    MessageObject message;
    MessageObject primaryMessage;
    if (v instanceof ChatMessageCell) {
        message = ((ChatMessageCell) v).getMessageObject();
        primaryMessage = ((ChatMessageCell) v).getPrimaryMessageObject();
    } else if (v instanceof ChatActionCell) {
        message = ((ChatActionCell) v).getMessageObject();
        primaryMessage = message;
    } else {
        primaryMessage = null;
        message = null;
    }
    if (message == null) {
        return;
    }
    final int type = getMessageType(message);
    if (single) {
        if (message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
            if (message.getReplyMsgId() != 0) {
                scrollToMessageId(message.getReplyMsgId(), message.messageOwner.id, true, message.getDialogId() == mergeDialogId ? 1 : 0, false, 0);
            } else {
                Toast.makeText(getParentActivity(), LocaleController.getString("MessageNotFound", R.string.MessageNotFound), Toast.LENGTH_SHORT).show();
            }
            return;
        } else if (message.messageOwner.action instanceof TLRPC.TL_messageActionSetMessagesTTL) {
            if (avatarContainer.openSetTimer()) {
                return;
            }
        } else if (message.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent && message.replyMessageObject != null && message.replyMessageObject.isInvoice()) {
            TLRPC.TL_payments_getPaymentReceipt req = new TLRPC.TL_payments_getPaymentReceipt();
            req.msg_id = message.getId();
            req.peer = getMessagesController().getInputPeer(message.messageOwner.peer_id);
            getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                if (response instanceof TLRPC.TL_payments_paymentReceipt) {
                    presentFragment(new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response));
                }
            }), ConnectionsManager.RequestFlagFailOnServerErrors);
            return;
        } else if (message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
            if (getParentActivity() == null) {
                return;
            }
            VoIPService sharedInstance = VoIPService.getSharedInstance();
            if (sharedInstance != null) {
                if (sharedInstance.groupCall != null && message.messageOwner.action.call.id == sharedInstance.groupCall.call.id) {
                    if (getParentActivity() instanceof LaunchActivity) {
                        GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(currentAccount), null, null, false, null);
                    } else {
                        Intent intent = new Intent(getParentActivity(), LaunchActivity.class).setAction("voip_chat");
                        intent.putExtra("currentAccount", VoIPService.getSharedInstance().getAccount());
                        getParentActivity().startActivity(intent);
                    }
                } else {
                    createGroupCall = getGroupCall() == null;
                    VoIPHelper.startCall(currentChat, null, null, createGroupCall, getParentActivity(), ChatActivity.this, getAccountInstance());
                }
                return;
            } else if (fragmentContextView != null && getGroupCall() != null) {
                if (VoIPService.getSharedInstance() != null) {
                    GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(VoIPService.getSharedInstance().getAccount()), null, null, false, null);
                } else {
                    ChatObject.Call call = getGroupCall();
                    if (call == null) {
                        return;
                    }
                    VoIPHelper.startCall(getMessagesController().getChat(call.chatId), null, null, false, getParentActivity(), ChatActivity.this, getAccountInstance());
                }
                return;
            } else if (ChatObject.canManageCalls(currentChat)) {
                VoIPHelper.showGroupCallAlert(ChatActivity.this, currentChat, null, true, getAccountInstance());
                return;
            }
        } else if (message.messageOwner.action instanceof TLRPC.TL_messageActionSetChatTheme) {
            showChatThemeBottomSheet();
            return;
        }
    }
    if (message.isSponsored() || threadMessageObjects != null && threadMessageObjects.contains(message)) {
        single = true;
    }
    selectedObject = null;
    selectedObjectGroup = null;
    forwardingMessage = null;
    forwardingMessageGroup = null;
    selectedObjectToEditCaption = null;
    for (int a = 1; a >= 0; a--) {
        selectedMessagesCanCopyIds[a].clear();
        selectedMessagesCanStarIds[a].clear();
        selectedMessagesIds[a].clear();
    }
    hideActionMode();
    updatePinnedMessageView(true);
    MessageObject.GroupedMessages groupedMessages;
    if (searchGroup) {
        groupedMessages = getValidGroupedMessage(message);
    } else {
        groupedMessages = null;
    }
    boolean allowChatActions = true;
    boolean allowPin;
    if (chatMode == MODE_SCHEDULED || isThreadChat()) {
        allowPin = false;
    } else if (currentChat != null) {
        allowPin = message.getDialogId() != mergeDialogId && ChatObject.canPinMessages(currentChat);
    } else if (currentEncryptedChat == null) {
        if (UserObject.isDeleted(currentUser)) {
            allowPin = false;
        } else if (userInfo != null) {
            allowPin = userInfo.can_pin_message;
        } else {
            allowPin = false;
        }
    } else {
        allowPin = false;
    }
    allowPin = allowPin && message.getId() > 0 && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty);
    boolean noforwards = getMessagesController().isChatNoForwards(currentChat) || message.messageOwner.noforwards;
    boolean allowUnpin = message.getDialogId() != mergeDialogId && allowPin && (pinnedMessageObjects.containsKey(message.getId()) || groupedMessages != null && !groupedMessages.messages.isEmpty() && pinnedMessageObjects.containsKey(groupedMessages.messages.get(0).getId()));
    boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId;
    if (allowEdit && groupedMessages != null) {
        int captionsCount = 0;
        for (int a = 0, N = groupedMessages.messages.size(); a < N; a++) {
            MessageObject messageObject = groupedMessages.messages.get(a);
            if (a == 0 || !TextUtils.isEmpty(messageObject.caption)) {
                selectedObjectToEditCaption = messageObject;
                if (!TextUtils.isEmpty(messageObject.caption)) {
                    captionsCount++;
                }
            }
        }
        allowEdit = captionsCount < 2;
    }
    if (chatMode == MODE_SCHEDULED || threadMessageObjects != null && threadMessageObjects.contains(message) || message.isSponsored() || type == 1 && message.getDialogId() == mergeDialogId || message.messageOwner.action instanceof TLRPC.TL_messageActionSecureValuesSent || currentEncryptedChat == null && message.getId() < 0 || bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE || currentChat != null && (ChatObject.isNotInChat(currentChat) && !isThreadChat() || ChatObject.isChannel(currentChat) && !ChatObject.canPost(currentChat) && !currentChat.megagroup || !ChatObject.canSendMessages(currentChat))) {
        allowChatActions = false;
    }
    if (single || type < 2 || type == 20) {
        if (getParentActivity() == null) {
            return;
        }
        ArrayList<Integer> icons = new ArrayList<>();
        ArrayList<CharSequence> items = new ArrayList<>();
        final ArrayList<Integer> options = new ArrayList<>();
        CharSequence messageText = null;
        if (type >= 0 || type == -1 && single && (message.isSending() || message.isEditing()) && currentEncryptedChat == null) {
            selectedObject = message;
            selectedObjectGroup = groupedMessages;
            // used only in translations
            messageText = getMessageCaption(selectedObject, selectedObjectGroup);
            if (messageText == null && selectedObject.isPoll()) {
                try {
                    TLRPC.Poll poll = ((TLRPC.TL_messageMediaPoll) selectedObject.messageOwner.media).poll;
                    StringBuilder pollText = new StringBuilder();
                    pollText = new StringBuilder(poll.question).append("\n");
                    for (TLRPC.TL_pollAnswer answer : poll.answers) pollText.append("\n\uD83D\uDD18 ").append(answer.text);
                    messageText = pollText.toString();
                } catch (Exception e) {
                }
            }
            if (messageText == null)
                messageText = getMessageContent(selectedObject, 0, false);
            if (messageText != null) {
                if (isEmoji(messageText.toString()))
                    // message fully consists of emojis, do not translate
                    messageText = null;
            }
            if (type == -1) {
                if ((selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !noforwards) {
                    items.add(LocaleController.getString("Copy", R.string.Copy));
                    options.add(OPTION_COPY);
                    icons.add(R.drawable.msg_copy);
                }
                items.add(LocaleController.getString("CancelSending", R.string.CancelSending));
                options.add(OPTION_CANCEL_SENDING);
                icons.add(R.drawable.msg_delete);
            } else if (type == 0) {
                items.add(LocaleController.getString("Retry", R.string.Retry));
                options.add(OPTION_RETRY);
                icons.add(R.drawable.msg_retry);
                items.add(LocaleController.getString("Delete", R.string.Delete));
                options.add(OPTION_DELETE);
                icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
            } else if (type == 1) {
                if (currentChat != null) {
                    if (allowChatActions) {
                        items.add(LocaleController.getString("Reply", R.string.Reply));
                        options.add(OPTION_REPLY);
                        icons.add(R.drawable.msg_reply);
                    }
                    if (!isThreadChat() && chatMode != MODE_SCHEDULED && message.hasReplies() && currentChat.megagroup && message.canViewThread()) {
                        items.add(LocaleController.formatPluralString("ViewReplies", message.getRepliesCount()));
                        options.add(OPTION_VIEW_REPLIES_OR_THREAD);
                        icons.add(R.drawable.msg_viewreplies);
                    }
                    if (allowUnpin) {
                        items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
                        options.add(OPTION_UNPIN);
                        icons.add(R.drawable.msg_unpin);
                    } else if (allowPin) {
                        items.add(LocaleController.getString("PinMessage", R.string.PinMessage));
                        options.add(OPTION_PIN);
                        icons.add(R.drawable.msg_pin);
                    }
                    if (selectedObject != null && selectedObject.contentType == 0 && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
                        items.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
                        options.add(29);
                        icons.add(R.drawable.msg_translate);
                    }
                    if (message.canEditMessage(currentChat)) {
                        items.add(LocaleController.getString("Edit", R.string.Edit));
                        options.add(OPTION_EDIT);
                        icons.add(R.drawable.msg_edit);
                    }
                    if (selectedObject.contentType == 0 && !selectedObject.isMediaEmptyWebpage() && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
                        items.add(LocaleController.getString("ReportChat", R.string.ReportChat));
                        options.add(OPTION_REPORT_CHAT);
                        icons.add(R.drawable.msg_report);
                    }
                } else {
                    if (selectedObject.getId() > 0 && allowChatActions) {
                        items.add(LocaleController.getString("Reply", R.string.Reply));
                        options.add(OPTION_REPLY);
                        icons.add(R.drawable.msg_reply);
                    }
                }
                if (message.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat) && (threadMessageObjects == null || !threadMessageObjects.contains(message))) {
                    items.add(LocaleController.getString("Delete", R.string.Delete));
                    options.add(OPTION_DELETE);
                    icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
                }
            } else if (type == 20) {
                items.add(LocaleController.getString("Retry", R.string.Retry));
                options.add(OPTION_RETRY);
                icons.add(R.drawable.msg_retry);
                if (!noforwards) {
                    items.add(LocaleController.getString("Copy", R.string.Copy));
                    options.add(OPTION_COPY);
                    icons.add(R.drawable.msg_copy);
                }
                items.add(LocaleController.getString("Delete", R.string.Delete));
                options.add(OPTION_DELETE);
                icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
            } else {
                if (currentEncryptedChat == null) {
                    if (chatMode == MODE_SCHEDULED) {
                        items.add(LocaleController.getString("MessageScheduleSend", R.string.MessageScheduleSend));
                        options.add(OPTION_SEND_NOW);
                        icons.add(R.drawable.outline_send);
                    }
                    if (selectedObject.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall) {
                        TLRPC.TL_messageActionPhoneCall call = (TLRPC.TL_messageActionPhoneCall) message.messageOwner.action;
                        items.add((call.reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || call.reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy) && !message.isOutOwner() ? LocaleController.getString("CallBack", R.string.CallBack) : LocaleController.getString("CallAgain", R.string.CallAgain));
                        options.add(OPTION_CALL_AGAIN);
                        icons.add(R.drawable.msg_callback);
                        if (VoIPHelper.canRateCall(call)) {
                            items.add(LocaleController.getString("CallMessageReportProblem", R.string.CallMessageReportProblem));
                            options.add(OPTION_RATE_CALL);
                            icons.add(R.drawable.msg_fave);
                        }
                    }
                    if (allowChatActions) {
                        items.add(LocaleController.getString("Reply", R.string.Reply));
                        options.add(8);
                        icons.add(R.drawable.msg_reply);
                    }
                    if ((selectedObject.type == 0 || selectedObject.isDice() || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !noforwards) {
                        items.add(LocaleController.getString("Copy", R.string.Copy));
                        options.add(3);
                        icons.add(R.drawable.msg_copy);
                    }
                    if (!isThreadChat() && chatMode != MODE_SCHEDULED && currentChat != null && (currentChat.has_link || message.hasReplies()) && currentChat.megagroup && message.canViewThread()) {
                        if (message.hasReplies()) {
                            items.add(LocaleController.formatPluralString("ViewReplies", message.getRepliesCount()));
                        } else {
                            items.add(LocaleController.getString("ViewThread", R.string.ViewThread));
                        }
                        options.add(27);
                        icons.add(R.drawable.msg_viewreplies);
                    }
                    if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && ChatObject.isChannel(currentChat) && selectedObject.getDialogId() != mergeDialogId) {
                        items.add(LocaleController.getString("CopyLink", R.string.CopyLink));
                        options.add(22);
                        icons.add(R.drawable.msg_link);
                    }
                    if (type == 2) {
                        if (chatMode != MODE_SCHEDULED) {
                            if (selectedObject.type == MessageObject.TYPE_POLL && !message.isPollClosed()) {
                                if (message.canUnvote()) {
                                    items.add(LocaleController.getString("Unvote", R.string.Unvote));
                                    options.add(25);
                                    icons.add(R.drawable.msg_unvote);
                                }
                                if (!message.isForwarded() && (message.isOut() && (!ChatObject.isChannel(currentChat) || currentChat.megagroup) || ChatObject.isChannel(currentChat) && !currentChat.megagroup && (currentChat.creator || currentChat.admin_rights != null && currentChat.admin_rights.edit_messages))) {
                                    if (message.isQuiz()) {
                                        items.add(LocaleController.getString("StopQuiz", R.string.StopQuiz));
                                    } else {
                                        items.add(LocaleController.getString("StopPoll", R.string.StopPoll));
                                    }
                                    options.add(26);
                                    icons.add(R.drawable.msg_pollstop);
                                }
                            } else if (selectedObject.isMusic() && !noforwards) {
                                items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
                                options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                                icons.add(R.drawable.msg_download);
                            } else if (selectedObject.isDocument() && !noforwards) {
                                items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
                                options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                                icons.add(R.drawable.msg_download);
                            }
                        }
                    } else if (type == 3 && !noforwards) {
                        if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject.isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) {
                            items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
                            options.add(11);
                            icons.add(R.drawable.msg_gif);
                        }
                    } else if (type == 4) {
                        if (!noforwards) {
                            if (selectedObject.isVideo()) {
                                if (!selectedObject.needDrawBluredPreview()) {
                                    items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
                                    options.add(4);
                                    icons.add(R.drawable.msg_gallery);
                                    items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                                    options.add(6);
                                    icons.add(R.drawable.msg_shareout);
                                }
                            } else if (selectedObject.isMusic()) {
                                items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
                                options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                                icons.add(R.drawable.msg_download);
                                items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                                options.add(6);
                                icons.add(R.drawable.msg_shareout);
                            } else if (selectedObject.getDocument() != null) {
                                if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
                                    items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
                                    options.add(11);
                                    icons.add(R.drawable.msg_gif);
                                }
                                items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
                                options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                                icons.add(R.drawable.msg_download);
                                items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                                options.add(6);
                                icons.add(R.drawable.msg_shareout);
                            } else {
                                if (!selectedObject.needDrawBluredPreview()) {
                                    items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
                                    options.add(4);
                                    icons.add(R.drawable.msg_gallery);
                                }
                            }
                        }
                    } else if (type == 5) {
                        items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
                        options.add(5);
                        icons.add(R.drawable.msg_language);
                        if (!noforwards) {
                            items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
                            options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                            icons.add(R.drawable.msg_download);
                            items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                            options.add(6);
                            icons.add(R.drawable.msg_shareout);
                        }
                    } else if (type == 10) {
                        items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
                        options.add(5);
                        icons.add(R.drawable.msg_theme);
                        if (!noforwards) {
                            items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
                            options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                            icons.add(R.drawable.msg_download);
                            items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                            options.add(6);
                            icons.add(R.drawable.msg_shareout);
                        }
                    } else if (type == 6 && !noforwards) {
                        items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
                        options.add(7);
                        icons.add(R.drawable.msg_gallery);
                        items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
                        options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                        icons.add(R.drawable.msg_download);
                        items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                        options.add(6);
                        icons.add(R.drawable.msg_shareout);
                    } else if (type == 7) {
                        if (selectedObject.isMask()) {
                            items.add(LocaleController.getString("AddToMasks", R.string.AddToMasks));
                            options.add(9);
                            icons.add(R.drawable.msg_sticker);
                        } else {
                            items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers));
                            options.add(9);
                            icons.add(R.drawable.msg_sticker);
                            TLRPC.Document document = selectedObject.getDocument();
                            if (!getMediaDataController().isStickerInFavorites(document)) {
                                if (getMediaDataController().canAddStickerToFavorites() && MessageObject.isStickerHasSet(document)) {
                                    items.add(LocaleController.getString("AddToFavorites", R.string.AddToFavorites));
                                    options.add(20);
                                    icons.add(R.drawable.msg_fave);
                                }
                            } else {
                                items.add(LocaleController.getString("DeleteFromFavorites", R.string.DeleteFromFavorites));
                                options.add(21);
                                icons.add(R.drawable.msg_unfave);
                            }
                        }
                    } else if (type == 8) {
                        long uid = selectedObject.messageOwner.media.user_id;
                        TLRPC.User user = null;
                        if (uid != 0) {
                            user = MessagesController.getInstance(currentAccount).getUser(uid);
                        }
                        if (user != null && user.id != getUserConfig().getClientUserId() && getContactsController().contactsDict.get(user.id) == null) {
                            items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
                            options.add(15);
                            icons.add(R.drawable.msg_addcontact);
                        }
                        if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
                            if (!noforwards) {
                                items.add(LocaleController.getString("Copy", R.string.Copy));
                                options.add(16);
                                icons.add(R.drawable.msg_copy);
                            }
                            items.add(LocaleController.getString("Call", R.string.Call));
                            options.add(17);
                            icons.add(R.drawable.msg_callback);
                        }
                    } else if (type == 9) {
                        TLRPC.Document document = selectedObject.getDocument();
                        if (!getMediaDataController().isStickerInFavorites(document)) {
                            if (MessageObject.isStickerHasSet(document)) {
                                items.add(LocaleController.getString("AddToFavorites", R.string.AddToFavorites));
                                options.add(20);
                                icons.add(R.drawable.msg_fave);
                            }
                        } else {
                            items.add(LocaleController.getString("DeleteFromFavorites", R.string.DeleteFromFavorites));
                            options.add(21);
                            icons.add(R.drawable.msg_unfave);
                        }
                    }
                    if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && !selectedObject.needDrawBluredPreview() && !selectedObject.isLiveLocation() && selectedObject.type != 16 && !noforwards) {
                        items.add(LocaleController.getString("Forward", R.string.Forward));
                        options.add(2);
                        icons.add(R.drawable.msg_forward);
                    }
                    if (allowUnpin) {
                        items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
                        options.add(14);
                        icons.add(R.drawable.msg_unpin);
                    } else if (allowPin) {
                        items.add(LocaleController.getString("PinMessage", R.string.PinMessage));
                        options.add(13);
                        icons.add(R.drawable.msg_pin);
                    }
                    if (selectedObject != null && selectedObject.contentType == 0 && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
                        items.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
                        options.add(29);
                        icons.add(R.drawable.msg_translate);
                    }
                    if (allowEdit) {
                        items.add(LocaleController.getString("Edit", R.string.Edit));
                        options.add(12);
                        icons.add(R.drawable.msg_edit);
                    }
                    if (chatMode == MODE_SCHEDULED && selectedObject.canEditMessageScheduleTime(currentChat)) {
                        items.add(LocaleController.getString("MessageScheduleEditTime", R.string.MessageScheduleEditTime));
                        options.add(102);
                        icons.add(R.drawable.msg_schedule);
                    }
                    if (chatMode != MODE_SCHEDULED && selectedObject.contentType == 0 && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
                        if (UserObject.isReplyUser(currentUser)) {
                            items.add(LocaleController.getString("BlockContact", R.string.BlockContact));
                            options.add(23);
                            icons.add(R.drawable.msg_block2);
                        } else {
                            items.add(LocaleController.getString("ReportChat", R.string.ReportChat));
                            options.add(23);
                            icons.add(R.drawable.msg_report);
                        }
                    }
                    if (message.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat) && (threadMessageObjects == null || !threadMessageObjects.contains(message))) {
                        items.add(LocaleController.getString("Delete", R.string.Delete));
                        options.add(1);
                        icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
                    }
                } else {
                    if (allowChatActions) {
                        items.add(LocaleController.getString("Reply", R.string.Reply));
                        options.add(8);
                        icons.add(R.drawable.msg_reply);
                    }
                    if ((selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !noforwards) {
                        items.add(LocaleController.getString("Copy", R.string.Copy));
                        options.add(3);
                        icons.add(R.drawable.msg_copy);
                    }
                    if (!isThreadChat() && chatMode != MODE_SCHEDULED && currentChat != null && (currentChat.has_link || message.hasReplies()) && currentChat.megagroup && message.canViewThread()) {
                        if (message.hasReplies()) {
                            items.add(LocaleController.formatPluralString("ViewReplies", message.getRepliesCount()));
                        } else {
                            items.add(LocaleController.getString("ViewThread", R.string.ViewThread));
                        }
                        options.add(27);
                        icons.add(R.drawable.msg_viewreplies);
                    }
                    if (type == 4 && !noforwards) {
                        if (selectedObject.isVideo()) {
                            items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
                            options.add(4);
                            icons.add(R.drawable.msg_gallery);
                            items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                            options.add(6);
                            icons.add(R.drawable.msg_shareout);
                        } else if (selectedObject.isMusic()) {
                            items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
                            options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                            icons.add(R.drawable.msg_download);
                            items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                            options.add(6);
                            icons.add(R.drawable.msg_shareout);
                        } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) {
                            items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
                            options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
                            icons.add(R.drawable.msg_download);
                            items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
                            options.add(6);
                            icons.add(R.drawable.msg_shareout);
                        } else {
                            items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
                            options.add(4);
                            icons.add(R.drawable.msg_gallery);
                        }
                    } else if (type == 5) {
                        items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
                        options.add(5);
                        icons.add(R.drawable.msg_language);
                    } else if (type == 10) {
                        items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
                        options.add(5);
                        icons.add(R.drawable.msg_theme);
                    } else if (type == 7) {
                        items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers));
                        options.add(9);
                        icons.add(R.drawable.msg_sticker);
                    } else if (type == 8) {
                        long uid = selectedObject.messageOwner.media.user_id;
                        TLRPC.User user = null;
                        if (uid != 0) {
                            user = MessagesController.getInstance(currentAccount).getUser(uid);
                        }
                        if (user != null && user.id != getUserConfig().getClientUserId() && getContactsController().contactsDict.get(user.id) == null) {
                            items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
                            options.add(15);
                            icons.add(R.drawable.msg_addcontact);
                        }
                        if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
                            if (!noforwards) {
                                items.add(LocaleController.getString("Copy", R.string.Copy));
                                options.add(16);
                                icons.add(R.drawable.msg_copy);
                            }
                            items.add(LocaleController.getString("Call", R.string.Call));
                            options.add(17);
                            icons.add(R.drawable.msg_callback);
                        }
                    }
                    items.add(LocaleController.getString("Delete", R.string.Delete));
                    options.add(1);
                    icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
                }
            }
        }
        if (options.isEmpty()) {
            return;
        }
        if (scrimPopupWindow != null) {
            closeMenu();
            menuDeleteItem = null;
            scrimPopupWindowItems = null;
            return;
        }
        final AtomicBoolean waitForLangDetection = new AtomicBoolean(false);
        final AtomicReference<Runnable> onLangDetectionDone = new AtomicReference(null);
        Rect rect = new Rect();
        List<TLRPC.TL_availableReaction> availableReacts = getMediaDataController().getEnabledReactionsList();
        boolean isReactionsViewAvailable = !isSecretChat() && !isInScheduleMode() && currentUser == null && message.hasReactions() && (!ChatObject.isChannel(currentChat) || currentChat.megagroup) && !availableReacts.isEmpty() && message.messageOwner.reactions.can_see_list;
        boolean isReactionsAvailable;
        if (message.isForwardedChannelPost()) {
            TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(-message.getFromChatId());
            if (chatInfo == null) {
                isReactionsAvailable = true;
            } else {
                isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty()) && !availableReacts.isEmpty();
            }
        } else {
            isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty() || (chatInfo == null && !ChatObject.isChannel(currentChat)) || currentUser != null) && !availableReacts.isEmpty();
        }
        boolean showMessageSeen = !isReactionsViewAvailable && !isInScheduleMode() && currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < getMessagesController().chatReadMarkExpirePeriod) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && chatInfo != null && chatInfo.participants_count < getMessagesController().chatReadMarkSizeThreshold && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest) && (v instanceof ChatMessageCell);
        int flags = 0;
        if (isReactionsViewAvailable || showMessageSeen) {
            flags |= ActionBarPopupWindow.ActionBarPopupWindowLayout.FLAG_USE_SWIPEBACK;
        }
        ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity(), R.drawable.popup_fixed_alert, themeDelegate, flags);
        popupLayout.setMinimumWidth(AndroidUtilities.dp(200));
        Rect backgroundPaddings = new Rect();
        Drawable shadowDrawable = getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
        shadowDrawable.getPadding(backgroundPaddings);
        popupLayout.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
        if (isReactionsViewAvailable) {
            ReactedHeaderView reactedView = new ReactedHeaderView(contentView.getContext(), currentAccount, message, dialog_id);
            int count = 0;
            if (message.messageOwner.reactions != null) {
                for (TLRPC.TL_reactionCount r : message.messageOwner.reactions.results) {
                    count += r.count;
                }
            }
            boolean hasHeader = count > 10;
            LinearLayout linearLayout = new LinearLayout(contentView.getContext()) {

                @Override
                protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                    int size = MeasureSpec.getSize(widthMeasureSpec);
                    if (size < AndroidUtilities.dp(240)) {
                        size = AndroidUtilities.dp(240);
                    }
                    super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY), heightMeasureSpec);
                }
            };
            linearLayout.setOrientation(LinearLayout.VERTICAL);
            linearLayout.setLayoutParams(new FrameLayout.LayoutParams(AndroidUtilities.dp(200), AndroidUtilities.dp(6 * 48 + (hasHeader ? 44 * 2 + 8 : 44)) + (!hasHeader ? 1 : 0)));
            ActionBarMenuSubItem backCell = new ActionBarMenuSubItem(getParentActivity(), true, false, themeDelegate);
            backCell.setItemHeight(44);
            backCell.setTextAndIcon(LocaleController.getString("Back", R.string.Back), R.drawable.msg_arrow_back);
            backCell.getTextView().setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(40), 0, LocaleController.isRTL ? AndroidUtilities.dp(40) : 0, 0);
            backCell.setOnClickListener(v1 -> popupLayout.getSwipeBack().closeForeground());
            linearLayout.addView(backCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
            int[] foregroundIndex = new int[1];
            if (hasHeader) {
                List<TLRPC.TL_reactionCount> counters = message.messageOwner.reactions.results;
                LinearLayout tabsView = new LinearLayout(contentView.getContext());
                tabsView.setOrientation(LinearLayout.HORIZONTAL);
                ViewPager pager = new ViewPager(contentView.getContext());
                HorizontalScrollView tabsScrollView = new HorizontalScrollView(contentView.getContext());
                AtomicBoolean suppressTabsScroll = new AtomicBoolean();
                int size = counters.size() + 1;
                for (int i = 0; i < size; i++) {
                    ReactionTabHolderView hv = new ReactionTabHolderView(contentView.getContext());
                    if (i == 0) {
                        hv.setCounter(count);
                    } else
                        hv.setCounter(currentAccount, counters.get(i - 1));
                    int finalI = i;
                    hv.setOnClickListener(v1 -> {
                        int from = pager.getCurrentItem();
                        if (finalI == from)
                            return;
                        ReactionTabHolderView fv = (ReactionTabHolderView) tabsView.getChildAt(from);
                        suppressTabsScroll.set(true);
                        pager.setCurrentItem(finalI, true);
                        float fSX = tabsScrollView.getScrollX(), tSX = hv.getX() - (tabsScrollView.getWidth() - hv.getWidth()) / 2f;
                        ValueAnimator a = ValueAnimator.ofFloat(0, 1).setDuration(150);
                        a.setInterpolator(CubicBezierInterpolator.DEFAULT);
                        a.addUpdateListener(animation -> {
                            float f = (float) animation.getAnimatedValue();
                            tabsScrollView.setScrollX((int) (fSX + (tSX - fSX) * f));
                            fv.setOutlineProgress(1f - f);
                            hv.setOutlineProgress(f);
                        });
                        a.start();
                    });
                    tabsView.addView(hv, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL, i == 0 ? 6 : 0, 6, 6, 6));
                }
                tabsScrollView.setHorizontalScrollBarEnabled(false);
                tabsScrollView.addView(tabsView);
                linearLayout.addView(tabsScrollView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 44));
                View divider = new FrameLayout(contentView.getContext());
                divider.setBackgroundColor(Theme.getColor(Theme.key_graySection));
                linearLayout.addView(divider, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) Theme.dividerPaint.getStrokeWidth()));
                int head = AndroidUtilities.dp(44 * 2) + 1;
                SparseArray<ReactedUsersListView> cachedViews = new SparseArray<>();
                SparseIntArray cachedHeights = new SparseIntArray();
                for (int i = 0; i < counters.size() + 1; i++) cachedHeights.put(i, head + AndroidUtilities.dp(ReactedUsersListView.ITEM_HEIGHT_DP * ReactedUsersListView.VISIBLE_ITEMS));
                pager.setAdapter(new PagerAdapter() {

                    @Override
                    public int getCount() {
                        return counters.size() + 1;
                    }

                    @Override
                    public boolean isViewFromObject(View view, Object object) {
                        return view == object;
                    }

                    @Override
                    public Object instantiateItem(ViewGroup container, int position) {
                        View cached = cachedViews.get(position);
                        if (cached != null) {
                            container.addView(cached);
                            return cached;
                        }
                        ReactedUsersListView v = new ReactedUsersListView(container.getContext(), themeDelegate, currentAccount, message, position == 0 ? null : counters.get(position - 1), true).setSeenUsers(reactedView.getSeenUsers()).setOnProfileSelectedListener((view, userId) -> {
                            Bundle args = new Bundle();
                            args.putLong("user_id", userId);
                            ProfileActivity fragment = new ProfileActivity(args);
                            presentFragment(fragment);
                            closeMenu();
                        }).setOnHeightChangedListener((view, newHeight) -> {
                            cachedHeights.put(position, head + newHeight);
                            if (pager.getCurrentItem() == position)
                                popupLayout.getSwipeBack().setNewForegroundHeight(foregroundIndex[0], head + newHeight);
                        });
                        if (position == 0)
                            reactedView.setSeenCallback(v::setSeenUsers);
                        container.addView(v);
                        cachedViews.put(position, v);
                        return v;
                    }

                    @Override
                    public void destroyItem(ViewGroup container, int position, Object object) {
                        container.removeView((View) object);
                    }
                });
                pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

                    @Override
                    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                        if (!suppressTabsScroll.get()) {
                            float fX = -1, tX = -1;
                            for (int i = 0; i < tabsView.getChildCount(); i++) {
                                ReactionTabHolderView ch = (ReactionTabHolderView) tabsView.getChildAt(i);
                                ch.setOutlineProgress(i == position ? 1f - positionOffset : i == (position + 1) % size ? positionOffset : 0);
                                if (i == position) {
                                    fX = ch.getX() - (tabsScrollView.getWidth() - ch.getWidth()) / 2f;
                                }
                                if (i == position + 1) {
                                    tX = ch.getX() - (tabsScrollView.getWidth() - ch.getWidth()) / 2f;
                                }
                            }
                            if (fX != -1 && tX != -1)
                                tabsScrollView.setScrollX((int) (fX + (tX - fX) * positionOffset));
                        }
                    }

                    @Override
                    public void onPageSelected(int position) {
                        int h = cachedHeights.get(position);
                        popupLayout.getSwipeBack().setNewForegroundHeight(foregroundIndex[0], h);
                    }

                    @Override
                    public void onPageScrollStateChanged(int state) {
                        if (state == ViewPager.SCROLL_STATE_IDLE) {
                            suppressTabsScroll.set(false);
                        }
                    }
                });
                linearLayout.addView(pager, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 0, 1f));
            } else {
                View gap = new FrameLayout(contentView.getContext());
                gap.setBackgroundColor(Theme.getColor(Theme.key_graySection));
                linearLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
                ReactedUsersListView lv = new ReactedUsersListView(contentView.getContext(), themeDelegate, currentAccount, message, null, true).setSeenUsers(reactedView.getSeenUsers()).setOnProfileSelectedListener((view, userId) -> {
                    Bundle args = new Bundle();
                    args.putLong("user_id", userId);
                    ProfileActivity fragment = new ProfileActivity(args);
                    presentFragment(fragment);
                    closeMenu();
                }).setOnHeightChangedListener((view, newHeight) -> popupLayout.getSwipeBack().setNewForegroundHeight(foregroundIndex[0], AndroidUtilities.dp(44 + 8) + newHeight));
                reactedView.setSeenCallback(lv::setSeenUsers);
                linearLayout.addView(lv, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 0, 1f));
            }
            foregroundIndex[0] = popupLayout.addViewToSwipeBack(linearLayout);
            reactedView.setOnClickListener(v1 -> {
                popupLayout.getSwipeBack().openForeground(foregroundIndex[0]);
            });
            popupLayout.addView(reactedView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
            View gap = new FrameLayout(contentView.getContext());
            gap.setBackgroundColor(Theme.getColor(Theme.key_graySection));
            popupLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
        }
        MessageSeenView messageSeenView = null;
        if (showMessageSeen) {
            messageSeenView = new MessageSeenView(contentView.getContext(), currentAccount, message, currentChat);
            FrameLayout messageSeenLayout = new FrameLayout(contentView.getContext());
            messageSeenLayout.addView(messageSeenView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
            MessageSeenView finalMessageSeenView = messageSeenView;
            ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), true, true, themeDelegate);
            cell.setItemHeight(44);
            cell.setTextAndIcon(LocaleController.getString("Back", R.string.Back), R.drawable.msg_arrow_back);
            cell.getTextView().setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(40), 0, LocaleController.isRTL ? AndroidUtilities.dp(40) : 0, 0);
            FrameLayout backContainer = new FrameLayout(contentView.getContext());
            LinearLayout linearLayout = new LinearLayout(contentView.getContext());
            linearLayout.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
            linearLayout.setOrientation(LinearLayout.VERTICAL);
            RecyclerListView listView2 = finalMessageSeenView.createListView();
            backContainer.addView(cell);
            linearLayout.addView(backContainer);
            backContainer.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    popupLayout.getSwipeBack().closeForeground();
                }
            });
            int[] foregroundIndex = new int[1];
            messageSeenView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (scrimPopupWindow == null || finalMessageSeenView.users.isEmpty()) {
                        return;
                    }
                    if (finalMessageSeenView.users.size() == 1) {
                        TLRPC.User user = finalMessageSeenView.users.get(0);
                        if (user == null) {
                            return;
                        }
                        Bundle args = new Bundle();
                        args.putLong("user_id", user.id);
                        ProfileActivity fragment = new ProfileActivity(args);
                        presentFragment(fragment);
                        closeMenu();
                        return;
                    }
                    int totalHeight = contentView.getHeightWithKeyboard();
                    int availableHeight = totalHeight - scrimPopupY - AndroidUtilities.dp(46 + 16) - (isReactionsAvailable ? AndroidUtilities.dp(52) : 0);
                    if (SharedConfig.messageSeenHintCount > 0 && contentView.getKeyboardHeight() < AndroidUtilities.dp(20)) {
                        availableHeight -= AndroidUtilities.dp(52);
                        Bulletin bulletin = BulletinFactory.of(ChatActivity.this).createErrorBulletin(AndroidUtilities.replaceTags(LocaleController.getString("MessageSeenTooltipMessage", R.string.MessageSeenTooltipMessage)));
                        bulletin.tag = 1;
                        bulletin.setDuration(4000);
                        bulletin.show();
                        SharedConfig.updateMessageSeenHintCount(SharedConfig.messageSeenHintCount - 1);
                    } else if (contentView.getKeyboardHeight() > AndroidUtilities.dp(20)) {
                        availableHeight -= contentView.getKeyboardHeight() / 3f;
                    }
                    int listViewTotalHeight = AndroidUtilities.dp(8) + AndroidUtilities.dp(44) * listView2.getAdapter().getItemCount();
                    if (listViewTotalHeight > availableHeight) {
                        if (availableHeight > AndroidUtilities.dp(620)) {
                            listView2.getLayoutParams().height = AndroidUtilities.dp(620);
                        } else {
                            listView2.getLayoutParams().height = availableHeight;
                        }
                    } else {
                        listView2.getLayoutParams().height = listViewTotalHeight;
                    }
                    linearLayout.getLayoutParams().height = AndroidUtilities.dp(44) + listView2.getLayoutParams().height;
                    listView2.requestLayout();
                    linearLayout.requestLayout();
                    listView2.getAdapter().notifyDataSetChanged();
                    popupLayout.getSwipeBack().openForeground(foregroundIndex[0]);
                }
            });
            linearLayout.addView(listView2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 320));
            listView2.setOnItemClickListener((view1, position) -> {
                TLRPC.User user = finalMessageSeenView.users.get(position);
                if (user == null) {
                    return;
                }
                Bundle args = new Bundle();
                args.putLong("user_id", user.id);
                ProfileActivity fragment = new ProfileActivity(args);
                presentFragment(fragment);
            });
            foregroundIndex[0] = popupLayout.addViewToSwipeBack(linearLayout);
            popupLayout.addView(messageSeenLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 44));
            View gap = new FrameLayout(contentView.getContext());
            gap.setBackgroundColor(Theme.getColor(Theme.key_graySection));
            popupLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
        }
        if (popupLayout.getSwipeBack() != null) {
            popupLayout.getSwipeBack().setOnClickListener(e -> closeMenu());
        }
        scrimPopupWindowItems = new ActionBarMenuSubItem[items.size() + (selectedObject.isSponsored() ? 1 : 0)];
        for (int a = 0, N = items.size(); a < N; a++) {
            if (a == 0 && selectedObject.isSponsored()) {
                ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), true, true, themeDelegate);
                cell.setTextAndIcon(LocaleController.getString("SponsoredMessageInfo", R.string.SponsoredMessageInfo), R.drawable.menu_info);
                cell.setItemHeight(56);
                cell.setTag(R.id.width_tag, 240);
                cell.setMultiline();
                scrimPopupWindowItems[scrimPopupWindowItems.length - 1] = cell;
                popupLayout.addView(cell);
                cell.setOnClickListener(v1 -> {
                    if (contentView == null || getParentActivity() == null) {
                        return;
                    }
                    BottomSheet.Builder builder = new BottomSheet.Builder(contentView.getContext());
                    builder.setCustomView(new SponsoredMessageInfoView(getParentActivity(), themeDelegate));
                    builder.show();
                });
                View gap = new View(getParentActivity());
                gap.setMinimumWidth(AndroidUtilities.dp(196));
                gap.setTag(1000);
                gap.setTag(R.id.object_tag, 1);
                popupLayout.addView(gap);
                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) cell.getLayoutParams();
                if (LocaleController.isRTL) {
                    layoutParams.gravity = Gravity.RIGHT;
                }
                layoutParams.width = LayoutHelper.MATCH_PARENT;
                layoutParams.height = AndroidUtilities.dp(6);
                gap.setLayoutParams(layoutParams);
            }
            ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == N - 1, themeDelegate);
            cell.setMinimumWidth(AndroidUtilities.dp(200));
            cell.setTextAndIcon(items.get(a), icons.get(a));
            Integer option = options.get(a);
            if (option == 1 && selectedObject.messageOwner.ttl_period != 0) {
                menuDeleteItem = cell;
                updateDeleteItemRunnable.run();
                cell.setSubtextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText6));
            }
            scrimPopupWindowItems[a] = cell;
            popupLayout.addView(cell);
            final int i = a;
            cell.setOnClickListener(v1 -> {
                if (selectedObject == null || i >= options.size()) {
                    return;
                }
                processSelectedOption(options.get(i));
            });
            if (option == 29) {
                // "Translate" button
                String toLang = LocaleController.getInstance().getCurrentLocale().getLanguage();
                final CharSequence finalMessageText = messageText;
                TranslateAlert.OnLinkPress onLinkPress = (link) -> {
                    didPressMessageUrl(link, false, selectedObject, v instanceof ChatMessageCell ? (ChatMessageCell) v : null);
                };
                TLRPC.InputPeer inputPeer = getMessagesController().getInputPeer(dialog_id);
                int messageId = selectedObject.messageOwner.id;
                /*if (LanguageDetector.hasSupport()) {
                        final String[] fromLang = { null };
                        cell.setVisibility(View.GONE);
                        waitForLangDetection.set(true);
                        LanguageDetector.detectLanguage(
                            finalMessageText.toString(),
                            (String lang) -> {
                                fromLang[0] = lang;
                                if (fromLang[0] != null && (!fromLang[0].equals(toLang) || fromLang[0].equals("und")) &&
                                        !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(fromLang[0])) {
                                    cell.setVisibility(View.VISIBLE);
                                }
                                waitForLangDetection.set(false);
                                if (onLangDetectionDone.get() != null) {
                                    onLangDetectionDone.get().run();
                                    onLangDetectionDone.set(null);
                                }
                            },
                            (Exception e) -> {
                                FileLog.e("mlkit: failed to detect language in message");
                                e.printStackTrace();
                                waitForLangDetection.set(false);
                                if (onLangDetectionDone.get() != null) {
                                    onLangDetectionDone.get().run();
                                    onLangDetectionDone.set(null);
                                }
                            }
                        );
                        cell.setOnClickListener(e -> {
                            if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
                                return;
                            }
                            TranslateAlert alert = TranslateAlert.showAlert(getParentActivity(), this, currentAccount, inputPeer, messageId, fromLang[0], toLang, finalMessageText, noforwards, onLinkPress, () -> dimBehindView(false));
                            alert.showDim(false);
                            closeMenu(false);
                        });
                        cell.postDelayed(() -> {
                            if (onLangDetectionDone.get() != null) {
                                onLangDetectionDone.getAndSet(null).run();
                            }
                        }, 250);
                    } else {*/
                cell.setOnClickListener(e -> {
                    if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
                        return;
                    }
                    TranslateAlert alert = TranslateAlert.showAlert(getParentActivity(), this, currentAccount, inputPeer, messageId, "und", toLang, finalMessageText, noforwards, onLinkPress, () -> dimBehindView(false));
                    alert.showDim(false);
                    closeMenu(false);
                });
            // }
            }
        }
        ChatScrimPopupContainerLayout scrimPopupContainerLayout = new ChatScrimPopupContainerLayout(contentView.getContext()) {

            @Override
            public boolean dispatchKeyEvent(KeyEvent event) {
                if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
                    closeMenu();
                }
                return super.dispatchKeyEvent(event);
            }

            @Override
            public boolean dispatchTouchEvent(MotionEvent ev) {
                boolean b = super.dispatchTouchEvent(ev);
                if (ev.getAction() == MotionEvent.ACTION_DOWN && !b) {
                    closeMenu();
                }
                return b;
            }
        };
        scrimPopupContainerLayout.setOnTouchListener(new View.OnTouchListener() {

            private int[] pos = new int[2];

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                    if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
                        View contentView = scrimPopupWindow.getContentView();
                        contentView.getLocationInWindow(pos);
                        rect.set(pos[0], pos[1], pos[0] + contentView.getMeasuredWidth(), pos[1] + contentView.getMeasuredHeight());
                        if (!rect.contains((int) event.getX(), (int) event.getY())) {
                            closeMenu();
                        }
                    }
                } else if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
                    closeMenu();
                }
                return false;
            }
        });
        ReactionsContainerLayout reactionsLayout = new ReactionsContainerLayout(contentView.getContext(), currentAccount, getResourceProvider());
        if (isReactionsAvailable) {
            int pad = 22;
            int sPad = 24;
            reactionsLayout.setPadding(AndroidUtilities.dp(4) + (LocaleController.isRTL ? 0 : sPad), AndroidUtilities.dp(4), AndroidUtilities.dp(4) + (LocaleController.isRTL ? sPad : 0), AndroidUtilities.dp(pad));
            reactionsLayout.setDelegate((rView, reaction, longress) -> {
                selectReaction(primaryMessage, reactionsLayout, 0, 0, reaction, false, longress);
            });
            LinearLayout.LayoutParams params = LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 52 + pad, Gravity.RIGHT, 0, 50, 0, -20);
            scrimPopupContainerLayout.addView(reactionsLayout, params);
            scrimPopupContainerLayout.reactionsLayout = reactionsLayout;
            scrimPopupContainerLayout.setClipChildren(false);
            reactionsLayout.setMessage(message, chatInfo);
            reactionsLayout.setTransitionProgress(0);
            if (popupLayout.getSwipeBack() != null) {
                popupLayout.getSwipeBack().setOnSwipeBackProgressListener((layout, toProgress, progress) -> {
                    if (toProgress == 0) {
                        reactionsLayout.startEnterAnimation();
                    } else if (toProgress == 1)
                        reactionsLayout.setAlpha(1f - progress);
                });
            }
        }
        boolean showNoForwards = noforwards && message.messageOwner.action == null && message.isSent() && !message.isEditing() && chatMode != MODE_SCHEDULED;
        scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinearRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, isReactionsAvailable ? 16 : 0, 0, isReactionsAvailable ? 36 : 0, 0));
        scrimPopupContainerLayout.popupWindowLayout = popupLayout;
        if (showNoForwards) {
            popupLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            boolean isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
            TextView tv = new TextView(contentView.getContext());
            tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            tv.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
            if (getMessagesController().isChatNoForwards(currentChat)) {
                tv.setText(isChannel ? LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel) : LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup));
            } else {
                tv.setText(LocaleController.getString("ForwardsRestrictedInfoBot", R.string.ForwardsRestrictedInfoBot));
            }
            tv.setMaxWidth(popupLayout.getMeasuredWidth() - AndroidUtilities.dp(38));
            Drawable shadowDrawable2 = ContextCompat.getDrawable(contentView.getContext(), R.drawable.popup_fixed_alert).mutate();
            shadowDrawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), PorterDuff.Mode.MULTIPLY));
            FrameLayout fl = new FrameLayout(contentView.getContext());
            fl.setBackground(shadowDrawable2);
            fl.addView(tv, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 11, 11, 11, 11));
            scrimPopupContainerLayout.addView(fl, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, isReactionsAvailable ? 16 : 0, -8, isReactionsAvailable ? 36 : 0, 0));
        }
        scrimPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {

            @Override
            public void dismiss() {
                super.dismiss();
                if (scrimPopupWindow != this) {
                    return;
                }
                scrimPopupWindow = null;
                menuDeleteItem = null;
                scrimPopupWindowItems = null;
                chatLayoutManager.setCanScrollVertically(true);
                if (scrimPopupWindowHideDimOnDismiss) {
                    dimBehindView(false);
                } else {
                    scrimPopupWindowHideDimOnDismiss = true;
                }
                if (chatActivityEnterView != null) {
                    chatActivityEnterView.getEditField().setAllowDrawCursor(true);
                }
            }
        };
        scrimPopupWindow.setPauseNotifications(true);
        scrimPopupWindow.setDismissAnimationDuration(220);
        scrimPopupWindow.setOutsideTouchable(true);
        scrimPopupWindow.setClippingEnabled(true);
        scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
        scrimPopupWindow.setFocusable(true);
        scrimPopupContainerLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
        scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
        scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
        scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
        popupLayout.setFitItems(true);
        int popupX = v.getLeft() + (int) x - scrimPopupContainerLayout.getMeasuredWidth() + backgroundPaddings.left - AndroidUtilities.dp(28);
        if (popupX < AndroidUtilities.dp(6)) {
            popupX = AndroidUtilities.dp(6);
        } else if (popupX > chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth()) {
            popupX = chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth();
        }
        if (AndroidUtilities.isTablet()) {
            int[] location = new int[2];
            fragmentView.getLocationInWindow(location);
            popupX += location[0];
        }
        int totalHeight = contentView.getHeight();
        int height = scrimPopupContainerLayout.getMeasuredHeight() + AndroidUtilities.dp(48);
        int keyboardHeight = contentView.measureKeyboardHeight();
        if (keyboardHeight > AndroidUtilities.dp(20)) {
            totalHeight += keyboardHeight;
        }
        int popupY;
        if (height < totalHeight) {
            popupY = (int) (chatListView.getY() + v.getTop() + y);
            if (height - backgroundPaddings.top - backgroundPaddings.bottom > AndroidUtilities.dp(240)) {
                popupY += AndroidUtilities.dp(240) - height;
            }
            if (popupY < chatListView.getY() + AndroidUtilities.dp(24)) {
                popupY = (int) (chatListView.getY() + AndroidUtilities.dp(24));
            } else if (popupY > totalHeight - height - AndroidUtilities.dp(8)) {
                popupY = totalHeight - height - AndroidUtilities.dp(8);
            }
        } else {
            popupY = inBubbleMode ? 0 : AndroidUtilities.statusBarHeight;
        }
        final int finalPopupX = scrimPopupX = popupX;
        final int finalPopupY = scrimPopupY = popupY;
        Runnable showMenu = () -> {
            if (scrimPopupWindow == null || fragmentView == null) {
                return;
            }
            scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
            if (isReactionsAvailable) {
                reactionsLayout.startEnterAnimation();
            }
        };
        if (waitForLangDetection.get()) {
            onLangDetectionDone.set(showMenu);
        } else {
            showMenu.run();
        }
        chatListView.stopScroll();
        chatLayoutManager.setCanScrollVertically(false);
        dimBehindView(v, true);
        hideHints(false);
        if (topUndoView != null) {
            topUndoView.hide(true, 1);
        }
        if (undoView != null) {
            undoView.hide(true, 1);
        }
        if (chatActivityEnterView != null) {
            chatActivityEnterView.getEditField().setAllowDrawCursor(false);
        }
        return;
    }
    if (chatActivityEnterView != null && (chatActivityEnterView.isRecordingAudioVideo() || chatActivityEnterView.isRecordLocked())) {
        return;
    }
    final ActionBarMenu actionMode = actionBar.createActionMode();
    View item = actionMode.getItem(delete);
    if (item != null) {
        item.setVisibility(View.VISIBLE);
    }
    bottomMessagesActionContainer.setVisibility(View.VISIBLE);
    int translationY = chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51);
    if (chatActivityEnterView.getVisibility() == View.VISIBLE) {
        ArrayList<View> views = new ArrayList<>();
        views.add(chatActivityEnterView);
        if (mentionContainer != null && mentionContainer.getVisibility() == View.VISIBLE) {
            views.add(mentionContainer);
        }
        if (stickersPanel != null && stickersPanel.getVisibility() == View.VISIBLE) {
            views.add(stickersPanel);
        }
        actionBar.showActionMode(true, bottomMessagesActionContainer, null, views.toArray(new View[0]), new boolean[] { false, true, true }, chatListView, translationY);
        if (getParentActivity() instanceof LaunchActivity) {
            ((LaunchActivity) getParentActivity()).hideVisibleActionMode();
        }
        chatActivityEnterView.getEditField().setAllowDrawCursor(false);
    } else if (bottomOverlayChat.getVisibility() == View.VISIBLE) {
        actionBar.showActionMode(true, bottomMessagesActionContainer, null, new View[] { bottomOverlayChat }, new boolean[] { true }, chatListView, translationY);
    } else {
        actionBar.showActionMode(true, bottomMessagesActionContainer, null, null, null, chatListView, translationY);
    }
    closeMenu();
    chatLayoutManager.setCanScrollVertically(true);
    updatePinnedMessageView(true);
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> animators = new ArrayList<>();
    for (int a = 0; a < actionModeViews.size(); a++) {
        View view = actionModeViews.get(a);
        view.setPivotY(ActionBar.getCurrentActionBarHeight() / 2);
        AndroidUtilities.clearDrawableAnimation(view);
        animators.add(ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.1f, 1.0f));
    }
    animatorSet.playTogether(animators);
    animatorSet.setDuration(250);
    animatorSet.start();
    addToSelectedMessages(message, listView);
    if (chatActivityEnterView != null) {
        chatActivityEnterView.preventInput = true;
    }
    selectedMessagesCountTextView.setNumber(selectedMessagesIds[0].size() + selectedMessagesIds[1].size(), false);
    updateVisibleRows();
    if (chatActivityEnterView != null) {
        chatActivityEnterView.hideBotCommands();
    }
}
Also used : ViewHelper(org.telegram.ui.Components.ViewHelper) Bundle(android.os.Bundle) BotHelpCell(org.telegram.ui.Cells.BotHelpCell) AdjustPanLayoutHelper(org.telegram.ui.ActionBar.AdjustPanLayoutHelper) StickersAlert(org.telegram.ui.Components.StickersAlert) RecyclerAnimationScrollHelper(org.telegram.ui.Components.RecyclerAnimationScrollHelper) URLSpanUserMention(org.telegram.ui.Components.URLSpanUserMention) Property(android.util.Property) HorizontalScrollView(android.widget.HorizontalScrollView) ChatThemeController(org.telegram.messenger.ChatThemeController) MediaStore(android.provider.MediaStore) Map(java.util.Map) Shader(android.graphics.Shader) ContextCompat(androidx.core.content.ContextCompat) NotificationCenter(org.telegram.messenger.NotificationCenter) PinnedLineView(org.telegram.ui.Components.PinnedLineView) CountDownLatch(java.util.concurrent.CountDownLatch) Layout(android.text.Layout) EmojiData(org.telegram.messenger.EmojiData) ForwardingMessagesParams(org.telegram.messenger.ForwardingMessagesParams) BotCommandsMenuView(org.telegram.ui.Components.BotCommandsMenuView) Paint(android.graphics.Paint) Path(android.graphics.Path) ReactedHeaderView(org.telegram.ui.Components.ReactedHeaderView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) SystemClock(android.os.SystemClock) ChatBlurredFrameLayout(org.telegram.ui.Components.ChatBlurredFrameLayout) SpannableStringBuilder(android.text.SpannableStringBuilder) Calendar(java.util.Calendar) Toast(android.widget.Toast) PhoneFormat(org.telegram.PhoneFormat.PhoneFormat) Menu(android.view.Menu) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) JoinGroupAlert(org.telegram.ui.Components.JoinGroupAlert) AspectRatioFrameLayout(com.google.android.exoplayer2.ui.AspectRatioFrameLayout) LongSparseIntArray(org.telegram.messenger.support.LongSparseIntArray) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) URLSpan(android.text.style.URLSpan) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) ChatActivityMemberRequestsDelegate(org.telegram.ui.Delegates.ChatActivityMemberRequestsDelegate) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) ContactsController(org.telegram.messenger.ContactsController) MessagesStorage(org.telegram.messenger.MessagesStorage) EditText(android.widget.EditText) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) URLDecoder(java.net.URLDecoder) PackageManager(android.content.pm.PackageManager) WindowManager(android.view.WindowManager) Animator(android.animation.Animator) TypefaceSpan(org.telegram.ui.Components.TypefaceSpan) ChatAttachAlertDocumentLayout(org.telegram.ui.Components.ChatAttachAlertDocumentLayout) DatePickerDialog(android.app.DatePickerDialog) ChatMessageCell(org.telegram.ui.Cells.ChatMessageCell) RecyclerView(androidx.recyclerview.widget.RecyclerView) StickersAdapter(org.telegram.ui.Adapters.StickersAdapter) RectF(android.graphics.RectF) ReportAlert(org.telegram.ui.Components.ReportAlert) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) ChatActionCell(org.telegram.ui.Cells.ChatActionCell) ChatThemeBottomSheet(org.telegram.ui.Components.ChatThemeBottomSheet) PorterDuff(android.graphics.PorterDuff) SendMessagesHelper(org.telegram.messenger.SendMessagesHelper) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ShareAlert(org.telegram.ui.Components.ShareAlert) BluredView(org.telegram.ui.Components.BluredView) UserConfig(org.telegram.messenger.UserConfig) TextStyleSpan(org.telegram.ui.Components.TextStyleSpan) EmojiThemes(org.telegram.ui.ActionBar.EmojiThemes) InstantCameraView(org.telegram.ui.Components.InstantCameraView) PhonebookShareAlert(org.telegram.ui.Components.PhonebookShareAlert) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ImportingAlert(org.telegram.ui.Components.ImportingAlert) Spanned(android.text.Spanned) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SparseIntArray(android.util.SparseIntArray) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LocaleController(org.telegram.messenger.LocaleController) ChatActivityEnterTopView(org.telegram.ui.Components.ChatActivityEnterTopView) ExtendedGridLayoutManager(org.telegram.ui.Components.ExtendedGridLayoutManager) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) ActionBar(org.telegram.ui.ActionBar.ActionBar) LinearSmoothScrollerCustom(androidx.recyclerview.widget.LinearSmoothScrollerCustom) TLObject(org.telegram.tgnet.TLObject) Size(org.telegram.ui.Components.Size) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) Build(android.os.Build) ChatAvatarContainer(org.telegram.ui.Components.ChatAvatarContainer) PollVotesAlert(org.telegram.ui.Components.PollVotesAlert) EmbedBottomSheet(org.telegram.ui.Components.EmbedBottomSheet) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) LayoutHelper(org.telegram.ui.Components.LayoutHelper) TextureView(android.view.TextureView) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) CharacterStyle(android.text.style.CharacterStyle) ViewTreeObserver(android.view.ViewTreeObserver) Vibrator(android.os.Vibrator) Comparator(java.util.Comparator) Activity(android.app.Activity) ImageReceiver(org.telegram.messenger.ImageReceiver) RecyclerListView(org.telegram.ui.Components.RecyclerListView) Arrays(java.util.Arrays) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) Bulletin(org.telegram.ui.Components.Bulletin) RadialProgressView(org.telegram.ui.Components.RadialProgressView) Manifest(android.Manifest) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) Matcher(java.util.regex.Matcher) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) Canvas(android.graphics.Canvas) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Emoji(org.telegram.messenger.Emoji) MessagesSearchAdapter(org.telegram.ui.Adapters.MessagesSearchAdapter) ColorMatrix(android.graphics.ColorMatrix) ForegroundColorSpan(android.text.style.ForegroundColorSpan) TargetApi(android.annotation.TargetApi) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) BackButtonMenu(org.telegram.ui.Components.BackButtonMenu) ChatListItemAnimator(androidx.recyclerview.widget.ChatListItemAnimator) MentionsAdapter(org.telegram.ui.Adapters.MentionsAdapter) UndoView(org.telegram.ui.Components.UndoView) AnimationProperties(org.telegram.ui.Components.AnimationProperties) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) CounterView(org.telegram.ui.Components.CounterView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) TrendingStickersAlert(org.telegram.ui.Components.TrendingStickersAlert) Outline(android.graphics.Outline) HapticFeedbackConstants(android.view.HapticFeedbackConstants) TextPaint(android.text.TextPaint) BotSwitchCell(org.telegram.ui.Cells.BotSwitchCell) HintView(org.telegram.ui.Components.HintView) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) URLSpanBotCommand(org.telegram.ui.Components.URLSpanBotCommand) ReactionsLayoutInBubble(org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble) ExifInterface(androidx.exifinterface.media.ExifInterface) FileLoader(org.telegram.messenger.FileLoader) ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) ClearHistoryAlert(org.telegram.ui.Components.ClearHistoryAlert) Space(android.widget.Space) ViewPager(androidx.viewpager.widget.ViewPager) Dialog(android.app.Dialog) BitmapFactory(android.graphics.BitmapFactory) GigagroupConvertAlert(org.telegram.ui.Components.GigagroupConvertAlert) URLSpanMono(org.telegram.ui.Components.URLSpanMono) URLSpanNoUnderline(org.telegram.ui.Components.URLSpanNoUnderline) AlertsCreator(org.telegram.ui.Components.AlertsCreator) BlurBehindDrawable(org.telegram.ui.Components.BlurBehindDrawable) ArrayList(java.util.ArrayList) SharedMediaLayout(org.telegram.ui.Components.SharedMediaLayout) FragmentContextView(org.telegram.ui.Components.FragmentContextView) TLRPC(org.telegram.tgnet.TLRPC) EditTextCaption(org.telegram.ui.Components.EditTextCaption) BuildConfig(org.telegram.messenger.BuildConfig) DialogCell(org.telegram.ui.Cells.DialogCell) SpannableString(android.text.SpannableString) BufferedWriter(java.io.BufferedWriter) FileOutputStream(java.io.FileOutputStream) TextUtils(android.text.TextUtils) ChatUnreadCell(org.telegram.ui.Cells.ChatUnreadCell) ChatLoadingCell(org.telegram.ui.Cells.ChatLoadingCell) ClippingImageView(org.telegram.ui.Components.ClippingImageView) File(java.io.File) ReactionsEffectOverlay(org.telegram.ui.Components.Reactions.ReactionsEffectOverlay) Gravity(android.view.Gravity) PorterDuffXfermode(android.graphics.PorterDuffXfermode) TypedValue(android.util.TypedValue) Configuration(android.content.res.Configuration) StickerCell(org.telegram.ui.Cells.StickerCell) ReactionsContainerLayout(org.telegram.ui.Components.ReactionsContainerLayout) ColorUtils(androidx.core.graphics.ColorUtils) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) EmojiView(org.telegram.ui.Components.EmojiView) ValueAnimator(android.animation.ValueAnimator) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) ChatScrimPopupContainerLayout(org.telegram.ui.Components.ChatScrimPopupContainerLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) Spannable(android.text.Spannable) AccountInstance(org.telegram.messenger.AccountInstance) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) ChecksHintView(org.telegram.ui.Components.ChecksHintView) MediaController(org.telegram.messenger.MediaController) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) Matrix(android.graphics.Matrix) SearchCounterView(org.telegram.ui.Components.SearchCounterView) ForwardingPreviewView(org.telegram.ui.Components.ForwardingPreviewView) BitmapShader(android.graphics.BitmapShader) Utilities(org.telegram.messenger.Utilities) HideViewAfterAnimation(org.telegram.ui.Components.HideViewAfterAnimation) ObjectAnimator(android.animation.ObjectAnimator) GridLayoutManagerFixed(androidx.recyclerview.widget.GridLayoutManagerFixed) ImageLocation(org.telegram.messenger.ImageLocation) MentionCell(org.telegram.ui.Cells.MentionCell) ReactionTabHolderView(org.telegram.ui.Components.ReactionTabHolderView) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) ViewGroup(android.view.ViewGroup) SparseArray(android.util.SparseArray) List(java.util.List) TextView(android.widget.TextView) MotionBackgroundDrawable(org.telegram.ui.Components.MotionBackgroundDrawable) SecretChatHelper(org.telegram.messenger.SecretChatHelper) FileProvider(androidx.core.content.FileProvider) Pattern(java.util.regex.Pattern) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Typeface(android.graphics.Typeface) Context(android.content.Context) StaticLayout(android.text.StaticLayout) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TextSelectionHelper(org.telegram.ui.Cells.TextSelectionHelper) ReactedUsersListView(org.telegram.ui.Components.ReactedUsersListView) KeyEvent(android.view.KeyEvent) VoIPService(org.telegram.messenger.voip.VoIPService) Theme(org.telegram.ui.ActionBar.Theme) PagerAdapter(androidx.viewpager.widget.PagerAdapter) ViewOutlineProvider(android.view.ViewOutlineProvider) BulletinFactory(org.telegram.ui.Components.BulletinFactory) Intent(android.content.Intent) HashMap(java.util.HashMap) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) TranslateAlert(org.telegram.ui.Components.TranslateAlert) AtomicReference(java.util.concurrent.atomic.AtomicReference) ClipData(android.content.ClipData) SuppressLint(android.annotation.SuppressLint) VideoEditedInfo(org.telegram.messenger.VideoEditedInfo) MotionEvent(android.view.MotionEvent) AnimatorSet(android.animation.AnimatorSet) MediaDataController(org.telegram.messenger.MediaDataController) DialogInterface(android.content.DialogInterface) Browser(org.telegram.messenger.browser.Browser) FireworksOverlay(org.telegram.ui.Components.FireworksOverlay) LongSparseArray(androidx.collection.LongSparseArray) FileWriter(java.io.FileWriter) FileLog(org.telegram.messenger.FileLog) URLSpanReplacement(org.telegram.ui.Components.URLSpanReplacement) MessagesController(org.telegram.messenger.MessagesController) NumberTextView(org.telegram.ui.Components.NumberTextView) ChatAttachAlert(org.telegram.ui.Components.ChatAttachAlert) InviteMembersBottomSheet(org.telegram.ui.Components.InviteMembersBottomSheet) Collections(java.util.Collections) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Rect(android.graphics.Rect) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) BlurBehindDrawable(org.telegram.ui.Components.BlurBehindDrawable) MotionBackgroundDrawable(org.telegram.ui.Components.MotionBackgroundDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ViewPager(androidx.viewpager.widget.ViewPager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ChatActionCell(org.telegram.ui.Cells.ChatActionCell) LongSparseIntArray(org.telegram.messenger.support.LongSparseIntArray) SparseIntArray(android.util.SparseIntArray) UserObject(org.telegram.messenger.UserObject) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) ChatObject(org.telegram.messenger.ChatObject) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ChatScrimPopupContainerLayout(org.telegram.ui.Components.ChatScrimPopupContainerLayout) Intent(android.content.Intent) AtomicReference(java.util.concurrent.atomic.AtomicReference) ReactionsContainerLayout(org.telegram.ui.Components.ReactionsContainerLayout) ChatMessageCell(org.telegram.ui.Cells.ChatMessageCell) Animator(android.animation.Animator) ChatListItemAnimator(androidx.recyclerview.widget.ChatListItemAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) Bulletin(org.telegram.ui.Components.Bulletin) SpannableStringBuilder(android.text.SpannableStringBuilder) ValueAnimator(android.animation.ValueAnimator) TLRPC(org.telegram.tgnet.TLRPC) PagerAdapter(androidx.viewpager.widget.PagerAdapter) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) TextView(android.widget.TextView) NumberTextView(org.telegram.ui.Components.NumberTextView) TranslateAlert(org.telegram.ui.Components.TranslateAlert) HorizontalScrollView(android.widget.HorizontalScrollView) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) ReactedUsersListView(org.telegram.ui.Components.ReactedUsersListView) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) ChatThemeBottomSheet(org.telegram.ui.Components.ChatThemeBottomSheet) EmbedBottomSheet(org.telegram.ui.Components.EmbedBottomSheet) InviteMembersBottomSheet(org.telegram.ui.Components.InviteMembersBottomSheet) SpannableStringBuilder(android.text.SpannableStringBuilder) ChatObject(org.telegram.messenger.ChatObject) AnimatorSet(android.animation.AnimatorSet) KeyEvent(android.view.KeyEvent) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) VoIPService(org.telegram.messenger.voip.VoIPService) ViewGroup(android.view.ViewGroup) Bundle(android.os.Bundle) ReactedHeaderView(org.telegram.ui.Components.ReactedHeaderView) HorizontalScrollView(android.widget.HorizontalScrollView) PinnedLineView(org.telegram.ui.Components.PinnedLineView) BotCommandsMenuView(org.telegram.ui.Components.BotCommandsMenuView) ReactedHeaderView(org.telegram.ui.Components.ReactedHeaderView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) BluredView(org.telegram.ui.Components.BluredView) InstantCameraView(org.telegram.ui.Components.InstantCameraView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ChatActivityEnterTopView(org.telegram.ui.Components.ChatActivityEnterTopView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) BackupImageView(org.telegram.ui.Components.BackupImageView) TextureView(android.view.TextureView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) UndoView(org.telegram.ui.Components.UndoView) CounterView(org.telegram.ui.Components.CounterView) HintView(org.telegram.ui.Components.HintView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) ClippingImageView(org.telegram.ui.Components.ClippingImageView) EmojiView(org.telegram.ui.Components.EmojiView) ChecksHintView(org.telegram.ui.Components.ChecksHintView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) SearchCounterView(org.telegram.ui.Components.SearchCounterView) ForwardingPreviewView(org.telegram.ui.Components.ForwardingPreviewView) ReactionTabHolderView(org.telegram.ui.Components.ReactionTabHolderView) TextView(android.widget.TextView) ReactedUsersListView(org.telegram.ui.Components.ReactedUsersListView) NumberTextView(org.telegram.ui.Components.NumberTextView) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) ReactionTabHolderView(org.telegram.ui.Components.ReactionTabHolderView) MotionEvent(android.view.MotionEvent) SparseArray(android.util.SparseArray) LongSparseArray(androidx.collection.LongSparseArray) ChatBlurredFrameLayout(org.telegram.ui.Components.ChatBlurredFrameLayout) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) AspectRatioFrameLayout(com.google.android.exoplayer2.ui.AspectRatioFrameLayout) FrameLayout(android.widget.FrameLayout) MessageObject(org.telegram.messenger.MessageObject) LinearLayout(android.widget.LinearLayout)

Example 4 with FragmentContextView

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

the class ChatActivity method getThemeDescriptions.

@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
    if (isPauseOnThemePreview) {
        isPauseOnThemePreview = false;
        return null;
    }
    ThemeDescription.ThemeDescriptionDelegate selectedBackgroundDelegate = () -> {
        if (chatActivityEnterView != null) {
            chatActivityEnterView.updateColors();
        }
        Theme.refreshAttachButtonsColors();
        if (chatAttachAlert != null) {
            chatAttachAlert.checkColors();
        }
        if (chatListView != null) {
            int count = chatListView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = chatListView.getChildAt(a);
                if (child instanceof ChatMessageCell) {
                    ((ChatMessageCell) child).createSelectorDrawable(0);
                } else if (child instanceof ChatActionCell) {
                    ((ChatActionCell) child).setInvalidateColors(true);
                }
            }
        }
        if (messagesSearchListView != null) {
            int count = messagesSearchListView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = messagesSearchListView.getChildAt(a);
                if (child instanceof DialogCell) {
                    ((DialogCell) child).update(0);
                }
            }
        }
        if (scrimPopupWindowItems != null) {
            for (int a = 0; a < scrimPopupWindowItems.length; a++) {
                scrimPopupWindowItems[a].setColors(getThemedColor(Theme.key_actionBarDefaultSubmenuItem), getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon));
                scrimPopupWindowItems[a].setSelectorColor(getThemedColor(Theme.key_dialogButtonSelector));
            }
        }
        if (scrimPopupWindow != null) {
            final View contentView = scrimPopupWindow.getContentView();
            contentView.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
            contentView.invalidate();
        }
        if (instantCameraView != null) {
            instantCameraView.invalidateBlur();
        }
        if (pinnedLineView != null) {
            pinnedLineView.updateColors();
        }
        if (chatActivityEnterTopView != null && chatActivityEnterTopView.getEditView() != null) {
            chatActivityEnterTopView.getEditView().updateColors();
        }
        if (headerItem != null) {
            headerItem.updateColor();
        }
        setNavigationBarColor(getThemedColor(Theme.key_windowBackgroundGray));
        if (fragmentContextView != null) {
            fragmentContextView.updateColors();
        }
        if (avatarContainer != null) {
            avatarContainer.updateColors();
        }
        if (pinnedMessageView != null) {
            pinnedMessageView.backgroundColor = getThemedColor(Theme.key_chat_topPanelBackground);
        }
        if (topChatPanelView != null) {
            topChatPanelView.backgroundColor = getThemedColor(Theme.key_chat_topPanelBackground);
        }
    };
    ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
    themeDescriptions.add(new ThemeDescription(fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper));
    themeDescriptions.add(new ThemeDescription(fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper_gradient_to1));
    themeDescriptions.add(new ThemeDescription(fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper_gradient_to2));
    themeDescriptions.add(new ThemeDescription(fragmentView, 0, null, null, null, null, Theme.key_chat_wallpaper_gradient_to3));
    themeDescriptions.add(new ThemeDescription(messagesSearchListView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
    if (reportType < 0) {
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultSubtitle));
    } else {
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefault));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
        themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
    }
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, selectedBackgroundDelegate, Theme.key_actionBarDefaultSubmenuBackground));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, selectedBackgroundDelegate, Theme.key_actionBarDefaultSubmenuItem));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM | ThemeDescription.FLAG_IMAGECOLOR, null, null, null, selectedBackgroundDelegate, Theme.key_actionBarDefaultSubmenuItemIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTitleTextView() : null, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_actionBarDefaultSubtitle));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getSubtitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, new Paint[] { Theme.chat_statusPaint, Theme.chat_statusRecordPaint }, null, null, Theme.key_chat_status, null));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getSubtitleTextView() : null, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_actionBarDefaultSubtitle, null));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_BACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefault));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_TOPBACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefaultTop));
    themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(selectedMessagesCountTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTitleTextView() : null, 0, null, null, new Drawable[] { Theme.chat_muteIconDrawable }, null, Theme.key_chat_muteIcon));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTitleTextView() : null, 0, null, null, new Drawable[] { Theme.chat_lockIconDrawable }, null, Theme.key_chat_lockIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundRed));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundOrange));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundViolet));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundGreen));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundCyan));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundBlue));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_backgroundPink));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessageRed));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessageOrange));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessageViolet));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessageGreen));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessageCyan));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessageBlue));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_avatar_nameInMessagePink));
    Theme.MessageDrawable msgInDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgIn);
    Theme.MessageDrawable msgInMediaDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgInMedia);
    Theme.MessageDrawable msgInSelectedDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgInSelected);
    Theme.MessageDrawable msgInMediaSelectedDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgInMediaSelected);
    Theme.MessageDrawable msgOutDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgOut);
    Theme.MessageDrawable msgOutMediaDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgOutMedia);
    Theme.MessageDrawable msgOutSelectedDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgOutSelected);
    Theme.MessageDrawable msgOutMediaSelectedDrawable = (Theme.MessageDrawable) getThemedDrawable(Theme.key_drawable_msgOutMediaSelected);
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class, BotHelpCell.class }, null, new Drawable[] { msgInDrawable, msgInMediaDrawable }, null, Theme.key_chat_inBubble));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgInSelectedDrawable, msgInMediaSelectedDrawable }, null, Theme.key_chat_inBubbleSelected));
    if (msgInDrawable != null) {
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, msgInDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow));
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, msgInMediaDrawable.getShadowDrawables(), null, Theme.key_chat_inBubbleShadow));
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, msgOutDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow));
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, msgOutMediaDrawable.getShadowDrawables(), null, Theme.key_chat_outBubbleShadow));
    }
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgOutDrawable, msgOutMediaDrawable }, null, Theme.key_chat_outBubble));
    if (!themeDelegate.isThemeChangeAvailable()) {
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgOutDrawable, msgOutMediaDrawable }, null, Theme.key_chat_outBubbleGradient1));
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgOutDrawable, msgOutMediaDrawable }, null, Theme.key_chat_outBubbleGradient2));
        themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgOutDrawable, msgOutMediaDrawable }, null, Theme.key_chat_outBubbleGradient3));
    }
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgOutSelectedDrawable, msgOutMediaSelectedDrawable }, null, Theme.key_chat_outBubbleSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { msgOutSelectedDrawable, msgOutMediaSelectedDrawable }, null, Theme.key_chat_outBubbleGradientSelectedOverlay));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { ChatActionCell.class }, getThemedPaint(Theme.key_paint_chatActionText), null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[] { ChatActionCell.class }, getThemedPaint(Theme.key_paint_chatActionText), null, null, Theme.key_chat_serviceLink));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_botCardDrawalbe, getThemedDrawable(Theme.key_drawable_shareIcon), getThemedDrawable(Theme.key_drawable_replyIcon), getThemedDrawable(Theme.key_drawable_botInline), getThemedDrawable(Theme.key_drawable_botLink), getThemedDrawable(Theme.key_drawable_goIcon), getThemedDrawable(Theme.key_drawable_commentSticker) }, null, Theme.key_chat_serviceIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class, ChatActionCell.class }, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class, ChatActionCell.class }, null, null, null, Theme.key_chat_serviceBackgroundSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class, BotHelpCell.class }, null, null, null, Theme.key_chat_messageTextIn));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_messageTextOut));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[] { ChatMessageCell.class, BotHelpCell.class }, null, null, null, Theme.key_chat_messageLinkIn, null));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_messageLinkOut, null));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgNoSoundDrawable }, null, Theme.key_chat_mediaTimeText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutCheck) }, null, Theme.key_chat_outSentCheck));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutCheckSelected) }, null, Theme.key_chat_outSentCheckSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutCheckRead), getThemedDrawable(Theme.key_drawable_msgOutHalfCheck) }, null, Theme.key_chat_outSentCheckRead));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutCheckReadSelected), getThemedDrawable(Theme.key_drawable_msgOutHalfCheckSelected) }, null, Theme.key_chat_outSentCheckReadSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outSentClock));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outSentClockSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inSentClock));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inSentClockSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgMediaCheckDrawable, Theme.chat_msgMediaHalfCheckDrawable }, null, Theme.key_chat_mediaSentCheck));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgStickerHalfCheck), getThemedDrawable(Theme.key_drawable_msgStickerCheck), getThemedDrawable(Theme.key_drawable_msgStickerClock), getThemedDrawable(Theme.key_drawable_msgStickerViews), getThemedDrawable(Theme.key_drawable_msgStickerReplies), getThemedDrawable(Theme.key_drawable_msgStickerPinned) }, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_mediaSentClock));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutViews), getThemedDrawable(Theme.key_drawable_msgOutReplies), getThemedDrawable(Theme.key_drawable_msgOutPinned) }, null, Theme.key_chat_outViews));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutViewsSelected), getThemedDrawable(Theme.key_drawable_msgOutRepliesSelected), getThemedDrawable(Theme.key_drawable_msgOutPinnedSelected) }, null, Theme.key_chat_outViewsSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgInViewsDrawable, Theme.chat_msgInRepliesDrawable, Theme.chat_msgInPinnedDrawable }, null, Theme.key_chat_inViews));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgInViewsSelectedDrawable, Theme.chat_msgInRepliesSelectedDrawable, Theme.chat_msgInPinnedSelectedDrawable }, null, Theme.key_chat_inViewsSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgMediaViewsDrawable, Theme.chat_msgMediaRepliesDrawable, Theme.chat_msgMediaPinnedDrawable }, null, Theme.key_chat_mediaViews));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutMenu) }, null, Theme.key_chat_outMenu));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutMenuSelected) }, null, Theme.key_chat_outMenuSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgInMenuDrawable }, null, Theme.key_chat_inMenu));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgInMenuSelectedDrawable }, null, Theme.key_chat_inMenuSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgMediaMenuDrawable }, null, Theme.key_chat_mediaMenu));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutInstant) }, null, Theme.key_chat_outInstant));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgInInstantDrawable, Theme.chat_commentDrawable, Theme.chat_commentArrowDrawable }, null, Theme.key_chat_inInstant));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutCallAudio), getThemedDrawable(Theme.key_drawable_msgOutCallVideo) }, null, Theme.key_chat_outInstant));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { getThemedDrawable(Theme.key_drawable_msgOutCallAudioSelected), getThemedDrawable(Theme.key_drawable_msgOutCallVideoSelected) }, null, Theme.key_chat_outInstant));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, Theme.chat_msgInCallDrawable, null, Theme.key_chat_inInstant));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, Theme.chat_msgInCallSelectedDrawable, null, Theme.key_chat_inInstantSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgCallUpGreenDrawable }, null, Theme.key_chat_outGreenCall));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgCallDownRedDrawable }, null, Theme.key_chat_inRedCall));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgCallDownGreenDrawable }, null, Theme.key_chat_inGreenCall));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_msgErrorPaint, null, null, Theme.key_chat_sentError));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_msgErrorDrawable }, null, Theme.key_chat_sentErrorIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, selectedBackgroundDelegate, Theme.key_chat_selectedBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_durationPaint, null, null, Theme.key_chat_previewDurationText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_gamePaint, null, null, Theme.key_chat_previewGameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inPreviewInstantText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outPreviewInstantText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inPreviewInstantSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outPreviewInstantSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_deleteProgressPaint, null, null, Theme.key_chat_secretTimeText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_stickerNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, getThemedPaint(Theme.key_paint_chatBotButton), null, null, Theme.key_chat_botButtonText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_botProgressPaint, null, null, Theme.key_chat_botProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, getThemedPaint(Theme.key_paint_chatTimeBackground), null, null, Theme.key_chat_mediaTimeBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inForwardedNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outForwardedNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inPsaNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outPsaNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inViaBotNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outViaBotNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_stickerViaBotNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inReplyLine));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outReplyLine));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_stickerReplyLine));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inReplyNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outReplyNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_stickerReplyNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inReplyMessageText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outReplyMessageText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inReplyMediaMessageText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outReplyMediaMessageText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inReplyMediaMessageSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outReplyMediaMessageSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_stickerReplyMessageText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inPreviewLine));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outPreviewLine));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inSiteNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outSiteNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inContactNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outContactNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inContactPhoneText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inContactPhoneSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outContactPhoneText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outContactPhoneSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_mediaProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioSelectedProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioSelectedProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_mediaTimeText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inTimeText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outTimeText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inTimeSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAdminText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAdminSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAdminText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAdminSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outTimeSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioPerformerText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioPerformerSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioPerformerText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioPerformerSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioTitleText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioTitleText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioDurationText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioDurationText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioDurationSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioDurationSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioSeekbar));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioSeekbar));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioSeekbarSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioSeekbarSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioSeekbarFill));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inAudioCacheSeekbar));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioSeekbarFill));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outAudioCacheSeekbar));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inVoiceSeekbar));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outVoiceSeekbar));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inVoiceSeekbarSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outVoiceSeekbarSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inVoiceSeekbarFill));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outVoiceSeekbarFill));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileProgress));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileProgressSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileProgressSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileNameText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileInfoText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileInfoText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileInfoSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileInfoSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inFileBackgroundSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outFileBackgroundSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inVenueInfoText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outVenueInfoText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inVenueInfoSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outVenueInfoSelectedText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_mediaInfoText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_urlPaint, null, null, Theme.key_chat_linkSelectBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, Theme.chat_textSearchSelectionPaint, null, null, Theme.key_chat_textSelectBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outLoader));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outMediaIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outLoaderSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outMediaIconSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inLoader));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inMediaIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inLoaderSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inMediaIconSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[0][0], Theme.chat_photoStatesDrawables[1][0], Theme.chat_photoStatesDrawables[2][0], Theme.chat_photoStatesDrawables[3][0] }, null, Theme.key_chat_mediaLoaderPhoto));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[0][0], Theme.chat_photoStatesDrawables[1][0], Theme.chat_photoStatesDrawables[2][0], Theme.chat_photoStatesDrawables[3][0] }, null, Theme.key_chat_mediaLoaderPhotoIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[0][1], Theme.chat_photoStatesDrawables[1][1], Theme.chat_photoStatesDrawables[2][1], Theme.chat_photoStatesDrawables[3][1] }, null, Theme.key_chat_mediaLoaderPhotoSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[0][1], Theme.chat_photoStatesDrawables[1][1], Theme.chat_photoStatesDrawables[2][1], Theme.chat_photoStatesDrawables[3][1] }, null, Theme.key_chat_mediaLoaderPhotoIconSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[7][0], Theme.chat_photoStatesDrawables[8][0] }, null, Theme.key_chat_outLoaderPhoto));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[7][0], Theme.chat_photoStatesDrawables[8][0] }, null, Theme.key_chat_outLoaderPhotoIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[7][1], Theme.chat_photoStatesDrawables[8][1] }, null, Theme.key_chat_outLoaderPhotoSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[7][1], Theme.chat_photoStatesDrawables[8][1] }, null, Theme.key_chat_outLoaderPhotoIconSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[10][0], Theme.chat_photoStatesDrawables[11][0] }, null, Theme.key_chat_inLoaderPhoto));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[10][0], Theme.chat_photoStatesDrawables[11][0] }, null, Theme.key_chat_inLoaderPhotoIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[10][1], Theme.chat_photoStatesDrawables[11][1] }, null, Theme.key_chat_inLoaderPhotoSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[10][1], Theme.chat_photoStatesDrawables[11][1] }, null, Theme.key_chat_inLoaderPhotoIconSelected));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[9][0] }, null, Theme.key_chat_outFileIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[9][1] }, null, Theme.key_chat_outFileSelectedIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[12][0] }, null, Theme.key_chat_inFileIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_photoStatesDrawables[12][1] }, null, Theme.key_chat_inFileSelectedIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_contactDrawable[0] }, null, Theme.key_chat_inContactBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_contactDrawable[0] }, null, Theme.key_chat_inContactIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_contactDrawable[1] }, null, Theme.key_chat_outContactBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_contactDrawable[1] }, null, Theme.key_chat_outContactIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inLocationBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_locationDrawable[0] }, null, Theme.key_chat_inLocationIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outLocationBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_locationDrawable[1] }, null, Theme.key_chat_outLocationIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inPollCorrectAnswer));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outPollCorrectAnswer));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_inPollWrongAnswer));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, null, null, Theme.key_chat_outPollWrongAnswer));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_pollHintDrawable[0] }, null, Theme.key_chat_inPreviewInstantText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_pollHintDrawable[1] }, null, Theme.key_chat_outPreviewInstantText));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_psaHelpDrawable[0] }, null, Theme.key_chat_inViews));
    themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[] { ChatMessageCell.class }, null, new Drawable[] { Theme.chat_psaHelpDrawable[1] }, null, Theme.key_chat_outViews));
    if (!themeDelegate.isThemeChangeAvailable()) {
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, Theme.dialogs_countPaint, null, null, Theme.key_chats_unreadCounter));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Paint[] { Theme.dialogs_namePaint[0], Theme.dialogs_namePaint[1], Theme.dialogs_searchNamePaint }, null, null, Theme.key_chats_name));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Paint[] { Theme.dialogs_nameEncryptedPaint[0], Theme.dialogs_nameEncryptedPaint[1], Theme.dialogs_searchNameEncryptedPaint }, null, null, Theme.key_chats_secretName));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Drawable[] { Theme.dialogs_lockDrawable }, null, Theme.key_chats_secretIcon));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Drawable[] { Theme.dialogs_groupDrawable, Theme.dialogs_broadcastDrawable, Theme.dialogs_botDrawable }, null, Theme.key_chats_nameIcon));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Drawable[] { Theme.dialogs_scamDrawable, Theme.dialogs_fakeDrawable }, null, Theme.key_chats_draft));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, Theme.dialogs_messagePaint[1], null, null, Theme.key_chats_message_threeLines));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, Theme.dialogs_messageNamePaint, null, null, Theme.key_chats_nameMessage_threeLines));
        themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chats_nameMessage));
        themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chats_attachMessage));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, Theme.dialogs_messagePrintingPaint, null, null, Theme.key_chats_actionMessage));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, Theme.dialogs_timePaint, null, null, Theme.key_chats_date));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Drawable[] { Theme.dialogs_checkDrawable }, null, Theme.key_chats_sentCheck));
        themeDescriptions.add(new ThemeDescription(messagesSearchListView, 0, new Class[] { DialogCell.class }, null, new Drawable[] { Theme.dialogs_checkReadDrawable, Theme.dialogs_halfCheckDrawable }, null, Theme.key_chats_sentReadCheck));
    }
    themeDescriptions.add(new ThemeDescription(mentionContainer, 0, null, getThemedPaint(Theme.key_paint_chatComposeBackground), null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(mentionContainer, 0, null, null, new Drawable[] { Theme.chat_composeShadowDrawable }, null, Theme.key_chat_messagePanelShadow));
    themeDescriptions.add(new ThemeDescription(mentionContainer, 0, null, null, new Drawable[] { Theme.chat_composeShadowRoundDrawable }, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(searchContainer, 0, null, getThemedPaint(Theme.key_paint_chatComposeBackground), null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(searchContainer, 0, null, null, new Drawable[] { Theme.chat_composeShadowDrawable }, null, Theme.key_chat_messagePanelShadow));
    themeDescriptions.add(new ThemeDescription(bottomOverlay, 0, null, getThemedPaint(Theme.key_paint_chatComposeBackground), null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(bottomOverlay, 0, null, null, new Drawable[] { Theme.chat_composeShadowDrawable }, null, Theme.key_chat_messagePanelShadow));
    themeDescriptions.add(new ThemeDescription(bottomOverlayChat, 0, null, getThemedPaint(Theme.key_paint_chatComposeBackground), null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(bottomOverlayChat, 0, null, null, new Drawable[] { Theme.chat_composeShadowDrawable }, null, Theme.key_chat_messagePanelShadow));
    themeDescriptions.add(new ThemeDescription(bottomMessagesActionContainer, 0, null, getThemedPaint(Theme.key_paint_chatComposeBackground), null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(bottomMessagesActionContainer, 0, null, null, new Drawable[] { Theme.chat_composeShadowDrawable }, null, Theme.key_chat_messagePanelShadow));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, null, getThemedPaint(Theme.key_paint_chatComposeBackground), null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, null, null, new Drawable[] { Theme.chat_composeShadowDrawable }, null, Theme.key_chat_messagePanelShadow));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "messageEditText" }, null, null, null, Theme.key_chat_messagePanelText));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_CURSORCOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "messageEditText" }, null, null, null, Theme.key_chat_messagePanelCursor));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "messageEditText" }, null, null, null, Theme.key_chat_messagePanelHint));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "sendButton" }, null, null, null, Theme.key_chat_messagePanelSend));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "sendButton" }, null, null, 24, null, Theme.key_chat_messagePanelSend));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "botButton" }, null, null, null, Theme.key_chat_messagePanelIcons));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "botButton" }, null, null, null, Theme.key_listSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "notifyButton" }, null, null, null, Theme.key_chat_messagePanelIcons));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR | ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatActivityEnterView.class }, new String[] { "scheduledButton" }, null, null, null, Theme.key_chat_messagePanelIcons));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "scheduledButton" }, null, null, null, Theme.key_chat_recordedVoiceDot));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "scheduledButton" }, null, null, null, Theme.key_listSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "attachButton" }, null, null, null, Theme.key_chat_messagePanelIcons));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "attachButton" }, null, null, null, Theme.key_listSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "audioSendButton" }, null, null, null, Theme.key_chat_messagePanelIcons));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "videoSendButton" }, null, null, null, Theme.key_chat_messagePanelIcons));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "notifyButton" }, null, null, null, Theme.key_chat_messagePanelVideoFrame));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "notifyButton" }, null, null, null, Theme.key_listSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "videoTimelineView" }, null, null, null, Theme.key_chat_messagePanelSend));
    // themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"doneButtonImage"}, null, null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "micDrawable" }, null, null, null, Theme.key_chat_messagePanelVoicePressed));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "cameraDrawable" }, null, null, null, Theme.key_chat_messagePanelVoicePressed));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "sendDrawable" }, null, null, null, Theme.key_chat_messagePanelVoicePressed));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, null, null, null, null, Theme.key_chat_messagePanelVoiceLock));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, null, null, null, Theme.key_chat_messagePanelVoiceLockBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "lockShadowDrawable" }, null, null, null, Theme.key_chat_messagePanelVoiceLockShadow));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "recordDeleteImageView" }, null, null, null, Theme.key_listSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ChatActivityEnterView.class }, new String[] { "recordedAudioBackground" }, null, null, null, Theme.key_chat_recordedVoiceBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, null, null, null, null, Theme.key_chat_recordTime));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, null, null, null, null, Theme.key_chat_recordVoiceCancel));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "recordedAudioTimeTextView" }, null, null, null, Theme.key_chat_messagePanelVoiceDuration));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, null, null, null, null, Theme.key_chat_recordVoiceCancel));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "doneButtonProgress" }, null, null, null, Theme.key_contextProgressInner1));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "doneButtonProgress" }, null, null, null, Theme.key_contextProgressOuter1));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { ChatActivityEnterView.class }, new String[] { "cancelBotButton" }, null, null, null, Theme.key_chat_messagePanelCancelInlineBot));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { ChatActivityEnterView.class }, new String[] { "cancelBotButton" }, null, null, null, Theme.key_listSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "redDotPaint" }, null, null, null, Theme.key_chat_recordedVoiceDot));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "paint" }, null, null, null, Theme.key_chat_messagePanelVoiceBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "seekBarWaveform" }, null, null, null, Theme.key_chat_recordedVoiceProgress));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "seekBarWaveform" }, null, null, null, Theme.key_chat_recordedVoiceProgressInner));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, new String[] { "dotPaint" }, null, null, null, Theme.key_chat_emojiPanelNewTrending));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[] { ChatActivityEnterView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_recordedVoicePlayPause));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelShadowLine));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelEmptyText));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelIcon));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelIconSelected));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelStickerPackSelector));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelBackspace));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelTrendingTitle));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelTrendingDescription));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelBadgeText));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelBadgeBackground));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiBottomPanelIcon));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiSearchIcon));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelStickerSetNameHighlight));
    themeDescriptions.add(new ThemeDescription(chatActivityEnterView != null ? chatActivityEnterView.getEmojiView() : null, 0, new Class[] { EmojiView.class }, null, null, null, selectedBackgroundDelegate, Theme.key_chat_emojiPanelStickerPackSelectorLine));
    if (chatActivityEnterView != null) {
        final TrendingStickersAlert trendingStickersAlert = chatActivityEnterView.getTrendingStickersAlert();
        if (trendingStickersAlert != null) {
            themeDescriptions.addAll(trendingStickersAlert.getThemeDescriptions());
        }
        themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, new Drawable[] { chatActivityEnterView.getStickersArrowDrawable() }, null, Theme.key_chat_messagePanelIcons));
    }
    for (int a = 0; a < 2; a++) {
        UndoView v = a == 0 ? undoView : topUndoView;
        themeDescriptions.add(new ThemeDescription(v, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background));
        themeDescriptions.add(new ThemeDescription(v, 0, new Class[] { UndoView.class }, new String[] { "undoImageView" }, null, null, null, Theme.key_undo_cancelColor));
        themeDescriptions.add(new ThemeDescription(v, 0, new Class[] { UndoView.class }, new String[] { "undoTextView" }, null, null, null, Theme.key_undo_cancelColor));
        themeDescriptions.add(new ThemeDescription(v, 0, new Class[] { UndoView.class }, new String[] { "infoTextView" }, null, null, null, Theme.key_undo_infoColor));
        themeDescriptions.add(new ThemeDescription(v, 0, new Class[] { UndoView.class }, new String[] { "subinfoTextView" }, null, null, null, Theme.key_undo_infoColor));
        themeDescriptions.add(new ThemeDescription(v, ThemeDescription.FLAG_LINKCOLOR, new Class[] { UndoView.class }, new String[] { "subinfoTextView" }, null, null, null, Theme.key_undo_cancelColor));
        themeDescriptions.add(new ThemeDescription(v, 0, new Class[] { UndoView.class }, new String[] { "textPaint" }, null, null, null, Theme.key_undo_infoColor));
        themeDescriptions.add(new ThemeDescription(v, 0, new Class[] { UndoView.class }, new String[] { "progressPaint" }, null, null, null, Theme.key_undo_infoColor));
        themeDescriptions.add(new ThemeDescription(v, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { UndoView.class }, new String[] { "leftImageView" }, null, null, null, Theme.key_undo_infoColor));
    }
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_botKeyboardButtonText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_botKeyboardButtonBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_botKeyboardButtonBackgroundPressed));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "frameLayout" }, null, null, null, Theme.key_inappPlayerBackground));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { FragmentContextView.class }, new String[] { "playButton" }, null, null, null, Theme.key_inappPlayerPlayPause));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "titleTextView" }, null, null, null, Theme.key_inappPlayerTitle));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "titleTextView" }, null, null, null, Theme.key_inappPlayerPerformer));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_FASTSCROLL, new Class[] { FragmentContextView.class }, new String[] { "subtitleTextView" }, null, null, null, Theme.key_inappPlayerClose));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { FragmentContextView.class }, new String[] { "closeButton" }, null, null, null, Theme.key_inappPlayerClose));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "frameLayout" }, null, null, null, Theme.key_returnToCallBackground));
    themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "titleTextView" }, null, null, null, Theme.key_returnToCallText));
    themeDescriptions.add(new ThemeDescription(pinnedLineView, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_topPanelLine));
    themeDescriptions.add(new ThemeDescription(pinnedLineView, 0, null, null, null, selectedBackgroundDelegate, Theme.key_windowBackgroundWhite));
    themeDescriptions.add(new ThemeDescription(pinnedCounterTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelTitle));
    for (int a = 0; a < 2; a++) {
        themeDescriptions.add(new ThemeDescription(pinnedNameTextView[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelTitle));
        themeDescriptions.add(new ThemeDescription(pinnedMessageTextView[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelMessage));
    }
    themeDescriptions.add(new ThemeDescription(alertNameTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelTitle));
    themeDescriptions.add(new ThemeDescription(alertTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_topPanelMessage));
    themeDescriptions.add(new ThemeDescription(closePinned, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_topPanelClose));
    themeDescriptions.add(new ThemeDescription(pinnedListButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_topPanelClose));
    themeDescriptions.add(new ThemeDescription(closeReportSpam, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_topPanelClose));
    themeDescriptions.add(new ThemeDescription(topChatPanelView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_topPanelBackground));
    themeDescriptions.add(new ThemeDescription(alertView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_topPanelBackground));
    themeDescriptions.add(new ThemeDescription(pinnedMessageView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_topPanelBackground));
    themeDescriptions.add(new ThemeDescription(addToContactsButton, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_addContact));
    themeDescriptions.add(new ThemeDescription(reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_chat_reportSpam));
    themeDescriptions.add(new ThemeDescription(reportSpamButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_chat_addContact));
    themeDescriptions.add(new ThemeDescription(replyLineView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_chat_replyPanelLine));
    themeDescriptions.add(new ThemeDescription(replyNameTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_replyPanelName));
    themeDescriptions.add(new ThemeDescription(replyObjectTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
    themeDescriptions.add(new ThemeDescription(replyObjectHintTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
    themeDescriptions.add(new ThemeDescription(replyIconImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_replyPanelIcons));
    themeDescriptions.add(new ThemeDescription(replyCloseImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_replyPanelClose));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_replyPanelName));
    themeDescriptions.add(new ThemeDescription(searchUpButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_searchPanelIcons));
    themeDescriptions.add(new ThemeDescription(searchUpButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(searchDownButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_searchPanelIcons));
    themeDescriptions.add(new ThemeDescription(searchDownButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(searchCalendarButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_searchPanelIcons));
    themeDescriptions.add(new ThemeDescription(searchCalendarButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(searchUserButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_searchPanelIcons));
    themeDescriptions.add(new ThemeDescription(searchUserButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(searchCountText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_searchPanelText));
    themeDescriptions.add(new ThemeDescription(searchAsListTogglerView, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(replyButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
    themeDescriptions.add(new ThemeDescription(replyButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(forwardButton, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
    themeDescriptions.add(new ThemeDescription(forwardButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
    themeDescriptions.add(new ThemeDescription(bottomOverlayText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_secretChatStatusText));
    themeDescriptions.add(new ThemeDescription(bottomOverlayChatText, 0, null, null, null, null, Theme.key_chat_fieldOverlayText));
    themeDescriptions.add(new ThemeDescription(bottomOverlayChatText, 0, null, null, null, null, Theme.key_chat_goDownButtonCounterBackground));
    themeDescriptions.add(new ThemeDescription(bottomOverlayChatText, 0, null, null, null, null, Theme.key_chat_messagePanelBackground));
    themeDescriptions.add(new ThemeDescription(bottomOverlayProgress, 0, null, null, null, null, Theme.key_chat_fieldOverlayText));
    themeDescriptions.add(new ThemeDescription(bottomOverlayImage, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_fieldOverlayText));
    themeDescriptions.add(new ThemeDescription(bigEmptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(progressBar, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(stickersPanelArrow, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_stickersHintPanel));
    themeDescriptions.add(new ThemeDescription(stickersListView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { StickerCell.class }, null, null, null, Theme.key_chat_stickersHintPanel));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE, new Class[] { ChatUnreadCell.class }, new String[] { "backgroundLayout" }, null, null, null, Theme.key_chat_unreadMessagesStartBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { ChatUnreadCell.class }, new String[] { "imageView" }, null, null, null, Theme.key_chat_unreadMessagesStartArrowIcon));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { ChatUnreadCell.class }, new String[] { "textView" }, null, null, null, Theme.key_chat_unreadMessagesStartText));
    themeDescriptions.add(new ThemeDescription(progressView2, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(bigEmptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_SERVICEBACKGROUND, new Class[] { ChatLoadingCell.class }, new String[] { "textView" }, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_PROGRESSBAR, new Class[] { ChatLoadingCell.class }, new String[] { "textView" }, null, null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(mentionListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { BotSwitchCell.class }, new String[] { "textView" }, null, null, null, Theme.key_chat_botSwitchToInlineText));
    themeDescriptions.add(new ThemeDescription(mentionListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { MentionCell.class }, new String[] { "nameTextView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
    themeDescriptions.add(new ThemeDescription(mentionListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { MentionCell.class }, new String[] { "usernameTextView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText3));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, new Drawable[] { Theme.chat_inlineResultFile, Theme.chat_inlineResultAudio, Theme.chat_inlineResultLocation }, null, Theme.key_chat_inlineResultIcon));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, null, null, Theme.key_windowBackgroundWhiteLinkText));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, null, null, Theme.key_chat_inAudioProgress));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, null, null, Theme.key_chat_inAudioSelectedProgress));
    themeDescriptions.add(new ThemeDescription(mentionListView, 0, new Class[] { ContextLinkCell.class }, null, null, null, Theme.key_divider));
    themeDescriptions.add(new ThemeDescription(gifHintTextView, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_gifSaveHintBackground));
    themeDescriptions.add(new ThemeDescription(gifHintTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_gifSaveHintText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachMediaBanBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachMediaBanText));
    themeDescriptions.add(new ThemeDescription(noSoundHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { HintView.class }, new String[] { "textView" }, null, null, null, Theme.key_chat_gifSaveHintText));
    themeDescriptions.add(new ThemeDescription(noSoundHintView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { HintView.class }, new String[] { "imageView" }, null, null, null, Theme.key_chat_gifSaveHintText));
    themeDescriptions.add(new ThemeDescription(noSoundHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { HintView.class }, new String[] { "arrowImageView" }, null, null, null, Theme.key_chat_gifSaveHintBackground));
    themeDescriptions.add(new ThemeDescription(forwardHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { HintView.class }, new String[] { "textView" }, null, null, null, Theme.key_chat_gifSaveHintText));
    themeDescriptions.add(new ThemeDescription(forwardHintView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { HintView.class }, new String[] { "arrowImageView" }, null, null, null, Theme.key_chat_gifSaveHintBackground));
    themeDescriptions.add(new ThemeDescription(pagedownButtonCounter, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_goDownButtonCounterBackground));
    themeDescriptions.add(new ThemeDescription(pagedownButtonCounter, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_goDownButtonCounter));
    themeDescriptions.add(new ThemeDescription(pagedownButtonImage, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_goDownButton));
    themeDescriptions.add(new ThemeDescription(pagedownButtonImage, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chat_goDownButtonShadow));
    themeDescriptions.add(new ThemeDescription(pagedownButtonImage, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_goDownButtonIcon));
    themeDescriptions.add(new ThemeDescription(mentiondownButtonCounter, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_goDownButtonCounterBackground));
    themeDescriptions.add(new ThemeDescription(mentiondownButtonCounter, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_goDownButtonCounter));
    themeDescriptions.add(new ThemeDescription(mentiondownButtonImage, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_goDownButton));
    themeDescriptions.add(new ThemeDescription(mentiondownButtonImage, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chat_goDownButtonShadow));
    themeDescriptions.add(new ThemeDescription(mentiondownButtonImage, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chat_goDownButtonIcon));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTimeItem() : null, 0, null, null, null, null, Theme.key_chat_secretTimerBackground));
    themeDescriptions.add(new ThemeDescription(avatarContainer != null ? avatarContainer.getTimeItem() : null, 0, null, null, null, null, Theme.key_chat_secretTimerText));
    themeDescriptions.add(new ThemeDescription(floatingDateView, 0, null, null, null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(floatingDateView, 0, null, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(infoTopView, 0, null, null, null, null, Theme.key_chat_serviceText));
    themeDescriptions.add(new ThemeDescription(infoTopView, 0, null, null, null, null, Theme.key_chat_serviceBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachGalleryIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachGalleryBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachGalleryText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachAudioIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachAudioBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachAudioText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachFileIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachFileBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachFileText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachContactIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachContactBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachContactText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachLocationIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachLocationBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachLocationText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachPollIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachPollBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachPollText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, new Drawable[] { Theme.chat_attachEmptyDrawable }, null, Theme.key_chat_attachEmptyImage));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_attachPhotoBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogBackgroundGray));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogTextGray2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogScrollGlow));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogGrayLine));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogCameraIcon));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_dialogButtonSelector));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_windowBackgroundWhiteLinkSelection));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_windowBackgroundWhiteInputField));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_outTextSelectionHighlight));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inTextSelectionHighlight));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_TextSelectionCursor));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayGreen1));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayGreen2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayBlue1));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayBlue2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGreen1));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGreen2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelBlue1));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelBlue2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGray));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientMuted));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientMuted2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientUnmuted));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientUnmuted2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient3));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertMutedByAdmin));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertMutedByAdmin2));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_windowBackgroundGray));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_outReactionButtonBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inReactionButtonBackground));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inReactionButtonText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_outReactionButtonText));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inReactionButtonTextSelected));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_chat_inReactionButtonTextSelected));
    themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, selectedBackgroundDelegate, Theme.key_chat_BlurAlpha));
    if (chatActivityEnterView != null) {
        themeDescriptions.add(new ThemeDescription(chatActivityEnterView.botCommandsMenuContainer.listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { BotCommandsMenuView.BotCommandView.class }, new String[] { "description" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
        themeDescriptions.add(new ThemeDescription(chatActivityEnterView.botCommandsMenuContainer.listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { BotCommandsMenuView.BotCommandView.class }, new String[] { "command" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
    }
    if (pendingRequestsDelegate != null) {
        pendingRequestsDelegate.fillThemeDescriptions(themeDescriptions);
    }
    for (ThemeDescription description : themeDescriptions) {
        description.resourcesProvider = themeDelegate;
    }
    return themeDescriptions;
}
Also used : ArrayList(java.util.ArrayList) ChatUnreadCell(org.telegram.ui.Cells.ChatUnreadCell) SpannableString(android.text.SpannableString) DialogCell(org.telegram.ui.Cells.DialogCell) StickerCell(org.telegram.ui.Cells.StickerCell) UndoView(org.telegram.ui.Components.UndoView) BotHelpCell(org.telegram.ui.Cells.BotHelpCell) EmojiView(org.telegram.ui.Components.EmojiView) ChatLoadingCell(org.telegram.ui.Cells.ChatLoadingCell) TrendingStickersAlert(org.telegram.ui.Components.TrendingStickersAlert) ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) BlurBehindDrawable(org.telegram.ui.Components.BlurBehindDrawable) MotionBackgroundDrawable(org.telegram.ui.Components.MotionBackgroundDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) HorizontalScrollView(android.widget.HorizontalScrollView) PinnedLineView(org.telegram.ui.Components.PinnedLineView) BotCommandsMenuView(org.telegram.ui.Components.BotCommandsMenuView) ReactedHeaderView(org.telegram.ui.Components.ReactedHeaderView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) BluredView(org.telegram.ui.Components.BluredView) InstantCameraView(org.telegram.ui.Components.InstantCameraView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ChatActivityEnterTopView(org.telegram.ui.Components.ChatActivityEnterTopView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) BackupImageView(org.telegram.ui.Components.BackupImageView) TextureView(android.view.TextureView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) UndoView(org.telegram.ui.Components.UndoView) CounterView(org.telegram.ui.Components.CounterView) HintView(org.telegram.ui.Components.HintView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) ClippingImageView(org.telegram.ui.Components.ClippingImageView) EmojiView(org.telegram.ui.Components.EmojiView) ChecksHintView(org.telegram.ui.Components.ChecksHintView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) SearchCounterView(org.telegram.ui.Components.SearchCounterView) ForwardingPreviewView(org.telegram.ui.Components.ForwardingPreviewView) ReactionTabHolderView(org.telegram.ui.Components.ReactionTabHolderView) TextView(android.widget.TextView) ReactedUsersListView(org.telegram.ui.Components.ReactedUsersListView) NumberTextView(org.telegram.ui.Components.NumberTextView) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) HintView(org.telegram.ui.Components.HintView) ChecksHintView(org.telegram.ui.Components.ChecksHintView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ChatActionCell(org.telegram.ui.Cells.ChatActionCell) ChatMessageCell(org.telegram.ui.Cells.ChatMessageCell) MentionCell(org.telegram.ui.Cells.MentionCell) FragmentContextView(org.telegram.ui.Components.FragmentContextView) Theme(org.telegram.ui.ActionBar.Theme) BotSwitchCell(org.telegram.ui.Cells.BotSwitchCell)

Example 5 with FragmentContextView

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

the class ChatActivity method invalidateChatListViewTopPadding.

private void invalidateChatListViewTopPadding() {
    if (!invalidateChatListViewTopPadding) {
        invalidateChatListViewTopPadding = true;
        if (contentView != null) {
            contentView.invalidate();
        }
        if (chatListView != null) {
            chatListView.invalidate();
        }
    }
    float translation = contentPanTranslation + contentPaddingTop + Math.max(0, AndroidUtilities.dp(48) + topChatPanelViewOffset);
    if (pinnedMessageView != null) {
        translation += pinnedMessageEnterOffset;
        pinnedMessageView.setTranslationY(translation);
        translation += AndroidUtilities.dp(48);
    }
    View pendingRequestsView = pendingRequestsDelegate != null ? pendingRequestsDelegate.getView() : null;
    if (pendingRequestsView != null) {
        translation += pendingRequestsDelegate.getViewEnterOffset();
        pendingRequestsView.setTranslationY(translation);
    }
    if (fragmentContextView != null) {
        float from = 0;
        if (fragmentLocationContextView != null && fragmentLocationContextView.getVisibility() == View.VISIBLE) {
            from += AndroidUtilities.dp(36);
        }
        fragmentContextView.setTranslationY(contentPanTranslation + from + fragmentContextView.getTopPadding());
    }
    if (fragmentLocationContextView != null) {
        float from = 0;
        if (fragmentContextView != null && fragmentContextView.getVisibility() == View.VISIBLE) {
            from += AndroidUtilities.dp(fragmentContextView.getStyleHeight()) + fragmentContextView.getTopPadding();
        }
        fragmentLocationContextView.setTranslationY(contentPanTranslation + from + fragmentLocationContextView.getTopPadding());
    }
    if (topChatPanelView != null) {
        topChatPanelView.setTranslationY(contentPanTranslation + contentPaddingTop + topChatPanelViewOffset);
    }
    if (mentionListView != null && mentionLayoutManager != null && mentionsAdapter != null && !mentionsAdapter.isBotCommands() && !mentionsAdapter.isStickers()) {
        if (mentionLayoutManager.getReverseLayout()) {
            mentionListView.setTranslationY(contentPanTranslation + contentPaddingTop);
        } else {
            mentionListView.setTranslationY(bottomPanelTranslationYReverse);
        }
    } else if (mentionListView != null) {
        mentionListView.setTranslationY(bottomPanelTranslationYReverse);
    }
    if (alertView != null && alertView.getVisibility() == View.VISIBLE) {
        alertView.setTranslationY(contentPanTranslation + contentPaddingTop - AndroidUtilities.dp(50) * (1f - alertViewEnterProgress));
    }
    if (bottomOverlayChat != null) {
        bottomOverlayChat.setTranslationY(bottomPanelTranslationYReverse);
    }
    if (bottomMessagesActionContainer != null) {
        bottomMessagesActionContainer.setTranslationY(bottomPanelTranslationYReverse);
    }
    if (undoView != null) {
        undoView.setAdditionalTranslationY(chatActivityEnterView.getHeightWithTopView() - chatActivityEnterView.getAnimatedTop());
    }
}
Also used : HorizontalScrollView(android.widget.HorizontalScrollView) PinnedLineView(org.telegram.ui.Components.PinnedLineView) BotCommandsMenuView(org.telegram.ui.Components.BotCommandsMenuView) ReactedHeaderView(org.telegram.ui.Components.ReactedHeaderView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) BluredView(org.telegram.ui.Components.BluredView) InstantCameraView(org.telegram.ui.Components.InstantCameraView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ChatActivityEnterTopView(org.telegram.ui.Components.ChatActivityEnterTopView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) BackupImageView(org.telegram.ui.Components.BackupImageView) TextureView(android.view.TextureView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) UndoView(org.telegram.ui.Components.UndoView) CounterView(org.telegram.ui.Components.CounterView) HintView(org.telegram.ui.Components.HintView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) ClippingImageView(org.telegram.ui.Components.ClippingImageView) EmojiView(org.telegram.ui.Components.EmojiView) ChecksHintView(org.telegram.ui.Components.ChecksHintView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) SearchCounterView(org.telegram.ui.Components.SearchCounterView) ForwardingPreviewView(org.telegram.ui.Components.ForwardingPreviewView) ReactionTabHolderView(org.telegram.ui.Components.ReactionTabHolderView) TextView(android.widget.TextView) ReactedUsersListView(org.telegram.ui.Components.ReactedUsersListView) NumberTextView(org.telegram.ui.Components.NumberTextView)

Aggregations

Paint (android.graphics.Paint)6 Drawable (android.graphics.drawable.Drawable)6 View (android.view.View)6 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)6 BackupImageView (org.telegram.ui.Components.BackupImageView)6 FragmentContextView (org.telegram.ui.Components.FragmentContextView)6 RecyclerListView (org.telegram.ui.Components.RecyclerListView)6 UndoView (org.telegram.ui.Components.UndoView)6 Manifest (android.Manifest)5 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 AnimatorSet (android.animation.AnimatorSet)5 ObjectAnimator (android.animation.ObjectAnimator)5 ValueAnimator (android.animation.ValueAnimator)5 SuppressLint (android.annotation.SuppressLint)5 Dialog (android.app.Dialog)5 Context (android.content.Context)5 DialogInterface (android.content.DialogInterface)5