use of org.telegram.ui.Components.URLSpanMono in project Telegram-FOSS by Telegram-FOSS-Team.
the class MessageObject method addEntitiesToText.
public static boolean addEntitiesToText(CharSequence text, ArrayList<TLRPC.MessageEntity> entities, boolean out, boolean usernames, boolean photoViewer, boolean useManualParse) {
if (!(text instanceof Spannable)) {
return false;
}
Spannable spannable = (Spannable) text;
URLSpan[] spans = spannable.getSpans(0, text.length(), URLSpan.class);
boolean hasUrls = spans != null && spans.length > 0;
if (entities.isEmpty()) {
return hasUrls;
}
byte t;
if (photoViewer) {
t = 2;
} else if (out) {
t = 1;
} else {
t = 0;
}
ArrayList<TextStyleSpan.TextStyleRun> runs = new ArrayList<>();
ArrayList<TLRPC.MessageEntity> entitiesCopy = new ArrayList<>(entities);
Collections.sort(entitiesCopy, (o1, o2) -> {
if (o1.offset > o2.offset) {
return 1;
} else if (o1.offset < o2.offset) {
return -1;
}
return 0;
});
for (int a = 0, N = entitiesCopy.size(); a < N; a++) {
TLRPC.MessageEntity entity = entitiesCopy.get(a);
if (entity.length <= 0 || entity.offset < 0 || entity.offset >= text.length()) {
continue;
} else if (entity.offset + entity.length > text.length()) {
entity.length = text.length() - entity.offset;
}
if (!useManualParse || entity instanceof TLRPC.TL_messageEntityBold || entity instanceof TLRPC.TL_messageEntityItalic || entity instanceof TLRPC.TL_messageEntityStrike || entity instanceof TLRPC.TL_messageEntityUnderline || entity instanceof TLRPC.TL_messageEntityBlockquote || entity instanceof TLRPC.TL_messageEntityCode || entity instanceof TLRPC.TL_messageEntityPre || entity instanceof TLRPC.TL_messageEntityMentionName || entity instanceof TLRPC.TL_inputMessageEntityMentionName || entity instanceof TLRPC.TL_messageEntityTextUrl || entity instanceof TLRPC.TL_messageEntitySpoiler) {
if (spans != null && spans.length > 0) {
for (int b = 0; b < spans.length; b++) {
if (spans[b] == null) {
continue;
}
int start = spannable.getSpanStart(spans[b]);
int end = spannable.getSpanEnd(spans[b]);
if (entity.offset <= start && entity.offset + entity.length >= start || entity.offset <= end && entity.offset + entity.length >= end) {
spannable.removeSpan(spans[b]);
spans[b] = null;
}
}
}
}
TextStyleSpan.TextStyleRun newRun = new TextStyleSpan.TextStyleRun();
newRun.start = entity.offset;
newRun.end = newRun.start + entity.length;
TLRPC.MessageEntity urlEntity = null;
if (entity instanceof TLRPC.TL_messageEntitySpoiler) {
newRun.flags = TextStyleSpan.FLAG_STYLE_SPOILER;
} else if (entity instanceof TLRPC.TL_messageEntityStrike) {
newRun.flags = TextStyleSpan.FLAG_STYLE_STRIKE;
} else if (entity instanceof TLRPC.TL_messageEntityUnderline) {
newRun.flags = TextStyleSpan.FLAG_STYLE_UNDERLINE;
} else if (entity instanceof TLRPC.TL_messageEntityBlockquote) {
newRun.flags = TextStyleSpan.FLAG_STYLE_QUOTE;
} else if (entity instanceof TLRPC.TL_messageEntityBold) {
newRun.flags = TextStyleSpan.FLAG_STYLE_BOLD;
} else if (entity instanceof TLRPC.TL_messageEntityItalic) {
newRun.flags = TextStyleSpan.FLAG_STYLE_ITALIC;
} else if (entity instanceof TLRPC.TL_messageEntityCode || entity instanceof TLRPC.TL_messageEntityPre) {
newRun.flags = TextStyleSpan.FLAG_STYLE_MONO;
} else if (entity instanceof TLRPC.TL_messageEntityMentionName) {
if (!usernames) {
continue;
}
newRun.flags = TextStyleSpan.FLAG_STYLE_MENTION;
newRun.urlEntity = entity;
} else if (entity instanceof TLRPC.TL_inputMessageEntityMentionName) {
if (!usernames) {
continue;
}
newRun.flags = TextStyleSpan.FLAG_STYLE_MENTION;
newRun.urlEntity = entity;
} else {
if (useManualParse && !(entity instanceof TLRPC.TL_messageEntityTextUrl)) {
continue;
}
if ((entity instanceof TLRPC.TL_messageEntityUrl || entity instanceof TLRPC.TL_messageEntityTextUrl) && Browser.isPassportUrl(entity.url)) {
continue;
}
if (entity instanceof TLRPC.TL_messageEntityMention && !usernames) {
continue;
}
newRun.flags = TextStyleSpan.FLAG_STYLE_URL;
newRun.urlEntity = entity;
}
for (int b = 0, N2 = runs.size(); b < N2; b++) {
TextStyleSpan.TextStyleRun run = runs.get(b);
if (newRun.start > run.start) {
if (newRun.start >= run.end) {
continue;
}
if (newRun.end < run.end) {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(newRun);
r.merge(run);
b++;
N2++;
runs.add(b, r);
r = new TextStyleSpan.TextStyleRun(run);
r.start = newRun.end;
b++;
N2++;
runs.add(b, r);
} else {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(newRun);
r.merge(run);
r.end = run.end;
b++;
N2++;
runs.add(b, r);
}
int temp = newRun.start;
newRun.start = run.end;
run.end = temp;
} else {
if (run.start >= newRun.end) {
continue;
}
int temp = run.start;
if (newRun.end == run.end) {
run.merge(newRun);
} else if (newRun.end < run.end) {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(run);
r.merge(newRun);
r.end = newRun.end;
b++;
N2++;
runs.add(b, r);
run.start = newRun.end;
} else {
TextStyleSpan.TextStyleRun r = new TextStyleSpan.TextStyleRun(newRun);
r.start = run.end;
b++;
N2++;
runs.add(b, r);
run.merge(newRun);
}
newRun.end = temp;
}
}
if (newRun.start < newRun.end) {
runs.add(newRun);
}
}
int count = runs.size();
for (int a = 0; a < count; a++) {
TextStyleSpan.TextStyleRun run = runs.get(a);
boolean setRun = false;
String url = run.urlEntity != null ? TextUtils.substring(text, run.urlEntity.offset, run.urlEntity.offset + run.urlEntity.length) : null;
if (run.urlEntity instanceof TLRPC.TL_messageEntityBotCommand) {
spannable.setSpan(new URLSpanBotCommand(url, t, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityHashtag || run.urlEntity instanceof TLRPC.TL_messageEntityMention || run.urlEntity instanceof TLRPC.TL_messageEntityCashtag) {
spannable.setSpan(new URLSpanNoUnderline(url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityEmail) {
spannable.setSpan(new URLSpanReplacement("mailto:" + url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityUrl) {
hasUrls = true;
String lowerCase = url.toLowerCase();
if (!lowerCase.contains("://")) {
spannable.setSpan(new URLSpanBrowser("http://" + url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
spannable.setSpan(new URLSpanBrowser(url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityBankCard) {
hasUrls = true;
spannable.setSpan(new URLSpanNoUnderline("card:" + url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityPhone) {
hasUrls = true;
String tel = PhoneFormat.stripExceptNumbers(url);
if (url.startsWith("+")) {
tel = "+" + tel;
}
spannable.setSpan(new URLSpanBrowser("tel:" + tel, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityTextUrl) {
spannable.setSpan(new URLSpanReplacement(run.urlEntity.url, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_messageEntityMentionName) {
spannable.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_messageEntityMentionName) run.urlEntity).user_id, t, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (run.urlEntity instanceof TLRPC.TL_inputMessageEntityMentionName) {
spannable.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_inputMessageEntityMentionName) run.urlEntity).user_id.user_id, t, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if ((run.flags & TextStyleSpan.FLAG_STYLE_MONO) != 0) {
spannable.setSpan(new URLSpanMono(spannable, run.start, run.end, t, run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
setRun = true;
spannable.setSpan(new TextStyleSpan(run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (!setRun && (run.flags & TextStyleSpan.FLAG_STYLE_SPOILER) != 0) {
spannable.setSpan(new TextStyleSpan(run), run.start, run.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
return hasUrls;
}
use of org.telegram.ui.Components.URLSpanMono in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatMessageCell method onLongPress.
@Override
protected boolean onLongPress() {
if (isRoundVideo && isPlayingRound && MediaController.getInstance().isPlayingMessage(currentMessageObject)) {
float touchRadius = (lastTouchX - photoImage.getCenterX()) * (lastTouchX - photoImage.getCenterX()) + (lastTouchY - photoImage.getCenterY()) * (lastTouchY - photoImage.getCenterY());
float r1 = (photoImage.getImageWidth() / 2f) * (photoImage.getImageWidth() / 2f);
if (touchRadius < r1 && (lastTouchX > photoImage.getCenterX() + photoImage.getImageWidth() / 4f || lastTouchX < photoImage.getCenterX() - photoImage.getImageWidth() / 4f)) {
boolean forward = lastTouchX > photoImage.getCenterX();
if (videoPlayerRewinder == null) {
videoForwardDrawable = new VideoForwardDrawable(true);
videoPlayerRewinder = new VideoPlayerRewinder() {
@Override
protected void onRewindCanceled() {
onTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0));
videoForwardDrawable.setShowing(false);
}
@Override
protected void updateRewindProgressUi(long timeDiff, float progress, boolean rewindByBackSeek) {
videoForwardDrawable.setTime(Math.abs(timeDiff));
if (rewindByBackSeek) {
currentMessageObject.audioProgress = progress;
updatePlayingMessageProgress();
}
}
@Override
protected void onRewindStart(boolean rewindForward) {
videoForwardDrawable.setDelegate(new VideoForwardDrawable.VideoForwardDrawableDelegate() {
@Override
public void onAnimationEnd() {
}
@Override
public void invalidate() {
ChatMessageCell.this.invalidate();
}
});
videoForwardDrawable.setOneShootAnimation(false);
videoForwardDrawable.setLeftSide(!rewindForward);
videoForwardDrawable.setShowing(true);
invalidate();
}
};
getParent().requestDisallowInterceptTouchEvent(true);
}
videoPlayerRewinder.startRewind(MediaController.getInstance().getVideoPlayer(), forward, MediaController.getInstance().getPlaybackSpeed(false));
return false;
}
}
if (pressedLink instanceof URLSpanMono) {
delegate.didPressUrl(this, pressedLink, true);
return true;
} else if (pressedLink instanceof URLSpanNoUnderline) {
URLSpanNoUnderline url = (URLSpanNoUnderline) pressedLink;
if (ChatActivity.isClickableLink(url.getURL()) || url.getURL().startsWith("/")) {
delegate.didPressUrl(this, pressedLink, true);
return true;
}
} else if (pressedLink instanceof URLSpan) {
delegate.didPressUrl(this, pressedLink, true);
return true;
}
resetPressedLink(-1);
if (buttonPressed != 0 || miniButtonPressed != 0 || videoButtonPressed != 0 || pressedBotButton != -1) {
buttonPressed = 0;
miniButtonPressed = 0;
videoButtonPressed = 0;
pressedBotButton = -1;
invalidate();
}
linkPreviewPressed = false;
sideButtonPressed = false;
imagePressed = false;
timePressed = false;
gamePreviewPressed = false;
if (pressedVoteButton != -1 || pollHintPressed || psaHintPressed || instantPressed || otherPressed || commentButtonPressed) {
instantPressed = instantButtonPressed = commentButtonPressed = false;
pressedVoteButton = -1;
pollHintPressed = false;
psaHintPressed = false;
otherPressed = false;
if (Build.VERSION.SDK_INT >= 21) {
for (int a = 0; a < selectorDrawable.length; a++) {
if (selectorDrawable[a] != null) {
selectorDrawable[a].setState(StateSet.NOTHING);
}
}
}
invalidate();
}
if (delegate != null) {
boolean handled = false;
if (avatarPressed) {
if (currentUser != null) {
if (currentUser.id != 0) {
handled = delegate.didLongPressUserAvatar(this, currentUser, lastTouchX, lastTouchY);
}
} else if (currentChat != null) {
final int id;
if (currentMessageObject.messageOwner.fwd_from != null) {
if ((currentMessageObject.messageOwner.fwd_from.flags & 16) != 0) {
id = currentMessageObject.messageOwner.fwd_from.saved_from_msg_id;
} else {
id = currentMessageObject.messageOwner.fwd_from.channel_post;
}
} else {
id = 0;
}
handled = delegate.didLongPressChannelAvatar(this, currentChat, id, lastTouchX, lastTouchY);
}
}
if (!handled) {
delegate.didLongPress(this, lastTouchX, lastTouchY);
}
}
return true;
}
use of org.telegram.ui.Components.URLSpanMono in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method didPressMessageUrl.
private void didPressMessageUrl(CharacterStyle url, boolean longPress, MessageObject messageObject, ChatMessageCell cell) {
if (url == null || getParentActivity() == null) {
return;
}
boolean noforwards = getMessagesController().isChatNoForwards(currentChat) || (messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards);
if (url instanceof URLSpanMono) {
if (!noforwards) {
((URLSpanMono) url).copyToClipboard();
getUndoView().showWithAction(0, UndoView.ACTION_TEXT_COPIED, null);
}
} else if (url instanceof URLSpanUserMention) {
TLRPC.User user = getMessagesController().getUser(Utilities.parseLong(((URLSpanUserMention) url).getURL()));
if (user != null) {
MessagesController.openChatOrProfileWith(user, null, ChatActivity.this, 0, false);
}
} else if (url instanceof URLSpanNoUnderline) {
String str = ((URLSpanNoUnderline) url).getURL();
if (messageObject != null && str.startsWith("/")) {
if (URLSpanBotCommand.enabled) {
chatActivityEnterView.setCommand(messageObject, str, longPress, currentChat != null && currentChat.megagroup);
if (!longPress && chatActivityEnterView.getFieldText() == null) {
hideFieldPanel(false);
}
}
} else if (messageObject != null && str.startsWith("video") && !longPress) {
int seekTime = Utilities.parseInt(str);
TLRPC.WebPage webPage;
if (messageObject.isYouTubeVideo()) {
webPage = messageObject.messageOwner.media.webpage;
} else if (messageObject.replyMessageObject != null && messageObject.replyMessageObject.isYouTubeVideo()) {
webPage = messageObject.replyMessageObject.messageOwner.media.webpage;
messageObject = messageObject.replyMessageObject;
} else {
webPage = null;
}
if (webPage != null) {
EmbedBottomSheet.show(getParentActivity(), messageObject, photoViewerProvider, webPage.site_name, webPage.title, webPage.url, webPage.embed_url, webPage.embed_width, webPage.embed_height, seekTime, isKeyboardVisible());
} else {
if (!messageObject.isVideo() && messageObject.replyMessageObject != null) {
MessageObject obj = messagesDict[messageObject.replyMessageObject.getDialogId() == dialog_id ? 0 : 1].get(messageObject.replyMessageObject.getId());
cell = null;
if (obj == null) {
messageObject = messageObject.replyMessageObject;
} else {
messageObject = obj;
}
}
messageObject.forceSeekTo = seekTime / (float) messageObject.getDuration();
openPhotoViewerForMessage(cell, messageObject);
}
} else if (messageObject != null && str.startsWith("audio")) {
int seekTime = Utilities.parseInt(str);
if (!messageObject.isMusic() && messageObject.replyMessageObject != null) {
messageObject = messagesDict[messageObject.replyMessageObject.getDialogId() == dialog_id ? 0 : 1].get(messageObject.replyMessageObject.getId());
}
float progress = seekTime / (float) messageObject.getDuration();
MediaController mediaController = getMediaController();
if (mediaController.isPlayingMessage(messageObject)) {
messageObject.audioProgress = progress;
mediaController.seekToProgress(messageObject, progress);
if (mediaController.isMessagePaused()) {
mediaController.playMessage(messageObject);
}
} else {
messageObject.forceSeekTo = seekTime / (float) messageObject.getDuration();
mediaController.playMessage(messageObject);
}
} else if (str.startsWith("card:")) {
String number = str.substring(5);
final AlertDialog[] progressDialog = new AlertDialog[] { new AlertDialog(getParentActivity(), 3, themeDelegate) };
TLRPC.TL_payments_getBankCardData req = new TLRPC.TL_payments_getBankCardData();
req.number = number;
int requestId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog[0].dismiss();
} catch (Throwable ignore) {
}
progressDialog[0] = null;
if (response instanceof TLRPC.TL_payments_bankCardData) {
if (getParentActivity() == null) {
return;
}
TLRPC.TL_payments_bankCardData data = (TLRPC.TL_payments_bankCardData) response;
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false, themeDelegate);
ArrayList<CharSequence> arrayList = new ArrayList<>();
for (int a = 0, N = data.open_urls.size(); a < N; a++) {
arrayList.add(data.open_urls.get(a).name);
}
arrayList.add(LocaleController.getString("CopyCardNumber", R.string.CopyCardNumber));
builder.setTitle(data.title);
builder.setItems(arrayList.toArray(new CharSequence[0]), (dialog, which) -> {
if (which < data.open_urls.size()) {
Browser.openUrl(getParentActivity(), data.open_urls.get(which).url, inlineReturn == 0, false);
} else {
AndroidUtilities.addToClipboard(number);
Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("CardNumberCopied", R.string.CardNumberCopied), Toast.LENGTH_SHORT).show();
}
});
showDialog(builder.create());
}
}), null, null, 0, getMessagesController().webFileDatacenterId, ConnectionsManager.ConnectionTypeGeneric, true);
AndroidUtilities.runOnUIThread(() -> {
if (progressDialog[0] == null) {
return;
}
progressDialog[0].setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(requestId, true));
showDialog(progressDialog[0]);
}, 500);
} else {
if (longPress) {
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false, themeDelegate);
int timestamp = -1;
if (str.startsWith("video?")) {
timestamp = Utilities.parseInt(str);
}
if (timestamp >= 0) {
builder.setTitle(AndroidUtilities.formatDuration(timestamp, false));
} else {
builder.setTitle(str);
}
final int finalTimestamp = timestamp;
ChatMessageCell finalCell = cell;
MessageObject finalMessageObject = messageObject;
builder.setItems(noforwards ? new CharSequence[] { LocaleController.getString("Open", R.string.Open) } : new CharSequence[] { LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy) }, (dialog, which) -> {
if (which == 0) {
if (str.startsWith("video?")) {
didPressMessageUrl(url, false, finalMessageObject, finalCell);
} else {
openClickableLink(str);
}
} else if (which == 1) {
if (str.startsWith("video?") && finalMessageObject != null && !finalMessageObject.scheduled) {
MessageObject messageObject1 = finalMessageObject;
boolean isMedia = finalMessageObject.isVideo() || finalMessageObject.isRoundVideo() || finalMessageObject.isVoice() || finalMessageObject.isMusic();
if (!isMedia && finalMessageObject.replyMessageObject != null) {
messageObject1 = finalMessageObject.replyMessageObject;
}
long dialogId = messageObject1.getDialogId();
int messageId = messageObject1.getId();
String link = null;
if (messageObject1.messageOwner.fwd_from != null) {
if (messageObject1.messageOwner.fwd_from.saved_from_peer != null) {
dialogId = MessageObject.getPeerId(messageObject1.messageOwner.fwd_from.saved_from_peer);
messageId = messageObject1.messageOwner.fwd_from.saved_from_msg_id;
} else if (messageObject1.messageOwner.fwd_from.from_id != null) {
dialogId = MessageObject.getPeerId(messageObject1.messageOwner.fwd_from.from_id);
messageId = messageObject1.messageOwner.fwd_from.channel_post;
}
}
if (DialogObject.isChatDialog(dialogId)) {
TLRPC.Chat currentChat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
if (currentChat != null && currentChat.username != null) {
link = "https://t.me/" + currentChat.username + "/" + messageId + "?t=" + finalTimestamp;
}
} else {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
if (user != null && user.username != null) {
link = "https://t.me/" + user.username + "/" + messageId + "?t=" + finalTimestamp;
}
}
if (link == null) {
return;
}
AndroidUtilities.addToClipboard(link);
} else {
AndroidUtilities.addToClipboard(str);
}
if (str.startsWith("@")) {
undoView.showWithAction(0, UndoView.ACTION_USERNAME_COPIED, null);
} else if (str.startsWith("#") || str.startsWith("$")) {
undoView.showWithAction(0, UndoView.ACTION_HASHTAG_COPIED, null);
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
}
}
});
showDialog(builder.create());
} else {
openClickableLink(str);
}
}
} else {
final String urlFinal = ((URLSpan) url).getURL();
if (longPress) {
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false, themeDelegate);
builder.setTitle(urlFinal);
builder.setItems(noforwards ? new CharSequence[] { LocaleController.getString("Open", R.string.Open) } : new CharSequence[] { LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy) }, (dialog, which) -> {
if (which == 0) {
processExternalUrl(1, urlFinal, false);
} else if (which == 1) {
String url1 = urlFinal;
boolean tel = false;
boolean mail = false;
if (url1.startsWith("mailto:")) {
url1 = url1.substring(7);
mail = true;
} else if (url1.startsWith("tel:")) {
url1 = url1.substring(4);
tel = true;
}
AndroidUtilities.addToClipboard(url1);
if (mail) {
undoView.showWithAction(0, UndoView.ACTION_EMAIL_COPIED, null);
} else if (tel) {
undoView.showWithAction(0, UndoView.ACTION_PHONE_COPIED, null);
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
}
}
});
showDialog(builder.create());
} else {
boolean forceAlert = url instanceof URLSpanReplacement;
if (url instanceof URLSpanReplacement && (urlFinal == null || !urlFinal.startsWith("mailto:")) || AndroidUtilities.shouldShowUrlInAlert(urlFinal)) {
if (openLinkInternally(urlFinal, messageObject != null ? messageObject.getId() : 0)) {
return;
}
forceAlert = true;
} else {
if (messageObject != null && messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage != null && messageObject.messageOwner.media.webpage.cached_page != null) {
String lowerUrl = urlFinal.toLowerCase();
String lowerUrl2 = messageObject.messageOwner.media.webpage.url.toLowerCase();
if ((lowerUrl.contains("telegram.org/blog") || Browser.isTelegraphUrl(lowerUrl, false) || lowerUrl.contains("t.me/iv")) && (lowerUrl.contains(lowerUrl2) || lowerUrl2.contains(lowerUrl))) {
ArticleViewer.getInstance().setParentActivity(getParentActivity(), ChatActivity.this);
ArticleViewer.getInstance().open(messageObject);
return;
}
}
if (openLinkInternally(urlFinal, messageObject != null ? messageObject.getId() : 0)) {
return;
}
}
if (Browser.urlMustNotHaveConfirmation(urlFinal)) {
forceAlert = false;
}
processExternalUrl(2, urlFinal, forceAlert);
}
}
}
Aggregations