Search in sources :

Example 6 with GroupCreateSpan

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

the class GroupCreateActivity method createView.

@Override
public View createView(Context context) {
    searching = false;
    searchWas = false;
    allSpans.clear();
    selectedContacts.clear();
    currentDeletingSpan = null;
    doneButtonVisible = chatType == ChatObject.CHAT_TYPE_CHANNEL;
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (chatType == ChatObject.CHAT_TYPE_CHANNEL) {
        actionBar.setTitle(LocaleController.getString("ChannelAddSubscribers", R.string.ChannelAddSubscribers));
    } else {
        if (addToGroup) {
            if (channelId != 0) {
                actionBar.setTitle(LocaleController.getString("ChannelAddSubscribers", R.string.ChannelAddSubscribers));
            } else {
                actionBar.setTitle(LocaleController.getString("GroupAddMembers", R.string.GroupAddMembers));
            }
        } else if (isAlwaysShare) {
            if (chatAddType == 2) {
                actionBar.setTitle(LocaleController.getString("FilterAlwaysShow", R.string.FilterAlwaysShow));
            } else if (chatAddType == 1) {
                actionBar.setTitle(LocaleController.getString("AlwaysAllow", R.string.AlwaysAllow));
            } else {
                actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
            }
        } else if (isNeverShare) {
            if (chatAddType == 2) {
                actionBar.setTitle(LocaleController.getString("FilterNeverShow", R.string.FilterNeverShow));
            } else if (chatAddType == 1) {
                actionBar.setTitle(LocaleController.getString("NeverAllow", R.string.NeverAllow));
            } else {
                actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
            }
        } else {
            actionBar.setTitle(chatType == ChatObject.CHAT_TYPE_CHAT ? LocaleController.getString("NewGroup", R.string.NewGroup) : LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
        }
    }
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                onDonePressed(true);
            }
        }
    });
    fragmentView = new ViewGroup(context) {

        private VerticalPositionAutoAnimator verticalPositionAutoAnimator;

        @Override
        public void onViewAdded(View child) {
            if (child == floatingButton && verticalPositionAutoAnimator == null) {
                verticalPositionAutoAnimator = VerticalPositionAutoAnimator.attach(child);
            }
        }

        @Override
        protected void onAttachedToWindow() {
            super.onAttachedToWindow();
            if (verticalPositionAutoAnimator != null) {
                verticalPositionAutoAnimator.ignoreNextLayout();
            }
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            int height = MeasureSpec.getSize(heightMeasureSpec);
            setMeasuredDimension(width, height);
            if (AndroidUtilities.isTablet() || height > width) {
                maxSize = AndroidUtilities.dp(144);
            } else {
                maxSize = AndroidUtilities.dp(56);
            }
            scrollView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
            listView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight(), MeasureSpec.EXACTLY));
            emptyView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight(), MeasureSpec.EXACTLY));
            if (floatingButton != null) {
                int w = AndroidUtilities.dp(Build.VERSION.SDK_INT >= 21 ? 56 : 60);
                floatingButton.measure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY));
            }
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            scrollView.layout(0, 0, scrollView.getMeasuredWidth(), scrollView.getMeasuredHeight());
            listView.layout(0, scrollView.getMeasuredHeight(), listView.getMeasuredWidth(), scrollView.getMeasuredHeight() + listView.getMeasuredHeight());
            emptyView.layout(0, scrollView.getMeasuredHeight(), emptyView.getMeasuredWidth(), scrollView.getMeasuredHeight() + emptyView.getMeasuredHeight());
            if (floatingButton != null) {
                int l = LocaleController.isRTL ? AndroidUtilities.dp(14) : (right - left) - AndroidUtilities.dp(14) - floatingButton.getMeasuredWidth();
                int t = bottom - top - AndroidUtilities.dp(14) - floatingButton.getMeasuredHeight();
                floatingButton.layout(l, t, l + floatingButton.getMeasuredWidth(), t + floatingButton.getMeasuredHeight());
            }
        }

        @Override
        protected void dispatchDraw(Canvas canvas) {
            super.dispatchDraw(canvas);
            parentLayout.drawHeaderShadow(canvas, Math.min(maxSize, measuredContainerHeight + containerHeight - measuredContainerHeight));
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (child == listView) {
                canvas.save();
                canvas.clipRect(child.getLeft(), Math.min(maxSize, measuredContainerHeight + containerHeight - measuredContainerHeight), child.getRight(), child.getBottom());
                boolean result = super.drawChild(canvas, child, drawingTime);
                canvas.restore();
                return result;
            } else if (child == scrollView) {
                canvas.save();
                canvas.clipRect(child.getLeft(), child.getTop(), child.getRight(), Math.min(maxSize, measuredContainerHeight + containerHeight - measuredContainerHeight));
                boolean result = super.drawChild(canvas, child, drawingTime);
                canvas.restore();
                return result;
            } else {
                return super.drawChild(canvas, child, drawingTime);
            }
        }
    };
    ViewGroup frameLayout = (ViewGroup) fragmentView;
    frameLayout.setFocusableInTouchMode(true);
    frameLayout.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView = new ScrollView(context) {

        @Override
        public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
            if (ignoreScrollEvent) {
                ignoreScrollEvent = false;
                return false;
            }
            rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
            rectangle.top += fieldY + AndroidUtilities.dp(20);
            rectangle.bottom += fieldY + AndroidUtilities.dp(50);
            return super.requestChildRectangleOnScreen(child, rectangle, immediate);
        }
    };
    scrollView.setClipChildren(false);
    frameLayout.setClipChildren(false);
    scrollView.setVerticalScrollBarEnabled(false);
    AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_windowBackgroundWhite));
    frameLayout.addView(scrollView);
    spansContainer = new SpansContainer(context);
    scrollView.addView(spansContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    spansContainer.setOnClickListener(v -> {
        editText.clearFocus();
        editText.requestFocus();
        AndroidUtilities.showKeyboard(editText);
    });
    editText = new EditTextBoldCursor(context) {

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (currentDeletingSpan != null) {
                currentDeletingSpan.cancelDeleteAnimation();
                currentDeletingSpan = null;
            }
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (!AndroidUtilities.showKeyboard(this)) {
                    clearFocus();
                    requestFocus();
                }
            }
            return super.onTouchEvent(event);
        }
    };
    editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    editText.setHintColor(Theme.getColor(Theme.key_groupcreate_hintText));
    editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    editText.setCursorColor(Theme.getColor(Theme.key_groupcreate_cursor));
    editText.setCursorWidth(1.5f);
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    editText.setSingleLine(true);
    editText.setBackgroundDrawable(null);
    editText.setVerticalScrollBarEnabled(false);
    editText.setHorizontalScrollBarEnabled(false);
    editText.setTextIsSelectable(false);
    editText.setPadding(0, 0, 0, 0);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    editText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    spansContainer.addView(editText);
    updateEditTextHint();
    editText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {

        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }
    });
    editText.setOnEditorActionListener((v, actionId, event) -> actionId == EditorInfo.IME_ACTION_DONE && onDonePressed(true));
    editText.setOnKeyListener(new View.OnKeyListener() {

        private boolean wasEmpty;

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_DEL) {
                if (event.getAction() == KeyEvent.ACTION_DOWN) {
                    wasEmpty = editText.length() == 0;
                } else if (event.getAction() == KeyEvent.ACTION_UP && wasEmpty && !allSpans.isEmpty()) {
                    spansContainer.removeSpan(allSpans.get(allSpans.size() - 1));
                    updateHint();
                    checkVisibleRows();
                    return true;
                }
            }
            return false;
        }
    });
    editText.addTextChangedListener(new TextWatcher() {

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

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

        @Override
        public void afterTextChanged(Editable editable) {
            if (editText.length() != 0) {
                if (!adapter.searching) {
                    searching = true;
                    searchWas = true;
                    adapter.setSearching(true);
                    itemDecoration.setSearching(true);
                    listView.setFastScrollVisible(false);
                    listView.setVerticalScrollBarEnabled(true);
                }
                adapter.searchDialogs(editText.getText().toString());
                emptyView.showProgress(true, false);
            } else {
                closeSearch();
            }
        }
    });
    FlickerLoadingView flickerLoadingView = new FlickerLoadingView(context);
    flickerLoadingView.setViewType(FlickerLoadingView.USERS_TYPE);
    flickerLoadingView.showDate(false);
    emptyView = new StickerEmptyView(context, flickerLoadingView, StickerEmptyView.STICKER_TYPE_SEARCH);
    emptyView.addView(flickerLoadingView);
    emptyView.showProgress(true, false);
    emptyView.title.setText(LocaleController.getString("NoResult", R.string.NoResult));
    frameLayout.addView(emptyView);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
    listView = new RecyclerListView(context);
    listView.setFastScrollEnabled(RecyclerListView.FastScroll.LETTER_TYPE);
    listView.setEmptyView(emptyView);
    listView.setAdapter(adapter = new GroupCreateAdapter(context));
    listView.setLayoutManager(linearLayoutManager);
    listView.setVerticalScrollBarEnabled(false);
    listView.setVerticalScrollbarPosition(LocaleController.isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT);
    listView.addItemDecoration(itemDecoration = new GroupCreateDividerItemDecoration());
    frameLayout.addView(listView);
    listView.setOnItemClickListener((view, position) -> {
        if (position == 0 && adapter.inviteViaLink != 0 && !adapter.searching) {
            sharedLinkBottomSheet = new PermanentLinkBottomSheet(context, false, this, info, chatId, channelId != 0);
            showDialog(sharedLinkBottomSheet);
        } else if (view instanceof GroupCreateUserCell) {
            GroupCreateUserCell cell = (GroupCreateUserCell) view;
            Object object = cell.getObject();
            long id;
            if (object instanceof TLRPC.User) {
                id = ((TLRPC.User) object).id;
            } else if (object instanceof TLRPC.Chat) {
                id = -((TLRPC.Chat) object).id;
            } else {
                return;
            }
            if (ignoreUsers != null && ignoreUsers.indexOfKey(id) >= 0) {
                return;
            }
            boolean exists;
            if (exists = selectedContacts.indexOfKey(id) >= 0) {
                GroupCreateSpan span = selectedContacts.get(id);
                spansContainer.removeSpan(span);
            } else {
                if (maxCount != 0 && selectedContacts.size() == maxCount) {
                    return;
                }
                if (chatType == ChatObject.CHAT_TYPE_CHAT && selectedContacts.size() == getMessagesController().maxGroupCount) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                    builder.setMessage(LocaleController.getString("SoftUserLimitAlert", R.string.SoftUserLimitAlert));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                    showDialog(builder.create());
                    return;
                }
                if (object instanceof TLRPC.User) {
                    TLRPC.User user = (TLRPC.User) object;
                    if (addToGroup && user.bot) {
                        if (channelId == 0 && user.bot_nochats) {
                            try {
                                BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups)).show();
                            } catch (Exception e) {
                                FileLog.e(e);
                            }
                            return;
                        }
                        if (channelId != 0) {
                            TLRPC.Chat chat = getMessagesController().getChat(channelId);
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            if (ChatObject.canAddAdmins(chat)) {
                                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                                builder.setMessage(LocaleController.getString("AddBotAsAdmin", R.string.AddBotAsAdmin));
                                builder.setPositiveButton(LocaleController.getString("MakeAdmin", R.string.MakeAdmin), (dialogInterface, i) -> {
                                    delegate2.needAddBot(user);
                                    if (editText.length() > 0) {
                                        editText.setText(null);
                                    }
                                });
                                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                            } else {
                                builder.setMessage(LocaleController.getString("CantAddBotAsAdmin", R.string.CantAddBotAsAdmin));
                                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                            }
                            showDialog(builder.create());
                            return;
                        }
                    }
                    getMessagesController().putUser(user, !searching);
                } else {
                    TLRPC.Chat chat = (TLRPC.Chat) object;
                    getMessagesController().putChat(chat, !searching);
                }
                GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
                spansContainer.addSpan(span);
                span.setOnClickListener(GroupCreateActivity.this);
            }
            updateHint();
            if (searching || searchWas) {
                AndroidUtilities.showKeyboard(editText);
            } else {
                cell.setChecked(!exists, true);
            }
            if (editText.length() > 0) {
                editText.setText(null);
            }
        }
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                editText.hideActionMode();
                AndroidUtilities.hideKeyboard(editText);
            }
        }
    });
    listView.setAnimateEmptyView(true, 0);
    floatingButton = new ImageView(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 (isNeverShare || isAlwaysShare || addToGroup) {
        floatingButton.setImageResource(R.drawable.floating_check);
    } else {
        BackDrawable backDrawable = new BackDrawable(false);
        backDrawable.setArrowRotation(180);
        floatingButton.setImageDrawable(backDrawable);
    }
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, "translationZ", 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));
            }
        });
    }
    frameLayout.addView(floatingButton);
    floatingButton.setOnClickListener(v -> onDonePressed(true));
    if (chatType != ChatObject.CHAT_TYPE_CHANNEL) {
        floatingButton.setVisibility(View.INVISIBLE);
        floatingButton.setScaleX(0.0f);
        floatingButton.setScaleY(0.0f);
        floatingButton.setAlpha(0.0f);
    }
    floatingButton.setContentDescription(LocaleController.getString("Next", R.string.Next));
    updateHint();
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) ActionMode(android.view.ActionMode) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) AndroidUtilities(org.telegram.messenger.AndroidUtilities) Animator(android.animation.Animator) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) TypefaceSpan(org.telegram.ui.Components.TypefaceSpan) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) Keep(androidx.annotation.Keep) StateListAnimator(android.animation.StateListAnimator) TextCell(org.telegram.ui.Cells.TextCell) View(android.view.View) GroupCreateDividerItemDecoration(org.telegram.ui.Components.GroupCreateDividerItemDecoration) Canvas(android.graphics.Canvas) RecyclerView(androidx.recyclerview.widget.RecyclerView) VerticalPositionAutoAnimator(org.telegram.ui.Components.VerticalPositionAutoAnimator) ForegroundColorSpan(android.text.style.ForegroundColorSpan) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) Utilities(org.telegram.messenger.Utilities) GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan) GroupCreateUserCell(org.telegram.ui.Cells.GroupCreateUserCell) PermanentLinkBottomSheet(org.telegram.ui.Components.PermanentLinkBottomSheet) ObjectAnimator(android.animation.ObjectAnimator) InputType(android.text.InputType) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PorterDuff(android.graphics.PorterDuff) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ViewGroup(android.view.ViewGroup) NotificationCenter(org.telegram.messenger.NotificationCenter) Outline(android.graphics.Outline) SearchAdapterHelper(org.telegram.ui.Adapters.SearchAdapterHelper) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) EditorInfo(android.view.inputmethod.EditorInfo) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) TextWatcher(android.text.TextWatcher) Context(android.content.Context) Spanned(android.text.Spanned) KeyEvent(android.view.KeyEvent) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) BulletinFactory(org.telegram.ui.Components.BulletinFactory) LocaleController(org.telegram.messenger.LocaleController) GroupCreateSectionCell(org.telegram.ui.Cells.GroupCreateSectionCell) Editable(android.text.Editable) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) SpannableStringBuilder(android.text.SpannableStringBuilder) MotionEvent(android.view.MotionEvent) TLRPC(org.telegram.tgnet.TLRPC) ActionBar(org.telegram.ui.ActionBar.ActionBar) Menu(android.view.Menu) TLObject(org.telegram.tgnet.TLObject) AnimatorSet(android.animation.AnimatorSet) Build(android.os.Build) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) 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) UserObject(org.telegram.messenger.UserObject) TypedValue(android.util.TypedValue) ScrollView(android.widget.ScrollView) ContactsController(org.telegram.messenger.ContactsController) ViewTreeObserver(android.view.ViewTreeObserver) Comparator(java.util.Comparator) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Collections(java.util.Collections) RecyclerListView(org.telegram.ui.Components.RecyclerListView) SpannableStringBuilder(android.text.SpannableStringBuilder) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) VerticalPositionAutoAnimator(org.telegram.ui.Components.VerticalPositionAutoAnimator) ImageView(android.widget.ImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) ActionMode(android.view.ActionMode) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TLObject(org.telegram.tgnet.TLObject) DialogObject(org.telegram.messenger.DialogObject) UserObject(org.telegram.messenger.UserObject) ChatObject(org.telegram.messenger.ChatObject) GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan) StateListAnimator(android.animation.StateListAnimator) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) GroupCreateUserCell(org.telegram.ui.Cells.GroupCreateUserCell) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) KeyEvent(android.view.KeyEvent) PermanentLinkBottomSheet(org.telegram.ui.Components.PermanentLinkBottomSheet) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Menu(android.view.Menu) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) Outline(android.graphics.Outline) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) StickerEmptyView(org.telegram.ui.Components.StickerEmptyView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) ScrollView(android.widget.ScrollView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ViewOutlineProvider(android.view.ViewOutlineProvider) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) GroupCreateDividerItemDecoration(org.telegram.ui.Components.GroupCreateDividerItemDecoration) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 7 with GroupCreateSpan

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

