Search in sources :

Example 1 with GroupCreateSpan

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

the class GroupCreateActivity method onClick.

@Override
public void onClick(View v) {
    GroupCreateSpan span = (GroupCreateSpan) v;
    if (span.isDeleting()) {
        currentDeletingSpan = null;
        spansContainer.removeSpan(span);
        updateHint();
        checkVisibleRows();
    } else {
        if (currentDeletingSpan != null) {
            currentDeletingSpan.cancelDeleteAnimation();
        }
        currentDeletingSpan = span;
        span.startDeleteAnimation();
    }
}
Also used : GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan)

Example 2 with GroupCreateSpan

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

the class InviteContactsActivity method createView.

@Override
public View createView(Context context) {
    searching = false;
    searchWas = false;
    allSpans.clear();
    selectedContacts.clear();
    currentDeletingSpan = null;
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("InviteFriends", R.string.InviteFriends));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

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

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            int height = MeasureSpec.getSize(heightMeasureSpec);
            setMeasuredDimension(width, height);
            int maxSize;
            if (AndroidUtilities.isTablet() || height > width) {
                maxSize = AndroidUtilities.dp(144);
            } else {
                maxSize = AndroidUtilities.dp(56);
            }
            int h;
            infoTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
            counterView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
            if (infoTextView.getVisibility() == VISIBLE) {
                h = infoTextView.getMeasuredHeight();
            } else {
                h = counterView.getMeasuredHeight();
            }
            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() - h, MeasureSpec.EXACTLY));
            emptyView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight() - AndroidUtilities.dp(72), 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() + AndroidUtilities.dp(72), emptyView.getMeasuredWidth(), scrollView.getMeasuredHeight() + emptyView.getMeasuredHeight());
            int y = bottom - top - infoTextView.getMeasuredHeight();
            infoTextView.layout(0, y, infoTextView.getMeasuredWidth(), y + infoTextView.getMeasuredHeight());
            y = bottom - top - counterView.getMeasuredHeight();
            counterView.layout(0, y, counterView.getMeasuredWidth(), y + counterView.getMeasuredHeight());
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (child == listView || child == emptyView) {
                parentLayout.drawHeaderShadow(canvas, scrollView.getMeasuredHeight());
            }
            return result;
        }
    };
    ViewGroup frameLayout = (ViewGroup) fragmentView;
    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.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));
    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, 18);
    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);
    editText.setHintText(LocaleController.getString("SearchFriends", R.string.SearchFriends));
    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(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                return actionId == EditorInfo.IME_ACTION_DONE && onDonePressed();
            }
        });*/
    editText.setOnKeyListener(new View.OnKeyListener() {

        private boolean wasEmpty;

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            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) {
                searching = true;
                searchWas = true;
                adapter.setSearching(true);
                adapter.searchDialogs(editText.getText().toString());
                listView.setFastScrollVisible(false);
                listView.setVerticalScrollBarEnabled(true);
                emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
            } else {
                closeSearch();
            }
        }
    });
    emptyView = new EmptyTextProgressView(context);
    if (ContactsController.getInstance(currentAccount).isLoadingContacts()) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }
    emptyView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
    frameLayout.addView(emptyView);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
    listView = new RecyclerListView(context);
    listView.setEmptyView(emptyView);
    listView.setAdapter(adapter = new InviteAdapter(context));
    listView.setLayoutManager(linearLayoutManager);
    listView.setVerticalScrollBarEnabled(true);
    listView.setVerticalScrollbarPosition(LocaleController.isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT);
    listView.addItemDecoration(decoration = new GroupCreateDividerItemDecoration());
    frameLayout.addView(listView);
    listView.setOnItemClickListener((view, position) -> {
        if (position == 0 && !searching) {
            try {
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/plain");
                String text = ContactsController.getInstance(currentAccount).getInviteText(0);
                intent.putExtra(Intent.EXTRA_TEXT, text);
                getParentActivity().startActivityForResult(Intent.createChooser(intent, text), 500);
            } catch (Exception e) {
                FileLog.e(e);
            }
            return;
        }
        if (!(view instanceof InviteUserCell)) {
            return;
        }
        InviteUserCell cell = (InviteUserCell) view;
        ContactsController.Contact contact = cell.getContact();
        if (contact == null) {
            return;
        }
        boolean exists;
        if (exists = selectedContacts.containsKey(contact.key)) {
            GroupCreateSpan span = selectedContacts.get(contact.key);
            spansContainer.removeSpan(span);
        } else {
            GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), contact);
            spansContainer.addSpan(span);
            span.setOnClickListener(InviteContactsActivity.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) {
                AndroidUtilities.hideKeyboard(editText);
            }
        }
    });
    infoTextView = new TextView(context);
    infoTextView.setBackgroundColor(Theme.getColor(Theme.key_contacts_inviteBackground));
    infoTextView.setTextColor(Theme.getColor(Theme.key_contacts_inviteText));
    infoTextView.setGravity(Gravity.CENTER);
    infoTextView.setText(LocaleController.getString("InviteFriendsHelp", R.string.InviteFriendsHelp));
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    infoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    infoTextView.setPadding(AndroidUtilities.dp(17), AndroidUtilities.dp(9), AndroidUtilities.dp(17), AndroidUtilities.dp(9));
    frameLayout.addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
    counterView = new FrameLayout(context);
    counterView.setBackgroundColor(Theme.getColor(Theme.key_contacts_inviteBackground));
    counterView.setVisibility(View.INVISIBLE);
    frameLayout.addView(counterView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
    counterView.setOnClickListener(v -> {
        try {
            StringBuilder builder = new StringBuilder();
            int num = 0;
            for (int a = 0; a < allSpans.size(); a++) {
                ContactsController.Contact contact = allSpans.get(a).getContact();
                if (builder.length() != 0) {
                    builder.append(';');
                }
                builder.append(contact.phones.get(0));
                if (a == 0 && allSpans.size() == 1) {
                    num = contact.imported;
                }
            }
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + builder.toString()));
            intent.putExtra("sms_body", ContactsController.getInstance(currentAccount).getInviteText(num));
            getParentActivity().startActivityForResult(intent, 500);
        } catch (Exception e) {
            FileLog.e(e);
        }
        finishFragment();
    });
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    counterView.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER));
    counterTextView = new TextView(context);
    counterTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    counterTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    counterTextView.setTextColor(Theme.getColor(Theme.key_contacts_inviteBackground));
    counterTextView.setGravity(Gravity.CENTER);
    counterTextView.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(10), Theme.getColor(Theme.key_contacts_inviteText)));
    counterTextView.setMinWidth(AndroidUtilities.dp(20));
    counterTextView.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), AndroidUtilities.dp(1));
    linearLayout.addView(counterTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 20, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));
    textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setTextColor(Theme.getColor(Theme.key_contacts_inviteText));
    textView.setGravity(Gravity.CENTER);
    textView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    textView.setText(LocaleController.getString("InviteToTelegram", R.string.InviteToTelegram).toUpperCase());
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
    updateHint();
    adapter.notifyDataSetChanged();
    return fragmentView;
}
Also used : ContactsController(org.telegram.messenger.ContactsController) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) RecyclerListView(org.telegram.ui.Components.RecyclerListView) KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) Menu(android.view.Menu) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ActionBar(org.telegram.ui.ActionBar.ActionBar) Rect(android.graphics.Rect) InviteUserCell(org.telegram.ui.Cells.InviteUserCell) ViewGroup(android.view.ViewGroup) Canvas(android.graphics.Canvas) MenuItem(android.view.MenuItem) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) Intent(android.content.Intent) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) MotionEvent(android.view.MotionEvent) GroupCreateDividerItemDecoration(org.telegram.ui.Components.GroupCreateDividerItemDecoration) ScrollView(android.widget.ScrollView) ActionMode(android.view.ActionMode) FrameLayout(android.widget.FrameLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout) GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan)

