use of org.telegram.ui.Components.Bulletin in project Telegram-FOSS by Telegram-FOSS-Team.
the class EmojiAnimationsOverlay method onTapItem.
public void onTapItem(ChatMessageCell view, ChatActivity chatActivity) {
if (chatActivity.currentUser == null || chatActivity.isSecretChat() || view.getMessageObject() == null || view.getMessageObject().getId() < 0) {
return;
}
boolean show = showAnimationForCell(view, -1, true, false);
if (show && !EmojiData.hasEmojiSupportVibration(view.getMessageObject().getStickerEmoji())) {
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
}
Integer printingType = MessagesController.getInstance(currentAccount).getPrintingStringType(dialogId, threadMsgId);
boolean canShowHint = true;
if (printingType != null && printingType == 5) {
canShowHint = false;
}
if (canShowHint && hintRunnable == null && show && (Bulletin.getVisibleBulletin() == null || !Bulletin.getVisibleBulletin().isShowing()) && SharedConfig.emojiInteractionsHintCount > 0 && UserConfig.getInstance(currentAccount).getClientUserId() != chatActivity.currentUser.id) {
SharedConfig.updateEmojiInteractionsHintCount(SharedConfig.emojiInteractionsHintCount - 1);
TLRPC.Document document = MediaDataController.getInstance(currentAccount).getEmojiAnimatedSticker(view.getMessageObject().getStickerEmoji());
StickerSetBulletinLayout layout = new StickerSetBulletinLayout(chatActivity.getParentActivity(), null, StickerSetBulletinLayout.TYPE_EMPTY, document, chatActivity.getResourceProvider());
layout.subtitleTextView.setVisibility(View.GONE);
layout.titleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("EmojiInteractionTapHint", R.string.EmojiInteractionTapHint, chatActivity.currentUser.first_name)));
layout.titleTextView.setTypeface(null);
layout.titleTextView.setMaxLines(3);
layout.titleTextView.setSingleLine(false);
Bulletin bulletin = Bulletin.make(chatActivity, layout, Bulletin.DURATION_LONG);
AndroidUtilities.runOnUIThread(hintRunnable = new Runnable() {
@Override
public void run() {
bulletin.show();
hintRunnable = null;
}
}, 1500);
}
}
use of org.telegram.ui.Components.Bulletin in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method createMenu.
private void createMenu(View v, boolean single, boolean listView, float x, float y, boolean searchGroup) {
if (actionBar.isActionModeShowed() || reportType >= 0) {
return;
}
MessageObject message;
MessageObject primaryMessage;
if (v instanceof ChatMessageCell) {
message = ((ChatMessageCell) v).getMessageObject();
primaryMessage = ((ChatMessageCell) v).getPrimaryMessageObject();
} else if (v instanceof ChatActionCell) {
message = ((ChatActionCell) v).getMessageObject();
primaryMessage = message;
} else {
primaryMessage = null;
message = null;
}
if (message == null) {
return;
}
final int type = getMessageType(message);
if (single) {
if (message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
if (message.getReplyMsgId() != 0) {
scrollToMessageId(message.getReplyMsgId(), message.messageOwner.id, true, message.getDialogId() == mergeDialogId ? 1 : 0, false, 0);
} else {
Toast.makeText(getParentActivity(), LocaleController.getString("MessageNotFound", R.string.MessageNotFound), Toast.LENGTH_SHORT).show();
}
return;
} else if (message.messageOwner.action instanceof TLRPC.TL_messageActionSetMessagesTTL) {
if (avatarContainer.openSetTimer()) {
return;
}
} else if (message.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent && message.replyMessageObject != null && message.replyMessageObject.isInvoice()) {
TLRPC.TL_payments_getPaymentReceipt req = new TLRPC.TL_payments_getPaymentReceipt();
req.msg_id = message.getId();
req.peer = getMessagesController().getInputPeer(message.messageOwner.peer_id);
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_payments_paymentReceipt) {
presentFragment(new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response));
}
}), ConnectionsManager.RequestFlagFailOnServerErrors);
return;
} else if (message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
if (getParentActivity() == null) {
return;
}
VoIPService sharedInstance = VoIPService.getSharedInstance();
if (sharedInstance != null) {
if (sharedInstance.groupCall != null && message.messageOwner.action.call.id == sharedInstance.groupCall.call.id) {
if (getParentActivity() instanceof LaunchActivity) {
GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(currentAccount), null, null, false, null);
} else {
Intent intent = new Intent(getParentActivity(), LaunchActivity.class).setAction("voip_chat");
intent.putExtra("currentAccount", VoIPService.getSharedInstance().getAccount());
getParentActivity().startActivity(intent);
}
} else {
createGroupCall = getGroupCall() == null;
VoIPHelper.startCall(currentChat, null, null, createGroupCall, getParentActivity(), ChatActivity.this, getAccountInstance());
}
return;
} else if (fragmentContextView != null && getGroupCall() != null) {
if (VoIPService.getSharedInstance() != null) {
GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(VoIPService.getSharedInstance().getAccount()), null, null, false, null);
} else {
ChatObject.Call call = getGroupCall();
if (call == null) {
return;
}
VoIPHelper.startCall(getMessagesController().getChat(call.chatId), null, null, false, getParentActivity(), ChatActivity.this, getAccountInstance());
}
return;
} else if (ChatObject.canManageCalls(currentChat)) {
VoIPHelper.showGroupCallAlert(ChatActivity.this, currentChat, null, true, getAccountInstance());
return;
}
} else if (message.messageOwner.action instanceof TLRPC.TL_messageActionSetChatTheme) {
showChatThemeBottomSheet();
return;
}
}
if (message.isSponsored() || threadMessageObjects != null && threadMessageObjects.contains(message)) {
single = true;
}
selectedObject = null;
selectedObjectGroup = null;
forwardingMessage = null;
forwardingMessageGroup = null;
selectedObjectToEditCaption = null;
for (int a = 1; a >= 0; a--) {
selectedMessagesCanCopyIds[a].clear();
selectedMessagesCanStarIds[a].clear();
selectedMessagesIds[a].clear();
}
hideActionMode();
updatePinnedMessageView(true);
MessageObject.GroupedMessages groupedMessages;
if (searchGroup) {
groupedMessages = getValidGroupedMessage(message);
} else {
groupedMessages = null;
}
boolean allowChatActions = true;
boolean allowPin;
if (chatMode == MODE_SCHEDULED || isThreadChat()) {
allowPin = false;
} else if (currentChat != null) {
allowPin = message.getDialogId() != mergeDialogId && ChatObject.canPinMessages(currentChat);
} else if (currentEncryptedChat == null) {
if (UserObject.isDeleted(currentUser)) {
allowPin = false;
} else if (userInfo != null) {
allowPin = userInfo.can_pin_message;
} else {
allowPin = false;
}
} else {
allowPin = false;
}
allowPin = allowPin && message.getId() > 0 && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty);
boolean noforwards = getMessagesController().isChatNoForwards(currentChat) || message.messageOwner.noforwards;
boolean allowUnpin = message.getDialogId() != mergeDialogId && allowPin && (pinnedMessageObjects.containsKey(message.getId()) || groupedMessages != null && !groupedMessages.messages.isEmpty() && pinnedMessageObjects.containsKey(groupedMessages.messages.get(0).getId()));
boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId;
if (allowEdit && groupedMessages != null) {
int captionsCount = 0;
for (int a = 0, N = groupedMessages.messages.size(); a < N; a++) {
MessageObject messageObject = groupedMessages.messages.get(a);
if (a == 0 || !TextUtils.isEmpty(messageObject.caption)) {
selectedObjectToEditCaption = messageObject;
if (!TextUtils.isEmpty(messageObject.caption)) {
captionsCount++;
}
}
}
allowEdit = captionsCount < 2;
}
if (chatMode == MODE_SCHEDULED || threadMessageObjects != null && threadMessageObjects.contains(message) || message.isSponsored() || type == 1 && message.getDialogId() == mergeDialogId || message.messageOwner.action instanceof TLRPC.TL_messageActionSecureValuesSent || currentEncryptedChat == null && message.getId() < 0 || bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE || currentChat != null && (ChatObject.isNotInChat(currentChat) && !isThreadChat() || ChatObject.isChannel(currentChat) && !ChatObject.canPost(currentChat) && !currentChat.megagroup || !ChatObject.canSendMessages(currentChat))) {
allowChatActions = false;
}
if (single || type < 2 || type == 20) {
if (getParentActivity() == null) {
return;
}
ArrayList<Integer> icons = new ArrayList<>();
ArrayList<CharSequence> items = new ArrayList<>();
final ArrayList<Integer> options = new ArrayList<>();
CharSequence messageText = null;
if (type >= 0 || type == -1 && single && (message.isSending() || message.isEditing()) && currentEncryptedChat == null) {
selectedObject = message;
selectedObjectGroup = groupedMessages;
// used only in translations
messageText = getMessageCaption(selectedObject, selectedObjectGroup);
if (messageText == null && selectedObject.isPoll()) {
try {
TLRPC.Poll poll = ((TLRPC.TL_messageMediaPoll) selectedObject.messageOwner.media).poll;
StringBuilder pollText = new StringBuilder();
pollText = new StringBuilder(poll.question).append("\n");
for (TLRPC.TL_pollAnswer answer : poll.answers) pollText.append("\n\uD83D\uDD18 ").append(answer.text);
messageText = pollText.toString();
} catch (Exception e) {
}
}
if (messageText == null)
messageText = getMessageContent(selectedObject, 0, false);
if (messageText != null) {
if (isEmoji(messageText.toString()))
// message fully consists of emojis, do not translate
messageText = null;
}
if (type == -1) {
if ((selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !noforwards) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(OPTION_COPY);
icons.add(R.drawable.msg_copy);
}
items.add(LocaleController.getString("CancelSending", R.string.CancelSending));
options.add(OPTION_CANCEL_SENDING);
icons.add(R.drawable.msg_delete);
} else if (type == 0) {
items.add(LocaleController.getString("Retry", R.string.Retry));
options.add(OPTION_RETRY);
icons.add(R.drawable.msg_retry);
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(OPTION_DELETE);
icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
} else if (type == 1) {
if (currentChat != null) {
if (allowChatActions) {
items.add(LocaleController.getString("Reply", R.string.Reply));
options.add(OPTION_REPLY);
icons.add(R.drawable.msg_reply);
}
if (!isThreadChat() && chatMode != MODE_SCHEDULED && message.hasReplies() && currentChat.megagroup && message.canViewThread()) {
items.add(LocaleController.formatPluralString("ViewReplies", message.getRepliesCount()));
options.add(OPTION_VIEW_REPLIES_OR_THREAD);
icons.add(R.drawable.msg_viewreplies);
}
if (allowUnpin) {
items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
options.add(OPTION_UNPIN);
icons.add(R.drawable.msg_unpin);
} else if (allowPin) {
items.add(LocaleController.getString("PinMessage", R.string.PinMessage));
options.add(OPTION_PIN);
icons.add(R.drawable.msg_pin);
}
if (selectedObject != null && selectedObject.contentType == 0 && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
items.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
options.add(29);
icons.add(R.drawable.msg_translate);
}
if (message.canEditMessage(currentChat)) {
items.add(LocaleController.getString("Edit", R.string.Edit));
options.add(OPTION_EDIT);
icons.add(R.drawable.msg_edit);
}
if (selectedObject.contentType == 0 && !selectedObject.isMediaEmptyWebpage() && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
items.add(LocaleController.getString("ReportChat", R.string.ReportChat));
options.add(OPTION_REPORT_CHAT);
icons.add(R.drawable.msg_report);
}
} else {
if (selectedObject.getId() > 0 && allowChatActions) {
items.add(LocaleController.getString("Reply", R.string.Reply));
options.add(OPTION_REPLY);
icons.add(R.drawable.msg_reply);
}
}
if (message.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat) && (threadMessageObjects == null || !threadMessageObjects.contains(message))) {
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(OPTION_DELETE);
icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
}
} else if (type == 20) {
items.add(LocaleController.getString("Retry", R.string.Retry));
options.add(OPTION_RETRY);
icons.add(R.drawable.msg_retry);
if (!noforwards) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(OPTION_COPY);
icons.add(R.drawable.msg_copy);
}
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(OPTION_DELETE);
icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
} else {
if (currentEncryptedChat == null) {
if (chatMode == MODE_SCHEDULED) {
items.add(LocaleController.getString("MessageScheduleSend", R.string.MessageScheduleSend));
options.add(OPTION_SEND_NOW);
icons.add(R.drawable.outline_send);
}
if (selectedObject.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall) {
TLRPC.TL_messageActionPhoneCall call = (TLRPC.TL_messageActionPhoneCall) message.messageOwner.action;
items.add((call.reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || call.reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy) && !message.isOutOwner() ? LocaleController.getString("CallBack", R.string.CallBack) : LocaleController.getString("CallAgain", R.string.CallAgain));
options.add(OPTION_CALL_AGAIN);
icons.add(R.drawable.msg_callback);
if (VoIPHelper.canRateCall(call)) {
items.add(LocaleController.getString("CallMessageReportProblem", R.string.CallMessageReportProblem));
options.add(OPTION_RATE_CALL);
icons.add(R.drawable.msg_fave);
}
}
if (allowChatActions) {
items.add(LocaleController.getString("Reply", R.string.Reply));
options.add(8);
icons.add(R.drawable.msg_reply);
}
if ((selectedObject.type == 0 || selectedObject.isDice() || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !noforwards) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(3);
icons.add(R.drawable.msg_copy);
}
if (!isThreadChat() && chatMode != MODE_SCHEDULED && currentChat != null && (currentChat.has_link || message.hasReplies()) && currentChat.megagroup && message.canViewThread()) {
if (message.hasReplies()) {
items.add(LocaleController.formatPluralString("ViewReplies", message.getRepliesCount()));
} else {
items.add(LocaleController.getString("ViewThread", R.string.ViewThread));
}
options.add(27);
icons.add(R.drawable.msg_viewreplies);
}
if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && ChatObject.isChannel(currentChat) && selectedObject.getDialogId() != mergeDialogId) {
items.add(LocaleController.getString("CopyLink", R.string.CopyLink));
options.add(22);
icons.add(R.drawable.msg_link);
}
if (type == 2) {
if (chatMode != MODE_SCHEDULED) {
if (selectedObject.type == MessageObject.TYPE_POLL && !message.isPollClosed()) {
if (message.canUnvote()) {
items.add(LocaleController.getString("Unvote", R.string.Unvote));
options.add(25);
icons.add(R.drawable.msg_unvote);
}
if (!message.isForwarded() && (message.isOut() && (!ChatObject.isChannel(currentChat) || currentChat.megagroup) || ChatObject.isChannel(currentChat) && !currentChat.megagroup && (currentChat.creator || currentChat.admin_rights != null && currentChat.admin_rights.edit_messages))) {
if (message.isQuiz()) {
items.add(LocaleController.getString("StopQuiz", R.string.StopQuiz));
} else {
items.add(LocaleController.getString("StopPoll", R.string.StopPoll));
}
options.add(26);
icons.add(R.drawable.msg_pollstop);
}
} else if (selectedObject.isMusic() && !noforwards) {
items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
} else if (selectedObject.isDocument() && !noforwards) {
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
}
}
} else if (type == 3 && !noforwards) {
if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject.isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) {
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
options.add(11);
icons.add(R.drawable.msg_gif);
}
} else if (type == 4) {
if (!noforwards) {
if (selectedObject.isVideo()) {
if (!selectedObject.needDrawBluredPreview()) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
icons.add(R.drawable.msg_gallery);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
}
} else if (selectedObject.isMusic()) {
items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
} else if (selectedObject.getDocument() != null) {
if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
options.add(11);
icons.add(R.drawable.msg_gif);
}
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
} else {
if (!selectedObject.needDrawBluredPreview()) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
icons.add(R.drawable.msg_gallery);
}
}
}
} else if (type == 5) {
items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
options.add(5);
icons.add(R.drawable.msg_language);
if (!noforwards) {
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
}
} else if (type == 10) {
items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
options.add(5);
icons.add(R.drawable.msg_theme);
if (!noforwards) {
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
}
} else if (type == 6 && !noforwards) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(7);
icons.add(R.drawable.msg_gallery);
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
} else if (type == 7) {
if (selectedObject.isMask()) {
items.add(LocaleController.getString("AddToMasks", R.string.AddToMasks));
options.add(9);
icons.add(R.drawable.msg_sticker);
} else {
items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers));
options.add(9);
icons.add(R.drawable.msg_sticker);
TLRPC.Document document = selectedObject.getDocument();
if (!getMediaDataController().isStickerInFavorites(document)) {
if (getMediaDataController().canAddStickerToFavorites() && MessageObject.isStickerHasSet(document)) {
items.add(LocaleController.getString("AddToFavorites", R.string.AddToFavorites));
options.add(20);
icons.add(R.drawable.msg_fave);
}
} else {
items.add(LocaleController.getString("DeleteFromFavorites", R.string.DeleteFromFavorites));
options.add(21);
icons.add(R.drawable.msg_unfave);
}
}
} else if (type == 8) {
long uid = selectedObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user != null && user.id != getUserConfig().getClientUserId() && getContactsController().contactsDict.get(user.id) == null) {
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
options.add(15);
icons.add(R.drawable.msg_addcontact);
}
if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
if (!noforwards) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(16);
icons.add(R.drawable.msg_copy);
}
items.add(LocaleController.getString("Call", R.string.Call));
options.add(17);
icons.add(R.drawable.msg_callback);
}
} else if (type == 9) {
TLRPC.Document document = selectedObject.getDocument();
if (!getMediaDataController().isStickerInFavorites(document)) {
if (MessageObject.isStickerHasSet(document)) {
items.add(LocaleController.getString("AddToFavorites", R.string.AddToFavorites));
options.add(20);
icons.add(R.drawable.msg_fave);
}
} else {
items.add(LocaleController.getString("DeleteFromFavorites", R.string.DeleteFromFavorites));
options.add(21);
icons.add(R.drawable.msg_unfave);
}
}
if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && !selectedObject.needDrawBluredPreview() && !selectedObject.isLiveLocation() && selectedObject.type != 16 && !noforwards) {
items.add(LocaleController.getString("Forward", R.string.Forward));
options.add(2);
icons.add(R.drawable.msg_forward);
}
if (allowUnpin) {
items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
options.add(14);
icons.add(R.drawable.msg_unpin);
} else if (allowPin) {
items.add(LocaleController.getString("PinMessage", R.string.PinMessage));
options.add(13);
icons.add(R.drawable.msg_pin);
}
if (selectedObject != null && selectedObject.contentType == 0 && (messageText != null && messageText.length() > 0 && !selectedObject.isAnimatedEmoji() && !selectedObject.isDice()) && MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
items.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
options.add(29);
icons.add(R.drawable.msg_translate);
}
if (allowEdit) {
items.add(LocaleController.getString("Edit", R.string.Edit));
options.add(12);
icons.add(R.drawable.msg_edit);
}
if (chatMode == MODE_SCHEDULED && selectedObject.canEditMessageScheduleTime(currentChat)) {
items.add(LocaleController.getString("MessageScheduleEditTime", R.string.MessageScheduleEditTime));
options.add(102);
icons.add(R.drawable.msg_schedule);
}
if (chatMode != MODE_SCHEDULED && selectedObject.contentType == 0 && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) {
if (UserObject.isReplyUser(currentUser)) {
items.add(LocaleController.getString("BlockContact", R.string.BlockContact));
options.add(23);
icons.add(R.drawable.msg_block2);
} else {
items.add(LocaleController.getString("ReportChat", R.string.ReportChat));
options.add(23);
icons.add(R.drawable.msg_report);
}
}
if (message.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat) && (threadMessageObjects == null || !threadMessageObjects.contains(message))) {
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(1);
icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
}
} else {
if (allowChatActions) {
items.add(LocaleController.getString("Reply", R.string.Reply));
options.add(8);
icons.add(R.drawable.msg_reply);
}
if ((selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !noforwards) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(3);
icons.add(R.drawable.msg_copy);
}
if (!isThreadChat() && chatMode != MODE_SCHEDULED && currentChat != null && (currentChat.has_link || message.hasReplies()) && currentChat.megagroup && message.canViewThread()) {
if (message.hasReplies()) {
items.add(LocaleController.formatPluralString("ViewReplies", message.getRepliesCount()));
} else {
items.add(LocaleController.getString("ViewThread", R.string.ViewThread));
}
options.add(27);
icons.add(R.drawable.msg_viewreplies);
}
if (type == 4 && !noforwards) {
if (selectedObject.isVideo()) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
icons.add(R.drawable.msg_gallery);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
} else if (selectedObject.isMusic()) {
items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
} else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) {
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
} else {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
icons.add(R.drawable.msg_gallery);
}
} else if (type == 5) {
items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
options.add(5);
icons.add(R.drawable.msg_language);
} else if (type == 10) {
items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
options.add(5);
icons.add(R.drawable.msg_theme);
} else if (type == 7) {
items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers));
options.add(9);
icons.add(R.drawable.msg_sticker);
} else if (type == 8) {
long uid = selectedObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user != null && user.id != getUserConfig().getClientUserId() && getContactsController().contactsDict.get(user.id) == null) {
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
options.add(15);
icons.add(R.drawable.msg_addcontact);
}
if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
if (!noforwards) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(16);
icons.add(R.drawable.msg_copy);
}
items.add(LocaleController.getString("Call", R.string.Call));
options.add(17);
icons.add(R.drawable.msg_callback);
}
}
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(1);
icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
}
}
}
if (options.isEmpty()) {
return;
}
if (scrimPopupWindow != null) {
closeMenu();
menuDeleteItem = null;
scrimPopupWindowItems = null;
return;
}
final AtomicBoolean waitForLangDetection = new AtomicBoolean(false);
final AtomicReference<Runnable> onLangDetectionDone = new AtomicReference(null);
Rect rect = new Rect();
List<TLRPC.TL_availableReaction> availableReacts = getMediaDataController().getEnabledReactionsList();
boolean isReactionsViewAvailable = !isSecretChat() && !isInScheduleMode() && currentUser == null && message.hasReactions() && (!ChatObject.isChannel(currentChat) || currentChat.megagroup) && !availableReacts.isEmpty() && message.messageOwner.reactions.can_see_list;
boolean isReactionsAvailable;
if (message.isForwardedChannelPost()) {
TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(-message.getFromChatId());
if (chatInfo == null) {
isReactionsAvailable = true;
} else {
isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty()) && !availableReacts.isEmpty();
}
} else {
isReactionsAvailable = !isSecretChat() && !isInScheduleMode() && message.isReactionsAvailable() && (chatInfo != null && !chatInfo.available_reactions.isEmpty() || (chatInfo == null && !ChatObject.isChannel(currentChat)) || currentUser != null) && !availableReacts.isEmpty();
}
boolean showMessageSeen = !isReactionsViewAvailable && !isInScheduleMode() && currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < getMessagesController().chatReadMarkExpirePeriod) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && chatInfo != null && chatInfo.participants_count < getMessagesController().chatReadMarkSizeThreshold && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest) && (v instanceof ChatMessageCell);
int flags = 0;
if (isReactionsViewAvailable || showMessageSeen) {
flags |= ActionBarPopupWindow.ActionBarPopupWindowLayout.FLAG_USE_SWIPEBACK;
}
ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity(), R.drawable.popup_fixed_alert, themeDelegate, flags);
popupLayout.setMinimumWidth(AndroidUtilities.dp(200));
Rect backgroundPaddings = new Rect();
Drawable shadowDrawable = getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
shadowDrawable.getPadding(backgroundPaddings);
popupLayout.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
if (isReactionsViewAvailable) {
ReactedHeaderView reactedView = new ReactedHeaderView(contentView.getContext(), currentAccount, message, dialog_id);
int count = 0;
if (message.messageOwner.reactions != null) {
for (TLRPC.TL_reactionCount r : message.messageOwner.reactions.results) {
count += r.count;
}
}
boolean hasHeader = count > 10;
LinearLayout linearLayout = new LinearLayout(contentView.getContext()) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int size = MeasureSpec.getSize(widthMeasureSpec);
if (size < AndroidUtilities.dp(240)) {
size = AndroidUtilities.dp(240);
}
super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY), heightMeasureSpec);
}
};
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setLayoutParams(new FrameLayout.LayoutParams(AndroidUtilities.dp(200), AndroidUtilities.dp(6 * 48 + (hasHeader ? 44 * 2 + 8 : 44)) + (!hasHeader ? 1 : 0)));
ActionBarMenuSubItem backCell = new ActionBarMenuSubItem(getParentActivity(), true, false, themeDelegate);
backCell.setItemHeight(44);
backCell.setTextAndIcon(LocaleController.getString("Back", R.string.Back), R.drawable.msg_arrow_back);
backCell.getTextView().setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(40), 0, LocaleController.isRTL ? AndroidUtilities.dp(40) : 0, 0);
backCell.setOnClickListener(v1 -> popupLayout.getSwipeBack().closeForeground());
linearLayout.addView(backCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
int[] foregroundIndex = new int[1];
if (hasHeader) {
List<TLRPC.TL_reactionCount> counters = message.messageOwner.reactions.results;
LinearLayout tabsView = new LinearLayout(contentView.getContext());
tabsView.setOrientation(LinearLayout.HORIZONTAL);
ViewPager pager = new ViewPager(contentView.getContext());
HorizontalScrollView tabsScrollView = new HorizontalScrollView(contentView.getContext());
AtomicBoolean suppressTabsScroll = new AtomicBoolean();
int size = counters.size() + 1;
for (int i = 0; i < size; i++) {
ReactionTabHolderView hv = new ReactionTabHolderView(contentView.getContext());
if (i == 0) {
hv.setCounter(count);
} else
hv.setCounter(currentAccount, counters.get(i - 1));
int finalI = i;
hv.setOnClickListener(v1 -> {
int from = pager.getCurrentItem();
if (finalI == from)
return;
ReactionTabHolderView fv = (ReactionTabHolderView) tabsView.getChildAt(from);
suppressTabsScroll.set(true);
pager.setCurrentItem(finalI, true);
float fSX = tabsScrollView.getScrollX(), tSX = hv.getX() - (tabsScrollView.getWidth() - hv.getWidth()) / 2f;
ValueAnimator a = ValueAnimator.ofFloat(0, 1).setDuration(150);
a.setInterpolator(CubicBezierInterpolator.DEFAULT);
a.addUpdateListener(animation -> {
float f = (float) animation.getAnimatedValue();
tabsScrollView.setScrollX((int) (fSX + (tSX - fSX) * f));
fv.setOutlineProgress(1f - f);
hv.setOutlineProgress(f);
});
a.start();
});
tabsView.addView(hv, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL, i == 0 ? 6 : 0, 6, 6, 6));
}
tabsScrollView.setHorizontalScrollBarEnabled(false);
tabsScrollView.addView(tabsView);
linearLayout.addView(tabsScrollView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 44));
View divider = new FrameLayout(contentView.getContext());
divider.setBackgroundColor(Theme.getColor(Theme.key_graySection));
linearLayout.addView(divider, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) Theme.dividerPaint.getStrokeWidth()));
int head = AndroidUtilities.dp(44 * 2) + 1;
SparseArray<ReactedUsersListView> cachedViews = new SparseArray<>();
SparseIntArray cachedHeights = new SparseIntArray();
for (int i = 0; i < counters.size() + 1; i++) cachedHeights.put(i, head + AndroidUtilities.dp(ReactedUsersListView.ITEM_HEIGHT_DP * ReactedUsersListView.VISIBLE_ITEMS));
pager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return counters.size() + 1;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View cached = cachedViews.get(position);
if (cached != null) {
container.addView(cached);
return cached;
}
ReactedUsersListView v = new ReactedUsersListView(container.getContext(), themeDelegate, currentAccount, message, position == 0 ? null : counters.get(position - 1), true).setSeenUsers(reactedView.getSeenUsers()).setOnProfileSelectedListener((view, userId) -> {
Bundle args = new Bundle();
args.putLong("user_id", userId);
ProfileActivity fragment = new ProfileActivity(args);
presentFragment(fragment);
closeMenu();
}).setOnHeightChangedListener((view, newHeight) -> {
cachedHeights.put(position, head + newHeight);
if (pager.getCurrentItem() == position)
popupLayout.getSwipeBack().setNewForegroundHeight(foregroundIndex[0], head + newHeight);
});
if (position == 0)
reactedView.setSeenCallback(v::setSeenUsers);
container.addView(v);
cachedViews.put(position, v);
return v;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
});
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (!suppressTabsScroll.get()) {
float fX = -1, tX = -1;
for (int i = 0; i < tabsView.getChildCount(); i++) {
ReactionTabHolderView ch = (ReactionTabHolderView) tabsView.getChildAt(i);
ch.setOutlineProgress(i == position ? 1f - positionOffset : i == (position + 1) % size ? positionOffset : 0);
if (i == position) {
fX = ch.getX() - (tabsScrollView.getWidth() - ch.getWidth()) / 2f;
}
if (i == position + 1) {
tX = ch.getX() - (tabsScrollView.getWidth() - ch.getWidth()) / 2f;
}
}
if (fX != -1 && tX != -1)
tabsScrollView.setScrollX((int) (fX + (tX - fX) * positionOffset));
}
}
@Override
public void onPageSelected(int position) {
int h = cachedHeights.get(position);
popupLayout.getSwipeBack().setNewForegroundHeight(foregroundIndex[0], h);
}
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE) {
suppressTabsScroll.set(false);
}
}
});
linearLayout.addView(pager, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 0, 1f));
} else {
View gap = new FrameLayout(contentView.getContext());
gap.setBackgroundColor(Theme.getColor(Theme.key_graySection));
linearLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
ReactedUsersListView lv = new ReactedUsersListView(contentView.getContext(), themeDelegate, currentAccount, message, null, true).setSeenUsers(reactedView.getSeenUsers()).setOnProfileSelectedListener((view, userId) -> {
Bundle args = new Bundle();
args.putLong("user_id", userId);
ProfileActivity fragment = new ProfileActivity(args);
presentFragment(fragment);
closeMenu();
}).setOnHeightChangedListener((view, newHeight) -> popupLayout.getSwipeBack().setNewForegroundHeight(foregroundIndex[0], AndroidUtilities.dp(44 + 8) + newHeight));
reactedView.setSeenCallback(lv::setSeenUsers);
linearLayout.addView(lv, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 0, 1f));
}
foregroundIndex[0] = popupLayout.addViewToSwipeBack(linearLayout);
reactedView.setOnClickListener(v1 -> {
popupLayout.getSwipeBack().openForeground(foregroundIndex[0]);
});
popupLayout.addView(reactedView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
View gap = new FrameLayout(contentView.getContext());
gap.setBackgroundColor(Theme.getColor(Theme.key_graySection));
popupLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
}
MessageSeenView messageSeenView = null;
if (showMessageSeen) {
messageSeenView = new MessageSeenView(contentView.getContext(), currentAccount, message, currentChat);
FrameLayout messageSeenLayout = new FrameLayout(contentView.getContext());
messageSeenLayout.addView(messageSeenView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
MessageSeenView finalMessageSeenView = messageSeenView;
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), true, true, themeDelegate);
cell.setItemHeight(44);
cell.setTextAndIcon(LocaleController.getString("Back", R.string.Back), R.drawable.msg_arrow_back);
cell.getTextView().setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(40), 0, LocaleController.isRTL ? AndroidUtilities.dp(40) : 0, 0);
FrameLayout backContainer = new FrameLayout(contentView.getContext());
LinearLayout linearLayout = new LinearLayout(contentView.getContext());
linearLayout.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
linearLayout.setOrientation(LinearLayout.VERTICAL);
RecyclerListView listView2 = finalMessageSeenView.createListView();
backContainer.addView(cell);
linearLayout.addView(backContainer);
backContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popupLayout.getSwipeBack().closeForeground();
}
});
int[] foregroundIndex = new int[1];
messageSeenView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (scrimPopupWindow == null || finalMessageSeenView.users.isEmpty()) {
return;
}
if (finalMessageSeenView.users.size() == 1) {
TLRPC.User user = finalMessageSeenView.users.get(0);
if (user == null) {
return;
}
Bundle args = new Bundle();
args.putLong("user_id", user.id);
ProfileActivity fragment = new ProfileActivity(args);
presentFragment(fragment);
closeMenu();
return;
}
int totalHeight = contentView.getHeightWithKeyboard();
int availableHeight = totalHeight - scrimPopupY - AndroidUtilities.dp(46 + 16) - (isReactionsAvailable ? AndroidUtilities.dp(52) : 0);
if (SharedConfig.messageSeenHintCount > 0 && contentView.getKeyboardHeight() < AndroidUtilities.dp(20)) {
availableHeight -= AndroidUtilities.dp(52);
Bulletin bulletin = BulletinFactory.of(ChatActivity.this).createErrorBulletin(AndroidUtilities.replaceTags(LocaleController.getString("MessageSeenTooltipMessage", R.string.MessageSeenTooltipMessage)));
bulletin.tag = 1;
bulletin.setDuration(4000);
bulletin.show();
SharedConfig.updateMessageSeenHintCount(SharedConfig.messageSeenHintCount - 1);
} else if (contentView.getKeyboardHeight() > AndroidUtilities.dp(20)) {
availableHeight -= contentView.getKeyboardHeight() / 3f;
}
int listViewTotalHeight = AndroidUtilities.dp(8) + AndroidUtilities.dp(44) * listView2.getAdapter().getItemCount();
if (listViewTotalHeight > availableHeight) {
if (availableHeight > AndroidUtilities.dp(620)) {
listView2.getLayoutParams().height = AndroidUtilities.dp(620);
} else {
listView2.getLayoutParams().height = availableHeight;
}
} else {
listView2.getLayoutParams().height = listViewTotalHeight;
}
linearLayout.getLayoutParams().height = AndroidUtilities.dp(44) + listView2.getLayoutParams().height;
listView2.requestLayout();
linearLayout.requestLayout();
listView2.getAdapter().notifyDataSetChanged();
popupLayout.getSwipeBack().openForeground(foregroundIndex[0]);
}
});
linearLayout.addView(listView2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 320));
listView2.setOnItemClickListener((view1, position) -> {
TLRPC.User user = finalMessageSeenView.users.get(position);
if (user == null) {
return;
}
Bundle args = new Bundle();
args.putLong("user_id", user.id);
ProfileActivity fragment = new ProfileActivity(args);
presentFragment(fragment);
});
foregroundIndex[0] = popupLayout.addViewToSwipeBack(linearLayout);
popupLayout.addView(messageSeenLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 44));
View gap = new FrameLayout(contentView.getContext());
gap.setBackgroundColor(Theme.getColor(Theme.key_graySection));
popupLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
}
if (popupLayout.getSwipeBack() != null) {
popupLayout.getSwipeBack().setOnClickListener(e -> closeMenu());
}
scrimPopupWindowItems = new ActionBarMenuSubItem[items.size() + (selectedObject.isSponsored() ? 1 : 0)];
for (int a = 0, N = items.size(); a < N; a++) {
if (a == 0 && selectedObject.isSponsored()) {
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), true, true, themeDelegate);
cell.setTextAndIcon(LocaleController.getString("SponsoredMessageInfo", R.string.SponsoredMessageInfo), R.drawable.menu_info);
cell.setItemHeight(56);
cell.setTag(R.id.width_tag, 240);
cell.setMultiline();
scrimPopupWindowItems[scrimPopupWindowItems.length - 1] = cell;
popupLayout.addView(cell);
cell.setOnClickListener(v1 -> {
if (contentView == null || getParentActivity() == null) {
return;
}
BottomSheet.Builder builder = new BottomSheet.Builder(contentView.getContext());
builder.setCustomView(new SponsoredMessageInfoView(getParentActivity(), themeDelegate));
builder.show();
});
View gap = new View(getParentActivity());
gap.setMinimumWidth(AndroidUtilities.dp(196));
gap.setTag(1000);
gap.setTag(R.id.object_tag, 1);
popupLayout.addView(gap);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) cell.getLayoutParams();
if (LocaleController.isRTL) {
layoutParams.gravity = Gravity.RIGHT;
}
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(6);
gap.setLayoutParams(layoutParams);
}
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == N - 1, themeDelegate);
cell.setMinimumWidth(AndroidUtilities.dp(200));
cell.setTextAndIcon(items.get(a), icons.get(a));
Integer option = options.get(a);
if (option == 1 && selectedObject.messageOwner.ttl_period != 0) {
menuDeleteItem = cell;
updateDeleteItemRunnable.run();
cell.setSubtextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText6));
}
scrimPopupWindowItems[a] = cell;
popupLayout.addView(cell);
final int i = a;
cell.setOnClickListener(v1 -> {
if (selectedObject == null || i >= options.size()) {
return;
}
processSelectedOption(options.get(i));
});
if (option == 29) {
// "Translate" button
String toLang = LocaleController.getInstance().getCurrentLocale().getLanguage();
final CharSequence finalMessageText = messageText;
TranslateAlert.OnLinkPress onLinkPress = (link) -> {
didPressMessageUrl(link, false, selectedObject, v instanceof ChatMessageCell ? (ChatMessageCell) v : null);
};
TLRPC.InputPeer inputPeer = getMessagesController().getInputPeer(dialog_id);
int messageId = selectedObject.messageOwner.id;
/*if (LanguageDetector.hasSupport()) {
final String[] fromLang = { null };
cell.setVisibility(View.GONE);
waitForLangDetection.set(true);
LanguageDetector.detectLanguage(
finalMessageText.toString(),
(String lang) -> {
fromLang[0] = lang;
if (fromLang[0] != null && (!fromLang[0].equals(toLang) || fromLang[0].equals("und")) &&
!RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(fromLang[0])) {
cell.setVisibility(View.VISIBLE);
}
waitForLangDetection.set(false);
if (onLangDetectionDone.get() != null) {
onLangDetectionDone.get().run();
onLangDetectionDone.set(null);
}
},
(Exception e) -> {
FileLog.e("mlkit: failed to detect language in message");
e.printStackTrace();
waitForLangDetection.set(false);
if (onLangDetectionDone.get() != null) {
onLangDetectionDone.get().run();
onLangDetectionDone.set(null);
}
}
);
cell.setOnClickListener(e -> {
if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
return;
}
TranslateAlert alert = TranslateAlert.showAlert(getParentActivity(), this, currentAccount, inputPeer, messageId, fromLang[0], toLang, finalMessageText, noforwards, onLinkPress, () -> dimBehindView(false));
alert.showDim(false);
closeMenu(false);
});
cell.postDelayed(() -> {
if (onLangDetectionDone.get() != null) {
onLangDetectionDone.getAndSet(null).run();
}
}, 250);
} else {*/
cell.setOnClickListener(e -> {
if (selectedObject == null || i >= options.size() || getParentActivity() == null) {
return;
}
TranslateAlert alert = TranslateAlert.showAlert(getParentActivity(), this, currentAccount, inputPeer, messageId, "und", toLang, finalMessageText, noforwards, onLinkPress, () -> dimBehindView(false));
alert.showDim(false);
closeMenu(false);
});
// }
}
}
ChatScrimPopupContainerLayout scrimPopupContainerLayout = new ChatScrimPopupContainerLayout(contentView.getContext()) {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
closeMenu();
}
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
boolean b = super.dispatchTouchEvent(ev);
if (ev.getAction() == MotionEvent.ACTION_DOWN && !b) {
closeMenu();
}
return b;
}
};
scrimPopupContainerLayout.setOnTouchListener(new View.OnTouchListener() {
private int[] pos = new int[2];
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
View contentView = scrimPopupWindow.getContentView();
contentView.getLocationInWindow(pos);
rect.set(pos[0], pos[1], pos[0] + contentView.getMeasuredWidth(), pos[1] + contentView.getMeasuredHeight());
if (!rect.contains((int) event.getX(), (int) event.getY())) {
closeMenu();
}
}
} else if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
closeMenu();
}
return false;
}
});
ReactionsContainerLayout reactionsLayout = new ReactionsContainerLayout(contentView.getContext(), currentAccount, getResourceProvider());
if (isReactionsAvailable) {
int pad = 22;
int sPad = 24;
reactionsLayout.setPadding(AndroidUtilities.dp(4) + (LocaleController.isRTL ? 0 : sPad), AndroidUtilities.dp(4), AndroidUtilities.dp(4) + (LocaleController.isRTL ? sPad : 0), AndroidUtilities.dp(pad));
reactionsLayout.setDelegate((rView, reaction, longress) -> {
selectReaction(primaryMessage, reactionsLayout, 0, 0, reaction, false, longress);
});
LinearLayout.LayoutParams params = LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 52 + pad, Gravity.RIGHT, 0, 50, 0, -20);
scrimPopupContainerLayout.addView(reactionsLayout, params);
scrimPopupContainerLayout.reactionsLayout = reactionsLayout;
scrimPopupContainerLayout.setClipChildren(false);
reactionsLayout.setMessage(message, chatInfo);
reactionsLayout.setTransitionProgress(0);
if (popupLayout.getSwipeBack() != null) {
popupLayout.getSwipeBack().setOnSwipeBackProgressListener((layout, toProgress, progress) -> {
if (toProgress == 0) {
reactionsLayout.startEnterAnimation();
} else if (toProgress == 1)
reactionsLayout.setAlpha(1f - progress);
});
}
}
boolean showNoForwards = noforwards && message.messageOwner.action == null && message.isSent() && !message.isEditing() && chatMode != MODE_SCHEDULED;
scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinearRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, isReactionsAvailable ? 16 : 0, 0, isReactionsAvailable ? 36 : 0, 0));
scrimPopupContainerLayout.popupWindowLayout = popupLayout;
if (showNoForwards) {
popupLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
boolean isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
TextView tv = new TextView(contentView.getContext());
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
tv.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
if (getMessagesController().isChatNoForwards(currentChat)) {
tv.setText(isChannel ? LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel) : LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup));
} else {
tv.setText(LocaleController.getString("ForwardsRestrictedInfoBot", R.string.ForwardsRestrictedInfoBot));
}
tv.setMaxWidth(popupLayout.getMeasuredWidth() - AndroidUtilities.dp(38));
Drawable shadowDrawable2 = ContextCompat.getDrawable(contentView.getContext(), R.drawable.popup_fixed_alert).mutate();
shadowDrawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), PorterDuff.Mode.MULTIPLY));
FrameLayout fl = new FrameLayout(contentView.getContext());
fl.setBackground(shadowDrawable2);
fl.addView(tv, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 11, 11, 11, 11));
scrimPopupContainerLayout.addView(fl, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, isReactionsAvailable ? 16 : 0, -8, isReactionsAvailable ? 36 : 0, 0));
}
scrimPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
@Override
public void dismiss() {
super.dismiss();
if (scrimPopupWindow != this) {
return;
}
scrimPopupWindow = null;
menuDeleteItem = null;
scrimPopupWindowItems = null;
chatLayoutManager.setCanScrollVertically(true);
if (scrimPopupWindowHideDimOnDismiss) {
dimBehindView(false);
} else {
scrimPopupWindowHideDimOnDismiss = true;
}
if (chatActivityEnterView != null) {
chatActivityEnterView.getEditField().setAllowDrawCursor(true);
}
}
};
scrimPopupWindow.setPauseNotifications(true);
scrimPopupWindow.setDismissAnimationDuration(220);
scrimPopupWindow.setOutsideTouchable(true);
scrimPopupWindow.setClippingEnabled(true);
scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
scrimPopupWindow.setFocusable(true);
scrimPopupContainerLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
popupLayout.setFitItems(true);
int popupX = v.getLeft() + (int) x - scrimPopupContainerLayout.getMeasuredWidth() + backgroundPaddings.left - AndroidUtilities.dp(28);
if (popupX < AndroidUtilities.dp(6)) {
popupX = AndroidUtilities.dp(6);
} else if (popupX > chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth()) {
popupX = chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth();
}
if (AndroidUtilities.isTablet()) {
int[] location = new int[2];
fragmentView.getLocationInWindow(location);
popupX += location[0];
}
int totalHeight = contentView.getHeight();
int height = scrimPopupContainerLayout.getMeasuredHeight() + AndroidUtilities.dp(48);
int keyboardHeight = contentView.measureKeyboardHeight();
if (keyboardHeight > AndroidUtilities.dp(20)) {
totalHeight += keyboardHeight;
}
int popupY;
if (height < totalHeight) {
popupY = (int) (chatListView.getY() + v.getTop() + y);
if (height - backgroundPaddings.top - backgroundPaddings.bottom > AndroidUtilities.dp(240)) {
popupY += AndroidUtilities.dp(240) - height;
}
if (popupY < chatListView.getY() + AndroidUtilities.dp(24)) {
popupY = (int) (chatListView.getY() + AndroidUtilities.dp(24));
} else if (popupY > totalHeight - height - AndroidUtilities.dp(8)) {
popupY = totalHeight - height - AndroidUtilities.dp(8);
}
} else {
popupY = inBubbleMode ? 0 : AndroidUtilities.statusBarHeight;
}
final int finalPopupX = scrimPopupX = popupX;
final int finalPopupY = scrimPopupY = popupY;
Runnable showMenu = () -> {
if (scrimPopupWindow == null || fragmentView == null) {
return;
}
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
if (isReactionsAvailable) {
reactionsLayout.startEnterAnimation();
}
};
if (waitForLangDetection.get()) {
onLangDetectionDone.set(showMenu);
} else {
showMenu.run();
}
chatListView.stopScroll();
chatLayoutManager.setCanScrollVertically(false);
dimBehindView(v, true);
hideHints(false);
if (topUndoView != null) {
topUndoView.hide(true, 1);
}
if (undoView != null) {
undoView.hide(true, 1);
}
if (chatActivityEnterView != null) {
chatActivityEnterView.getEditField().setAllowDrawCursor(false);
}
return;
}
if (chatActivityEnterView != null && (chatActivityEnterView.isRecordingAudioVideo() || chatActivityEnterView.isRecordLocked())) {
return;
}
final ActionBarMenu actionMode = actionBar.createActionMode();
View item = actionMode.getItem(delete);
if (item != null) {
item.setVisibility(View.VISIBLE);
}
bottomMessagesActionContainer.setVisibility(View.VISIBLE);
int translationY = chatActivityEnterView.getMeasuredHeight() - AndroidUtilities.dp(51);
if (chatActivityEnterView.getVisibility() == View.VISIBLE) {
ArrayList<View> views = new ArrayList<>();
views.add(chatActivityEnterView);
if (mentionContainer != null && mentionContainer.getVisibility() == View.VISIBLE) {
views.add(mentionContainer);
}
if (stickersPanel != null && stickersPanel.getVisibility() == View.VISIBLE) {
views.add(stickersPanel);
}
actionBar.showActionMode(true, bottomMessagesActionContainer, null, views.toArray(new View[0]), new boolean[] { false, true, true }, chatListView, translationY);
if (getParentActivity() instanceof LaunchActivity) {
((LaunchActivity) getParentActivity()).hideVisibleActionMode();
}
chatActivityEnterView.getEditField().setAllowDrawCursor(false);
} else if (bottomOverlayChat.getVisibility() == View.VISIBLE) {
actionBar.showActionMode(true, bottomMessagesActionContainer, null, new View[] { bottomOverlayChat }, new boolean[] { true }, chatListView, translationY);
} else {
actionBar.showActionMode(true, bottomMessagesActionContainer, null, null, null, chatListView, translationY);
}
closeMenu();
chatLayoutManager.setCanScrollVertically(true);
updatePinnedMessageView(true);
AnimatorSet animatorSet = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<>();
for (int a = 0; a < actionModeViews.size(); a++) {
View view = actionModeViews.get(a);
view.setPivotY(ActionBar.getCurrentActionBarHeight() / 2);
AndroidUtilities.clearDrawableAnimation(view);
animators.add(ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.1f, 1.0f));
}
animatorSet.playTogether(animators);
animatorSet.setDuration(250);
animatorSet.start();
addToSelectedMessages(message, listView);
if (chatActivityEnterView != null) {
chatActivityEnterView.preventInput = true;
}
selectedMessagesCountTextView.setNumber(selectedMessagesIds[0].size() + selectedMessagesIds[1].size(), false);
updateVisibleRows();
if (chatActivityEnterView != null) {
chatActivityEnterView.hideBotCommands();
}
}
use of org.telegram.ui.Components.Bulletin in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method processSelectedOption.
private void processSelectedOption(int option) {
if (selectedObject == null || getParentActivity() == null) {
return;
}
boolean preserveDim = false;
switch(option) {
case 0:
{
if (selectedObjectGroup != null) {
boolean success = true;
for (int a = 0; a < selectedObjectGroup.messages.size(); a++) {
if (!getSendMessagesHelper().retrySendMessage(selectedObjectGroup.messages.get(a), false)) {
success = false;
}
}
if (success && chatMode == 0) {
moveScrollToLastMessage(false);
}
} else {
if (getSendMessagesHelper().retrySendMessage(selectedObject, false)) {
updateVisibleRows();
if (chatMode == 0) {
moveScrollToLastMessage(false);
}
}
}
break;
}
case OPTION_DELETE:
{
if (getParentActivity() == null) {
selectedObject = null;
selectedObjectToEditCaption = null;
selectedObjectGroup = null;
return;
}
preserveDim = true;
createDeleteMessagesAlert(selectedObject, selectedObjectGroup);
break;
}
case 2:
{
forwardingMessage = selectedObject;
forwardingMessageGroup = selectedObjectGroup;
Bundle args = new Bundle();
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", 3);
args.putInt("messagesCount", forwardingMessageGroup == null ? 1 : forwardingMessageGroup.messages.size());
args.putInt("hasPoll", forwardingMessage.isPoll() ? (forwardingMessage.isPublicPoll() ? 2 : 1) : 0);
args.putBoolean("hasInvoice", forwardingMessage.isInvoice());
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(this);
presentFragment(fragment);
break;
}
case 3:
{
if (selectedObject.isDice()) {
AndroidUtilities.addToClipboard(selectedObject.getDiceEmoji());
} else {
CharSequence caption = getMessageCaption(selectedObject, selectedObjectGroup);
if (caption != null) {
AndroidUtilities.addToClipboard(caption);
} else {
AndroidUtilities.addToClipboard(getMessageContent(selectedObject, 0, false));
}
}
undoView.showWithAction(0, UndoView.ACTION_MESSAGE_COPIED, null);
break;
}
case 4:
{
if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
getParentActivity().requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 4);
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
return;
}
if (selectedObjectGroup != null) {
int filesAmount = selectedObjectGroup.messages.size();
boolean allPhotos = true, allVideos = true;
for (int a = 0; a < filesAmount; a++) {
MessageObject messageObject = selectedObjectGroup.messages.get(a);
saveMessageToGallery(messageObject);
allPhotos &= messageObject.isPhoto();
allVideos &= messageObject.isVideo();
}
final BulletinFactory.FileType fileType;
if (allPhotos) {
fileType = BulletinFactory.FileType.PHOTOS;
} else if (allVideos) {
fileType = BulletinFactory.FileType.VIDEOS;
} else {
fileType = BulletinFactory.FileType.MEDIA;
}
BulletinFactory.of(this).createDownloadBulletin(fileType, filesAmount, themeDelegate).show();
} else {
saveMessageToGallery(selectedObject);
if (getParentActivity() != null) {
BulletinFactory.createSaveToGalleryBulletin(this, selectedObject.isVideo(), themeDelegate).show();
}
}
break;
}
case 5:
{
File locFile = null;
if (!TextUtils.isEmpty(selectedObject.messageOwner.attachPath)) {
File f = new File(selectedObject.messageOwner.attachPath);
if (f.exists()) {
locFile = f;
}
}
if (locFile == null) {
File f = FileLoader.getPathToMessage(selectedObject.messageOwner);
if (f.exists()) {
locFile = f;
}
}
if (locFile != null) {
if (locFile.getName().toLowerCase().endsWith("attheme")) {
Theme.ThemeInfo themeInfo = Theme.applyThemeFile(locFile, selectedObject.getDocumentName(), null, true);
if (themeInfo != null) {
presentFragment(new ThemePreviewActivity(themeInfo));
} else {
scrollToPositionOnRecreate = -1;
if (getParentActivity() == null) {
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), themeDelegate);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("IncorrectTheme", R.string.IncorrectTheme));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
preserveDim = true;
builder.setDimEnabled(false);
builder.setOnPreDismissListener(di -> dimBehindView(false));
showDialog(builder.create());
}
} else {
if (LocaleController.getInstance().applyLanguageFile(locFile, currentAccount)) {
presentFragment(new LanguageSelectActivity());
} else {
if (getParentActivity() == null) {
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), themeDelegate);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("IncorrectLocalization", R.string.IncorrectLocalization));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
preserveDim = true;
builder.setDimEnabled(false);
builder.setOnPreDismissListener(di -> dimBehindView(false));
showDialog(builder.create());
}
}
}
break;
}
case 6:
{
String path = selectedObject.messageOwner.attachPath;
if (path != null && path.length() > 0) {
File temp = new File(path);
if (!temp.exists()) {
path = null;
}
}
if (path == null || path.length() == 0) {
path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString();
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType(selectedObject.getDocument().mime_type);
File f = new File(path);
if (Build.VERSION.SDK_INT >= 24) {
try {
intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", f));
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} catch (Exception ignore) {
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
}
} else {
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
}
try {
getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500);
} catch (Throwable ignore) {
}
break;
}
case 7:
{
String path = selectedObject.messageOwner.attachPath;
if (path != null && path.length() > 0) {
File temp = new File(path);
if (!temp.exists()) {
path = null;
}
}
if (path == null || path.length() == 0) {
path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString();
}
if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
getParentActivity().requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 4);
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
return;
}
MediaController.saveFile(path, getParentActivity(), 0, null, null);
BulletinFactory.createSaveToGalleryBulletin(this, selectedObject.isVideo(), themeDelegate).show();
break;
}
case 8:
{
showFieldPanelForReply(selectedObject);
break;
}
case 9:
{
StickersAlert alert = new StickersAlert(getParentActivity(), this, selectedObject.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE && (currentChat == null || ChatObject.canSendStickers(currentChat)) ? chatActivityEnterView : null, themeDelegate);
alert.setCalcMandatoryInsets(isKeyboardVisible());
preserveDim = true;
alert.setDimBehind(false);
alert.setOnDismissListener(() -> dimBehindView(false));
showDialog(alert);
break;
}
case OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC:
{
// TODO scopped storage
if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
getParentActivity().requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 4);
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
return;
}
boolean isMusic = selectedObject.isMusic();
boolean isDocument = selectedObject.isDocument();
if (isMusic || isDocument) {
ArrayList<MessageObject> messageObjects;
if (selectedObjectGroup != null) {
messageObjects = new ArrayList<>(selectedObjectGroup.messages);
} else {
messageObjects = new ArrayList<>();
messageObjects.add(selectedObject);
}
MediaController.saveFilesFromMessages(getParentActivity(), getAccountInstance(), messageObjects, (count) -> {
if (getParentActivity() == null || fragmentView == null) {
return;
}
if (count > 0) {
BulletinFactory.of(this).createDownloadBulletin(isMusic ? BulletinFactory.FileType.AUDIOS : BulletinFactory.FileType.UNKNOWNS, count, themeDelegate).show();
}
});
} else {
boolean video = selectedObject.isVideo();
boolean photo = selectedObject.isPhoto();
boolean gif = selectedObject.isGif();
String fileName = FileLoader.getDocumentFileName(selectedObject.getDocument());
if (TextUtils.isEmpty(fileName)) {
fileName = selectedObject.getFileName();
}
String path = selectedObject.messageOwner.attachPath;
if (path != null && path.length() > 0) {
File temp = new File(path);
if (!temp.exists()) {
path = null;
}
}
if (path == null || path.length() == 0) {
path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString();
}
MediaController.saveFile(path, getParentActivity(), 2, fileName, selectedObject.getDocument() != null ? selectedObject.getDocument().mime_type : "", () -> {
if (getParentActivity() == null) {
return;
}
final BulletinFactory.FileType fileType;
if (photo) {
fileType = BulletinFactory.FileType.PHOTO_TO_DOWNLOADS;
} else if (video) {
fileType = BulletinFactory.FileType.VIDEO_TO_DOWNLOADS;
} else if (gif) {
fileType = BulletinFactory.FileType.GIF_TO_DOWNLOADS;
} else {
fileType = BulletinFactory.FileType.UNKNOWN;
}
BulletinFactory.of(this).createDownloadBulletin(fileType, themeDelegate).show();
});
}
break;
}
case 11:
{
TLRPC.Document document = selectedObject.getDocument();
getMessagesController().saveGif(selectedObject, document);
if (!showGifHint() && getParentActivity() != null) {
BulletinFactory.of(this).createDownloadBulletin(BulletinFactory.FileType.GIF, themeDelegate).show();
}
chatActivityEnterView.addRecentGif(document);
break;
}
case 12:
{
if (selectedObjectToEditCaption != null) {
startEditingMessageObject(selectedObjectToEditCaption);
} else {
startEditingMessageObject(selectedObject);
}
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
break;
}
case 13:
{
final int mid;
if (selectedObjectGroup != null && !selectedObjectGroup.messages.isEmpty()) {
mid = selectedObjectGroup.messages.get(0).getId();
} else {
mid = selectedObject.getId();
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), themeDelegate);
builder.setTitle(LocaleController.getString("PinMessageAlertTitle", R.string.PinMessageAlertTitle));
preserveDim = true;
builder.setDimEnabled(false);
builder.setOnPreDismissListener(di -> dimBehindView(false));
final boolean[] checks;
if (currentUser != null) {
if (currentPinnedMessageId != 0 && mid < currentPinnedMessageId) {
builder.setMessage(LocaleController.getString("PinOldMessageAlert", R.string.PinOldMessageAlert));
} else {
builder.setMessage(LocaleController.getString("PinMessageAlertChat", R.string.PinMessageAlertChat));
}
checks = new boolean[] { false, false };
if (!UserObject.isUserSelf(currentUser)) {
FrameLayout frameLayout = new FrameLayout(getParentActivity());
CheckBoxCell cell = new CheckBoxCell(getParentActivity(), 1, themeDelegate);
cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
cell.setText(LocaleController.formatString("PinAlsoFor", R.string.PinAlsoFor, UserObject.getFirstName(currentUser)), "", false, false);
cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(8) : 0, 0, LocaleController.isRTL ? 0 : AndroidUtilities.dp(8), 0);
frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 8, 0, 8, 0));
cell.setOnClickListener(v -> {
CheckBoxCell cell1 = (CheckBoxCell) v;
checks[1] = !checks[1];
cell1.setChecked(checks[1], true);
});
builder.setView(frameLayout);
}
} else if (ChatObject.isChannel(currentChat) && currentChat.megagroup || currentChat != null && !ChatObject.isChannel(currentChat)) {
if (!pinnedMessageIds.isEmpty() && mid < pinnedMessageIds.get(0)) {
builder.setMessage(LocaleController.getString("PinOldMessageAlert", R.string.PinOldMessageAlert));
checks = new boolean[] { false, true };
} else {
builder.setMessage(LocaleController.getString("PinMessageAlert", R.string.PinMessageAlert));
checks = new boolean[] { true, true };
FrameLayout frameLayout = new FrameLayout(getParentActivity());
CheckBoxCell cell = new CheckBoxCell(getParentActivity(), 1, themeDelegate);
cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
cell.setText(LocaleController.getString("PinNotify", R.string.PinNotify), "", true, false);
cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(8) : 0, 0, LocaleController.isRTL ? 0 : AndroidUtilities.dp(8), 0);
frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 8, 0, 8, 0));
cell.setOnClickListener(v -> {
CheckBoxCell cell1 = (CheckBoxCell) v;
checks[0] = !checks[0];
cell1.setChecked(checks[0], true);
});
builder.setView(frameLayout);
}
} else {
if (currentPinnedMessageId != 0 && mid < currentPinnedMessageId) {
builder.setMessage(LocaleController.getString("PinOldMessageAlert", R.string.PinOldMessageAlert));
} else {
builder.setMessage(LocaleController.getString("PinMessageAlertChannel", R.string.PinMessageAlertChannel));
}
checks = new boolean[] { false, true };
}
builder.setPositiveButton(LocaleController.getString("PinMessage", R.string.PinMessage), (dialogInterface, i) -> {
getMessagesController().pinMessage(currentChat, currentUser, mid, false, !checks[1], checks[0]);
Bulletin bulletin = BulletinFactory.createPinMessageBulletin(this, themeDelegate);
bulletin.show();
View view = bulletin.getLayout();
view.postDelayed(() -> {
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}, 550);
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
break;
}
case 14:
{
MessageObject messageObject;
if (pinnedMessageObjects.containsKey(selectedObject.getId())) {
messageObject = selectedObject;
} else if (selectedObjectGroup != null && !selectedObjectGroup.messages.isEmpty()) {
messageObject = selectedObjectGroup.messages.get(0);
} else {
messageObject = selectedObject;
}
if (chatMode == MODE_PINNED && messages.size() == 2) {
finishFragment();
chatActivityDelegate.onUnpin(false, false);
} else {
unpinMessage(messageObject);
}
break;
}
case 15:
{
Bundle args = new Bundle();
args.putLong("user_id", selectedObject.messageOwner.media.user_id);
args.putString("phone", selectedObject.messageOwner.media.phone_number);
args.putBoolean("addContact", true);
presentFragment(new ContactAddActivity(args));
break;
}
case 16:
{
AndroidUtilities.addToClipboard(selectedObject.messageOwner.media.phone_number);
break;
}
case 17:
{
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + selectedObject.messageOwner.media.phone_number));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getParentActivity().startActivityForResult(intent, 500);
} catch (Exception e) {
FileLog.e(e);
}
break;
}
case 18:
{
if (currentUser != null) {
VoIPHelper.startCall(currentUser, selectedObject.isVideoCall(), userInfo != null && userInfo.video_calls_available, getParentActivity(), getMessagesController().getUserFull(currentUser.id), getAccountInstance());
}
break;
}
case 19:
{
VoIPHelper.showRateAlert(getParentActivity(), (TLRPC.TL_messageActionPhoneCall) selectedObject.messageOwner.action);
break;
}
case 20:
{
getMediaDataController().addRecentSticker(MediaDataController.TYPE_FAVE, selectedObject, selectedObject.getDocument(), (int) (System.currentTimeMillis() / 1000), false);
break;
}
case 21:
{
getMediaDataController().addRecentSticker(MediaDataController.TYPE_FAVE, selectedObject, selectedObject.getDocument(), (int) (System.currentTimeMillis() / 1000), true);
break;
}
case 22:
{
TLRPC.TL_channels_exportMessageLink req = new TLRPC.TL_channels_exportMessageLink();
if (selectedObject == replyingMessageObject && isComments) {
req.id = replyOriginalMessageId;
req.channel = MessagesController.getInputChannel(replyOriginalChat);
} else {
req.id = selectedObject.getId();
req.channel = MessagesController.getInputChannel(currentChat);
req.thread = isReplyChatComment();
}
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) {
TLRPC.TL_exportedMessageLink exportedMessageLink = (TLRPC.TL_exportedMessageLink) response;
try {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", exportedMessageLink.link);
clipboard.setPrimaryClip(clip);
if (BulletinFactory.canShowBulletin(ChatActivity.this)) {
BulletinFactory.of(ChatActivity.this).createCopyLinkBulletin(!isThreadChat() && exportedMessageLink.link.contains("/c/"), themeDelegate).show();
}
} catch (Exception e) {
FileLog.e(e);
}
}
}));
break;
}
case OPTION_REPORT_CHAT:
{
if (UserObject.isReplyUser(currentUser)) {
if (selectedObject.messageOwner.fwd_from != null) {
preserveDim = true;
AlertsCreator.showBlockReportSpamReplyAlert(ChatActivity.this, selectedObject, MessageObject.getPeerId(selectedObject.messageOwner.fwd_from.from_id), themeDelegate, () -> dimBehindView(false));
}
} else {
preserveDim = true;
AlertsCreator.createReportAlert(getParentActivity(), dialog_id, selectedObject.getId(), ChatActivity.this, themeDelegate, () -> dimBehindView(false));
}
break;
}
case 24:
{
if (selectedObject.isEditing() || selectedObject.isSending() && selectedObjectGroup == null) {
getSendMessagesHelper().cancelSendingMessage(selectedObject);
} else if (selectedObject.isSending() && selectedObjectGroup != null) {
for (int a = 0; a < selectedObjectGroup.messages.size(); a++) {
getSendMessagesHelper().cancelSendingMessage(new ArrayList<>(selectedObjectGroup.messages));
}
}
break;
}
case 25:
{
final AlertDialog[] progressDialog = new AlertDialog[] { new AlertDialog(getParentActivity(), 3, themeDelegate) };
int requestId = getSendMessagesHelper().sendVote(selectedObject, null, () -> {
try {
progressDialog[0].dismiss();
} catch (Throwable ignore) {
}
progressDialog[0] = null;
});
if (requestId != 0) {
AndroidUtilities.runOnUIThread(() -> {
if (progressDialog[0] == null) {
return;
}
progressDialog[0].setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(requestId, true));
showDialog(progressDialog[0]);
}, 500);
}
break;
}
case 26:
{
MessageObject object = selectedObject;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity(), themeDelegate);
preserveDim = true;
builder.setDimEnabled(false);
builder.setOnPreDismissListener(di -> dimBehindView(false));
if (object.isQuiz()) {
builder.setTitle(LocaleController.getString("StopQuizAlertTitle", R.string.StopQuizAlertTitle));
builder.setMessage(LocaleController.getString("StopQuizAlertText", R.string.StopQuizAlertText));
} else {
builder.setTitle(LocaleController.getString("StopPollAlertTitle", R.string.StopPollAlertTitle));
builder.setMessage(LocaleController.getString("StopPollAlertText", R.string.StopPollAlertText));
}
builder.setPositiveButton(LocaleController.getString("Stop", R.string.Stop), (dialogInterface, i) -> {
final AlertDialog[] progressDialog = new AlertDialog[] { new AlertDialog(getParentActivity(), 3, themeDelegate) };
TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage();
TLRPC.TL_messageMediaPoll mediaPoll = (TLRPC.TL_messageMediaPoll) object.messageOwner.media;
TLRPC.TL_inputMediaPoll poll = new TLRPC.TL_inputMediaPoll();
poll.poll = new TLRPC.TL_poll();
poll.poll.id = mediaPoll.poll.id;
poll.poll.question = mediaPoll.poll.question;
poll.poll.answers = mediaPoll.poll.answers;
poll.poll.closed = true;
req.media = poll;
req.peer = getMessagesController().getInputPeer(dialog_id);
req.id = object.getId();
req.flags |= 16384;
int requestId = getConnectionsManager().sendRequest(req, (response, error) -> {
AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog[0].dismiss();
} catch (Throwable ignore) {
}
progressDialog[0] = null;
});
if (error == null) {
getMessagesController().processUpdates((TLRPC.Updates) response, false);
} else {
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, ChatActivity.this, req));
}
});
AndroidUtilities.runOnUIThread(() -> {
if (progressDialog[0] == null) {
return;
}
progressDialog[0].setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(requestId, true));
showDialog(progressDialog[0]);
}, 500);
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
break;
}
case 27:
{
openDiscussionMessageChat(currentChat.id, null, selectedObject.getId(), 0, -1, 0, null);
break;
}
case 28:
{
presentFragment(new MessageStatisticActivity(selectedObject));
break;
}
case 100:
{
if (!checkSlowMode(chatActivityEnterView.getSendButton())) {
if (getMediaController().isPlayingMessage(selectedObject)) {
getMediaController().cleanupPlayer(true, true);
}
TLRPC.TL_messages_sendScheduledMessages req = new TLRPC.TL_messages_sendScheduledMessages();
req.peer = getMessagesController().getInputPeer(dialog_id);
if (selectedObjectGroup != null) {
for (int a = 0; a < selectedObjectGroup.messages.size(); a++) {
req.id.add(selectedObjectGroup.messages.get(a).getId());
}
} else {
req.id.add(selectedObject.getId());
}
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.Updates updates = (TLRPC.Updates) response;
getMessagesController().processUpdates(updates, false);
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.messagesDeleted, req.id, -dialog_id, true, dialog_id));
} else if (error.text != null) {
AndroidUtilities.runOnUIThread(() -> {
if (error.text.startsWith("SLOWMODE_WAIT_")) {
AlertsCreator.showSimpleToast(ChatActivity.this, LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError));
} else if (error.text.equals("CHAT_SEND_MEDIA_FORBIDDEN")) {
AlertsCreator.showSimpleToast(ChatActivity.this, LocaleController.getString("AttachMediaRestrictedForever", R.string.AttachMediaRestrictedForever));
} else {
AlertsCreator.showSimpleToast(ChatActivity.this, error.text);
}
});
}
});
break;
}
}
case 102:
{
MessageObject message = selectedObject;
MessageObject.GroupedMessages group = selectedObjectGroup;
AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), dialog_id, message.messageOwner.date, (notify, scheduleDate) -> {
if (group != null && !group.messages.isEmpty()) {
SendMessagesHelper.getInstance(currentAccount).editMessage(group.messages.get(0), null, false, ChatActivity.this, null, scheduleDate);
} else {
SendMessagesHelper.getInstance(currentAccount).editMessage(message, null, false, ChatActivity.this, null, scheduleDate);
}
}, null, themeDelegate).setOnPreDismissListener(di -> dimBehindView(false)).setDimBehind(false);
preserveDim = true;
break;
}
}
selectedObject = null;
selectedObjectGroup = null;
selectedObjectToEditCaption = null;
closeMenu(!preserveDim);
}
use of org.telegram.ui.Components.Bulletin in project Telegram-FOSS by Telegram-FOSS-Team.
the class BottomSheet method dismiss.
@Override
public void dismiss() {
if (delegate != null && !delegate.canDismiss()) {
return;
}
if (dismissed) {
return;
}
dismissed = true;
if (onHideListener != null) {
onHideListener.onDismiss(this);
}
cancelSheetAnimation();
long duration = 0;
if (!allowCustomAnimation || !onCustomCloseAnimation()) {
currentSheetAnimationType = 2;
currentSheetAnimation = new AnimatorSet();
currentSheetAnimation.playTogether(ObjectAnimator.ofFloat(containerView, View.TRANSLATION_Y, containerView.getMeasuredHeight() + container.keyboardHeight + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0));
if (useFastDismiss) {
int height = containerView.getMeasuredHeight();
duration = Math.max(60, (int) (250 * (height - containerView.getTranslationY()) / (float) height));
currentSheetAnimation.setDuration(duration);
useFastDismiss = false;
} else {
currentSheetAnimation.setDuration(duration = 250);
}
currentSheetAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
currentSheetAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
currentSheetAnimation = null;
currentSheetAnimationType = 0;
AndroidUtilities.runOnUIThread(() -> {
try {
dismissInternal();
} catch (Exception e) {
FileLog.e(e);
}
});
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 512);
}
@Override
public void onAnimationCancel(Animator animation) {
if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
currentSheetAnimation = null;
currentSheetAnimationType = 0;
}
}
});
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 512);
currentSheetAnimation.start();
}
Bulletin bulletin = Bulletin.getVisibleBulletin();
if (bulletin != null && bulletin.isShowing()) {
if (duration > 0) {
bulletin.hide((long) (duration * 0.6f));
} else {
bulletin.hide();
}
}
}
use of org.telegram.ui.Components.Bulletin in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsActivity method onResume.
@Override
public void onResume() {
super.onResume();
if (!parentLayout.isInPreviewMode() && blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
blurredView.setVisibility(View.GONE);
blurredView.setBackground(null);
}
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed || SharedConfig.getChatSwipeAction(currentAccount) != SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS);
}
if (viewPages != null) {
for (int a = 0; a < viewPages.length; a++) {
viewPages[a].dialogsAdapter.notifyDataSetChanged();
}
}
if (commentView != null) {
commentView.onResume();
}
if (!onlySelect && folderId == 0) {
getMediaDataController().checkStickers(MediaDataController.TYPE_EMOJI);
}
if (searchViewPager != null) {
searchViewPager.onResume();
}
final boolean tosAccepted;
if (!afterSignup) {
tosAccepted = getUserConfig().unacceptedTermsOfService == null;
} else {
tosAccepted = true;
afterSignup = false;
}
if (tosAccepted && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
Activity activity = getParentActivity();
if (activity != null) {
checkPermission = false;
boolean hasNotContactsPermission = activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED;
boolean hasNotStoragePermission = (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED;
if (hasNotContactsPermission || hasNotStoragePermission) {
askingForPermissions = true;
if (hasNotContactsPermission && askAboutContacts && getUserConfig().syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
askAboutContacts = param != 0;
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit();
askForPermissons(false);
});
showDialog(permissionDialog = builder.create());
} else if (hasNotStoragePermission && activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(permissionDialog = builder.create());
} else {
askForPermissons(true);
}
}
}
} else if (!onlySelect && XiaomiUtilities.isMIUI() && Build.VERSION.SDK_INT >= 19 && !XiaomiUtilities.isCustomPermissionGranted(XiaomiUtilities.OP_SHOW_WHEN_LOCKED)) {
if (getParentActivity() == null) {
return;
}
if (MessagesController.getGlobalNotificationsSettings().getBoolean("askedAboutMiuiLockscreen", false)) {
return;
}
showDialog(new AlertDialog.Builder(getParentActivity()).setTitle(LocaleController.getString("AppName", R.string.AppName)).setMessage(LocaleController.getString("PermissionXiaomiLockscreen", R.string.PermissionXiaomiLockscreen)).setPositiveButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialog, which) -> {
Intent intent = XiaomiUtilities.getPermissionManagerIntent();
if (intent != null) {
try {
getParentActivity().startActivity(intent);
} catch (Exception x) {
try {
intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
getParentActivity().startActivity(intent);
} catch (Exception xx) {
FileLog.e(xx);
}
}
}
}).setNegativeButton(LocaleController.getString("ContactsPermissionAlertNotNow", R.string.ContactsPermissionAlertNotNow), (dialog, which) -> MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askedAboutMiuiLockscreen", true).commit()).create());
}
showFiltersHint();
if (viewPages != null) {
for (int a = 0; a < viewPages.length; a++) {
if (viewPages[a].dialogsType == 0 && viewPages[a].archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && viewPages[a].layoutManager.findFirstVisibleItemPosition() == 0 && hasHiddenArchive()) {
viewPages[a].layoutManager.scrollToPositionWithOffset(1, 0);
}
if (a == 0) {
viewPages[a].dialogsAdapter.resume();
} else {
viewPages[a].dialogsAdapter.pause();
}
}
}
showNextSupportedSuggestion();
Bulletin.addDelegate(this, new Bulletin.Delegate() {
@Override
public void onOffsetChange(float offset) {
if (undoView[0] != null && undoView[0].getVisibility() == View.VISIBLE) {
return;
}
additionalFloatingTranslation = offset;
if (additionalFloatingTranslation < 0) {
additionalFloatingTranslation = 0;
}
if (!floatingHidden) {
updateFloatingButtonOffset();
}
}
@Override
public void onShow(Bulletin bulletin) {
if (undoView[0] != null && undoView[0].getVisibility() == View.VISIBLE) {
undoView[0].hide(true, 2);
}
}
});
if (searchIsShowed) {
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
}
updateVisibleRows(0, false);
}
Aggregations