the class FilterUsersActivity method onClick.

@Override
public void onClick(View v) {
    GroupCreateSpan span = (GroupCreateSpan) v;
    if (span.isDeleting()) {
        currentDeletingSpan = null;
        spansContainer.removeSpan(span);
        if (span.getUid() == Integer.MIN_VALUE) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
        } else if (span.getUid() == Integer.MIN_VALUE + 1) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
        } else if (span.getUid() == Integer.MIN_VALUE + 2) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_GROUPS;
        } else if (span.getUid() == Integer.MIN_VALUE + 3) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
        } else if (span.getUid() == Integer.MIN_VALUE + 4) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_BOTS;
        } else if (span.getUid() == Integer.MIN_VALUE + 5) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
        } else if (span.getUid() == Integer.MIN_VALUE + 6) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
        } else if (span.getUid() == Integer.MIN_VALUE + 7) {
            filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
        }
        updateHint();
        checkVisibleRows();
    } else {
        if (currentDeletingSpan != null) {
            currentDeletingSpan.cancelDeleteAnimation();
        }
        currentDeletingSpan = span;
        span.startDeleteAnimation();
    }
}
Also used : GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan)

Aggregations

GroupCreateSpan (org.telegram.ui.Components.GroupCreateSpan)7 View (android.view.View)4 ScrollView (android.widget.ScrollView)4 RecyclerListView (org.telegram.ui.Components.RecyclerListView)4 Canvas (android.graphics.Canvas)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 Rect (android.graphics.Rect)3 Drawable (android.graphics.drawable.Drawable)3 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 ActionMode (android.view.ActionMode)3 ImageView (android.widget.ImageView)3 CombinedDrawable (org.telegram.ui.Components.CombinedDrawable)3 StateListAnimator (android.animation.StateListAnimator)2 SuppressLint (android.annotation.SuppressLint)2 Outline (android.graphics.Outline)2 KeyEvent (android.view.KeyEvent)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2 MotionEvent (android.view.MotionEvent)2