Example 3 with GroupCreateSpan

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

the class InviteContactsActivity method onClick.

@Override
public void onClick(View v) {
    GroupCreateSpan span = (GroupCreateSpan) v;
    if (span.isDeleting()) {
        currentDeletingSpan = null;
        spansContainer.removeSpan(span);
        updateHint();
        checkVisibleRows();
    } else {
        if (currentDeletingSpan != null) {
            currentDeletingSpan.cancelDeleteAnimation();
        }
        currentDeletingSpan = span;
        span.startDeleteAnimation();
    }
}
Also used : GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan)

Example 4 with GroupCreateSpan

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

the class FilterUsersActivity method createView.

@Override
public View createView(Context context) {
    searching = false;
    searchWas = false;
    allSpans.clear();
    selectedContacts.clear();
    currentDeletingSpan = null;
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (isInclude) {
        actionBar.setTitle(LocaleController.getString("FilterAlwaysShow", R.string.FilterAlwaysShow));
    } else {
        actionBar.setTitle(LocaleController.getString("FilterNeverShow", R.string.FilterNeverShow));
    }
    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) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            int height = MeasureSpec.getSize(heightMeasureSpec);
            setMeasuredDimension(width, height);
            int maxSize;
            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 boolean drawChild(Canvas canvas, View child, long drawingTime) {
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (child == listView || child == emptyView) {
                parentLayout.drawHeaderShadow(canvas, scrollView.getMeasuredHeight());
            }
            return result;
        }
    };
    ViewGroup frameLayout = (ViewGroup) fragmentView;
    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.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);
    editText.setHintText(LocaleController.getString("SearchForPeopleAndGroups", R.string.SearchForPeopleAndGroups));
    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()) {
                    GroupCreateSpan span = allSpans.get(allSpans.size() - 1);
                    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();
                    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);
                    listView.setFastScrollVisible(false);
                    listView.setVerticalScrollBarEnabled(true);
                    emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
                    emptyView.showProgress();
                }
                adapter.searchDialogs(editText.getText().toString());
            } else {
                closeSearch();
            }
        }
    });
    emptyView = new EmptyTextProgressView(context);
    if (ContactsController.getInstance(currentAccount).isLoadingContacts()) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }
    emptyView.setShowAtCenter(true);
    emptyView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
    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(new ItemDecoration());
    frameLayout.addView(listView);
    listView.setOnItemClickListener((view, position) -> {
        if (view instanceof GroupCreateUserCell) {
            GroupCreateUserCell cell = (GroupCreateUserCell) view;
            Object object = cell.getObject();
            long id;
            if (object instanceof String) {
                int flag;
                if (isInclude) {
                    if (position == 1) {
                        flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
                        id = Integer.MIN_VALUE;
                    } else if (position == 2) {
                        flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
                        id = Integer.MIN_VALUE + 1;
                    } else if (position == 3) {
                        flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
                        id = Integer.MIN_VALUE + 2;
                    } else if (position == 4) {
                        flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
                        id = Integer.MIN_VALUE + 3;
                    } else {
                        flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
                        id = Integer.MIN_VALUE + 4;
                    }
                } else {
                    if (position == 1) {
                        flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
                        id = Integer.MIN_VALUE + 5;
                    } else if (position == 2) {
                        flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
                        id = Integer.MIN_VALUE + 6;
                    } else {
                        flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
                        id = Integer.MIN_VALUE + 7;
                    }
                }
                if (cell.isChecked()) {
                    filterFlags &= ~flag;
                } else {
                    filterFlags |= flag;
                }
            } else {
                if (object instanceof TLRPC.User) {
                    id = ((TLRPC.User) object).id;
                } else if (object instanceof TLRPC.Chat) {
                    id = -((TLRPC.Chat) object).id;
                } else {
                    return;
                }
            }
            boolean exists;
            if (exists = selectedContacts.indexOfKey(id) >= 0) {
                GroupCreateSpan span = selectedContacts.get(id);
                spansContainer.removeSpan(span);
            } else {
                if (!(object instanceof String) && selectedCount >= 100) {
                    return;
                }
                if (object instanceof TLRPC.User) {
                    TLRPC.User user = (TLRPC.User) object;
                    MessagesController.getInstance(currentAccount).putUser(user, !searching);
                } else if (object instanceof TLRPC.Chat) {
                    TLRPC.Chat chat = (TLRPC.Chat) object;
                    MessagesController.getInstance(currentAccount).putChat(chat, !searching);
                }
                GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
                spansContainer.addSpan(span, true);
                span.setOnClickListener(FilterUsersActivity.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) {
                AndroidUtilities.hideKeyboard(editText);
            }
        }
    });
    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));
    floatingButton.setImageResource(R.drawable.floating_check);
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        floatingButton.setStateListAnimator(animator);
        floatingButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }
    frameLayout.addView(floatingButton);
    floatingButton.setOnClickListener(v -> onDonePressed(true));
    /*floatingButton.setVisibility(View.INVISIBLE);
        floatingButton.setScaleX(0.0f);
        floatingButton.setScaleY(0.0f);
        floatingButton.setAlpha(0.0f);*/
    floatingButton.setContentDescription(LocaleController.getString("Next", R.string.Next));
    for (int position = 1, N = (isInclude ? 5 : 3); position <= N; position++) {
        int id;
        int flag;
        Object object;
        if (isInclude) {
            if (position == 1) {
                object = "contacts";
                flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
            } else if (position == 2) {
                object = "non_contacts";
                flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
            } else if (position == 3) {
                object = "groups";
                flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
            } else if (position == 4) {
                object = "channels";
                flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
            } else {
                object = "bots";
                flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
            }
        } else {
            if (position == 1) {
                object = "muted";
                flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
            } else if (position == 2) {
                object = "read";
                flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
            } else {
                object = "archived";
                flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
            }
        }
        if ((filterFlags & flag) != 0) {
            GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
            spansContainer.addSpan(span, false);
            span.setOnClickListener(FilterUsersActivity.this);
        }
    }
    if (initialIds != null && !initialIds.isEmpty()) {
        TLObject object;
        for (int a = 0, N = initialIds.size(); a < N; a++) {
            Long id = initialIds.get(a);
            if (id > 0) {
                object = getMessagesController().getUser(id);
            } else {
                object = getMessagesController().getChat(-id);
            }
            if (object == null) {
                continue;
            }
            GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
            spansContainer.addSpan(span, false);
            span.setOnClickListener(FilterUsersActivity.this);
        }
    }
    updateHint();
    return fragmentView;
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) 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) 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) GroupCreateSpan(org.telegram.ui.Components.GroupCreateSpan) StateListAnimator(android.animation.StateListAnimator) GroupCreateUserCell(org.telegram.ui.Cells.GroupCreateUserCell) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Menu(android.view.Menu) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) Outline(android.graphics.Outline) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) ScrollView(android.widget.ScrollView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ViewOutlineProvider(android.view.ViewOutlineProvider) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) ScrollView(android.widget.ScrollView) TLObject(org.telegram.tgnet.TLObject) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 5 with GroupCreateSpan

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

