Search in sources :

Example 1 with TextCell

use of org.telegram.ui.Cells.TextCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class DialogsAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            DialogCell dialogCell = new DialogCell(parentFragment, mContext, true, false, currentAccount, null);
            dialogCell.setArchivedPullAnimation(pullForegroundDrawable);
            dialogCell.setPreloader(preloader);
            view = dialogCell;
            break;
        case 1:
            FlickerLoadingView flickerLoadingView = new FlickerLoadingView(mContext);
            flickerLoadingView.setIsSingleCell(true);
            flickerLoadingView.setViewType(FlickerLoadingView.DIALOG_CELL_TYPE);
            view = flickerLoadingView;
            break;
        case 2:
            {
                HeaderCell headerCell = new HeaderCell(mContext);
                headerCell.setText(LocaleController.getString("RecentlyViewed", R.string.RecentlyViewed));
                TextView textView = new TextView(mContext);
                textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
                textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
                textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));
                textView.setText(LocaleController.getString("RecentlyViewedHide", R.string.RecentlyViewedHide));
                textView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
                headerCell.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 15, 17, 0));
                textView.setOnClickListener(view1 -> {
                    MessagesController.getInstance(currentAccount).hintDialogs.clear();
                    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                    preferences.edit().remove("installReferer").commit();
                    notifyDataSetChanged();
                });
                view = headerCell;
                break;
            }
        case 3:
            FrameLayout frameLayout = new FrameLayout(mContext) {

                @Override
                protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                    super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(12), MeasureSpec.EXACTLY));
                }
            };
            frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
            View v = new View(mContext);
            v.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            frameLayout.addView(v, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
            view = frameLayout;
            break;
        case 4:
            view = new DialogMeUrlCell(mContext);
            break;
        case 5:
            view = new DialogsEmptyCell(mContext);
            break;
        case 6:
            view = new UserCell(mContext, 8, 0, false);
            break;
        case 7:
            view = new HeaderCell(mContext);
            break;
        case 8:
            {
                view = new ShadowSectionCell(mContext);
                Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
                CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
                combinedDrawable.setFullsize(true);
                view.setBackgroundDrawable(combinedDrawable);
                break;
            }
        case 9:
            archiveHintCell = new ArchiveHintCell(mContext);
            view = archiveHintCell;
            break;
        case 10:
            {
                view = new LastEmptyView(mContext);
                break;
            }
        case 11:
            {
                view = new TextInfoPrivacyCell(mContext) {

                    private int movement;

                    private float moveProgress;

                    private long lastUpdateTime;

                    private int originalX;

                    private int originalY;

                    @Override
                    protected void afterTextDraw() {
                        if (arrowDrawable != null) {
                            Rect bounds = arrowDrawable.getBounds();
                            arrowDrawable.setBounds(originalX, originalY, originalX + bounds.width(), originalY + bounds.height());
                        }
                    }

                    @Override
                    protected void onTextDraw() {
                        if (arrowDrawable != null) {
                            Rect bounds = arrowDrawable.getBounds();
                            int dx = (int) (moveProgress * AndroidUtilities.dp(3));
                            originalX = bounds.left;
                            originalY = bounds.top;
                            arrowDrawable.setBounds(originalX + dx, originalY + AndroidUtilities.dp(1), originalX + dx + bounds.width(), originalY + AndroidUtilities.dp(1) + bounds.height());
                            long newUpdateTime = SystemClock.elapsedRealtime();
                            long dt = newUpdateTime - lastUpdateTime;
                            if (dt > 17) {
                                dt = 17;
                            }
                            lastUpdateTime = newUpdateTime;
                            if (movement == 0) {
                                moveProgress += dt / 664.0f;
                                if (moveProgress >= 1.0f) {
                                    movement = 1;
                                    moveProgress = 1.0f;
                                }
                            } else {
                                moveProgress -= dt / 664.0f;
                                if (moveProgress <= 0.0f) {
                                    movement = 0;
                                    moveProgress = 0.0f;
                                }
                            }
                            getTextView().invalidate();
                        }
                    }
                };
                Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
                CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
                combinedDrawable.setFullsize(true);
                view.setBackgroundDrawable(combinedDrawable);
                break;
            }
        case 12:
        default:
            {
                view = new TextCell(mContext);
            }
    }
    view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, viewType == 5 ? RecyclerView.LayoutParams.MATCH_PARENT : RecyclerView.LayoutParams.WRAP_CONTENT));
    return new RecyclerListView.Holder(view);
}
Also used : ArchiveHintCell(org.telegram.ui.Cells.ArchiveHintCell) Rect(android.graphics.Rect) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) TextCell(org.telegram.ui.Cells.TextCell) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) DialogsActivity(org.telegram.ui.DialogsActivity) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) ViewGroup(android.view.ViewGroup) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) ViewPager(androidx.viewpager.widget.ViewPager) SystemClock(android.os.SystemClock) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TLRPC(org.telegram.tgnet.TLRPC) ActionBar(org.telegram.ui.ActionBar.ActionBar) DialogMeUrlCell(org.telegram.ui.Cells.DialogMeUrlCell) TLObject(org.telegram.tgnet.TLObject) SharedConfig(org.telegram.messenger.SharedConfig) DialogsEmptyCell(org.telegram.ui.Cells.DialogsEmptyCell) BuildVars(org.telegram.messenger.BuildVars) Build(android.os.Build) DialogCell(org.telegram.ui.Cells.DialogCell) DialogObject(org.telegram.messenger.DialogObject) UserCell(org.telegram.ui.Cells.UserCell) R(org.telegram.messenger.R) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) MessagesController(org.telegram.messenger.MessagesController) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) Collections(java.util.Collections) RecyclerListView(org.telegram.ui.Components.RecyclerListView) HeaderCell(org.telegram.ui.Cells.HeaderCell) TextCell(org.telegram.ui.Cells.TextCell) DialogCell(org.telegram.ui.Cells.DialogCell) DialogsEmptyCell(org.telegram.ui.Cells.DialogsEmptyCell) TextView(android.widget.TextView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) UserCell(org.telegram.ui.Cells.UserCell) Rect(android.graphics.Rect) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) SharedPreferences(android.content.SharedPreferences) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) DialogMeUrlCell(org.telegram.ui.Cells.DialogMeUrlCell) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ArchiveHintCell(org.telegram.ui.Cells.ArchiveHintCell) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with TextCell

