Java Code Examples for org.telegram.messenger.MessagesController#DIALOG_FILTER_FLAG_ALL_CHATS

The following examples show how to use org.telegram.messenger.MessagesController#DIALOG_FILTER_FLAG_ALL_CHATS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterCreateActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void checkDoneButton(boolean animated) {
    boolean enabled = !TextUtils.isEmpty(newFilterName) && newFilterName.length() <= MAX_NAME_LENGTH;
    if (enabled) {
        enabled = (newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) != 0 || !newAlwaysShow.isEmpty();
        if (enabled && !creatingNew) {
            enabled = hasChanges();
        }
    }
    if (doneItem.isEnabled() == enabled) {
        return;
    }
    doneItem.setEnabled(enabled);
    if (animated) {
        doneItem.animate().alpha(enabled ? 1.0f : 0.0f).scaleX(enabled ? 1.0f : 0.0f).scaleY(enabled ? 1.0f : 0.0f).setDuration(180).start();
    } else {
        doneItem.setAlpha(enabled ? 1.0f : 0.0f);
        doneItem.setScaleX(enabled ? 1.0f : 0.0f);
        doneItem.setScaleY(enabled ? 1.0f : 0.0f);
    }
}
 
Example 2
Source File: FilterCreateActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void checkDoneButton(boolean animated) {
    boolean enabled = !TextUtils.isEmpty(newFilterName) && newFilterName.length() <= MAX_NAME_LENGTH;
    if (enabled) {
        enabled = (newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) != 0 || !newAlwaysShow.isEmpty();
        if (enabled && !creatingNew) {
            enabled = hasChanges();
        }
    }
    if (doneItem.isEnabled() == enabled) {
        return;
    }
    doneItem.setEnabled(enabled);
    if (animated) {
        doneItem.animate().alpha(enabled ? 1.0f : 0.0f).scaleX(enabled ? 1.0f : 0.0f).scaleY(enabled ? 1.0f : 0.0f).setDuration(180).start();
    } else {
        doneItem.setAlpha(enabled ? 1.0f : 0.0f);
        doneItem.setScaleX(enabled ? 1.0f : 0.0f);
        doneItem.setScaleY(enabled ? 1.0f : 0.0f);
    }
}
 
Example 3
Source File: FiltersListBottomSheet.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    BottomSheet.BottomSheetCell cell = (BottomSheet.BottomSheetCell) holder.itemView;
    if (position < dialogFilters.size()) {
        cell.getImageView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogIcon), PorterDuff.Mode.MULTIPLY));
        MessagesController.DialogFilter filter = dialogFilters.get(position);
        cell.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        int icon;
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == (MessagesController.DIALOG_FILTER_FLAG_CONTACTS | MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS)) {
            icon = R.drawable.menu_private;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ) != 0 && (filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) {
            icon = R.drawable.menu_unread;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_CHANNELS) {
            icon = R.drawable.menu_broadcast;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_GROUPS) {
            icon = R.drawable.menu_groups;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_CONTACTS) {
            icon = R.drawable.menu_contacts;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_BOTS) {
            icon = R.drawable.menu_bots;
        } else {
            icon = R.drawable.menu_folders;
        }
        cell.setTextAndIcon(filter.name, icon);
    } else {
        cell.getImageView().setColorFilter(null);
        Drawable drawable1 = context.getResources().getDrawable(R.drawable.poll_add_circle);
        Drawable drawable2 = context.getResources().getDrawable(R.drawable.poll_add_plus);
        drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_switchTrackChecked), PorterDuff.Mode.MULTIPLY));
        drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_checkboxCheck), PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(drawable1, drawable2);
        cell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
        cell.setTextAndIcon(LocaleController.getString("CreateNewFilter", R.string.CreateNewFilter), combinedDrawable);
    }
}
 
Example 4
Source File: FiltersListBottomSheet.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    BottomSheet.BottomSheetCell cell = (BottomSheet.BottomSheetCell) holder.itemView;
    if (position < dialogFilters.size()) {
        cell.getImageView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogIcon), PorterDuff.Mode.MULTIPLY));
        MessagesController.DialogFilter filter = dialogFilters.get(position);
        cell.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        int icon;
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == (MessagesController.DIALOG_FILTER_FLAG_CONTACTS | MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS)) {
            icon = R.drawable.menu_private;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ) != 0 && (filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) {
            icon = R.drawable.menu_unread;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_CHANNELS) {
            icon = R.drawable.menu_broadcast;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_GROUPS) {
            icon = R.drawable.menu_groups;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_CONTACTS) {
            icon = R.drawable.menu_contacts;
        } else if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_BOTS) {
            icon = R.drawable.menu_bots;
        } else {
            icon = R.drawable.menu_folders;
        }
        cell.setTextAndIcon(filter.name, icon);
    } else {
        cell.getImageView().setColorFilter(null);
        Drawable drawable1 = context.getResources().getDrawable(R.drawable.poll_add_circle);
        Drawable drawable2 = context.getResources().getDrawable(R.drawable.poll_add_plus);
        drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_switchTrackChecked), PorterDuff.Mode.MULTIPLY));
        drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_checkboxCheck), PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(drawable1, drawable2);
        cell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
        cell.setTextAndIcon(LocaleController.getString("CreateNewFilter", R.string.CreateNewFilter), combinedDrawable);
    }
}
 