the class ThemeDescription method processViewColor.

private void processViewColor(View child, int color) {
    for (int b = 0; b < listClasses.length; b++) {
        if (listClasses[b].isInstance(child)) {
            child.invalidate();
            boolean passedCheck;
            if ((changeFlags & FLAG_CHECKTAG) == 0 || checkTag(currentKey, child)) {
                passedCheck = true;
                child.invalidate();
                if (listClassesFieldName == null && (changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                    Drawable drawable = child.getBackground();
                    if (drawable != null) {
                        if ((changeFlags & FLAG_CELLBACKGROUNDCOLOR) != 0) {
                            if (drawable instanceof CombinedDrawable) {
                                Drawable back = ((CombinedDrawable) drawable).getBackground();
                                if (back instanceof ColorDrawable) {
                                    ((ColorDrawable) back).setColor(color);
                                }
                            }
                        } else {
                            if (drawable instanceof CombinedDrawable) {
                                drawable = ((CombinedDrawable) drawable).getIcon();
                            } else if (drawable instanceof StateListDrawable || Build.VERSION.SDK_INT >= 21 && drawable instanceof RippleDrawable) {
                                Theme.setSelectorDrawableColor(drawable, color, (changeFlags & FLAG_DRAWABLESELECTEDSTATE) != 0);
                            }
                            drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                        }
                    }
                } else if ((changeFlags & FLAG_CELLBACKGROUNDCOLOR) != 0) {
                    child.setBackgroundColor(color);
                } else if ((changeFlags & FLAG_TEXTCOLOR) != 0) {
                    if (child instanceof TextView) {
                        ((TextView) child).setTextColor(color);
                    } else if (child instanceof AudioPlayerAlert.ClippingTextViewSwitcher) {
                        for (int i = 0; i < 2; i++) {
                            TextView textView = i == 0 ? ((AudioPlayerAlert.ClippingTextViewSwitcher) child).getTextView() : ((AudioPlayerAlert.ClippingTextViewSwitcher) child).getNextTextView();
                            if (textView != null) {
                                textView.setTextColor(color);
                            }
                        }
                    }
                } else if ((changeFlags & FLAG_SERVICEBACKGROUND) != 0) {
                } else if ((changeFlags & FLAG_SELECTOR) != 0) {
                    child.setBackgroundDrawable(Theme.getSelectorDrawable(false));
                } else if ((changeFlags & FLAG_SELECTORWHITE) != 0) {
                    child.setBackgroundDrawable(Theme.getSelectorDrawable(true));
                }
            } else {
                passedCheck = false;
            }
            if (listClassesFieldName != null) {
                String key = listClasses[b] + "_" + listClassesFieldName[b];
                if (notFoundCachedFields != null && notFoundCachedFields.containsKey(key)) {
                    continue;
                }
                try {
                    Field field = cachedFields.get(key);
                    if (field == null) {
                        field = listClasses[b].getDeclaredField(listClassesFieldName[b]);
                        if (field != null) {
                            field.setAccessible(true);
                            cachedFields.put(key, field);
                        }
                    }
                    if (field != null) {
                        Object object = field.get(child);
                        if (object != null) {
                            if (!passedCheck && object instanceof View && !checkTag(currentKey, (View) object)) {
                                continue;
                            }
                            if (object instanceof View) {
                                ((View) object).invalidate();
                            }
                            if (lottieLayerName != null && object instanceof RLottieImageView) {
                                ((RLottieImageView) object).setLayerColor(lottieLayerName + ".**", color);
                            }
                            if ((changeFlags & FLAG_USEBACKGROUNDDRAWABLE) != 0 && object instanceof View) {
                                object = ((View) object).getBackground();
                            }
                            if ((changeFlags & FLAG_BACKGROUND) != 0 && object instanceof View) {
                                View view = (View) object;
                                Drawable background = view.getBackground();
                                if (background instanceof MessageBackgroundDrawable) {
                                    ((MessageBackgroundDrawable) background).setColor(color);
                                    ((MessageBackgroundDrawable) background).setCustomPaint(null);
                                } else {
                                    view.setBackgroundColor(color);
                                }
                            } else if (object instanceof EditTextCaption) {
                                if ((changeFlags & FLAG_HINTTEXTCOLOR) != 0) {
                                    ((EditTextCaption) object).setHintColor(color);
                                    ((EditTextCaption) object).setHintTextColor(color);
                                } else if ((changeFlags & FLAG_CURSORCOLOR) != 0) {
                                    ((EditTextCaption) object).setCursorColor(color);
                                } else {
                                    ((EditTextCaption) object).setTextColor(color);
                                }
                            } else if (object instanceof SimpleTextView) {
                                if ((changeFlags & FLAG_LINKCOLOR) != 0) {
                                    ((SimpleTextView) object).setLinkTextColor(color);
                                } else {
                                    ((SimpleTextView) object).setTextColor(color);
                                }
                            } else if (object instanceof TextView) {
                                TextView textView = (TextView) object;
                                if ((changeFlags & FLAG_IMAGECOLOR) != 0) {
                                    Drawable[] drawables = textView.getCompoundDrawables();
                                    if (drawables != null) {
                                        for (int a = 0; a < drawables.length; a++) {
                                            if (drawables[a] != null) {
                                                drawables[a].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                            }
                                        }
                                    }
                                } else if ((changeFlags & FLAG_LINKCOLOR) != 0) {
                                    textView.getPaint().linkColor = color;
                                    textView.invalidate();
                                } else if ((changeFlags & FLAG_FASTSCROLL) != 0) {
                                    CharSequence text = textView.getText();
                                    if (text instanceof SpannedString) {
                                        TypefaceSpan[] spans = ((SpannedString) text).getSpans(0, text.length(), TypefaceSpan.class);
                                        if (spans != null && spans.length > 0) {
                                            for (int i = 0; i < spans.length; i++) {
                                                spans[i].setColor(color);
                                            }
                                        }
                                    }
                                } else {
                                    textView.setTextColor(color);
                                }
                            } else if (object instanceof ImageView) {
                                ImageView imageView = (ImageView) object;
                                Drawable drawable = imageView.getDrawable();
                                if (drawable instanceof CombinedDrawable) {
                                    if ((changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                                        ((CombinedDrawable) drawable).getBackground().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                    } else {
                                        ((CombinedDrawable) drawable).getIcon().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                    }
                                } else {
                                    imageView.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                }
                            } else if (object instanceof BackupImageView) {
                                Drawable drawable = ((BackupImageView) object).getImageReceiver().getStaticThumb();
                                if (drawable instanceof CombinedDrawable) {
                                    if ((changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                                        ((CombinedDrawable) drawable).getBackground().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                    } else {
                                        ((CombinedDrawable) drawable).getIcon().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                    }
                                } else if (drawable != null) {
                                    drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                }
                            } else if (object instanceof Drawable) {
                                if (object instanceof LetterDrawable) {
                                    if ((changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                                        ((LetterDrawable) object).setBackgroundColor(color);
                                    } else {
                                        ((LetterDrawable) object).setColor(color);
                                    }
                                } else if (object instanceof CombinedDrawable) {
                                    if ((changeFlags & FLAG_BACKGROUNDFILTER) != 0) {
                                        ((CombinedDrawable) object).getBackground().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                    } else {
                                        ((CombinedDrawable) object).getIcon().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                    }
                                } else if (object instanceof StateListDrawable || Build.VERSION.SDK_INT >= 21 && object instanceof RippleDrawable) {
                                    Theme.setSelectorDrawableColor((Drawable) object, color, (changeFlags & FLAG_DRAWABLESELECTEDSTATE) != 0);
                                } else if (object instanceof GradientDrawable) {
                                    ((GradientDrawable) object).setColor(color);
                                } else {
                                    ((Drawable) object).setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
                                }
                            } else if (object instanceof CheckBox) {
                                if ((changeFlags & FLAG_CHECKBOX) != 0) {
                                    ((CheckBox) object).setBackgroundColor(color);
                                } else if ((changeFlags & FLAG_CHECKBOXCHECK) != 0) {
                                    ((CheckBox) object).setCheckColor(color);
                                }
                            } else if (object instanceof GroupCreateCheckBox) {
                                ((GroupCreateCheckBox) object).updateColors();
                            } else if (object instanceof Integer) {
                                field.set(child, color);
                            } else if (object instanceof RadioButton) {
                                if ((changeFlags & FLAG_CHECKBOX) != 0) {
                                    ((RadioButton) object).setBackgroundColor(color);
                                    ((RadioButton) object).invalidate();
                                } else if ((changeFlags & FLAG_CHECKBOXCHECK) != 0) {
                                    ((RadioButton) object).setCheckedColor(color);
                                    ((RadioButton) object).invalidate();
                                }
                            } else if (object instanceof TextPaint) {
                                if ((changeFlags & FLAG_LINKCOLOR) != 0) {
                                    ((TextPaint) object).linkColor = color;
                                } else {
                                    ((TextPaint) object).setColor(color);
                                }
                            } else if (object instanceof LineProgressView) {
                                if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
                                    ((LineProgressView) object).setProgressColor(color);
                                } else {
                                    ((LineProgressView) object).setBackColor(color);
                                }
                            } else if (object instanceof RadialProgressView) {
                                ((RadialProgressView) object).setProgressColor(color);
                            } else if (object instanceof Paint) {
                                ((Paint) object).setColor(color);
                                child.invalidate();
                            } else if (object instanceof SeekBarView) {
                                if ((changeFlags & FLAG_PROGRESSBAR) != 0) {
                                    ((SeekBarView) object).setOuterColor(color);
                                } else {
                                    ((SeekBarView) object).setInnerColor(color);
                                }
                            } else if (object instanceof AudioPlayerAlert.ClippingTextViewSwitcher) {
                                if ((changeFlags & FLAG_FASTSCROLL) != 0) {
                                    for (int k = 0; k < 2; k++) {
                                        TextView textView = k == 0 ? ((AudioPlayerAlert.ClippingTextViewSwitcher) object).getTextView() : ((AudioPlayerAlert.ClippingTextViewSwitcher) object).getNextTextView();
                                        if (textView != null) {
                                            CharSequence text = textView.getText();
                                            if (text instanceof SpannedString) {
                                                TypefaceSpan[] spans = ((SpannedString) text).getSpans(0, text.length(), TypefaceSpan.class);
                                                if (spans != null && spans.length > 0) {
                                                    for (int i = 0; i < spans.length; i++) {
                                                        spans[i].setColor(color);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                } else if ((changeFlags & FLAG_TEXTCOLOR) != 0) {
                                    if ((changeFlags & FLAG_CHECKTAG) == 0 || checkTag(currentKey, (View) object)) {
                                        for (int i = 0; i < 2; i++) {
                                            TextView textView = i == 0 ? ((AudioPlayerAlert.ClippingTextViewSwitcher) object).getTextView() : ((AudioPlayerAlert.ClippingTextViewSwitcher) object).getNextTextView();
                                            if (textView != null) {
                                                textView.setTextColor(color);
                                                CharSequence text = textView.getText();
                                                if (text instanceof SpannedString) {
                                                    TypefaceSpan[] spans = ((SpannedString) text).getSpans(0, text.length(), TypefaceSpan.class);
                                                    if (spans != null && spans.length > 0) {
                                                        for (int spanIdx = 0; spanIdx < spans.length; spanIdx++) {
                                                            spans[spanIdx].setColor(color);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                } catch (Throwable e) {
                    FileLog.e(e);
                    notFoundCachedFields.put(key, true);
                }
            } else if (child instanceof GroupCreateSpan) {
                ((GroupCreateSpan) child).updateColors();
            }
        }
    }
}
Also used : SpannedString(android.text.SpannedString) RLottieImageView(org.telegram.ui.Components.RLottieImageView) AudioPlayerAlert(org.telegram.ui.Components.AudioPlayerAlert) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) SpannedString(android.text.SpannedString) StateListDrawable(android.graphics.drawable.StateListDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) Field(java.lang.reflect.Field) BackupImageView(org.telegram.ui.Components.BackupImageView) GroupCreateCheckBox(org.telegram.ui.Components.GroupCreateCheckBox) TextView(android.widget.TextView) NumberTextView(org.telegram.ui.Components.NumberTextView) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) EditTextCaption(org.telegram.ui.Components.EditTextCaption) AnimatedArrowDrawable(org.telegram.ui.Components.AnimatedArrowDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) LetterDrawable(org.telegram.ui.Components.LetterDrawable) ScamDrawable(org.telegram.ui.Components.ScamDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) RadioButton(org.telegram.ui.Components.RadioButton) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) View(android.view.View) ContextProgressView(org.telegram.ui.Components.ContextProgressView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) VideoTimelineView(org.telegram.ui.Components.VideoTimelineView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) SeekBarView(org.telegram.ui.Components.SeekBarView) BackupImageView(org.telegram.ui.Components.BackupImageView) LineProgressView(org.telegram.ui.Components.LineProgressView) NumberTextView(org.telegram.ui.Components.NumberTextView) ScrollView(android.widget.ScrollView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) SeekBarView(org.telegram.ui.Components.SeekBarView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) GradientDrawable(android.graphics.drawable.GradientDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) TextPaint(android.text.TextPaint) ColorDrawable(android.graphics.drawable.ColorDrawable) CheckBox(org.telegram.ui.Components.CheckBox) GroupCreateCheckBox(org.telegram.ui.Components.GroupCreateCheckBox) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) LetterDrawable(org.telegram.ui.Components.LetterDrawable) LineProgressView(org.telegram.ui.Components.LineProgressView) TypefaceSpan(org.telegram.ui.Components.TypefaceSpan) 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