use of org.telegram.ui.Cells.TextCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ContactsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    switch(holder.getItemViewType()) {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            userCell.setAvatarPadding(sortType == 2 || disableSections ? 6 : 58);
            ArrayList<TLRPC.TL_contact> arr;
            if (sortType == 2) {
                arr = onlineContacts;
            } else {
                HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict;
                ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray;
                arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1)));
            }
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id);
            userCell.setData(user, null, null, 0);
            if (checkedMap != null) {
                userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling);
            }
            if (ignoreUsers != null) {
                if (ignoreUsers.indexOfKey(user.id) >= 0) {
                    userCell.setAlpha(0.5f);
                } else {
                    userCell.setAlpha(1.0f);
                }
            }
            break;
        case 1:
            TextCell textCell = (TextCell) holder.itemView;
            if (section == 0) {
                if (needPhonebook) {
                    if (position == 0) {
                        textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite, false);
                    } else if (position == 1) {
                        textCell.setTextAndIcon(LocaleController.getString("AddPeopleNearby", R.string.AddPeopleNearby), R.drawable.menu_location, false);
                    }
                } else if (isAdmin) {
                    if (isChannel) {
                        textCell.setTextAndIcon(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink), R.drawable.profile_link, false);
                    } else {
                        textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.profile_link, false);
                    }
                } else {
                    if (position == 0) {
                        textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups, false);
                    } else if (position == 1) {
                        textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret, false);
                    } else if (position == 2) {
                        textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast, false);
                    }
                }
            } else {
                ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position);
                if (contact.first_name != null && contact.last_name != null) {
                    textCell.setText(contact.first_name + " " + contact.last_name, false);
                } else if (contact.first_name != null && contact.last_name == null) {
                    textCell.setText(contact.first_name, false);
                } else {
                    textCell.setText(contact.last_name, false);
                }
            }
            break;
        case 2:
            GraySectionCell sectionCell = (GraySectionCell) holder.itemView;
            if (sortType == 0) {
                sectionCell.setText(LocaleController.getString("Contacts", R.string.Contacts));
            } else if (sortType == 1) {
                sectionCell.setText(LocaleController.getString("SortedByName", R.string.SortedByName));
            } else {
                sectionCell.setText(LocaleController.getString("SortedByLastSeen", R.string.SortedByLastSeen));
            }
            break;
    }
}
Also used : ContactsController(org.telegram.messenger.ContactsController) GraySectionCell(org.telegram.ui.Cells.GraySectionCell) ArrayList(java.util.ArrayList) TLRPC(org.telegram.tgnet.TLRPC) TextCell(org.telegram.ui.Cells.TextCell) UserCell(org.telegram.ui.Cells.UserCell)

Example 3 with TextCell

use of org.telegram.ui.Cells.TextCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ContactsAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            view = new UserCell(mContext, 58, 1, false);
            break;
        case 1:
            view = new TextCell(mContext);
            break;
        case 2:
            view = new GraySectionCell(mContext);
            break;
        case 3:
            view = new DividerCell(mContext);
            view.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 28 : 72), AndroidUtilities.dp(8), AndroidUtilities.dp(LocaleController.isRTL ? 72 : 28), AndroidUtilities.dp(8));
            break;
        case 4:
            FrameLayout frameLayout = new FrameLayout(mContext) {

                @Override
                protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                    int height;
                    height = MeasureSpec.getSize(heightMeasureSpec);
                    if (height == 0) {
                        height = parent.getMeasuredHeight();
                    }
                    if (height == 0) {
                        height = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
                    }
                    int cellHeight = AndroidUtilities.dp(50);
                    int totalHeight = onlyUsers != 0 ? 0 : cellHeight + AndroidUtilities.dp(30);
                    if (hasGps) {
                        totalHeight += cellHeight;
                    }
                    if (!isAdmin && !needPhonebook) {
                        totalHeight += cellHeight;
                    }
                    if (totalHeight < height) {
                        height = height - totalHeight;
                    } else {
                        height = 0;
                    }
                    super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                }
            };
            ContactsEmptyView emptyView = new ContactsEmptyView(mContext);
            frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
            view = frameLayout;
            break;
        case 5:
        default:
            view = new ShadowSectionCell(mContext);
            Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
            CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
            combinedDrawable.setFullsize(true);
            view.setBackgroundDrawable(combinedDrawable);
            break;
    }
    return new RecyclerListView.Holder(view);
}
Also used : GraySectionCell(org.telegram.ui.Cells.GraySectionCell) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ContactsEmptyView(org.telegram.ui.Components.ContactsEmptyView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextCell(org.telegram.ui.Cells.TextCell) DividerCell(org.telegram.ui.Cells.DividerCell) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) UserCell(org.telegram.ui.Cells.UserCell) ContactsEmptyView(org.telegram.ui.Components.ContactsEmptyView)

