Search in sources :

Example 1 with FilteredSearchView

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

the class SearchViewPager method getThemeDescriptors.

public void getThemeDescriptors(ArrayList<ThemeDescription> arrayList) {
    for (int i = 0; i < getChildCount(); i++) {
        if (getChildAt(i) instanceof FilteredSearchView) {
            arrayList.addAll(((FilteredSearchView) getChildAt(i)).getThemeDescriptions());
        }
    }
    int n = viewsByType.size();
    for (int i = 0; i < n; i++) {
        View v = viewsByType.valueAt(i);
        if (v instanceof FilteredSearchView) {
            arrayList.addAll(((FilteredSearchView) v).getThemeDescriptions());
        }
    }
    if (noMediaFiltersSearchView != null) {
        arrayList.addAll(noMediaFiltersSearchView.getThemeDescriptions());
    }
    arrayList.add(new ThemeDescription(emptyView.title, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
    arrayList.add(new ThemeDescription(emptyView.subtitle, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
}
Also used : FilteredSearchView(org.telegram.ui.FilteredSearchView) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) FiltersView(org.telegram.ui.Adapters.FiltersView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FilteredSearchView(org.telegram.ui.FilteredSearchView)

Example 2 with FilteredSearchView

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

the class SearchViewPager method showActionMode.

private void showActionMode(boolean show) {
    if (isActionModeShowed == show) {
        return;
    }
    if (show && parent.getActionBar().isActionModeShowed()) {
        return;
    }
    if (show && !parent.getActionBar().actionModeIsExist(actionModeTag)) {
        ActionBarMenu actionMode = parent.getActionBar().createActionMode(true, actionModeTag);
        selectedMessagesCountTextView = new NumberTextView(actionMode.getContext());
        selectedMessagesCountTextView.setTextSize(18);
        selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        selectedMessagesCountTextView.setTextColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon));
        actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0));
        selectedMessagesCountTextView.setOnTouchListener((v, event) -> true);
        gotoItem = actionMode.addItemWithWidth(gotoItemId, R.drawable.msg_message, AndroidUtilities.dp(54), LocaleController.getString("AccDescrGoToMessage", R.string.AccDescrGoToMessage));
        forwardItem = actionMode.addItemWithWidth(forwardItemId, R.drawable.msg_forward, AndroidUtilities.dp(54), LocaleController.getString("Forward", R.string.Forward));
    }
    if (parent.getActionBar().getBackButton().getDrawable() instanceof MenuDrawable) {
        parent.getActionBar().setBackButtonDrawable(new BackDrawable(false));
    }
    isActionModeShowed = show;
    if (show) {
        AndroidUtilities.hideKeyboard(parent.getParentActivity().getCurrentFocus());
        parent.getActionBar().showActionMode();
        selectedMessagesCountTextView.setNumber(selectedFiles.size(), false);
        gotoItem.setVisibility(View.VISIBLE);
        forwardItem.setVisibility(View.VISIBLE);
    } else {
        parent.getActionBar().hideActionMode();
        selectedFiles.clear();
        for (int i = 0; i < getChildCount(); i++) {
            if (getChildAt(i) instanceof FilteredSearchView) {
                ((FilteredSearchView) getChildAt(i)).update();
            }
        }
        if (noMediaFiltersSearchView != null) {
            noMediaFiltersSearchView.update();
        }
        int n = viewsByType.size();
        for (int i = 0; i < n; i++) {
            View v = viewsByType.valueAt(i);
            if (v instanceof FilteredSearchView) {
                ((FilteredSearchView) v).update();
            }
        }
    }
}
Also used : FilteredSearchView(org.telegram.ui.FilteredSearchView) MenuDrawable(org.telegram.ui.ActionBar.MenuDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) FiltersView(org.telegram.ui.Adapters.FiltersView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FilteredSearchView(org.telegram.ui.FilteredSearchView)

Example 3 with FilteredSearchView

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

the class SearchViewPager method search.

private void search(View view, int position, String query, boolean reset) {
    long dialogId = 0;
    long minDate = 0;
    long maxDate = 0;
    boolean includeFolder = false;
    for (int i = 0; i < currentSearchFilters.size(); i++) {
        FiltersView.MediaFilterData data = currentSearchFilters.get(i);
        if (data.filterType == FiltersView.FILTER_TYPE_CHAT) {
            if (data.chat instanceof TLRPC.User) {
                dialogId = ((TLRPC.User) data.chat).id;
            } else if (data.chat instanceof TLRPC.Chat) {
                dialogId = -((TLRPC.Chat) data.chat).id;
            }
        } else if (data.filterType == FiltersView.FILTER_TYPE_DATE) {
            minDate = data.dateData.minDate;
            maxDate = data.dateData.maxDate;
        } else if (data.filterType == FiltersView.FILTER_TYPE_ARCHIVE) {
            includeFolder = true;
        }
    }
    if (view == searchContainer) {
        if (dialogId == 0 && minDate == 0 && maxDate == 0) {
            lastSearchScrolledToTop = false;
            dialogsSearchAdapter.searchDialogs(query, includeFolder ? 1 : 0);
            dialogsSearchAdapter.setFiltersDelegate(filteredSearchViewDelegate, false);
            noMediaFiltersSearchView.animate().setListener(null).cancel();
            noMediaFiltersSearchView.setDelegate(null, false);
            if (reset) {
                emptyView.showProgress(!dialogsSearchAdapter.isSearching(), false);
                emptyView.showProgress(dialogsSearchAdapter.isSearching(), false);
            } else {
                if (!dialogsSearchAdapter.hasRecentSearch()) {
                    emptyView.showProgress(dialogsSearchAdapter.isSearching(), true);
                }
            }
            if (reset) {
                noMediaFiltersSearchView.setVisibility(View.GONE);
            } else {
                if (noMediaFiltersSearchView.getVisibility() != View.GONE) {
                    noMediaFiltersSearchView.animate().alpha(0).setListener(new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            noMediaFiltersSearchView.setVisibility(View.GONE);
                        }
                    }).setDuration(150).start();
                }
            }
            noMediaFiltersSearchView.setTag(null);
        } else {
            noMediaFiltersSearchView.setTag(1);
            noMediaFiltersSearchView.setDelegate(filteredSearchViewDelegate, false);
            noMediaFiltersSearchView.animate().setListener(null).cancel();
            if (reset) {
                noMediaFiltersSearchView.setVisibility(View.VISIBLE);
                noMediaFiltersSearchView.setAlpha(1f);
            } else {
                if (noMediaFiltersSearchView.getVisibility() != View.VISIBLE) {
                    noMediaFiltersSearchView.setVisibility(View.VISIBLE);
                    noMediaFiltersSearchView.setAlpha(0f);
                    reset = true;
                }
                noMediaFiltersSearchView.animate().alpha(1f).setDuration(150).start();
            }
            noMediaFiltersSearchView.search(dialogId, minDate, maxDate, null, includeFolder, query, reset);
            emptyView.setVisibility(View.GONE);
        }
        emptyView.setKeyboardHeight(keyboardSize, false);
        noMediaFiltersSearchView.setKeyboardHeight(keyboardSize, false);
    } else {
        ((FilteredSearchView) view).setKeyboardHeight(keyboardSize, false);
        ((FilteredSearchView) view).search(dialogId, minDate, maxDate, FiltersView.filters[position - 1], includeFolder, query, reset);
    }
}
Also used : FilteredSearchView(org.telegram.ui.FilteredSearchView) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FiltersView(org.telegram.ui.Adapters.FiltersView) TLRPC(org.telegram.tgnet.TLRPC)

