org.telegram.ui.Components.URLSpanNoUnderline Java Examples

The following examples show how to use org.telegram.ui.Components.URLSpanNoUnderline. 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: StickersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private CharSequence addStickersBotSpan(String text) {
    final String botName = "@stickers";
    final int index = text.indexOf(botName);
    if (index != -1) {
        try {
            SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
            URLSpanNoUnderline urlSpan = new URLSpanNoUnderline("@stickers") {
                @Override
                public void onClick(View widget) {
                    MessagesController.getInstance(currentAccount).openByUserName("stickers", StickersActivity.this, 3);
                }
            };
            stringBuilder.setSpan(urlSpan, index, index + botName.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            return stringBuilder;
        } catch (Exception e) {
            FileLog.e(e);
            return text;
        }
    } else {
        return text;
    }
}
 
Example #2
Source File: StickersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private CharSequence addStickersBotSpan(String text) {
    final String botName = "@stickers";
    final int index = text.indexOf(botName);
    if (index != -1) {
        try {
            SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
            URLSpanNoUnderline urlSpan = new URLSpanNoUnderline("@stickers") {
                @Override
                public void onClick(View widget) {
                    MessagesController.getInstance(currentAccount).openByUserName("stickers", StickersActivity.this, 3);
                }
            };
            stringBuilder.setSpan(urlSpan, index, index + botName.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            return stringBuilder;
        } catch (Exception e) {
            FileLog.e(e);
            return text;
        }
    } else {
        return text;
    }
}
 
Example #3
Source File: AdminedChannelCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setChannel(TLRPC.Chat channel, boolean last) {
    TLRPC.FileLocation photo = null;
    if (channel.photo != null) {
        photo = channel.photo.photo_small;
    }
    final String url = MessagesController.getInstance(currentAccount).linkPrefix + "/";
    currentChannel = channel;
    avatarDrawable.setInfo(channel);
    nameTextView.setText(channel.title);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username);
    stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    statusTextView.setText(stringBuilder);
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
    isLast = last;
}
 
Example #4
Source File: AdminedChannelCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setChannel(TLRPC.Chat channel, boolean last) {
    TLRPC.FileLocation photo = null;
    if (channel.photo != null) {
        photo = channel.photo.photo_small;
    }
    final String url = MessagesController.getInstance(currentAccount).linkPrefix + "/";
    currentChannel = channel;
    avatarDrawable.setInfo(channel);
    nameTextView.setText(channel.title);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username);
    stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    statusTextView.setText(stringBuilder);
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
    isLast = last;
}
 
Example #5
Source File: AdminedChannelCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setChannel(TLRPC.Chat channel, boolean last) {
    final String url = MessagesController.getInstance(currentAccount).linkPrefix + "/";
    currentChannel = channel;
    avatarDrawable.setInfo(channel);
    nameTextView.setText(channel.title);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username);
    stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    statusTextView.setText(stringBuilder);
    avatarImageView.setImage(ImageLocation.getForChat(channel, false), "50_50", avatarDrawable, currentChannel);
    isLast = last;
}
 
Example #6
Source File: AdminedChannelCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setChannel(TLRPC.Chat channel, boolean last) {
    final String url = MessagesController.getInstance(currentAccount).linkPrefix + "/";
    currentChannel = channel;
    avatarDrawable.setInfo(channel);
    nameTextView.setText(channel.title);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username);
    stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    statusTextView.setText(stringBuilder);
    avatarImageView.setImage(ImageLocation.getForChat(channel, false), "50_50", avatarDrawable, currentChannel);
    isLast = last;
}
 