Example 4 with TextCell

use of org.telegram.ui.Cells.TextCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class SearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch(holder.getItemViewType()) {
        case 0:
            {
                TLObject object = (TLObject) getItem(position);
                if (object != null) {
                    long id = 0;
                    String un = null;
                    boolean self = false;
                    if (object instanceof TLRPC.User) {
                        un = ((TLRPC.User) object).username;
                        id = ((TLRPC.User) object).id;
                        self = ((TLRPC.User) object).self;
                    } else if (object instanceof TLRPC.Chat) {
                        un = ((TLRPC.Chat) object).username;
                        id = ((TLRPC.Chat) object).id;
                    }
                    CharSequence username = null;
                    CharSequence name = null;
                    if (position < searchResult.size()) {
                        name = searchResultNames.get(position);
                        if (name != null && un != null && un.length() > 0) {
                            if (name.toString().startsWith("@" + un)) {
                                username = name;
                                name = null;
                            }
                        }
                    } else if (position > searchResult.size() && un != null) {
                        String foundUserName = searchAdapterHelper.getLastFoundUsername();
                        if (foundUserName != null && foundUserName.startsWith("@")) {
                            foundUserName = foundUserName.substring(1);
                        }
                        try {
                            int index;
                            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                            spannableStringBuilder.append("@");
                            spannableStringBuilder.append(un);
                            if (foundUserName != null && (index = AndroidUtilities.indexOfIgnoreCase(un, foundUserName)) != -1) {
                                int len = foundUserName.length();
                                if (index == 0) {
                                    len++;
                                } else {
                                    index++;
                                }
                                spannableStringBuilder.setSpan(new ForegroundColorSpanThemable(Theme.key_windowBackgroundWhiteBlueText4), index, index + len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                            }
                            username = spannableStringBuilder;
                        } catch (Exception e) {
                            username = un;
                            FileLog.e(e);
                        }
                    }
                    if (useUserCell) {
                        UserCell userCell = (UserCell) holder.itemView;
                        userCell.setData(object, name, username, 0);
                        if (checkedMap != null) {
                            userCell.setChecked(checkedMap.indexOfKey(id) >= 0, false);
                        }
                    } else {
                        ProfileSearchCell profileSearchCell = (ProfileSearchCell) holder.itemView;
                        if (self) {
                            name = LocaleController.getString("SavedMessages", R.string.SavedMessages);
                        }
                        profileSearchCell.setData(object, null, name, username, false, self);
                        profileSearchCell.useSeparator = (position != getItemCount() - 1 && position != searchResult.size() - 1);
                    /*if (ignoreUsers != null) {
                            if (ignoreUsers.containsKey(id)) {
                                profileSearchCell.drawAlpha = 0.5f;
                            } else {
                                profileSearchCell.drawAlpha = 1.0f;
                            }
                        }*/
                    }
                }
                break;
            }
        case 1:
            {
                GraySectionCell cell = (GraySectionCell) holder.itemView;
                if (getItem(position) == null) {
                    cell.setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
                } else {
                    cell.setText(LocaleController.getString("PhoneNumberSearch", R.string.PhoneNumberSearch));
                }
                break;
            }
        case 2:
            {
                String str = (String) getItem(position);
                TextCell cell = (TextCell) holder.itemView;
                cell.setColors(null, Theme.key_windowBackgroundWhiteBlueText2);
                cell.setText(LocaleController.formatString("AddContactByPhone", R.string.AddContactByPhone, PhoneFormat.getInstance().format("+" + str)), false);
                break;
            }
    }
}
Also used : GraySectionCell(org.telegram.ui.Cells.GraySectionCell) TLRPC(org.telegram.tgnet.TLRPC) TextCell(org.telegram.ui.Cells.TextCell) ProfileSearchCell(org.telegram.ui.Cells.ProfileSearchCell) TLObject(org.telegram.tgnet.TLObject) UserCell(org.telegram.ui.Cells.UserCell) SpannableStringBuilder(android.text.SpannableStringBuilder) ForegroundColorSpanThemable(org.telegram.ui.Components.ForegroundColorSpanThemable)