Example 4 with FilteredSearchView

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

the class SearchViewPager method messagesDeleted.

public void messagesDeleted(long channelId, ArrayList<Integer> markAsDeletedMessages) {
    int n = viewsByType.size();
    for (int i = 0; i < n; i++) {
        View v = viewsByType.valueAt(i);
        if (v instanceof FilteredSearchView) {
            ((FilteredSearchView) v).messagesDeleted(channelId, markAsDeletedMessages);
        }
    }
    for (int i = 0; i < getChildCount(); i++) {
        if (getChildAt(i) instanceof FilteredSearchView) {
            ((FilteredSearchView) getChildAt(i)).messagesDeleted(channelId, markAsDeletedMessages);
        }
    }
    noMediaFiltersSearchView.messagesDeleted(channelId, markAsDeletedMessages);
    if (!selectedFiles.isEmpty()) {
        ArrayList<FilteredSearchView.MessageHashId> toRemove = null;
        Iterator<FilteredSearchView.MessageHashId> iterator = selectedFiles.keySet().iterator();
        while (iterator.hasNext()) {
            FilteredSearchView.MessageHashId hashId = iterator.next();
            MessageObject messageObject = selectedFiles.get(hashId);
            long dialogId = messageObject.getDialogId();
            int currentChannelId = dialogId < 0 && ChatObject.isChannel((int) -dialogId, currentAccount) ? (int) -dialogId : 0;
            if (currentChannelId == channelId) {
                for (int i = 0; i < markAsDeletedMessages.size(); i++) {
                    if (messageObject.getId() == markAsDeletedMessages.get(i)) {
                        toRemove = new ArrayList<>();
                        toRemove.add(hashId);
                    }
                }
            }
            if (toRemove != null) {
                for (int a = 0, N = toRemove.size(); a < N; a++) {
                    selectedFiles.remove(toRemove.get(a));
                }
                selectedMessagesCountTextView.setNumber(selectedFiles.size(), true);
                if (gotoItem != null) {
                    gotoItem.setVisibility(selectedFiles.size() == 1 ? View.VISIBLE : View.GONE);
                }
            }
        }
    }
}
Also used : FilteredSearchView(org.telegram.ui.FilteredSearchView) FiltersView(org.telegram.ui.Adapters.FiltersView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FilteredSearchView(org.telegram.ui.FilteredSearchView) MessageObject(org.telegram.messenger.MessageObject)

Example 5 with FilteredSearchView

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

the class SearchViewPager method updateColors.

public void updateColors() {
    for (int i = 0; i < getChildCount(); i++) {
        if (getChildAt(i) instanceof FilteredSearchView) {
            RecyclerListView recyclerListView = ((FilteredSearchView) getChildAt(i)).recyclerListView;
            int count = recyclerListView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = recyclerListView.getChildAt(a);
                if (child instanceof DialogCell) {
                    ((DialogCell) child).update(0);
                }
            }
        }
    }
    int n = viewsByType.size();
    for (int i = 0; i < n; i++) {
        View v = viewsByType.valueAt(i);
        if (v instanceof FilteredSearchView) {
            RecyclerListView recyclerListView = ((FilteredSearchView) v).recyclerListView;
            int count = recyclerListView.getChildCount();
            for (int a = 0; a < count; a++) {
                View child = recyclerListView.getChildAt(a);
                if (child instanceof DialogCell) {
                    ((DialogCell) child).update(0);
                }
            }
        }
    }
    if (noMediaFiltersSearchView != null) {
        RecyclerListView recyclerListView = noMediaFiltersSearchView.recyclerListView;
        int count = recyclerListView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = recyclerListView.getChildAt(a);
            if (child instanceof DialogCell) {
                ((DialogCell) child).update(0);
            }
        }
    }
}
Also used : FilteredSearchView(org.telegram.ui.FilteredSearchView) DialogCell(org.telegram.ui.Cells.DialogCell) FiltersView(org.telegram.ui.Adapters.FiltersView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FilteredSearchView(org.telegram.ui.FilteredSearchView)

Aggregations

FiltersView (org.telegram.ui.Adapters.FiltersView)5 FilteredSearchView (org.telegram.ui.FilteredSearchView)5 View (android.view.View)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 MessageObject (org.telegram.messenger.MessageObject)1 TLRPC (org.telegram.tgnet.TLRPC)1 ActionBarMenu (org.telegram.ui.ActionBar.ActionBarMenu)1 BackDrawable (org.telegram.ui.ActionBar.BackDrawable)1 MenuDrawable (org.telegram.ui.ActionBar.MenuDrawable)1 ThemeDescription (org.telegram.ui.ActionBar.ThemeDescription)1 DialogCell (org.telegram.ui.Cells.DialogCell)1