Example #7
Source File: StickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            ArrayList<TLRPC.TL_messages_stickerSet> arrayList = DataQuery.getInstance(currentAccount).getStickerSets(currentType);
            int row = position - stickersStartRow;
            ((StickerSetCell) holder.itemView).setStickersSet(arrayList.get(row), row != arrayList.size() - 1);
            break;
        case 1:
            if (position == featuredInfoRow) {
                String text = LocaleController.getString("FeaturedStickersInfo", R.string.FeaturedStickersInfo);
                String botName = "@stickers";
                int index = text.indexOf(botName);
                if (index != -1) {
                    try {
                        SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
                        URLSpanNoUnderline spanNoUnderline = new URLSpanNoUnderline("@stickers") {
                            @Override
                            public void onClick(View widget) {
                                MessagesController.getInstance(currentAccount).openByUserName("stickers", StickersActivity.this, 1);
                            }
                        };
                        stringBuilder.setSpan(spanNoUnderline, index, index + botName.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                        ((TextInfoPrivacyCell) holder.itemView).setText(stringBuilder);
                    } catch (Exception e) {
                        FileLog.e(e);
                        ((TextInfoPrivacyCell) holder.itemView).setText(text);
                    }
                } else {
                    ((TextInfoPrivacyCell) holder.itemView).setText(text);
                }
            } else if (position == archivedInfoRow) {
                if (currentType == DataQuery.TYPE_IMAGE) {
                    ((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("ArchivedStickersInfo", R.string.ArchivedStickersInfo));
                } else {
                    ((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("ArchivedMasksInfo", R.string.ArchivedMasksInfo));
                }
            } else if (position == masksInfoRow) {
                ((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("MasksInfo", R.string.MasksInfo));
            }
            break;
        case 2:
            if (position == featuredRow) {
                int count = DataQuery.getInstance(currentAccount).getUnreadStickerSets().size();
                ((TextSettingsCell) holder.itemView).setTextAndValue(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers), count != 0 ? String.format("%d", count) : "", false);
            } else if (position == archivedRow) {
                if (currentType == DataQuery.TYPE_IMAGE) {
                    ((TextSettingsCell) holder.itemView).setText(LocaleController.getString("ArchivedStickers", R.string.ArchivedStickers), false);
                } else {
                    ((TextSettingsCell) holder.itemView).setText(LocaleController.getString("ArchivedMasks", R.string.ArchivedMasks), false);
                }
            } else if (position == masksRow) {
                ((TextSettingsCell) holder.itemView).setText(LocaleController.getString("Masks", R.string.Masks), false);
            } else if (position == suggestRow) {
                String value;
                switch (SharedConfig.suggestStickers) {
                    case 0:
                        value = LocaleController.getString("SuggestStickersAll", R.string.SuggestStickersAll);
                        break;
                    case 1:
                        value = LocaleController.getString("SuggestStickersInstalled", R.string.SuggestStickersInstalled);
                        break;
                    case 2:
                    default:
                        value = LocaleController.getString("SuggestStickersNone", R.string.SuggestStickersNone);
                        break;
                }
                ((TextSettingsCell) holder.itemView).setTextAndValue(LocaleController.getString("SuggestStickers", R.string.SuggestStickers), value, true);
            }
            break;
        case 3:
            if (position == stickersShadowRow) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == suggestInfoRow) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example #8
Source File: StickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            ArrayList<TLRPC.TL_messages_stickerSet> arrayList = DataQuery.getInstance(currentAccount).getStickerSets(currentType);
            int row = position - stickersStartRow;
            ((StickerSetCell) holder.itemView).setStickersSet(arrayList.get(row), row != arrayList.size() - 1);
            break;
        case 1:
            if (position == featuredInfoRow) {
                String text = LocaleController.getString("FeaturedStickersInfo", R.string.FeaturedStickersInfo);
                String botName = "@stickers";
                int index = text.indexOf(botName);
                if (index != -1) {
                    try {
                        SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
                        URLSpanNoUnderline spanNoUnderline = new URLSpanNoUnderline("@stickers") {
                            @Override
                            public void onClick(View widget) {
                                MessagesController.getInstance(currentAccount).openByUserName("stickers", StickersActivity.this, 1);
                            }
                        };
                        stringBuilder.setSpan(spanNoUnderline, index, index + botName.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                        ((TextInfoPrivacyCell) holder.itemView).setText(stringBuilder);
                    } catch (Exception e) {
                        FileLog.e(e);
                        ((TextInfoPrivacyCell) holder.itemView).setText(text);
                    }
                } else {
                    ((TextInfoPrivacyCell) holder.itemView).setText(text);
                }
            } else if (position == archivedInfoRow) {
                if (currentType == DataQuery.TYPE_IMAGE) {
                    ((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("ArchivedStickersInfo", R.string.ArchivedStickersInfo));
                } else {
                    ((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("ArchivedMasksInfo", R.string.ArchivedMasksInfo));
                }
            } else if (position == masksInfoRow) {
                ((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("MasksInfo", R.string.MasksInfo));
            }
            break;
        case 2:
            if (position == featuredRow) {
                int count = DataQuery.getInstance(currentAccount).getUnreadStickerSets().size();
                ((TextSettingsCell) holder.itemView).setTextAndValue(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers), count != 0 ? String.format("%d", count) : "", false);
            } else if (position == archivedRow) {
                if (currentType == DataQuery.TYPE_IMAGE) {
                    ((TextSettingsCell) holder.itemView).setText(LocaleController.getString("ArchivedStickers", R.string.ArchivedStickers), false);
                } else {
                    ((TextSettingsCell) holder.itemView).setText(LocaleController.getString("ArchivedMasks", R.string.ArchivedMasks), false);
                }
            } else if (position == masksRow) {
                ((TextSettingsCell) holder.itemView).setText(LocaleController.getString("Masks", R.string.Masks), false);
            } else if (position == suggestRow) {
                String value;
                switch (SharedConfig.suggestStickers) {
                    case 0:
                        value = LocaleController.getString("SuggestStickersAll", R.string.SuggestStickersAll);
                        break;
                    case 1:
                        value = LocaleController.getString("SuggestStickersInstalled", R.string.SuggestStickersInstalled);
                        break;
                    case 2:
                    default:
                        value = LocaleController.getString("SuggestStickersNone", R.string.SuggestStickersNone);
                        break;
                }
                ((TextSettingsCell) holder.itemView).setTextAndValue(LocaleController.getString("SuggestStickers", R.string.SuggestStickers), value, true);
            }
            break;
        case 3:
            if (position == stickersShadowRow) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == suggestInfoRow) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}