Example 5 with TextCell

use of org.telegram.ui.Cells.TextCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatEditActivity method createView.

@Override
public View createView(Context context) {
    if (nameTextView != null) {
        nameTextView.onDestroy();
    }
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                if (checkDiscard()) {
                    finishFragment();
                }
            } else if (id == done_button) {
                processDone();
            }
        }
    });
    SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {

        private boolean ignoreLayout;

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int widthSize = MeasureSpec.getSize(widthMeasureSpec);
            int heightSize = MeasureSpec.getSize(heightMeasureSpec);
            setMeasuredDimension(widthSize, heightSize);
            heightSize -= getPaddingTop();
            measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
            int keyboardSize = measureKeyboardHeight();
            if (keyboardSize > AndroidUtilities.dp(20)) {
                ignoreLayout = true;
                nameTextView.hideEmojiView();
                ignoreLayout = false;
            }
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                View child = getChildAt(i);
                if (child == null || child.getVisibility() == GONE || child == actionBar) {
                    continue;
                }
                if (nameTextView != null && nameTextView.isPopupView(child)) {
                    if (AndroidUtilities.isInMultiwindow || AndroidUtilities.isTablet()) {
                        if (AndroidUtilities.isTablet()) {
                            child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(AndroidUtilities.isTablet() ? 200 : 320), heightSize - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
                        } else {
                            child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
                        }
                    } else {
                        child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
                    }
                } else {
                    measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
                }
            }
        }

        @Override
        protected void onLayout(boolean changed, int l, int t, int r, int b) {
            final int count = getChildCount();
            int keyboardSize = measureKeyboardHeight();
            int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
            setBottomClip(paddingBottom);
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);
                if (child.getVisibility() == GONE) {
                    continue;
                }
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                final int width = child.getMeasuredWidth();
                final int height = child.getMeasuredHeight();
                int childLeft;
                int childTop;
                int gravity = lp.gravity;
                if (gravity == -1) {
                    gravity = Gravity.TOP | Gravity.LEFT;
                }
                final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
                final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
                switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                    case Gravity.CENTER_HORIZONTAL:
                        childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
                        break;
                    case Gravity.RIGHT:
                        childLeft = r - width - lp.rightMargin;
                        break;
                    case Gravity.LEFT:
                    default:
                        childLeft = lp.leftMargin;
                }
                switch(verticalGravity) {
                    case Gravity.TOP:
                        childTop = lp.topMargin + getPaddingTop();
                        break;
                    case Gravity.CENTER_VERTICAL:
                        childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
                        break;
                    case Gravity.BOTTOM:
                        childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
                        break;
                    default:
                        childTop = lp.topMargin;
                }
                if (nameTextView != null && nameTextView.isPopupView(child)) {
                    if (AndroidUtilities.isTablet()) {
                        childTop = getMeasuredHeight() - child.getMeasuredHeight();
                    } else {
                        childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
                    }
                }
                child.layout(childLeft, childTop, childLeft + width, childTop + height);
            }
            notifyHeightChanged();
        }

        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }
    };
    sizeNotifierFrameLayout.setOnTouchListener((v, event) -> true);
    fragmentView = sizeNotifierFrameLayout;
    fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
    ScrollView scrollView = new ScrollView(context);
    scrollView.setFillViewport(true);
    sizeNotifierFrameLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    LinearLayout linearLayout1 = new LinearLayout(context);
    scrollView.addView(linearLayout1, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    linearLayout1.setOrientation(LinearLayout.VERTICAL);
    actionBar.setTitle(LocaleController.getString("ChannelEdit", R.string.ChannelEdit));
    avatarContainer = new LinearLayout(context);
    avatarContainer.setOrientation(LinearLayout.VERTICAL);
    avatarContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    linearLayout1.addView(avatarContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    FrameLayout frameLayout = new FrameLayout(context);
    avatarContainer.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    avatarImage = new BackupImageView(context) {

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

        @Override
        public void invalidate(int l, int t, int r, int b) {
            if (avatarOverlay != null) {
                avatarOverlay.invalidate();
            }
            super.invalidate(l, t, r, b);
        }
    };
    avatarImage.setRoundRadius(AndroidUtilities.dp(32));
    if (ChatObject.canChangeChatInfo(currentChat)) {
        frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 8));
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(0x55000000);
        avatarOverlay = new View(context) {

            @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);
                }
            }
        };
        frameLayout.addView(avatarOverlay, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 8));
        avatarProgressView = new RadialProgressView(context);
        avatarProgressView.setSize(AndroidUtilities.dp(30));
        avatarProgressView.setProgressColor(0xffffffff);
        avatarProgressView.setNoProgress(false);
        frameLayout.addView(avatarProgressView, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 8));
        showAvatarProgress(false, false);
        avatarContainer.setOnClickListener(v -> {
            if (imageUpdater.isUploadingImage()) {
                return;
            }
            TLRPC.Chat chat = getMessagesController().getChat(chatId);
            if (chat.photo != null && chat.photo.photo_big != null) {
                PhotoViewer.getInstance().setParentActivity(getParentActivity());
                if (chat.photo.dc_id != 0) {
                    chat.photo.photo_big.dc_id = chat.photo.dc_id;
                }
                ImageLocation videoLocation;
                if (info != null && (info.chat_photo instanceof TLRPC.TL_photo) && !info.chat_photo.video_sizes.isEmpty()) {
                    videoLocation = ImageLocation.getForPhoto(info.chat_photo.video_sizes.get(0), info.chat_photo);
                } else {
                    videoLocation = null;
                }
                PhotoViewer.getInstance().openPhotoWithVideo(chat.photo.photo_big, videoLocation, provider);
            }
        });
    } else {
        frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
    }
    nameTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, this, EditTextEmoji.STYLE_FRAGMENT);
    if (isChannel) {
        nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName));
    } else {
        nameTextView.setHint(LocaleController.getString("GroupName", R.string.GroupName));
    }
    nameTextView.setEnabled(ChatObject.canChangeChatInfo(currentChat));
    nameTextView.setFocusable(nameTextView.isEnabled());
    nameTextView.getEditText().addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            avatarDrawable.setInfo(5, nameTextView.getText().toString(), null);
            if (avatarImage != null) {
                avatarImage.invalidate();
            }
        }
    });
    InputFilter[] inputFilters = new InputFilter[1];
    inputFilters[0] = new InputFilter.LengthFilter(128);
    nameTextView.setFilters(inputFilters);
    frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 5 : 96, 0, LocaleController.isRTL ? 96 : 5, 0));
    settingsContainer = new LinearLayout(context);
    settingsContainer.setOrientation(LinearLayout.VERTICAL);
    settingsContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    linearLayout1.addView(settingsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    if (ChatObject.canChangeChatInfo(currentChat)) {
        setAvatarCell = new TextCell(context) {

            @Override
            protected void onDraw(Canvas canvas) {
                canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
            }
        };
        setAvatarCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        setAvatarCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
        setAvatarCell.setOnClickListener(v -> {
            imageUpdater.openMenu(avatar != null, () -> {
                avatar = null;
                MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null, 0, null, null, null, null);
                showAvatarProgress(false, true);
                avatarImage.setImage(null, null, avatarDrawable, currentChat);
                cameraDrawable.setCurrentFrame(0);
                setAvatarCell.imageView.playAnimation();
            }, dialogInterface -> {
                if (!imageUpdater.isUploadingImage()) {
                    cameraDrawable.setCustomEndFrame(86);
                    setAvatarCell.imageView.playAnimation();
                } else {
                    cameraDrawable.setCurrentFrame(0, false);
                }
            });
            cameraDrawable.setCurrentFrame(0);
            cameraDrawable.setCustomEndFrame(43);
            setAvatarCell.imageView.playAnimation();
        });
        settingsContainer.addView(setAvatarCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    descriptionTextView = new EditTextBoldCursor(context);
    descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    descriptionTextView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    descriptionTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6));
    descriptionTextView.setBackgroundDrawable(null);
    descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
    descriptionTextView.setEnabled(ChatObject.canChangeChatInfo(currentChat));
    descriptionTextView.setFocusable(descriptionTextView.isEnabled());
    inputFilters = new InputFilter[1];
    inputFilters[0] = new InputFilter.LengthFilter(255);
    descriptionTextView.setFilters(inputFilters);
    descriptionTextView.setHint(LocaleController.getString("DescriptionOptionalPlaceholder", R.string.DescriptionOptionalPlaceholder));
    descriptionTextView.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    descriptionTextView.setCursorSize(AndroidUtilities.dp(20));
    descriptionTextView.setCursorWidth(1.5f);
    if (descriptionTextView.isEnabled()) {
        settingsContainer.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 23, 15, 23, 9));
    } else {
        settingsContainer.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 23, 12, 23, 6));
    }
    descriptionTextView.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
            doneButton.performClick();
            return true;
        }
        return false;
    });
    descriptionTextView.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });
    settingsTopSectionCell = new ShadowSectionCell(context);
    linearLayout1.addView(settingsTopSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    typeEditContainer = new LinearLayout(context);
    typeEditContainer.setOrientation(LinearLayout.VERTICAL);
    typeEditContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    linearLayout1.addView(typeEditContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    if (currentChat.megagroup && (info == null || info.can_set_location)) {
        locationCell = new TextDetailCell(context);
        locationCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        typeEditContainer.addView(locationCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        locationCell.setOnClickListener(v -> {
            if (!AndroidUtilities.isGoogleMapsInstalled(ChatEditActivity.this)) {
                return;
            }
            LocationActivity fragment = new LocationActivity(LocationActivity.LOCATION_TYPE_GROUP);
            fragment.setDialogId(-chatId);
            if (info != null && info.location instanceof TLRPC.TL_channelLocation) {
                fragment.setInitialLocation((TLRPC.TL_channelLocation) info.location);
            }
            fragment.setDelegate((location, live, notify, scheduleDate) -> {
                TLRPC.TL_channelLocation channelLocation = new TLRPC.TL_channelLocation();
                channelLocation.address = location.address;
                channelLocation.geo_point = location.geo;
                info.location = channelLocation;
                info.flags |= 32768;
                updateFields(false);
                getMessagesController().loadFullChat(chatId, 0, true);
            });
            presentFragment(fragment);
        });
    }
    if (currentChat.creator && (info == null || info.can_set_username)) {
        typeCell = new TextDetailCell(context);
        typeCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        typeEditContainer.addView(typeCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        typeCell.setOnClickListener(v -> {
            ChatEditTypeActivity fragment = new ChatEditTypeActivity(chatId, locationCell != null && locationCell.getVisibility() == View.VISIBLE);
            fragment.setInfo(info);
            presentFragment(fragment);
        });
    }
    if (ChatObject.isChannel(currentChat) && (isChannel && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_CHANGE_INFO) || !isChannel && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_PIN))) {
        linkedCell = new TextDetailCell(context);
        linkedCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        typeEditContainer.addView(linkedCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        linkedCell.setOnClickListener(v -> {
            ChatLinkActivity fragment = new ChatLinkActivity(chatId);
            fragment.setInfo(info);
            presentFragment(fragment);
        });
    }
    if (!isChannel && ChatObject.canBlockUsers(currentChat) && (ChatObject.isChannel(currentChat) || currentChat.creator)) {
        historyCell = new TextDetailCell(context);
        historyCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        typeEditContainer.addView(historyCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        historyCell.setOnClickListener(v -> {
            BottomSheet.Builder builder = new BottomSheet.Builder(context);
            builder.setApplyTopPadding(false);
            LinearLayout linearLayout = new LinearLayout(context);
            linearLayout.setOrientation(LinearLayout.VERTICAL);
            HeaderCell headerCell = new HeaderCell(context, Theme.key_dialogTextBlue2, 23, 15, false);
            headerCell.setHeight(47);
            headerCell.setText(LocaleController.getString("ChatHistory", R.string.ChatHistory));
            linearLayout.addView(headerCell);
            LinearLayout linearLayoutInviteContainer = new LinearLayout(context);
            linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL);
            linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
            RadioButtonCell[] buttons = new RadioButtonCell[2];
            for (int a = 0; a < 2; a++) {
                buttons[a] = new RadioButtonCell(context, true);
                buttons[a].setTag(a);
                buttons[a].setBackgroundDrawable(Theme.getSelectorDrawable(false));
                if (a == 0) {
                    buttons[a].setTextAndValue(LocaleController.getString("ChatHistoryVisible", R.string.ChatHistoryVisible), LocaleController.getString("ChatHistoryVisibleInfo", R.string.ChatHistoryVisibleInfo), true, !historyHidden);
                } else {
                    if (ChatObject.isChannel(currentChat)) {
                        buttons[a].setTextAndValue(LocaleController.getString("ChatHistoryHidden", R.string.ChatHistoryHidden), LocaleController.getString("ChatHistoryHiddenInfo", R.string.ChatHistoryHiddenInfo), false, historyHidden);
                    } else {
                        buttons[a].setTextAndValue(LocaleController.getString("ChatHistoryHidden", R.string.ChatHistoryHidden), LocaleController.getString("ChatHistoryHiddenInfo2", R.string.ChatHistoryHiddenInfo2), false, historyHidden);
                    }
                }
                linearLayoutInviteContainer.addView(buttons[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
                buttons[a].setOnClickListener(v2 -> {
                    Integer tag = (Integer) v2.getTag();
                    buttons[0].setChecked(tag == 0, true);
                    buttons[1].setChecked(tag == 1, true);
                    historyHidden = tag == 1;
                    builder.getDismissRunnable().run();
                    updateFields(true);
                });
            }
            builder.setCustomView(linearLayout);
            showDialog(builder.create());
        });
    }
    if (isChannel) {
        signCell = new TextCheckCell(context);
        signCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        signCell.setTextAndValueAndCheck(LocaleController.getString("ChannelSignMessages", R.string.ChannelSignMessages), LocaleController.getString("ChannelSignMessagesInfo", R.string.ChannelSignMessagesInfo), signMessages, true, false);
        typeEditContainer.addView(signCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        signCell.setOnClickListener(v -> {
            signMessages = !signMessages;
            ((TextCheckCell) v).setChecked(signMessages);
        });
    }
    ActionBarMenu menu = actionBar.createMenu();
    if (ChatObject.canChangeChatInfo(currentChat) || signCell != null || historyCell != null) {
        doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
        doneButton.setContentDescription(LocaleController.getString("Done", R.string.Done));
    }
    if (locationCell != null || signCell != null || historyCell != null || typeCell != null || linkedCell != null) {
        settingsSectionCell = new ShadowSectionCell(context);
        linearLayout1.addView(settingsSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    infoContainer = new LinearLayout(context);
    infoContainer.setOrientation(LinearLayout.VERTICAL);
    infoContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    linearLayout1.addView(infoContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    blockCell = new TextCell(context);
    blockCell.setBackground(Theme.getSelectorDrawable(false));
    blockCell.setVisibility(ChatObject.isChannel(currentChat) || currentChat.creator || ChatObject.hasAdminRights(currentChat) && ChatObject.canChangeChatInfo(currentChat) ? View.VISIBLE : View.GONE);
    blockCell.setOnClickListener(v -> {
        Bundle args = new Bundle();
        args.putLong("chat_id", chatId);
        args.putInt("type", !isChannel && !currentChat.gigagroup ? ChatUsersActivity.TYPE_KICKED : ChatUsersActivity.TYPE_BANNED);
        ChatUsersActivity fragment = new ChatUsersActivity(args);
        fragment.setInfo(info);
        presentFragment(fragment);
    });
    inviteLinksCell = new TextCell(context);
    inviteLinksCell.setBackground(Theme.getSelectorDrawable(false));
    inviteLinksCell.setOnClickListener(v -> {
        ManageLinksActivity fragment = new ManageLinksActivity(chatId, 0, 0);
        fragment.setInfo(info, info.exported_invite);
        presentFragment(fragment);
    });
    reactionsCell = new TextCell(context);
    reactionsCell.setBackground(Theme.getSelectorDrawable(false));
    reactionsCell.setOnClickListener(v -> {
        Bundle args = new Bundle();
        args.putLong(ChatReactionsEditActivity.KEY_CHAT_ID, chatId);
        ChatReactionsEditActivity reactionsEditActivity = new ChatReactionsEditActivity(args);
        reactionsEditActivity.setInfo(info);
        presentFragment(reactionsEditActivity);
    });
    adminCell = new TextCell(context);
    adminCell.setBackground(Theme.getSelectorDrawable(false));
    adminCell.setOnClickListener(v -> {
        Bundle args = new Bundle();
        args.putLong("chat_id", chatId);
        args.putInt("type", ChatUsersActivity.TYPE_ADMIN);
        ChatUsersActivity fragment = new ChatUsersActivity(args);
        fragment.setInfo(info);
        presentFragment(fragment);
    });
    membersCell = new TextCell(context);
    membersCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    membersCell.setOnClickListener(v -> {
        Bundle args = new Bundle();
        args.putLong("chat_id", chatId);
        args.putInt("type", ChatUsersActivity.TYPE_USERS);
        ChatUsersActivity fragment = new ChatUsersActivity(args);
        fragment.setInfo(info);
        presentFragment(fragment);
    });
    if (!ChatObject.isChannelAndNotMegaGroup(currentChat)) {
        memberRequestsCell = new TextCell(context);
        memberRequestsCell.setBackground(Theme.getSelectorDrawable(false));
        memberRequestsCell.setOnClickListener(v -> {
            MemberRequestsActivity activity = new MemberRequestsActivity(chatId);
            presentFragment(activity);
        });
    }
    if (ChatObject.isChannel(currentChat) || currentChat.gigagroup) {
        logCell = new TextCell(context);
        logCell.setTextAndIcon(LocaleController.getString("EventLog", R.string.EventLog), R.drawable.group_log, false);
        logCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        logCell.setOnClickListener(v -> presentFragment(new ChannelAdminLogActivity(currentChat)));
    }
    infoContainer.addView(reactionsCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    if (!isChannel && !currentChat.gigagroup) {
        infoContainer.addView(blockCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    if (!isChannel) {
        infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    infoContainer.addView(adminCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    infoContainer.addView(membersCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    if (memberRequestsCell != null && info != null && info.requests_pending > 0) {
        infoContainer.addView(memberRequestsCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    if (isChannel) {
        infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    if (isChannel || currentChat.gigagroup) {
        infoContainer.addView(blockCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    if (logCell != null) {
        infoContainer.addView(logCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    infoSectionCell = new ShadowSectionCell(context);
    linearLayout1.addView(infoSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    if (!ChatObject.hasAdminRights(currentChat)) {
        infoContainer.setVisibility(View.GONE);
        settingsTopSectionCell.setVisibility(View.GONE);
    }
    if (!isChannel && info != null && info.can_set_stickers) {
        stickersContainer = new FrameLayout(context);
        stickersContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        linearLayout1.addView(stickersContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        stickersCell = new TextSettingsCell(context);
        stickersCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        stickersCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        stickersContainer.addView(stickersCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        stickersCell.setOnClickListener(v -> {
            GroupStickersActivity groupStickersActivity = new GroupStickersActivity(currentChat.id);
            groupStickersActivity.setInfo(info);
            presentFragment(groupStickersActivity);
        });
        stickersInfoCell3 = new TextInfoPrivacyCell(context);
        stickersInfoCell3.setText(LocaleController.getString("GroupStickersInfo", R.string.GroupStickersInfo));
        linearLayout1.addView(stickersInfoCell3, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    }
    if (currentChat.creator) {
        deleteContainer = new FrameLayout(context);
        deleteContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        linearLayout1.addView(deleteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        deleteCell = new TextSettingsCell(context);
        deleteCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText5));
        deleteCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
        if (isChannel) {
            deleteCell.setText(LocaleController.getString("ChannelDelete", R.string.ChannelDelete), false);
        } else {
            deleteCell.setText(LocaleController.getString("DeleteAndExitButton", R.string.DeleteAndExitButton), false);
        }
        deleteContainer.addView(deleteCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        deleteCell.setOnClickListener(v -> AlertsCreator.createClearOrDeleteDialogAlert(ChatEditActivity.this, false, true, false, currentChat, null, false, true, (param) -> {
            if (AndroidUtilities.isTablet()) {
                getNotificationCenter().postNotificationName(NotificationCenter.closeChats, -chatId);
            } else {
                getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
            }
            finishFragment();
            getNotificationCenter().postNotificationName(NotificationCenter.needDeleteDialog, -currentChat.id, null, currentChat, param);
        }, null));
        deleteInfoCell = new ShadowSectionCell(context);
        deleteInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
        linearLayout1.addView(deleteInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    } else {
        if (!isChannel) {
            if (stickersInfoCell3 == null) {
                infoSectionCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
        }
    }
    if (stickersInfoCell3 != null) {
        if (deleteInfoCell == null) {
            stickersInfoCell3.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
        } else {
            stickersInfoCell3.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
        }
    }
    undoView = new UndoView(context);
    sizeNotifierFrameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
    nameTextView.setText(currentChat.title);
    nameTextView.setSelection(nameTextView.length());
    if (info != null) {
        descriptionTextView.setText(info.about);
    }
    setAvatar();
    updateFields(true);
    return fragmentView;
}
Also used : ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ImageUpdater(org.telegram.ui.Components.ImageUpdater) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) Animator(android.animation.Animator) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) TextCell(org.telegram.ui.Cells.TextCell) View(android.view.View) Canvas(android.graphics.Canvas) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) UndoView(org.telegram.ui.Components.UndoView) InputType(android.text.InputType) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewGroup(android.view.ViewGroup) NotificationCenter(org.telegram.messenger.NotificationCenter) RadioButtonCell(org.telegram.ui.Cells.RadioButtonCell) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Paint(android.graphics.Paint) InputFilter(android.text.InputFilter) EditorInfo(android.view.inputmethod.EditorInfo) TextWatcher(android.text.TextWatcher) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) TextDetailCell(org.telegram.ui.Cells.TextDetailCell) Dialog(android.app.Dialog) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) Editable(android.text.Editable) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) TLRPC(org.telegram.tgnet.TLRPC) ActionBar(org.telegram.ui.ActionBar.ActionBar) EditTextEmoji(org.telegram.ui.Components.EditTextEmoji) AnimatorSet(android.animation.AnimatorSet) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) MessageObject(org.telegram.messenger.MessageObject) Build(android.os.Build) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) BackupImageView(org.telegram.ui.Components.BackupImageView) TextUtils(android.text.TextUtils) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) MessagesController(org.telegram.messenger.MessagesController) Gravity(android.view.Gravity) TypedValue(android.util.TypedValue) ScrollView(android.widget.ScrollView) MessagesStorage(org.telegram.messenger.MessagesStorage) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) Vibrator(android.os.Vibrator) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Collections(java.util.Collections) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) HeaderCell(org.telegram.ui.Cells.HeaderCell) TLRPC(org.telegram.tgnet.TLRPC) BackupImageView(org.telegram.ui.Components.BackupImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) InputFilter(android.text.InputFilter) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) Canvas(android.graphics.Canvas) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) Paint(android.graphics.Paint) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) RadioButtonCell(org.telegram.ui.Cells.RadioButtonCell) ImageLocation(org.telegram.messenger.ImageLocation) TextCell(org.telegram.ui.Cells.TextCell) UndoView(org.telegram.ui.Components.UndoView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) TextDetailCell(org.telegram.ui.Cells.TextDetailCell) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) Bundle(android.os.Bundle) RadialProgressView(org.telegram.ui.Components.RadialProgressView) View(android.view.View) UndoView(org.telegram.ui.Components.UndoView) BackupImageView(org.telegram.ui.Components.BackupImageView) ScrollView(android.widget.ScrollView) Paint(android.graphics.Paint) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) EditTextEmoji(org.telegram.ui.Components.EditTextEmoji) LinearLayout(android.widget.LinearLayout)

Aggregations

TextCell (org.telegram.ui.Cells.TextCell)9 View (android.view.View)7 ArrayList (java.util.ArrayList)5 GraySectionCell (org.telegram.ui.Cells.GraySectionCell)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 TLRPC (org.telegram.tgnet.TLRPC)4 ShadowSectionCell (org.telegram.ui.Cells.ShadowSectionCell)4 UserCell (org.telegram.ui.Cells.UserCell)4 RecyclerListView (org.telegram.ui.Components.RecyclerListView)4 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 FrameLayout (android.widget.FrameLayout)3 ScrollView (android.widget.ScrollView)3 Collections (java.util.Collections)3 AndroidUtilities (org.telegram.messenger.AndroidUtilities)3 ContactsController (org.telegram.messenger.ContactsController)3 FileLog (org.telegram.messenger.FileLog)3 LocaleController (org.telegram.messenger.LocaleController)3 MessagesController (org.telegram.messenger.MessagesController)3 R (org.telegram.messenger.R)3