Example 5
Source File: FiltersSetupActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void setFilter(MessagesController.DialogFilter filter, boolean divider) {
    currentFilter = filter;

    StringBuilder info = new StringBuilder();
    if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) {
        info.append(LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
    } else {
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterContacts", R.string.FilterContacts));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterNonContacts", R.string.FilterNonContacts));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterGroups", R.string.FilterGroups));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterChannels", R.string.FilterChannels));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterBots", R.string.FilterBots));
        }
    }
    if (!filter.alwaysShow.isEmpty() || !filter.neverShow.isEmpty()) {
        if (info.length() != 0) {
            info.append(", ");
        }
        info.append(LocaleController.formatPluralString("Exception", filter.alwaysShow.size() + filter.neverShow.size()));
    }
    if (info.length() == 0) {
        info.append(LocaleController.getString("FilterNoChats", R.string.FilterNoChats));
    }

    textView.setText(Emoji.replaceEmoji(filter.name, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
    valueTextView.setText(info);
    //valueTextView.setVisibility(VISIBLE);
    needDivider = divider;
}
 
Example 6
Source File: FilterCreateActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void fillFilterName() {
    if (!creatingNew || !TextUtils.isEmpty(newFilterName) && nameChangedManually) {
        return;
    }
    int flags = newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS;
    String newName = "";
    if ((flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) {
        if ((newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ) != 0) {
            newName = LocaleController.getString("FilterNameUnread", R.string.FilterNameUnread);
        } else if ((newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0) {
            newName = LocaleController.getString("FilterNameNonMuted", R.string.FilterNameNonMuted);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterContacts", R.string.FilterContacts);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterNonContacts", R.string.FilterNonContacts);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_GROUPS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterGroups", R.string.FilterGroups);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_BOTS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterBots", R.string.FilterBots);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterChannels", R.string.FilterChannels);
        }
    }
    if (newName != null && newName.length() > MAX_NAME_LENGTH) {
        newName = "";
    }
    newFilterName = newName;
    RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(nameRow);
    if (holder != null) {
        adapter.onViewAttachedToWindow(holder);
    }
}
 
Example 7
Source File: FiltersSetupActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void setFilter(MessagesController.DialogFilter filter, boolean divider) {
    currentFilter = filter;

    StringBuilder info = new StringBuilder();
    if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) {
        info.append(LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
    } else {
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterContacts", R.string.FilterContacts));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterNonContacts", R.string.FilterNonContacts));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterGroups", R.string.FilterGroups));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterChannels", R.string.FilterChannels));
        }
        if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) != 0) {
            if (info.length() != 0) {
                info.append(", ");
            }
            info.append(LocaleController.getString("FilterBots", R.string.FilterBots));
        }
    }
    if (!filter.alwaysShow.isEmpty() || !filter.neverShow.isEmpty()) {
        if (info.length() != 0) {
            info.append(", ");
        }
        info.append(LocaleController.formatPluralString("Exception", filter.alwaysShow.size() + filter.neverShow.size()));
    }
    if (info.length() == 0) {
        info.append(LocaleController.getString("FilterNoChats", R.string.FilterNoChats));
    }

    textView.setText(Emoji.replaceEmoji(filter.name, textView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false));
    valueTextView.setText(info);
    //valueTextView.setVisibility(VISIBLE);
    needDivider = divider;
}
 
Example 8
Source File: FilterCreateActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void fillFilterName() {
    if (!creatingNew || !TextUtils.isEmpty(newFilterName) && nameChangedManually) {
        return;
    }
    int flags = newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS;
    String newName = "";
    if ((flags & MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) == MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS) {
        if ((newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ) != 0) {
            newName = LocaleController.getString("FilterNameUnread", R.string.FilterNameUnread);
        } else if ((newFilterFlags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0) {
            newName = LocaleController.getString("FilterNameNonMuted", R.string.FilterNameNonMuted);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterContacts", R.string.FilterContacts);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterNonContacts", R.string.FilterNonContacts);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_GROUPS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterGroups", R.string.FilterGroups);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_BOTS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterBots", R.string.FilterBots);
        }
    } else if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) != 0) {
        flags &=~ MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
        if (flags == 0) {
            newName = LocaleController.getString("FilterChannels", R.string.FilterChannels);
        }
    }
    if (newName != null && newName.length() > MAX_NAME_LENGTH) {
        newName = "";
    }
    newFilterName = newName;
    RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(nameRow);
    if (holder != null) {
        adapter.onViewAttachedToWindow(holder);
    }
}